hexsha stringlengths 40 40 | size int64 19 11.4M | ext stringclasses 13 values | lang stringclasses 1 value | max_stars_repo_path stringlengths 3 270 | max_stars_repo_name stringlengths 5 110 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 270 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 270 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 19 11.4M | avg_line_length float64 1.93 229k | max_line_length int64 12 688k | alphanum_fraction float64 0.07 0.99 | matches listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1bdc2893306f358403c8d2f6f2c915aeaba23cef | 4,061 | cpp | C++ | src/vicon.cpp | netkimjh/libmotioncapture | 3bc4c5cd3fe09e25229fe7f510a9a68a184a17a6 | [
"MIT"
] | 1 | 2018-10-30T02:05:14.000Z | 2018-10-30T02:05:14.000Z | src/vicon.cpp | netkimjh/libmotioncapture | 3bc4c5cd3fe09e25229fe7f510a9a68a184a17a6 | [
"MIT"
] | null | null | null | src/vicon.cpp | netkimjh/libmotioncapture | 3bc4c5cd3fe09e25229fe7f510a9a68a184a17a6 | [
"MIT"
] | 1 | 2018-10-28T01:44:38.000Z | 2018-10-28T01:44:38.000Z | #include "libmotioncapture/vicon.h"
// VICON
#include "vicon_sdk/DataStreamClient.h"
using namespace ViconDataStreamSDK::CPP;
namespace libmotioncapture {
class MotionCaptureViconImpl
{
public:
Client client;
std::string version;
};
MotionCaptureVicon::MotionCaptureVicon(
const std::string& hostname,
bool enableObjects,
bool enablePointcloud)
{
pImpl = new MotionCaptureViconImpl;
// Try connecting...
while (!pImpl->client.IsConnected().Connected) {
pImpl->client.Connect(hostname);
}
if (enableObjects) {
pImpl->client.EnableSegmentData();
}
if (enablePointcloud) {
pImpl->client.EnableUnlabeledMarkerData();
}
// This is the lowest latency option
pImpl->client.SetStreamMode(ViconDataStreamSDK::CPP::StreamMode::ServerPush);
// Set the global up axis
pImpl->client.SetAxisMapping(Direction::Forward,
Direction::Left,
Direction::Up); // Z-up
// Discover the version number
Output_GetVersion version = pImpl->client.GetVersion();
std::stringstream sstr;
sstr << version.Major << "." << version.Minor << "." << version.Point;
pImpl->version = sstr.str();
}
MotionCaptureVicon::~MotionCaptureVicon()
{
delete pImpl;
}
const std::string& MotionCaptureVicon::version() const
{
return pImpl->version;
}
void MotionCaptureVicon::waitForNextFrame()
{
while (pImpl->client.GetFrame().Result != Result::Success) {
}
}
void MotionCaptureVicon::getObjects(
std::vector<Object>& result) const
{
result.clear();
size_t count = pImpl->client.GetSubjectCount().SubjectCount;
result.resize(count);
for (size_t i = 0; i < count; ++i) {
const std::string name = pImpl->client.GetSubjectName(i).SubjectName;
getObjectByName(name, result[i]);
}
}
void MotionCaptureVicon::getObjectByName(
const std::string& name,
Object& result) const
{
auto const translation = pImpl->client.GetSegmentGlobalTranslation(name, name);
auto const quaternion = pImpl->client.GetSegmentGlobalRotationQuaternion(name, name);
if ( translation.Result == Result::Success
&& quaternion.Result == Result::Success
&& !translation.Occluded
&& !quaternion.Occluded) {
Eigen::Vector3f position(
translation.Translation[0] / 1000.0,
translation.Translation[1] / 1000.0,
translation.Translation[2] / 1000.0);
Eigen::Quaternionf rotation(
quaternion.Rotation[3], // w
quaternion.Rotation[0], // x
quaternion.Rotation[1], // y
quaternion.Rotation[2] // z
);
result = Object(name, position, rotation);
} else {
result = Object(name);
}
}
void MotionCaptureVicon::getPointCloud(
pcl::PointCloud<pcl::PointXYZ>::Ptr result) const
{
result->clear();
size_t count = pImpl->client.GetUnlabeledMarkerCount().MarkerCount;
for(size_t i = 0; i < count; ++i) {
Output_GetUnlabeledMarkerGlobalTranslation translation =
pImpl->client.GetUnlabeledMarkerGlobalTranslation(i);
result->push_back(pcl::PointXYZ(
translation.Translation[0] / 1000.0,
translation.Translation[1] / 1000.0,
translation.Translation[2] / 1000.0));
}
}
void MotionCaptureVicon::getLatency(
std::vector<LatencyInfo>& result) const
{
result.clear();
size_t latencyCount = pImpl->client.GetLatencySampleCount().Count;
for(size_t i = 0; i < latencyCount; ++i) {
std::string sampleName = pImpl->client.GetLatencySampleName(i).Name;
double sampleValue = pImpl->client.GetLatencySampleValue(sampleName).Value;
result.emplace_back(LatencyInfo(sampleName, sampleValue));
}
}
bool MotionCaptureVicon::supportsObjectTracking() const
{
return true;
}
bool MotionCaptureVicon::supportsLatencyEstimate() const
{
return true;
}
bool MotionCaptureVicon::supportsPointCloud() const
{
return true;
}
}
| 27.073333 | 89 | 0.657227 | [
"object",
"vector"
] |
1be51b100a3ddc54deb19054fa63192dff589a50 | 1,446 | cpp | C++ | scegliclifordialog.cpp | GiadaTrevisani/SimpleBusinessManager | dec23378faffd4390befecfd52df8103a78b8523 | [
"MIT"
] | 2 | 2018-10-09T19:55:59.000Z | 2019-05-10T09:11:51.000Z | scegliclifordialog.cpp | GiadaTrevisani/SimpleBusinessManager | dec23378faffd4390befecfd52df8103a78b8523 | [
"MIT"
] | null | null | null | scegliclifordialog.cpp | GiadaTrevisani/SimpleBusinessManager | dec23378faffd4390befecfd52df8103a78b8523 | [
"MIT"
] | null | null | null | #include "scegliclifordialog.h"
#include "ui_scegliclifordialog.h"
ScegliCliForDialog::ScegliCliForDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ScegliCliForDialog)
{
ui->setupUi(this);
ui->searchTxt->setPlaceholderText("Cerca");
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
forn = true;
cdb = new ClientDatabaseManager(this);
fdb = new FornitoriDatabaseManager(this);
QObject::connect(ui->searchTxt, SIGNAL(textEdited(QString)), this, SLOT(searchChanged(QString)));
QObject::connect(ui->tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(elementClicked(QModelIndex)));
QObject::connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(elementClicked(QModelIndex)));
}
ScegliCliForDialog::~ScegliCliForDialog()
{
delete ui;
}
void ScegliCliForDialog::setType(bool forn)
{
this->forn = forn;
if(forn){
model = fdb->getModel();
} else {
model = cdb->getModel();
}
ui->tableView->setModel(model);
}
void ScegliCliForDialog::searchChanged(QString src)
{
delete model;
if(forn){
model = fdb->getModel(src);
} else {
model = cdb->getModel(src);
}
ui->tableView->setModel(model);
}
void ScegliCliForDialog::elementClicked(QModelIndex idx)
{
id = model->itemData(model->index(idx.row(), 0)).value(0).toString();
}
QString ScegliCliForDialog::getSelected()
{
return id;
}
| 24.508475 | 113 | 0.686722 | [
"model"
] |
1be6252991bbe1c5a92642eb440345734a85417d | 90,739 | cpp | C++ | test/com/ComModTestAAF/ModuleTests/CAAFEssenceAccessTest.cpp | Phygon/aaf | faef720e031f501190481e1d1fc1870a7dc8f98b | [
"Linux-OpenIB"
] | null | null | null | test/com/ComModTestAAF/ModuleTests/CAAFEssenceAccessTest.cpp | Phygon/aaf | faef720e031f501190481e1d1fc1870a7dc8f98b | [
"Linux-OpenIB"
] | null | null | null | test/com/ComModTestAAF/ModuleTests/CAAFEssenceAccessTest.cpp | Phygon/aaf | faef720e031f501190481e1d1fc1870a7dc8f98b | [
"Linux-OpenIB"
] | null | null | null | // @doc INTERNAL
// @com This file implements the module test for CAAFEssenceAccess
//=---------------------------------------------------------------------=
//
// $Id$ $Name$
//
// The contents of this file are subject to the AAF SDK Public Source
// License Agreement Version 2.0 (the "License"); You may not use this
// file except in compliance with the License. The License is available
// in AAFSDKPSL.TXT, or you may obtain a copy of the License from the
// Advanced Media Workflow Association, Inc., or its successor.
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
// the License for the specific language governing rights and limitations
// under the License. Refer to Section 3.3 of the License for proper use
// of this Exhibit.
//
// WARNING: Please contact the Advanced Media Workflow Association,
// Inc., for more information about any additional licenses to
// intellectual property covering the AAF Standard that may be required
// to create and distribute AAF compliant products.
// (http://www.amwa.tv/policies).
//
// Copyright Notices:
// The Original Code of this file is Copyright 1998-2009, licensor of the
// Advanced Media Workflow Association. All rights reserved.
//
// The Initial Developer of the Original Code of this file and the
// licensor of the Advanced Media Workflow Association is
// Avid Technology.
// All rights reserved.
//
//=---------------------------------------------------------------------=
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <iostream>
using namespace std;
#include "AAFPlatform.h"
#include "AAFTypes.h"
#include "AAFResult.h"
#include "ModuleTest.h"
#include "AAFDefUIDs.h"
#include "AAFDataDefs.h"
#include "AAFOperationDefs.h"
#include "AAFContainerDefs.h"
#include "AAFCodecDefs.h"
#include "AAFEssenceFormats.h"
#include "AAFCompressionDefs.h"
// Include the AAF interface declarations.
#include "AAF.h"
// Include the AAF Stored Object identifiers. These symbols are defined in aaf.lib.
#include "AAFStoredObjectIDs.h"
#include "CAAFBuiltinDefs.h"
// EssenceTestData.h contains sample audio and video data to use as essence data.
#include "EssenceTestData.h"
// convenient error handlers.
inline void checkResult(HRESULT r)
{
if (FAILED(r))
throw r;
}
inline void checkExpression(bool expression, HRESULT r)
{
if (!expression)
throw r;
}
// This static variables are here so they can be referenced
// thru out the whole program.
static const aafInt32 STD_SLOT_ID = 1;
static const aafInt32 STD_WIDTH = 128L;
static const aafInt32 STD_HEIGHT = 96L;
static const aafInt32 PIXELS_PER_FRAME = (STD_WIDTH * STD_HEIGHT);
static const aafInt32 FRAME_BYTES = (PIXELS_PER_FRAME * 3L);
static const aafInt32 SAMPLE_422_BYTES = (PIXELS_PER_FRAME * 2L);
static const aafUInt32 MAX_SAMPLE_COUNT = 2;
static const aafUInt32 STD_SAMPLE_COUNT = 1;
static const aafInt16 STD_PIXEL_SLOP = 4;
static const aafUInt8 green[] = { 0x00, 0xff, 0x00 };
/* This is the value of the YCbCr returned by IJG when decompressing
compressedJFIF */
static const aafUInt8 yuv_green[] = { 0x96, 0x2c, 0x15 };
static const aafUInt8 compressedJFIF[] =
{
0xFF,0xD8,0xFF,0xE0,0x00,0x10,0x41,0x56,0x49,0x31,0x00,0x00,0x00,0x00,0x03,0x6A,
0x00,0x00,0x03,0x6A,0xFF,0xFE,0x00,0x3D,0x41,0x56,0x49,0x44,0x11,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xDD,0x00,0x04,0x00,0x00,0xFF,0xDB,0x00,0x84,0x00,0x08,0x06,
0x06,0x07,0x06,0x05,0x08,0x07,0x07,0x07,0x09,0x09,0x08,0x0A,0x0C,0x14,0x0D,0x0C,
0x0B,0x0B,0x0C,0x19,0x12,0x13,0x0F,0x14,0x1D,0x1A,0x1F,0x1E,0x1D,0x1A,0x1C,0x1C,
0x20,0x24,0x2E,0x27,0x20,0x22,0x2C,0x23,0x1C,0x1C,0x28,0x37,0x29,0x2C,0x30,0x31,
0x34,0x34,0x34,0x1F,0x27,0x39,0x3D,0x38,0x32,0x3C,0x2E,0x33,0x34,0x32,0x01,0x09,
0x09,0x09,0x0C,0x0B,0x0C,0x18,0x0D,0x0D,0x18,0x32,0x21,0x1C,0x21,0x32,0x32,0x32,
0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,
0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,
0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0xFF,
0xC4,0x01,0xA2,0x00,0x00,0x01,0x05,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,
0x01,0x00,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x10,0x00,0x02,
0x01,0x03,0x03,0x02,0x04,0x03,0x05,0x05,0x04,0x04,0x00,0x00,0x01,0x7D,0x01,0x02,
0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,
0x14,0x32,0x81,0x91,0xA1,0x08,0x23,0x42,0xB1,0xC1,0x15,0x52,0xD1,0xF0,0x24,0x33,
0x62,0x72,0x82,0x09,0x0A,0x16,0x17,0x18,0x19,0x1A,0x25,0x26,0x27,0x28,0x29,0x2A,
0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x53,
0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x73,
0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x92,
0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,
0xAA,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,
0xC8,0xC9,0xCA,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xE1,0xE2,0xE3,0xE4,
0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,
0x11,0x00,0x02,0x01,0x02,0x04,0x04,0x03,0x04,0x07,0x05,0x04,0x04,0x00,0x01,0x02,
0x77,0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,
0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,0xA1,0xB1,0xC1,0x09,0x23,0x33,0x52,
0xF0,0x15,0x62,0x72,0xD1,0x0A,0x16,0x24,0x34,0xE1,0x25,0xF1,0x17,0x18,0x19,0x1A,
0x26,0x27,0x28,0x29,0x2A,0x35,0x36,0x37,0x38,0x39,0x3A,0x43,0x44,0x45,0x46,0x47,
0x48,0x49,0x4A,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x63,0x64,0x65,0x66,0x67,
0x68,0x69,0x6A,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x82,0x83,0x84,0x85,0x86,
0x87,0x88,0x89,0x8A,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0xA2,0xA3,0xA4,
0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xC2,
0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,
0xDA,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,
0xF8,0xF9,0xFA,0xFF,0xC0,0x00,0x11,0x08,0x00,0x60,0x00,0x80,0x03,0x01,0x22,0x00,
0x02,0x11,0x01,0x03,0x11,0x01,0xFF,0xDA,0x00,0x0C,0x03,0x01,0x00,0x02,0x11,0x03,
0x11,0x00,0x3F,0x00,0xD6,0xA2,0x8A,0x2B,0xF3,0x43,0xF2,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x00,
0xA2,0x8A,0x28,0x00,0xA2,0x8A,0x28,0x03,0xFF,0xD9
};
static const aafUInt8 compressed422JFIF[] =
{
0xFF,0xD8,0xFF,0xE0,0x00,0x10,0x41,0x56,0x49,0x31,0x00,0x00,0x00,0x00,0x03,0x9A,
0x00,0x00,0x03,0x9A,0xFF,0xFE,0x00,0x3D,0x41,0x56,0x49,0x44,0x11,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xDD,0x00,0x04,0x00,0x00,0xFF,0xDB,0x00,0x84,0x00,0x08,0x06,
0x06,0x07,0x06,0x05,0x08,0x07,0x07,0x07,0x09,0x09,0x08,0x0A,0x0C,0x14,0x0D,0x0C,
0x0B,0x0B,0x0C,0x19,0x12,0x13,0x0F,0x14,0x1D,0x1A,0x1F,0x1E,0x1D,0x1A,0x1C,0x1C,
0x20,0x24,0x2E,0x27,0x20,0x22,0x2C,0x23,0x1C,0x1C,0x28,0x37,0x29,0x2C,0x30,0x31,
0x34,0x34,0x34,0x1F,0x27,0x39,0x3D,0x38,0x32,0x3C,0x2E,0x33,0x34,0x32,0x01,0x09,
0x09,0x09,0x0C,0x0B,0x0C,0x18,0x0D,0x0D,0x18,0x32,0x21,0x1C,0x21,0x32,0x32,0x32,
0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,
0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,
0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0xFF,
0xC4,0x01,0xA2,0x00,0x00,0x01,0x05,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,
0x01,0x00,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x10,0x00,0x02,
0x01,0x03,0x03,0x02,0x04,0x03,0x05,0x05,0x04,0x04,0x00,0x00,0x01,0x7D,0x01,0x02,
0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,
0x14,0x32,0x81,0x91,0xA1,0x08,0x23,0x42,0xB1,0xC1,0x15,0x52,0xD1,0xF0,0x24,0x33,
0x62,0x72,0x82,0x09,0x0A,0x16,0x17,0x18,0x19,0x1A,0x25,0x26,0x27,0x28,0x29,0x2A,
0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x53,
0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x73,
0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x92,
0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,
0xAA,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,
0xC8,0xC9,0xCA,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xE1,0xE2,0xE3,0xE4,
0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,
0x11,0x00,0x02,0x01,0x02,0x04,0x04,0x03,0x04,0x07,0x05,0x04,0x04,0x00,0x01,0x02,
0x77,0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,
0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,0xA1,0xB1,0xC1,0x09,0x23,0x33,0x52,
0xF0,0x15,0x62,0x72,0xD1,0x0A,0x16,0x24,0x34,0xE1,0x25,0xF1,0x17,0x18,0x19,0x1A,
0x26,0x27,0x28,0x29,0x2A,0x35,0x36,0x37,0x38,0x39,0x3A,0x43,0x44,0x45,0x46,0x47,
0x48,0x49,0x4A,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x63,0x64,0x65,0x66,0x67,
0x68,0x69,0x6A,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x82,0x83,0x84,0x85,0x86,
0x87,0x88,0x89,0x8A,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0xA2,0xA3,0xA4,
0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xC2,
0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,
0xDA,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,
0xF8,0xF9,0xFA,0xFF,0xC0,0x00,0x11,0x08,0x00,0x60,0x00,0x80,0x03,0x01,0x21,0x00,
0x02,0x11,0x01,0x03,0x11,0x01,0xFF,0xDA,0x00,0x0C,0x03,0x01,0x00,0x02,0x11,0x03,
0x11,0x00,0x3F,0x00,0xD6,0xA2,0xBF,0x34,0x3F,0x20,0x0A,0x28,0x00,0xA2,0x80,0x0A,
0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,
0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,
0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,
0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,
0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,
0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,
0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,
0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,
0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,
0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,
0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,
0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,
0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,
0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x00,0xA2,0x80,
0x0A,0x28,0x00,0xA2,0x80,0x0A,0x28,0x03,0xFF,0xD9
};
// When tested with horizontalSubsample=1 need 24 bits per pixel, hence multiply by 3
static aafUInt8 uncompressUYVY[STD_WIDTH*STD_HEIGHT*3];
static aafUInt8 *initUncompressedVideo(aafUInt32 horizSubSample, aafUInt32 *bufferSize)
{
// fill with grey
memset(uncompressUYVY, 0x80, sizeof(uncompressUYVY));
if (horizSubSample == 2)
*bufferSize = sizeof(uncompressUYVY) * 2 / 3; // 4:2:2 (16 avg bpp)
else
*bufferSize = sizeof(uncompressUYVY); // 4:4:4 (24 avg bpp)
return uncompressUYVY;
}
static aafUInt8 *readDVframe(aafUInt32 *bufferSize)
{
*bufferSize = 144000;
aafUInt8 *buf = new aafUInt8[*bufferSize];
// Read in a DV-compressed frame
memcpy(buf, compressedDV_25_625, sizeof(compressedDV_25_625));
return buf;
}
// The URL conversion routines are also in ref-impl/src/impl/AAFUtils.cpp
// TODO: We need to create a general-purpose library which all tests and
// perhaps all examples have access to instead of duplicating code.
#ifdef _MSC_VER // MS VC++ dosen't provide POSIX strncasecmp, getcwd
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
#include <direct.h>
#define getcwd(buf, size) _getcwd(buf, size)
#else
#include <strings.h> // strncasecmp()
#include <unistd.h> // getcwd()
#endif
static bool acceptable_pchar(unsigned char c)
{
static const unsigned char isAcceptable[96] =
/* 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF */
{
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xF,0xE,0x0,0xF,0xF,0xC, /* 2x !"#$%&'()*+,-./ */
0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0x8,0x0,0x0,0x0,0x0,0x0, /* 3x 0123456789:;<=>? */
0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF, /* 4x @ABCDEFGHIJKLMNO */
0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0x0,0x0,0x0,0x0,0xF, /* 5x PQRSTUVWXYZ[\]^_ */
0x0,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF, /* 6x `abcdefghijklmno */
0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0x0,0x0,0x0,0x0,0x0 /* 7x pqrstuvwxyz{\}~DEL */
};
return (c >= 32 && c < 128 && isAcceptable[c - 32]);
}
static void escapeURI(const char *str, char *result)
{
const char *p, hex[] = "0123456789ABCDEF";
char *q;
if (!str || !result)
return;
for (q = result, p = str; *p; p++)
{
unsigned char a = *p;
if (!acceptable_pchar(a))
{
*q++ = '%';
*q++ = hex[a >> 4];
*q++ = hex[a & 15];
}
else
*q++ = *p;
}
*q++ = '\0';
}
static char asciiHexToChar (char c)
{
return c >= '0' && c <= '9' ? c - '0'
: c >= 'A' && c <= 'F'? c - 'A' + 10
: c - 'a' + 10; /* accept lowercase letters too */
}
// From RFC 1738
//
// <scheme>:<scheme-specific-part>
// ; the scheme is in lower case; interpreters should use case-ignore
// scheme = 1*[ lowalpha | digit | "+" | "-" | "." ]
//
// For file scheme:
// fileurl = "file://" [ host | "localhost" ] "/" fpath
static void unescapeURI(char *str)
{
char *p = str;
char *q = str;
while (*p)
{
if (*p == '%') // URI hex escape char
{
p++;
if (*p)
*q = asciiHexToChar(*p++) * 16;
if (*p)
*q = *q + asciiHexToChar(*p);
p++;
q++;
}
else
*q++ = *p++;
}
*q++ = 0;
}
static void wcsconvertURLtoFilepath(const wchar_t *url, wchar_t *filepath)
{
// Convert to char* for ease of processing.
// (wcsncasecmp and similiar are not available everywhere)
unsigned tlen = wcslen(url);
char *tmp = new char[tlen+1]; // +1 includes terminating '\0'
wcstombs(tmp, url, tlen+1);
// If no file scheme is found, assume a simple filepath and not a URI.
// Note that other schemes such as http and ftp are not supported.
if (strncasecmp(tmp, "file://", strlen("file://")) != 0)
{
wcscpy(filepath, url);
delete [] tmp;
return;
}
// Skip over the file://[host]/ to point to the fpath.
char *fpath = tmp + strlen("file://");
while (*fpath && *fpath != '/')
fpath++;
#ifdef _WIN32
// WIN32 filepaths must start with a drive letter, so remove the
// initial '/' from the URL.
if (*fpath == '/')
fpath++;
#endif
unescapeURI(fpath);
mbstowcs(filepath, fpath, strlen(fpath)+1); // convert back to wcs
delete [] tmp;
}
static void wcsconvertFilepathtoURL(wchar_t *filepath, wchar_t *url)
{
// convert to char* for ease of processing
int tlen = wcslen(filepath);
char *tmp = new char[tlen+1]; // +1 includes terminating '\0'
wcstombs(tmp, filepath, tlen+1);
#ifdef _WIN32
// On WIN32 backslash is the directory separator, not a regular filename
// character like under Unix or in a URL. So convert them to the URL
// directory separator, forward slash '/', to preserve the hierarchy.
char *p = tmp;
while (*p)
{
if (*p == '\\')
*p = '/';
p++;
}
#endif
// worst case: every char must be hex-escaped - therefore multiply by 3
char *escaped = new char[tlen*3+1];
escapeURI(tmp, escaped);
// prepare the file scheme URL (+1 for '/', +1 for '\0')
char *mb_url = new char[strlen(escaped) + strlen("file://") +1 +1];
strcpy(mb_url, "file://");
if (*escaped != '/') // ensure a leading path slash is present
strcat(mb_url, "/");
strcat(mb_url, escaped);
mbstowcs(url, mb_url, strlen(mb_url)+1); // convert back to wcs
delete [] mb_url;
delete [] escaped;
delete [] tmp;
}
// Assumes the file passed in is a relative filepath to the current
// directory e.g. "test.aaf".
static aafWChar *makeURLfromFileInCwd(const aafWChar *file, aafWChar *url)
{
char cwd[FILENAME_MAX];
if (getcwd(cwd, sizeof(cwd)) == NULL)
{
perror("getcwd");
return NULL;
}
aafWChar wide_cwd[FILENAME_MAX];
mbstowcs(wide_cwd, cwd, strlen(cwd)+1);
// Append file to cwd to give absolute path to the file
wcscat(wide_cwd, L"/");
wcscat(wide_cwd, file);
wcsconvertFilepathtoURL(wide_cwd, url);
return url;
}
// Prototype to satisfy the CW compiler.
extern "C" HRESULT CAAFEssenceAccess_test(
testMode_t mode,
aafUID_t fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_t productID);
#define TEST_PATH L"SomeFile.dat"
static void convert(char* cName, size_t length, const wchar_t* name)
{
size_t status = wcstombs(cName, name, length);
if (status == (size_t)-1) {
cerr << ": Error : Conversion failed." << endl;
exit(1);
}
}
static bool PixelCompare(const aafInt16 slop, aafDataBuffer_t buf1, aafDataBuffer_t buf2, aafUInt32 bufferSize)
{
aafUInt32 index;
aafInt16 diff;
for (index = 0; index < bufferSize; ++index)
{
diff = (aafInt16)buf1[index] - (aafInt16)buf2[index];
if (slop < diff)
return false;
}
return true;
}
#ifdef _DEBUG
static void HexDumpBuffer(const char* label, aafDataBuffer_t buffer, aafUInt32 bufferSize, aafUInt32 cols = 16)
{
int x;
printf("static const aafUInt8 %s[] =\n{", label);
if (buffer && 0 < bufferSize)
{
aafUInt32 i;
for (i = 0; i < (bufferSize - 1); ++i)
{
if ((i % cols) == 0)
printf("\n ");
x = buffer[i];
printf("0x%02X,", x);
}
x = buffer[i];
printf("0x%02X\n", x);
}
printf("};\n");
FILE* file = fopen(label, "wb");
if (NULL != file)
{
fwrite(buffer, 1, bufferSize, file);
fclose(file);
file = NULL;
}
}
#endif // #ifdef _DEBUG
static void MobIDtoString(aafMobID_constref uid, char *buf)
{
sprintf( buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x-" \
"%02x-%02x-%02x-%02x-" \
"%08x%04x%04x" \
"%02x%02x%02x%02x%02x%02x%02x%02x",
(int)uid.SMPTELabel[0], (int)uid.SMPTELabel[1],
(int)uid.SMPTELabel[2], (int)uid.SMPTELabel[3],
(int)uid.SMPTELabel[4], (int)uid.SMPTELabel[5],
(int)uid.SMPTELabel[6], (int)uid.SMPTELabel[7],
(int)uid.SMPTELabel[8], (int)uid.SMPTELabel[9],
(int)uid.SMPTELabel[10], (int)uid.SMPTELabel[11],
(int)uid.length, (int)uid.instanceHigh,
(int)uid.instanceMid, (int)uid.instanceLow,
uid.material.Data1, uid.material.Data2, uid.material.Data3,
(int)uid.material.Data4[0], (int)uid.material.Data4[1],
(int)uid.material.Data4[2], (int)uid.material.Data4[3],
(int)uid.material.Data4[4], (int)uid.material.Data4[5],
(int)uid.material.Data4[6], (int)uid.material.Data4[7] );
}
typedef enum { testStandardCalls, testMultiCalls } testType_t;
typedef aafInt16 AAFByteOrder;
const AAFByteOrder INTEL_ORDER = 0x4949; // 'II' for Intel
const AAFByteOrder MOTOROLA_ORDER = 0x4d4d; // 'MM' for Motorola
static AAFByteOrder getNativeByteOrder(void);
static void ByteSwap32(
aafInt32 *lp); /* IN/OUT -- Byte swap this value */
static void ByteSwap16(
aafInt16 * wp); /* IN/OUT -- Byte swap this value */
void scanWAVEData(aafUInt8 **srcBufHdl, aafInt32 maxsize, void *data);
void scanSwappedWAVEData(aafUInt8 **srcBufHdl, aafInt32 maxsize, void *data);
AAFRESULT loadWAVEHeader(aafUInt8 *buf,
aafUInt16 *bitsPerSample,
aafUInt16 *numCh,
aafRational_t *sampleRate,
aafUInt32 *dataOffset,
aafUInt32 *dataLen);
typedef struct
{
aafWChar *dataFilename;
aafUID_t dataFormat;
} testDataFile_t;
typedef IAAFSmartPointer<IAAFEssenceFormat> IAAFEssenceFormatSP;
const aafUID_t NIL_UID = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
static HRESULT hrSetTransformParameters=0;
static HRESULT ReadStaticEssenceAAFFile(aafWChar * pFileName, testType_t testType, aafUID_t codecID)
{
HRESULT hr = AAFRESULT_SUCCESS;
IAAFFile * pFile = NULL;
IAAFHeader * pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFEssenceAccess* pEssenceAccess = NULL;
IAAFEssenceMultiAccess* pMultiEssence = NULL;
IAAFEssenceFormat *fmtTemplate = NULL;
IEnumAAFMobs* pMobIter = NULL;
IAAFMob* pMob = NULL;
IAAFMasterMob* pMasterMob = NULL;
IAAFEssenceFormatSP pFormat;
aafNumSlots_t numMobs, numSlots;
aafSearchCrit_t criteria;
aafMobID_t mobID;
aafWChar namebuf[1204];
unsigned char AAFDataBuf[4096];
aafUInt32 AAFBytesRead, samplesRead;
try
{
checkResult(AAFFileOpenExistingRead ( pFileName, 0, &pFile));
checkResult(pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create valid AAF objects.
checkResult(pHeader->GetDictionary(&pDictionary));
// Here we checkResult on the number of mobs in the file.
// Get the number of master mobs in the file (should be one)
checkResult(pHeader->CountMobs(kAAFMasterMob, &numMobs));
checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);
criteria.searchTag = kAAFByMobKind;
criteria.tags.mobKind = kAAFMasterMob;
checkResult(pHeader->GetMobs(&criteria, &pMobIter));
while(AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
{
char mobIDstr[256];
char mobName[256];
checkResult(pMob->GetMobID (&mobID));
checkResult(pMob->GetName (namebuf, sizeof(namebuf)));
convert(mobName, sizeof(mobName), namebuf);
MobIDtoString(mobID, mobIDstr);
// Make sure we have one slot
checkResult(pMob->CountSlots(&numSlots));
checkExpression(1 == numSlots, AAFRESULT_TEST_FAILED);
// The essence data is in SlotID 1
// Get a Master Mob interface
checkResult(pMob->QueryInterface(IID_IAAFMasterMob, (void **)&pMasterMob));
// Open the Essence Data
checkResult(pMasterMob->OpenEssence( 1, // SlotID 1
NULL, // mediaCriteria (Don't care)
kAAFMediaOpenReadOnly, // Open mode
kAAFCompressionDisable,// Compress disabled
&pEssenceAccess));
aafUID_t tstCodecID = {0};
checkResult(pEssenceAccess->GetCodecID(&tstCodecID));
if (false && memcmp(&tstCodecID, &codecID, sizeof(codecID)))
{
cout << " Warning:GetCodecID did not return CodecJPEG." << endl;
}
// Read the Data from the AAF file
if(testType == testStandardCalls)
{
checkResult(pEssenceAccess->ReadSamples( 1, // number of samples - must be 1 for JPEG codec
sizeof(AAFDataBuf), // Maximum buffer size
AAFDataBuf, // Buffer for the data
&samplesRead, // Actual number of samples read
&AAFBytesRead)); // Actual number of bytes read
}
else if(testType == testMultiCalls)
{
cout << "testMultiCalls not supported in AAF Static Essence Tests" << endl;
}
// Now compare the data read from the AAF file to the actual WAV file
if (sizeof(compressedJFIF) != AAFBytesRead)
{
cout << "***Wrong number of bytes read ( was "
<< AAFBytesRead
<< ", should be "
<< sizeof(compressedJFIF)
<< ")"
<< endl;
}
if (memcmp( compressedJFIF, AAFDataBuf, sizeof(compressedJFIF)) != 0)
{
cout << "*** Data Read is different than the data in the compressedJFIF ***" << endl;
}
// cleanup the master mob.
pMasterMob->Release();
pMasterMob = NULL;
pMob->Release();
pMob = NULL;
}
}
catch (HRESULT& rhr)
{
hr = rhr; // return thrown error code.
}
catch (...)
{
// We CANNOT throw an exception out of a COM interface method!
// Return a reasonable exception code.
hr = AAFRESULT_UNEXPECTED_EXCEPTION;
}
// Cleanup and return
if (pMultiEssence)
pMultiEssence->Release();
if(fmtTemplate)
fmtTemplate->Release();
if (pEssenceAccess)
pEssenceAccess->Release();
if (pMasterMob)
pMob->Release();
if (pMob)
pMob->Release();
if (pMobIter)
pMobIter->Release();
if (pDictionary)
pDictionary->Release();
if (pHeader)
pHeader->Release();
if (pFile)
{
HRESULT local_hr = pFile->Close();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
pFile->Release();
}
return hr;
}
static HRESULT CreateStaticEssenceAAFFile(
aafWChar * pFileName,
aafUID_constref fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_constref productID,
testDataFile_t *dataFile,
testType_t testType,
aafUID_t codecID,
aafUID_t ddefID)
{
HRESULT hr = AAFRESULT_SUCCESS;
IAAFFile* pFile = NULL;
IAAFHeader* pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFDataDef* pDataDef = NULL;
IAAFMob* pMob = NULL;
IAAFMasterMob* pMasterMob = NULL;
IAAFMasterMob2* pMasterMob2 = NULL;
IAAFEssenceAccess* pEssenceAccess = NULL;
IAAFEssenceMultiAccess* pMultiEssence = NULL;
IAAFEssenceFormatSP pFormat;
IAAFEssenceFormat *format = NULL;
IAAFLocator *pLocator = NULL;
// !!!Previous revisions of this file contained variables here required to handle external essence
aafMobID_t masterMobID;
aafUID_t testContainer;
// delete any previous test file before continuing...
char chNameBuffer[1000];
try
{
convert(chNameBuffer, sizeof(chNameBuffer), pFileName);
remove(chNameBuffer);
if(dataFile != NULL)
{
// delete any previous test file before continuing...
char chNameBuffer[1000];
convert(chNameBuffer, sizeof(chNameBuffer), dataFile->dataFilename);
remove(chNameBuffer);
}
checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
checkResult(pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create valid AAF objects.
checkResult(pHeader->GetDictionary(&pDictionary));
CAAFBuiltinDefs defs (pDictionary);
// !!!Previous revisions of this file contained code here required to handle external essence
// Get a Master MOB Interface
checkResult(defs.cdMasterMob()->
CreateInstance(IID_IAAFMasterMob,
(IUnknown **)&pMasterMob));
// Get a Mob interface and set its variables.
checkResult(pMasterMob->QueryInterface(IID_IAAFMob, (void **)&pMob));
checkResult(pMob->GetMobID(&masterMobID));
checkResult(pMob->SetName(L"A Master Mob"));
// Add it to the file
checkResult(pHeader->AddMob(pMob));
pLocator = NULL;
testContainer = ContainerAAF;
// lookup datadef object to use
checkResult(pDictionary->LookupDataDef(ddefID, &pDataDef));
// now create the Essence data file
checkResult(pMasterMob->QueryInterface(IID_IAAFMasterMob2, (void **)&pMasterMob2));
checkResult(pMasterMob2->CreateStaticEssence(STD_SLOT_ID, // Slot ID
pDataDef, // MediaKind
codecID, // codecID
kAAFCompressionDisable, // compression enabled or disabled
pLocator, // In current file
testContainer, // In AAF Format
&pEssenceAccess));
// compressedJFIF
aafUInt32 samplesWritten, bytesWritten;
checkResult(pEssenceAccess->WriteSamples( STD_SAMPLE_COUNT,
sizeof(compressedJFIF),// buffer size
(aafDataBuffer_t) compressedJFIF, // THE data
&samplesWritten,
&bytesWritten));
checkResult(pEssenceAccess->CompleteWrite());
}
catch (HRESULT& rhr)
{
hr = rhr; // return thrown error code.
}
catch (...)
{
// We CANNOT throw an exception out of a COM interface method!
// Return a reasonable exception code.
hr = AAFRESULT_UNEXPECTED_EXCEPTION;
}
// Cleanup and return
if (pMultiEssence)
pMultiEssence->Release();
if(format)
format->Release();
if (pEssenceAccess)
pEssenceAccess->Release();
if(pLocator)
pLocator->Release();
if (pMob)
pMob->Release();
if (pMasterMob2)
pMasterMob2->Release();
if (pMasterMob)
pMasterMob->Release();
if(pDataDef)
pDataDef->Release();
if(pDictionary)
pDictionary->Release();
if(pHeader)
pHeader->Release();
if (pFile)
{ // Preserve previous errors...
HRESULT local_hr = pFile->Save();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
local_hr = pFile->Close();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
pFile->Release();
}
return hr;
}
static HRESULT CreateAudioAAFFile(
aafWChar * pFileName,
aafUID_constref fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_constref productID,
testDataFile_t *dataFile,
testType_t testType,
aafUID_t codecID,
aafUID_t ddefID,
aafBool bCallSetTransformParameters=kAAFFalse)
{
HRESULT hr = AAFRESULT_SUCCESS;
IAAFFile* pFile = NULL;
IAAFHeader* pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFDataDef* pDataDef = NULL;
IAAFMob* pMob = NULL;
IAAFMasterMob* pMasterMob = NULL;
IAAFEssenceAccess* pEssenceAccess = NULL;
IAAFEssenceMultiAccess* pMultiEssence = NULL;
IAAFEssenceFormatSP pFormat;
IAAFEssenceFormat *format = NULL;
IAAFLocator *pLocator = NULL;
// !!!Previous revisions of this file contained variables here required to handle external essence
aafMobID_t masterMobID;
aafRational_t editRate = {44100, 1};
aafRational_t sampleRate = {44100, 1};
unsigned char dataBuff[4096], *dataPtr;
aafUInt32 dataOffset, dataLen;
aafUInt16 bitsPerSample, numCh;
aafInt32 n, numSpecifiers;
aafUID_t essenceFormatCode, testContainer;
aafUInt32 samplesWritten, bytesWritten;
// delete any previous test file before continuing...
try
{
char chNameBuffer[FILENAME_MAX];
convert(chNameBuffer, sizeof(chNameBuffer), pFileName);
remove(chNameBuffer);
if(dataFile != NULL)
{
// delete any previous test file before continuing...
aafWChar filepath[FILENAME_MAX];
wcsconvertURLtoFilepath(dataFile->dataFilename, filepath);
convert(chNameBuffer, sizeof(chNameBuffer), filepath);
remove(chNameBuffer);
}
checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
checkResult(pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create valid AAF objects.
checkResult(pHeader->GetDictionary(&pDictionary));
CAAFBuiltinDefs defs (pDictionary);
// !!!Previous revisions of this file contained code here required to handle external essence
// Get a Master MOB Interface
checkResult(defs.cdMasterMob()->
CreateInstance(IID_IAAFMasterMob,
(IUnknown **)&pMasterMob));
// Get a Mob interface and set its variables.
checkResult(pMasterMob->QueryInterface(IID_IAAFMob, (void **)&pMob));
checkResult(pMob->GetMobID(&masterMobID));
checkResult(pMob->SetName(L"A Master Mob"));
// Add it to the file
checkResult(pHeader->AddMob(pMob));
// !!!Previous revisions of this file contained code here required to handle external essence
if(dataFile != NULL)
{
// Make a locator, and attach it to the EssenceDescriptor
checkResult(defs.cdNetworkLocator()->
CreateInstance(IID_IAAFLocator,
(IUnknown **)&pLocator));
checkResult(pLocator->SetPath (dataFile->dataFilename));
testContainer = dataFile->dataFormat;
}
else
{
pLocator = NULL;
testContainer = ContainerAAF;
}
// copy contents of Laser.wav into buffer
memcpy(dataBuff, uncompressedWAVE_Laser, sizeof(uncompressedWAVE_Laser));
checkResult(loadWAVEHeader(dataBuff,
&bitsPerSample,
&numCh,
&sampleRate,
&dataOffset,
&dataLen));
dataPtr = dataBuff + dataOffset;
// lookup datadef object to use
checkResult(pDictionary->LookupDataDef(ddefID, &pDataDef));
// now create the Essence data file
checkResult(pMasterMob->CreateEssence(STD_SLOT_ID, // Slot ID
pDataDef, // MediaKind
codecID, // kAAFCodecWAVE
editRate, // edit rate
sampleRate, // sample rate
kAAFCompressionDisable, // compression enabled or disabled
pLocator, // In current file
testContainer, // In AAF Format
&pEssenceAccess));
// Get the codecID and validate that it is what we expect.
aafUID_t codecID = {0};
checkResult(pEssenceAccess->GetCodecID(&codecID));
checkExpression(0 == memcmp(&codecID, &codecID, sizeof(codecID)), AAFRESULT_TEST_FAILED);
checkResult(pEssenceAccess->GetFileFormatParameterList (&format));
checkResult(format->NumFormatSpecifiers (&numSpecifiers));
for(n = 0; n < numSpecifiers; n++)
{
checkResult(format->GetIndexedFormatSpecifier (n, &essenceFormatCode, 0, NULL, NULL));
}
format->Release();
format = NULL;
// Tell the AAFEssenceAccess what the format is.
checkResult(pEssenceAccess->GetEmptyFileFormat (&pFormat));
checkResult(pFormat->NumFormatSpecifiers (&numSpecifiers));
aafInt32 sampleSize = bitsPerSample;
checkResult(pFormat->AddFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleSize), (aafUInt8 *)&sampleSize));
checkResult(pEssenceAccess->PutFileFormat (pFormat));
// At the time this test was written, SetTransformParameters() returned
// AAFRESULT_NOT_IN_CURRENT_VERSION, and therefore did not need to be
// tested. We simply store the HRESULT from SetTransformParameters(), and
// check at the end of CAAFEssenceAccess_test(testMode_t mode) if the function still
// returns that code.
if(bCallSetTransformParameters==kAAFTrue)
hrSetTransformParameters=pEssenceAccess->SetTransformParameters(
pFormat);
// NIL flavour is the only one available for kAAFCodecWAVE
checkResult(pEssenceAccess->SetEssenceCodecFlavour(kAAFNilCodecFlavour));
// write out the data
if(testType == testStandardCalls)
{
checkResult(pEssenceAccess->WriteSamples( dataLen, //!!! hardcoded bytes/sample ==1// Number of Samples
sizeof(dataBuff),// buffer size
dataPtr, // THE data
&samplesWritten,
&bytesWritten));
}
else if(testType == testMultiCalls)
{
aafmMultiXfer_t xfer;
aafmMultiResult_t result;
checkResult(pEssenceAccess->QueryInterface(IID_IAAFEssenceMultiAccess, (void **)&pMultiEssence));
//!!! xfer.subTrackNum = _channels[0].physicalOutChan;
xfer.numSamples = dataLen; //!!! hardcoded bytes/sample ==1
xfer.buflen = sizeof(dataBuff);
xfer.buffer = dataPtr;
result.bytesXfered = 0;
checkResult(pMultiEssence->WriteMultiSamples(1, &xfer, &result));
pMultiEssence->Release();
pMultiEssence = NULL;
samplesWritten = result.samplesXfered;
bytesWritten = result.bytesXfered;
}
// Finish writing the destination
checkResult(pEssenceAccess->CompleteWrite());
}
catch (HRESULT& rhr)
{
hr = rhr; // return thrown error code.
}
catch (...)
{
// We CANNOT throw an exception out of a COM interface method!
// Return a reasonable exception code.
hr = AAFRESULT_UNEXPECTED_EXCEPTION;
}
// Cleanup and return
if (pMultiEssence)
pMultiEssence->Release();
if(format)
format->Release();
if (pEssenceAccess)
pEssenceAccess->Release();
if(pLocator)
pLocator->Release();
if (pMob)
pMob->Release();
if (pMasterMob)
pMasterMob->Release();
if(pDataDef)
pDataDef->Release();
if(pDictionary)
pDictionary->Release();
if(pHeader)
pHeader->Release();
if (pFile)
{ // Preserve previous errors...
HRESULT local_hr = pFile->Save();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
local_hr = pFile->Close();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
pFile->Release();
}
return hr;
}
static HRESULT ReadAAFFile(aafWChar * pFileName, testType_t testType, aafUID_t codecID)
{
HRESULT hr = AAFRESULT_SUCCESS;
IAAFFile * pFile = NULL;
IAAFHeader * pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFEssenceAccess* pEssenceAccess = NULL;
IAAFEssenceMultiAccess* pMultiEssence = NULL;
IAAFEssenceFormat *fmtTemplate = NULL;
IEnumAAFMobs* pMobIter = NULL;
IAAFMob* pMob = NULL;
IAAFMasterMob* pMasterMob = NULL;
IAAFEssenceFormatSP pFormat;
aafNumSlots_t numMobs, numSlots;
aafSearchCrit_t criteria;
aafRational_t readSampleRate;
aafMobID_t mobID;
aafWChar namebuf[1204];
unsigned char AAFDataBuf[4096];
aafUInt32 AAFBytesRead, samplesRead;
unsigned char WAVDataBuf[4096], *dataPtr;
aafUInt32 dataOffset, dataLen;
aafUInt16 bitsPerSample, numCh;
try
{
checkResult(AAFFileOpenExistingRead ( pFileName, 0, &pFile));
checkResult(pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create valid AAF objects.
checkResult(pHeader->GetDictionary(&pDictionary));
// Here we checkResult on the number of mobs in the file.
// Get the number of master mobs in the file (should be one)
checkResult(pHeader->CountMobs(kAAFMasterMob, &numMobs));
checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);
criteria.searchTag = kAAFByMobKind;
criteria.tags.mobKind = kAAFMasterMob;
checkResult(pHeader->GetMobs(&criteria, &pMobIter));
while(AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
{
char mobIDstr[256];
char mobName[256];
checkResult(pMob->GetMobID (&mobID));
checkResult(pMob->GetName (namebuf, sizeof(namebuf)));
convert(mobName, sizeof(mobName), namebuf);
MobIDtoString(mobID, mobIDstr);
// Make sure we have one slot
checkResult(pMob->CountSlots(&numSlots));
checkExpression(1 == numSlots, AAFRESULT_TEST_FAILED);
// The essence data is in SlotID 1
// Get a Master Mob interface
checkResult(pMob->QueryInterface(IID_IAAFMasterMob, (void **)&pMasterMob));
// Open the Essence Data
checkResult(pMasterMob->OpenEssence(STD_SLOT_ID, // SlotID
NULL, // mediaCriteria (Don't care)
kAAFMediaOpenReadOnly, // Open mode
kAAFCompressionDisable,// Compress disabled
&pEssenceAccess));
aafUID_t tstCodecID = {0};
checkResult(pEssenceAccess->GetCodecID(&tstCodecID));
if (false && memcmp(&tstCodecID, &codecID, sizeof(codecID)))
{
cout << " Warning:GetCodecID did not return CodecJPEG." << endl;
}
// copy contents of Laser.wav into buffer
memcpy(WAVDataBuf, uncompressedWAVE_Laser, sizeof(uncompressedWAVE_Laser));
checkResult(loadWAVEHeader(WAVDataBuf,
&bitsPerSample,
&numCh,
&readSampleRate,
&dataOffset,
&dataLen));
dataPtr = WAVDataBuf + dataOffset;
aafUInt32 sampleBits;
aafInt32 bytesRead;
checkResult(pEssenceAccess->GetEmptyFileFormat (&fmtTemplate));
checkResult(fmtTemplate->AddFormatSpecifier (kAAFAudioSampleBits, 0, NULL));
checkResult(pEssenceAccess->GetFileFormat (fmtTemplate, &pFormat));
fmtTemplate->Release();
fmtTemplate = NULL;
checkResult(pFormat->GetFormatSpecifier (kAAFAudioSampleBits, sizeof(sampleBits),
(aafDataBuffer_t)&sampleBits, &bytesRead));
checkExpression(sampleBits == bitsPerSample, AAFRESULT_TEST_FAILED);
// Read the Data from the AAF file
if(testType == testStandardCalls)
{
checkResult(pEssenceAccess->ReadSamples( dataLen, //!!! Hardcoded // Number of Samples
sizeof(AAFDataBuf), // Maximum buffer size
AAFDataBuf, // Buffer for the data
&samplesRead, // Actual number of samples read
&AAFBytesRead)); // Actual number of bytes read
}
else if(testType == testMultiCalls)
{
aafmMultiXfer_t xfer;
aafmMultiResult_t result;
checkResult(pEssenceAccess->QueryInterface(IID_IAAFEssenceMultiAccess, (void **)&pMultiEssence));
xfer.numSamples = dataLen; //!!! Hardcoded // Number of Samples
xfer.buflen = sizeof(AAFDataBuf);
xfer.buffer = AAFDataBuf;
result.bytesXfered = 0;
checkResult(pMultiEssence->ReadMultiSamples(1, &xfer, &result));
samplesRead = result.samplesXfered;
AAFBytesRead = result.bytesXfered;
pMultiEssence->Release();
pMultiEssence = NULL;
}
// Now compare the data read from the AAF file to the actual WAV file
if (dataLen != AAFBytesRead)
{
cout << "***Wrong number of bytes read ( was "
<< AAFBytesRead
<< ", should be "
<< sizeof(uncompressedWAVE_Laser)
<< ")"
<< endl;
}
if (memcmp( dataPtr, AAFDataBuf, dataLen) != 0)
{
cout << "*** Data Read is different than the data in the WAV file ***" << endl;
}
// cleanup the master mob.
pMasterMob->Release();
pMasterMob = NULL;
pMob->Release();
pMob = NULL;
}
}
catch (HRESULT& rhr)
{
hr = rhr; // return thrown error code.
}
catch (...)
{
// We CANNOT throw an exception out of a COM interface method!
// Return a reasonable exception code.
hr = AAFRESULT_UNEXPECTED_EXCEPTION;
}
// Cleanup and return
if (pMultiEssence)
pMultiEssence->Release();
if(fmtTemplate)
fmtTemplate->Release();
if (pEssenceAccess)
pEssenceAccess->Release();
if (pMasterMob)
pMob->Release();
if (pMob)
pMob->Release();
if (pMobIter)
pMobIter->Release();
if (pDictionary)
pDictionary->Release();
if (pHeader)
pHeader->Release();
if (pFile)
{
HRESULT local_hr = pFile->Close();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
pFile->Release();
}
return hr;
}
static void FillSampleFrameBuffer(
aafDataBuffer_t buffer,
aafUInt32 height,
aafUInt32 width,
aafUInt32 padBytesPerRow,
const aafUInt8 color[])
{
aafUInt32 row, col, rowBytes, offset;
rowBytes = (width * 3) + padBytesPerRow;
for (row = offset = 0; row < height; ++row)
{
offset = row * rowBytes;
for (col = 0; col < width; ++col, offset += 3)
{
buffer[offset + 0] = color[0];
buffer[offset + 1] = color[1];
buffer[offset + 2] = color[2];
}
}
}
static void FillYCbCr422SampleBufferFromYCbCr(
aafDataBuffer_t buffer,
aafUInt32 height,
aafUInt32 width,
const aafUInt8 color[])
{
aafUInt32 row, col, offset;
for (row = offset = 0; row < height; ++row)
{
for (col = 0; col < width; ++col)
{
if (col % 2 == 0)
{
buffer[offset++] = color[1];
buffer[offset++] = color[0];
buffer[offset++] = color[2];
}
else
{
buffer[offset++] = color[0];
}
}
}
}
static HRESULT CreateVideoAAFFile(
aafWChar * pFileName,
aafUID_constref fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_constref productID,
testDataFile_t *dataFile,
aafCompressEnable_t compressEnable,
aafColorSpace_t colorSpace,
aafUInt32 horizontalSubsample,
aafUID_t codecID,
aafUID_t ddefID,
testType_t testType,
aafUID_t compression)
{
HRESULT hr = AAFRESULT_SUCCESS;
IAAFFile* pFile = NULL;
IAAFHeader* pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFDataDef* pDataDef = NULL;
IAAFMob* pMob = NULL;
IAAFMasterMob* pMasterMob = NULL;
IAAFEssenceAccess* pEssenceAccess = NULL;
IAAFEssenceMultiAccess* pMultiEssence = NULL;
IAAFEssenceFormatSP pFormat;
IAAFEssenceFormat *format = NULL;
IAAFEssenceFormat* pTransformFormat = NULL;
IAAFLocator *pLocator = NULL;
aafMobID_t masterMobID;
aafRational_t editRate = {30000, 1001};
aafRational_t sampleRate = {30000, 1001};
// unsigned char dataBuff[4096], *dataPtr;
// size_t bytesRead;
// aafUInt32 dataOffset, dataLen;
// aafUInt16 bitsPerSample, numCh;
// aafUInt32 bytesWritten;
aafInt32 n, numSpecifiers;
aafUID_t essenceFormatCode, testContainer;
aafCharacter wNameBuffer[500];
aafDataBuffer_t rgbColorBuffer = NULL, compressedBuffer = NULL;
aafDataBuffer_t writeBuffer = NULL;
aafUInt32 writeBufferSize = 0, compressedBufferSize = 0;
aafUInt32 samplesWritten, bytesWritten;
try
{
checkExpression((1 == horizontalSubsample ||
(2 == horizontalSubsample && kAAFColorSpaceYUV == colorSpace)),
AAFRESULT_TEST_FAILED);
// delete any previous test file before continuing...
char chNameBuffer[FILENAME_MAX];
convert(chNameBuffer, sizeof(chNameBuffer), pFileName);
remove(chNameBuffer);
if(dataFile != NULL)
{
// delete any previous test file before continuing...
aafWChar filepath[FILENAME_MAX];
wcsconvertURLtoFilepath(dataFile->dataFilename, filepath);
convert(chNameBuffer, sizeof(chNameBuffer), filepath);
remove(chNameBuffer);
}
aafRect_t rc;
rc.xOffset = rc.yOffset = 0;
rc.xSize = STD_WIDTH;
rc.ySize = STD_HEIGHT;
if (codecID == kAAFCodecJPEG)
{
if (kAAFColorSpaceYUV == colorSpace && 2 == horizontalSubsample)
{
compressedBuffer = const_cast<aafDataBuffer_t>(compressed422JFIF);
compressedBufferSize = sizeof(compressed422JFIF);
}
else
{
compressedBuffer = const_cast<aafDataBuffer_t>(compressedJFIF);
compressedBufferSize = sizeof(compressedJFIF);
}
if (compressEnable == kAAFCompressionEnable)
{
if (kAAFColorSpaceYUV == colorSpace)
{
if (2 == horizontalSubsample)
{
rgbColorBuffer = new aafUInt8[SAMPLE_422_BYTES];
checkExpression(NULL != rgbColorBuffer, AAFRESULT_NOMEMORY);
FillYCbCr422SampleBufferFromYCbCr(rgbColorBuffer, STD_HEIGHT, STD_WIDTH, yuv_green);
writeBufferSize = SAMPLE_422_BYTES;
}
else
{
rgbColorBuffer = new aafUInt8[FRAME_BYTES];
checkExpression(NULL != rgbColorBuffer, AAFRESULT_NOMEMORY);
FillSampleFrameBuffer(rgbColorBuffer, STD_HEIGHT, STD_WIDTH, 0, yuv_green);
writeBufferSize = FRAME_BYTES;
}
}
else
{
rgbColorBuffer = new aafUInt8[FRAME_BYTES];
checkExpression(NULL != rgbColorBuffer, AAFRESULT_NOMEMORY);
FillSampleFrameBuffer(rgbColorBuffer, STD_HEIGHT, STD_WIDTH, 0, green);
writeBufferSize = FRAME_BYTES;
}
writeBuffer = rgbColorBuffer;
}
else
{
writeBuffer = compressedBuffer;
writeBufferSize = compressedBufferSize;
}
}
else if (compression == kAAFCompressionDef_LegacyDV)
{
writeBuffer = readDVframe( &writeBufferSize );
rgbColorBuffer = writeBuffer; // to ensure it is freed
aafRational_t PAL_rate = {25, 1};
editRate = PAL_rate;
sampleRate = PAL_rate;
rc.xSize = 720;
rc.ySize = 576 / 2;
}
else // codecID is not JPEG Codec
{
// Uncompressed video
writeBuffer = initUncompressedVideo( horizontalSubsample, &writeBufferSize );
}
checkResult(CreateTestFile( pFileName, fileKind, rawStorageType, productID, &pFile ));
checkResult(pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create valid AAF objects.
checkResult(pHeader->GetDictionary(&pDictionary));
CAAFBuiltinDefs defs (pDictionary);
// Get a Master MOB Interface
checkResult(defs.cdMasterMob()->
CreateInstance(IID_IAAFMasterMob,
(IUnknown **)&pMasterMob));
// Get a Mob interface and set its variables.
checkResult(pMasterMob->QueryInterface(IID_IAAFMob, (void **)&pMob));
checkResult(pMob->GetMobID(&masterMobID));
checkResult(pMob->SetName(L"A Master Mob"));
// Add it to the file
checkResult(pHeader->AddMob(pMob));
// !!!Previous revisions of this file contained code here required to handle external essence
if(dataFile != NULL)
{
// Make a locator, and attach it to the EssenceDescriptor
checkResult(defs.cdNetworkLocator()->
CreateInstance(IID_IAAFLocator,
(IUnknown **)&pLocator));
checkResult(pLocator->SetPath (dataFile->dataFilename));
testContainer = dataFile->dataFormat;
}
else
{
pLocator = NULL;
testContainer = ContainerAAF;
}
// lookup datadef object to use
checkResult(pDictionary->LookupDataDef(ddefID, &pDataDef));
// now create the Essence data file
checkResult(pMasterMob->CreateEssence(STD_SLOT_ID, // Slot ID
pDataDef, // MediaKind
codecID, // e.g. kAAFCodecCDCI, kAAFCodecJPEG
editRate, // edit rate
sampleRate, // sample rate
compressEnable, // compression enabled or disabled
pLocator, // In current file
testContainer, // In AAF Format
&pEssenceAccess));
// For legacy DV, the convenient way is to set a CDCI codec flavour
if (compression == kAAFCompressionDef_LegacyDV)
checkResult(pEssenceAccess->SetEssenceCodecFlavour(kAAFCodecFlavour_LegacyDV_625_50));
// Get and display the current code name.
checkResult(pEssenceAccess->GetCodecName(sizeof(wNameBuffer), wNameBuffer));
convert(chNameBuffer, sizeof(chNameBuffer), wNameBuffer);
// Get the codecID and validate that it is what we expect.
aafUID_t expCodecID = {0};
checkResult(pEssenceAccess->GetCodecID(&expCodecID));
checkExpression(0 == memcmp(&expCodecID, &codecID, sizeof(expCodecID)), AAFRESULT_TEST_FAILED);
checkResult(pEssenceAccess->GetFileFormatParameterList (&format));
checkResult(format->NumFormatSpecifiers (&numSpecifiers));
for(n = 0; n < numSpecifiers; n++)
{
checkResult(format->GetIndexedFormatSpecifier (n, &essenceFormatCode, 0, NULL, NULL));
}
// Save the default pixel color space.
aafInt32 bytesRead = 0;
aafColorSpace_t defaultPixelColorSpace;
checkResult(format->GetFormatSpecifier (kAAFPixelFormat, sizeof(defaultPixelColorSpace),(aafDataBuffer_t)&defaultPixelColorSpace, &bytesRead));
checkExpression(sizeof(defaultPixelColorSpace) == bytesRead, AAFRESULT_TEST_FAILED);
format->Release();
format = NULL;
// Tell the AAFEssenceAccess what the format is.
checkResult(pEssenceAccess->GetEmptyFileFormat (&pFormat));
checkResult(pFormat->NumFormatSpecifiers (&numSpecifiers));
// Set the stored rectangle.
checkResult(pFormat->AddFormatSpecifier (kAAFStoredRect, sizeof(rc), (aafDataBuffer_t)&rc));
checkResult(pFormat->AddFormatSpecifier (kAAFSampledRect, sizeof(rc), (aafDataBuffer_t)&rc));
checkResult(pFormat->AddFormatSpecifier (kAAFDisplayRect, sizeof(rc), (aafDataBuffer_t)&rc));
if (compressEnable == kAAFCompressionEnable)
{
aafUInt8 quality = 75;
checkResult(pFormat->AddFormatSpecifier (kAAFCompressionQuality, sizeof(quality), (aafDataBuffer_t)&quality));
}
// Set the values for the codec.
checkResult(pEssenceAccess->PutFileFormat (pFormat));
// Change the output pixel format / color space if necessary.
if (compressEnable == kAAFCompressionEnable && defaultPixelColorSpace != colorSpace)
{
// NOTE: TransformParameters have not been implemented yet!
// For now just use the PutFileFormat method.
checkResult(pEssenceAccess->GetEmptyFileFormat (&pTransformFormat));
if (kAAFColorSpaceYUV == colorSpace)
{
checkResult(pTransformFormat->AddFormatSpecifier (kAAFCDCIHorizSubsampling, sizeof(horizontalSubsample), (aafDataBuffer_t)&horizontalSubsample));
}
checkResult(pTransformFormat->AddFormatSpecifier (kAAFPixelFormat, sizeof(colorSpace), (aafDataBuffer_t)&colorSpace));
checkResult(pEssenceAccess->PutFileFormat(pTransformFormat));
pTransformFormat->Release();
pTransformFormat = NULL;
}
if (codecID != kAAFCodecJPEG && compressEnable == kAAFCompressionDisable)
{
// For Legacy DV a flavour was set. For other formats use format specifiers.
if (compression != kAAFCompressionDef_LegacyDV)
{
// Set format specifiers needed for uncompressed CDCI video
checkResult(pEssenceAccess->GetEmptyFileFormat (&pTransformFormat));
checkResult(pTransformFormat->AddFormatSpecifier (kAAFCDCIHorizSubsampling, sizeof(horizontalSubsample), (aafDataBuffer_t)&horizontalSubsample));
checkResult(pEssenceAccess->PutFileFormat(pTransformFormat));
pTransformFormat->Release();
pTransformFormat = NULL;
}
}
// write out the data
aafUInt32 index;
for (index = 0; index < MAX_SAMPLE_COUNT; ++index)
{
if(testType == testStandardCalls)
{
checkResult(pEssenceAccess->WriteSamples(STD_SAMPLE_COUNT, //!!! hardcoded bytes/sample ==1// Number of Samples
writeBufferSize, // buffer size
writeBuffer, // THE data
&samplesWritten,
&bytesWritten));
}
else if(testType == testMultiCalls)
{
aafmMultiXfer_t xfer;
aafmMultiResult_t result;
checkResult(pEssenceAccess->QueryInterface(IID_IAAFEssenceMultiAccess, (void **)&pMultiEssence));
//!!! xfer.subTrackNum = _channels[0].physicalOutChan;
xfer.numSamples = STD_SAMPLE_COUNT; //!!! hardcoded bytes/sample ==1
xfer.buflen = writeBufferSize;
xfer.buffer = writeBuffer;
result.bytesXfered = 0;
HRESULT r = pMultiEssence->WriteMultiSamples(STD_SAMPLE_COUNT, &xfer, &result);
if (r == AAFRESULT_INVALID_OP_CODEC)
{
hr = r;
break;
}
checkResult(r);
pMultiEssence->Release();
pMultiEssence = NULL;
samplesWritten = result.samplesXfered;
bytesWritten = result.bytesXfered;
}
}
// Finish writing the destination
checkResult(pEssenceAccess->CompleteWrite());
}
catch (HRESULT& rhr)
{
hr = rhr; // return thrown error code.
}
catch (...)
{
// We CANNOT throw an exception out of a COM interface method!
// Return a reasonable exception code.
hr = AAFRESULT_UNEXPECTED_EXCEPTION;
}
// Cleanup and return
if (rgbColorBuffer)
delete [] rgbColorBuffer;
if (pMultiEssence)
pMultiEssence->Release();
if(format)
format->Release();
if (pTransformFormat)
pTransformFormat->Release();
if (pEssenceAccess)
pEssenceAccess->Release();
if(pLocator)
pLocator->Release();
if (pMob)
pMob->Release();
if (pMasterMob)
pMasterMob->Release();
if(pDataDef)
pDataDef->Release();
if(pDictionary)
pDictionary->Release();
if(pHeader)
pHeader->Release();
if (pFile)
{ // Preserve previous errors...
HRESULT local_hr = pFile->Save();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
local_hr = pFile->Close();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
pFile->Release();
}
return hr;
}
static HRESULT ReadVideoAAFFile(
aafWChar * pFileName,
aafCompressEnable_t compressEnable,
aafColorSpace_t colorSpace,
aafUInt32 horizontalSubsample,
aafUID_t codecID,
testType_t testType,
aafUID_t compression)
{
HRESULT hr = AAFRESULT_SUCCESS;
IAAFFile * pFile = NULL;
IAAFHeader * pHeader = NULL;
IAAFDictionary* pDictionary = NULL;
IAAFEssenceAccess* pEssenceAccess = NULL;
IAAFEssenceMultiAccess* pMultiEssence = NULL;
IAAFEssenceFormat *fmtTemplate = NULL;
IAAFEssenceFormat* pTransformFormat = NULL;
IEnumAAFMobs* pMobIter = NULL;
IAAFMob* pMob = NULL;
IAAFMasterMob* pMasterMob = NULL;
IAAFEssenceFormatSP pFormat;
aafNumSlots_t numMobs, numSlots;
aafSearchCrit_t criteria;
aafMobID_t mobID;
aafWChar namebuf[1204];
aafDataBuffer_t AAFDataBuf = NULL;
aafUInt32 AAFBytesRead = 0, samplesRead = 0;
aafDataBuffer_t checkBuffer = NULL, compressedBuffer = NULL;
aafUInt32 checkBufferSize = 0, compressedBufferSize = 0;
try
{
checkExpression((1 == horizontalSubsample ||
(2 == horizontalSubsample && kAAFColorSpaceYUV == colorSpace)),
AAFRESULT_TEST_FAILED);
// Validate the rectangle values that we originally wrote.
aafInt32 bytesRead = 0;
aafRect_t std_rc;
std_rc.xOffset = std_rc.yOffset = 0;
std_rc.xSize = STD_WIDTH;
std_rc.ySize = STD_HEIGHT;
if (codecID == kAAFCodecJPEG)
{
if (compressEnable == kAAFCompressionEnable)
{
if (kAAFColorSpaceYUV == colorSpace)
{
if (2 == horizontalSubsample)
{
checkBuffer = new aafUInt8[SAMPLE_422_BYTES];
checkExpression(NULL != checkBuffer, AAFRESULT_NOMEMORY);
FillYCbCr422SampleBufferFromYCbCr(checkBuffer, STD_HEIGHT, STD_WIDTH, yuv_green);
checkBufferSize = SAMPLE_422_BYTES;
}
else
{
checkBuffer = new aafUInt8[FRAME_BYTES];
checkExpression(NULL != checkBuffer, AAFRESULT_NOMEMORY);
FillSampleFrameBuffer(checkBuffer, STD_HEIGHT, STD_WIDTH, 0, yuv_green);
checkBufferSize = FRAME_BYTES;
}
}
else
{
checkBuffer = new aafUInt8[FRAME_BYTES];
checkExpression(NULL != checkBuffer, AAFRESULT_NOMEMORY);
FillSampleFrameBuffer(checkBuffer, STD_HEIGHT, STD_WIDTH, 0, green);
checkBufferSize = FRAME_BYTES;
}
}
else
{
if (kAAFColorSpaceYUV == colorSpace && 2 == horizontalSubsample)
{
compressedBufferSize = sizeof(compressed422JFIF);
compressedBuffer = new aafUInt8[compressedBufferSize];
checkExpression(NULL != compressedBuffer, AAFRESULT_NOMEMORY);
memcpy(compressedBuffer, compressed422JFIF, compressedBufferSize);
}
else
{
compressedBufferSize = sizeof(compressedJFIF);
compressedBuffer = new aafUInt8[compressedBufferSize];
checkExpression(NULL != compressedBuffer, AAFRESULT_NOMEMORY);
memcpy(compressedBuffer, compressedJFIF, compressedBufferSize);
}
}
}
else if (compression == kAAFCompressionDef_LegacyDV)
{
compressedBuffer = readDVframe( &compressedBufferSize );
std_rc.xSize = 720;
std_rc.ySize = 576 / 2;
}
else // codecID is not JPEG Codec
{
// Uncompressed video
aafUInt8 *video = initUncompressedVideo( horizontalSubsample, &compressedBufferSize );
compressedBuffer = new aafUInt8[compressedBufferSize];
checkExpression(NULL != compressedBuffer, AAFRESULT_NOMEMORY);
memcpy(compressedBuffer, video, compressedBufferSize);
}
checkResult(AAFFileOpenExistingRead ( pFileName, 0, &pFile));
checkResult(pFile->GetHeader(&pHeader));
// Get the AAF Dictionary so that we can create valid AAF objects.
checkResult(pHeader->GetDictionary(&pDictionary));
CAAFBuiltinDefs defs (pDictionary);
// Here we checkResult on the number of mobs in the file.
// Get the number of master mobs in the file (should be one)
checkResult(pHeader->CountMobs(kAAFMasterMob, &numMobs));
checkExpression(1 == numMobs, AAFRESULT_TEST_FAILED);
criteria.searchTag = kAAFByMobKind;
criteria.tags.mobKind = kAAFMasterMob;
checkResult(pHeader->GetMobs(&criteria, &pMobIter));
while(AAFRESULT_SUCCESS == pMobIter->NextOne(&pMob))
{
char mobIDstr[256];
char mobName[256];
checkResult(pMob->GetMobID (&mobID));
checkResult(pMob->GetName (namebuf, sizeof(namebuf)));
convert(mobName, sizeof(mobName), namebuf);
MobIDtoString(mobID, mobIDstr);
// Make sure we have one slot
checkResult(pMob->CountSlots(&numSlots));
checkExpression(1 == numSlots, AAFRESULT_TEST_FAILED);
// The essence data is in SlotID 1
// Get a Master Mob interface
checkResult(pMob->QueryInterface(IID_IAAFMasterMob, (void **)&pMasterMob));
// Open the Essence Data
checkResult(pMasterMob->OpenEssence(STD_SLOT_ID, // SlotID
NULL, // mediaCriteria (Don't care)
kAAFMediaOpenReadOnly, // Open mode
compressEnable,// Compression
&pEssenceAccess));
aafUID_t storedCodecID = {0};
checkResult(pEssenceAccess->GetCodecID(&storedCodecID));
if (memcmp(&storedCodecID, &codecID, sizeof(storedCodecID)))
{
cout << " Warning:GetCodecID did not return expected CodecID." << endl;
}
// Setup the formats that we want to query.
checkResult(pEssenceAccess->GetEmptyFileFormat (&fmtTemplate));
checkResult(fmtTemplate->AddFormatSpecifier (kAAFStoredRect, 0, NULL));
checkResult(fmtTemplate->AddFormatSpecifier (kAAFSampledRect, 0, NULL));
checkResult(fmtTemplate->AddFormatSpecifier (kAAFDisplayRect, 0, NULL));
checkResult(fmtTemplate->AddFormatSpecifier (kAAFPixelFormat, 0, NULL));
// Get the information from corresponding codec.
checkResult(pEssenceAccess->GetFileFormat (fmtTemplate, &pFormat));
fmtTemplate->Release();
fmtTemplate = NULL;
aafRect_t rc;
rc.xOffset = rc.yOffset = 0;
rc.xSize = rc.ySize = 0;
checkResult(pFormat->GetFormatSpecifier (kAAFStoredRect, sizeof(rc), (aafDataBuffer_t)&rc, &bytesRead));
checkExpression(sizeof(rc) == bytesRead, AAFRESULT_TEST_FAILED);
checkExpression(0 == memcmp(&rc, &std_rc, sizeof(rc)), AAFRESULT_TEST_FAILED);
checkResult(pFormat->GetFormatSpecifier (kAAFSampledRect, sizeof(rc),(aafDataBuffer_t)&rc, &bytesRead));
checkExpression(sizeof(rc) == bytesRead, AAFRESULT_TEST_FAILED);
checkExpression(0 == memcmp(&rc, &std_rc, sizeof(rc)), AAFRESULT_TEST_FAILED);
checkResult(pFormat->GetFormatSpecifier (kAAFDisplayRect, sizeof(rc),(aafDataBuffer_t)&rc, &bytesRead));
checkExpression(sizeof(rc) == bytesRead, AAFRESULT_TEST_FAILED);
checkExpression(0 == memcmp(&rc, &std_rc, sizeof(rc)), AAFRESULT_TEST_FAILED);
aafColorSpace_t defaultPixelColorSpace;
checkResult(pFormat->GetFormatSpecifier (kAAFPixelFormat, sizeof(defaultPixelColorSpace),(aafDataBuffer_t)&defaultPixelColorSpace, &bytesRead));
checkExpression(sizeof(defaultPixelColorSpace) == bytesRead, AAFRESULT_TEST_FAILED);
// Change the output pixel format / color space if necessary.
if (compressEnable == kAAFCompressionEnable)
{
// NOTE: TransformParameters have not been implemented yet!
// For now just use the PutFileFormat method.
checkResult(pEssenceAccess->GetEmptyFileFormat (&pTransformFormat));
checkResult(pTransformFormat->AddFormatSpecifier (kAAFPixelFormat, sizeof(colorSpace), (aafDataBuffer_t)&colorSpace));
checkResult(pEssenceAccess->PutFileFormat(pTransformFormat));
pTransformFormat->Release();
pTransformFormat = NULL;
}
// Get and display the current code name.
checkResult(pEssenceAccess->GetCodecName(sizeof(namebuf), namebuf));
// convert(chNameBuffer, sizeof(chNameBuffer), namebuf);
// cout << " Codec:" << chNameBuffer << endl;
aafLength_t maxSampleSize = 0;
checkResult(pEssenceAccess->GetLargestSampleSize(defs.ddkAAFPicture(), &maxSampleSize));
aafUInt32 sampleBufferSize = static_cast<aafUInt32>(maxSampleSize);
// Validate the buffer size.
if (kAAFCompressionDisable == compressEnable)
{ // If the data is compressed then the size of the buffer should be the
// same as the original compressed JFIF data.
checkExpression(compressedBufferSize == sampleBufferSize, AAFRESULT_TEST_FAILED);
}
// checkResult(pEssenceAccess->CountChannels());
// trr: The CountChannels interface needs to be redesigned. Why doesn't it
// defer to the current codec like all of the other information methods?
// Allocate the data buffer to hold the maximum sample (compressed)
AAFDataBuf = new aafUInt8[sampleBufferSize];
checkExpression(NULL != AAFDataBuf, AAFRESULT_NOMEMORY);
aafLength_t sampleCount = 0;
checkResult(pEssenceAccess->CountSamples(defs.ddkAAFPicture(), &sampleCount));
checkExpression(MAX_SAMPLE_COUNT == sampleCount, AAFRESULT_TEST_FAILED);
aafUInt32 index;
for (index = 0; index < sampleCount; ++index)
{
aafLength_t sampleSize;
checkResult(pEssenceAccess->GetIndexedSampleSize(defs.ddkAAFPicture(), index, &sampleSize));
if (kAAFCompressionDisable == compressEnable)
checkExpression(compressedBufferSize == sampleSize, AAFRESULT_TEST_FAILED);
else
checkExpression(sampleBufferSize == sampleSize, AAFRESULT_TEST_FAILED);
// Read the Data from the AAF file
samplesRead = 0;
AAFBytesRead = 0;
if(testType == testStandardCalls)
{
checkResult(pEssenceAccess->ReadSamples(STD_SAMPLE_COUNT, //!!! Hardcoded // Number of Samples
sampleBufferSize, // Maximum buffer size
AAFDataBuf, // Buffer for the data
&samplesRead, // Actual number of samples read
&AAFBytesRead)); // Actual number of bytes read
}
else if(testType == testMultiCalls)
{
aafmMultiXfer_t xfer;
aafmMultiResult_t result;
checkResult(pEssenceAccess->QueryInterface(IID_IAAFEssenceMultiAccess, (void **)&pMultiEssence));
xfer.numSamples = STD_SAMPLE_COUNT; //!!! Hardcoded // Number of Samples
xfer.buflen = sampleBufferSize;
xfer.buffer = AAFDataBuf;
result.bytesXfered = 0;
checkResult(pMultiEssence->ReadMultiSamples(STD_SAMPLE_COUNT, &xfer, &result));
samplesRead = result.samplesXfered;
AAFBytesRead = result.bytesXfered;
pMultiEssence->Release();
pMultiEssence = NULL;
}
if (codecID == kAAFCodecJPEG)
{
if (codecID == kAAFCodecJPEG && kAAFCompressionDisable == compressEnable)
{ // If compression is disabled then compare the bytes read to the original
// compressedJFIF data buffer.
if (compressedBufferSize != AAFBytesRead)
{
cout << "***Wrong number of bytes read ( was "
<< AAFBytesRead
<< ", should be "
<< sizeof(compressedJFIF)
<< ")"
<< endl;
throw HRESULT(AAFRESULT_TEST_FAILED);
}
else if (memcmp( compressedBuffer, AAFDataBuf, compressedBufferSize) != 0)
{
cout << "*** Data Read is different than the data originally written from the JPEG buffer ***" << endl;
throw HRESULT(AAFRESULT_TEST_FAILED);
}
}
else
{ // If compression is enabled then compare the bytes read to the original
// uncompressed data buffer. This buffer should be 100% green.
checkExpression(checkBufferSize == AAFBytesRead, AAFRESULT_TEST_FAILED);
checkExpression(PixelCompare(STD_PIXEL_SLOP, AAFDataBuf, checkBuffer, checkBufferSize), AAFRESULT_TEST_FAILED);
}
}
else
{
if (memcmp( compressedBuffer, AAFDataBuf, compressedBufferSize) != 0)
{
cout << "*** Data Read is different than the data originally written from the CDCI buffer ***" << endl;
throw HRESULT(AAFRESULT_TEST_FAILED);
}
}
}
// Cleanup the temporary buffer.
delete [] AAFDataBuf;
AAFDataBuf = NULL;
// cleanup the master mob.
pMasterMob->Release();
pMasterMob = NULL;
pMob->Release();
pMob = NULL;
}
}
catch (HRESULT& rhr)
{
hr = rhr; // return thrown error code.
}
catch (...)
{
// We CANNOT throw an exception out of a COM interface method!
// Return a reasonable exception code.
hr = AAFRESULT_UNEXPECTED_EXCEPTION;
}
// Cleanup and return
if (checkBuffer)
delete [] checkBuffer;
if (compressedBuffer)
delete [] compressedBuffer;
if (pMultiEssence)
pMultiEssence->Release();
if (pTransformFormat)
pTransformFormat->Release();
if(fmtTemplate)
fmtTemplate->Release();
if (NULL != AAFDataBuf)
{
#ifdef _DEBUG
if (kAAFCompressionDisable == compressEnable)
{
if (2 == horizontalSubsample)
HexDumpBuffer("compressed422JFIF.jpg", AAFDataBuf, AAFBytesRead);
else
HexDumpBuffer("compressedJFIF.jpg", AAFDataBuf, AAFBytesRead);
}
else if (2 == horizontalSubsample)
HexDumpBuffer("uncompressed422.raw", AAFDataBuf, AAFBytesRead);
else
HexDumpBuffer("uncompressedRGB.raw", AAFDataBuf, AAFBytesRead, 15);
#endif // #ifdef _DEBUG
delete [] AAFDataBuf;
}
if (pEssenceAccess)
pEssenceAccess->Release();
if (pMasterMob)
pMob->Release();
if (pMob)
pMob->Release();
if (pMobIter)
pMobIter->Release();
if (pDictionary)
pDictionary->Release();
if (pHeader)
pHeader->Release();
if (pFile)
{
HRESULT local_hr = pFile->Close();
if (FAILED(local_hr) && SUCCEEDED(hr))
hr = local_hr;
pFile->Release();
}
return hr;
}
//**********************
// Extra code required to scan the original WAVE headers and extract metadata parameters & data offset
AAFByteOrder getNativeByteOrder(void)
{
aafInt16 word = 0x1234;
aafInt8 byte = *((aafInt8*)&word);
AAFByteOrder result;
// ASSERT("Valid byte order", ((byte == 0x12) || (byte == 0x34)));
if (byte == 0x12) {
result = MOTOROLA_ORDER;
} else {
result = INTEL_ORDER;
}
return result;
}
void ByteSwap32(
aafInt32 *lp) /* IN/OUT -- Byte swap this value */
{
register unsigned char *cp = (unsigned char *) lp;
int t;
t = cp[3];
cp[3] = cp[0];
cp[0] = t;
t = cp[2];
cp[2] = cp[1];
cp[1] = t;
}
void ByteSwap16(
aafInt16 * wp) /* IN/OUT -- Byte swap this value */
{
register unsigned char *cp = (unsigned char *) wp;
int t;
t = cp[1];
cp[1] = cp[0];
cp[0] = t;
}
// app work on all WAVE files, not just laser.wav.
void scanWAVEData(aafUInt8 **srcBufHdl, aafInt32 maxsize, void *data)
{
memcpy(data, *srcBufHdl, maxsize);
(*srcBufHdl) += maxsize;
}
void scanSwappedWAVEData(aafUInt8 **srcBufHdl, aafInt32 maxsize, void *data)
{
AAFByteOrder nativeByteOrder = getNativeByteOrder()
;
memcpy(data, *srcBufHdl, maxsize);
(*srcBufHdl) += maxsize;
if ((maxsize == sizeof(aafInt32)) && (INTEL_ORDER != nativeByteOrder))
ByteSwap32((aafInt32 *) data);
else if ((maxsize == sizeof(aafInt16)) && (INTEL_ORDER != nativeByteOrder))
ByteSwap16((aafInt16 *) data);
}
AAFRESULT loadWAVEHeader(aafUInt8 *buf,
aafUInt16 *bitsPerSample,
aafUInt16 *numCh,
aafRational_t *sampleRate,
aafUInt32 *dataOffset,
aafUInt32 *dataLen)
{
aafInt32 formSize;
aafInt16 pcm_format, junk16;
aafUInt32 chunkSize;
aafBool fmtFound = kAAFFalse, dataFound = kAAFFalse;
aafUInt8 chunkID[4];
aafInt32 junk32, rate, bytesPerFrame = 0;
aafUInt8 *ptr;
ptr = buf;
scanWAVEData(&ptr, sizeof(chunkID), &chunkID);
if (memcmp(&chunkID, "RIFF", (size_t) 4) != 0)
return(AAFRESULT_BADWAVEDATA);
scanSwappedWAVEData(&ptr, sizeof(formSize), &formSize);
scanWAVEData(&ptr, sizeof(chunkID), &chunkID);
if (memcmp(&chunkID, "WAVE", (size_t) 4) != 0)
return(AAFRESULT_BADWAVEDATA);
scanWAVEData(&ptr, sizeof(chunkID), &chunkID);
while ((ptr-buf) < formSize)
{
scanSwappedWAVEData(&ptr, sizeof(chunkSize), &chunkSize);
if (memcmp(&chunkID, "fmt ", (size_t) 4) == 0)
{
// WAVE field: wFormatTag
scanSwappedWAVEData(&ptr, sizeof(aafUInt16), (aafUInt8 *)&pcm_format);
if (pcm_format != 1)
return(AAFRESULT_BADWAVEDATA);
// WAVE field: wChannels
scanSwappedWAVEData(&ptr, sizeof(aafUInt16), (aafUInt8 *)numCh);
// WAVE field: wSamplesPerSec
scanSwappedWAVEData(&ptr, sizeof(aafUInt32), (aafUInt8 *)&rate);
sampleRate->numerator = rate;
sampleRate->denominator = 1;
// Skip WAVE field: avgBytesPerSec (4 bytes)
scanSwappedWAVEData(&ptr, sizeof(junk32), (aafUInt8 *)&junk32);
// WAVE field wBlockAlign
scanSwappedWAVEData(&ptr, sizeof(aafUInt16), (aafUInt8 *)&junk16);
// WAVE field Sample Width
scanSwappedWAVEData(&ptr, sizeof(aafUInt16), (aafUInt8 *)bitsPerSample);
bytesPerFrame = (((*bitsPerSample) + 7) / 8) * (*numCh);
fmtFound = kAAFTrue;
} else if (memcmp(&chunkID, "data", (size_t) 4) == 0)
{
*dataLen = chunkSize / bytesPerFrame;
// Positioned at beginning of audio data
*dataOffset = ptr - buf;
dataFound = kAAFTrue;
}
if((ptr-buf) > formSize)
break;
if (fmtFound && dataFound) // Do we have all information yet?
break;
scanWAVEData(&ptr, sizeof(chunkID), &chunkID);
}
return(AAFRESULT_SUCCESS);
}
HRESULT CAAFEssenceAccess_test(
testMode_t mode,
aafUID_t fileKind,
testRawStorageType_t rawStorageType,
aafProductIdentification_t productID)
{
AAFRESULT hr = S_OK;
aafWChar tmpURL[FILENAME_MAX];
const size_t fileNameBufLen = 128;
aafWChar metadataFileName[ fileNameBufLen ] = L"";
aafWChar mediaFileName[ fileNameBufLen ] = L"";
const aafWChar *rawDataWave = L"EssenceAccessExtRaw.wav";
const aafWChar *rawDataAifc = L"EssenceAccessExtRaw.aif";
testDataFile_t dataFile;
cout << endl << endl;
cout << " Internal Essence (WAVE)" << endl;
/**/
GenerateTestFileName( L"EssenceAccessWAVE", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, testStandardCalls, kAAFCodecWAVE, kAAFDataDef_Sound, kAAFTrue);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadSamples" << endl;
hr = ReadAAFFile(metadataFileName, testStandardCalls, kAAFCodecWAVE);
}
/**/
GenerateTestFileName( L"EssenceAccessWAVELegacy", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (Legacy DDEF_Sound)" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, testStandardCalls, kAAFCodecWAVE, DDEF_Sound, kAAFTrue);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadSamples" << endl;
hr = ReadAAFFile(metadataFileName, testStandardCalls, kAAFCodecWAVE);
}
/**/
GenerateTestFileName( L"EssenceAccessMultiWAVE", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteMultiSamples" << endl;
checkResult(CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, testMultiCalls, kAAFCodecWAVE, kAAFDataDef_Sound));
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadMultiSamples" << endl;
hr = ReadAAFFile(metadataFileName, testMultiCalls, kAAFCodecWAVE);
}
/**/
/**/
GenerateTestFileName( L"EssenceAccessRawRef", fileKind, fileNameBufLen, metadataFileName );
dataFile.dataFilename = makeURLfromFileInCwd(rawDataWave, tmpURL);
dataFile.dataFormat = ContainerFile;
if(hr == AAFRESULT_SUCCESS)
cout << " External Essence (WAVE)" << endl;
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (External Raw Essence)" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
&dataFile, testStandardCalls, kAAFCodecWAVE, kAAFDataDef_Sound);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadSamples (External Raw Essence)" << endl;
hr = ReadAAFFile(metadataFileName, testStandardCalls, kAAFCodecWAVE);
}
/**/
GenerateTestFileName( L"EssenceAccessRef", fileKind, fileNameBufLen, metadataFileName );
GenerateTestFileName( L"EssenceAccessExtWAV", fileKind, fileNameBufLen, mediaFileName );
dataFile.dataFilename = makeURLfromFileInCwd(mediaFileName, tmpURL);
dataFile.dataFormat = ContainerAAF;
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (External AAF Essence)" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
&dataFile, testStandardCalls, kAAFCodecWAVE, kAAFDataDef_Sound);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadSamples (External AAF Essence)" << endl;
hr = ReadAAFFile(metadataFileName, testStandardCalls, kAAFCodecWAVE);
}
if(hr == AAFRESULT_SUCCESS)
cout << " Internal Essence (AIFC)" << endl;
/**/
GenerateTestFileName( L"EssenceAccessAIFC", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, testStandardCalls, kAAFCODEC_AIFC, kAAFDataDef_Sound);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadSamples" << endl;
hr = ReadAAFFile(metadataFileName, testStandardCalls, kAAFCODEC_AIFC);
}
/**/
GenerateTestFileName( L"EssenceAccessAIFCLegacy", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (Legacy DDEF_Sound)" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, testStandardCalls, kAAFCODEC_AIFC, DDEF_Sound);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadSamples" << endl;
hr = ReadAAFFile(metadataFileName, testStandardCalls, kAAFCODEC_AIFC);
}
/**/
GenerateTestFileName( L"EssenceAccessMultiAIFC", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteMultiSamples" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, testMultiCalls, kAAFCODEC_AIFC, kAAFDataDef_Sound);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadMultiSamples" << endl;
hr = ReadAAFFile(metadataFileName, testMultiCalls, kAAFCODEC_AIFC);
}
/**/
/**/
GenerateTestFileName( L"EssenceAccessRawRefAIFC", fileKind, fileNameBufLen, metadataFileName );
dataFile.dataFilename = makeURLfromFileInCwd(rawDataAifc, tmpURL);
dataFile.dataFormat = ContainerFile;
if(hr == AAFRESULT_SUCCESS)
cout << " External Essence (AIFC)" << endl;
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (External Raw Essence)" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
&dataFile, testStandardCalls, kAAFCODEC_AIFC, kAAFDataDef_Sound);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadSamples (External Raw Essence)" << endl;
hr = ReadAAFFile(metadataFileName, testStandardCalls, kAAFCODEC_AIFC);
}
/**/
GenerateTestFileName( L"EssenceAccessRefAIFC", fileKind, fileNameBufLen, metadataFileName );
GenerateTestFileName( L"EssenceAccessExtAIF", fileKind, fileNameBufLen, mediaFileName );
dataFile.dataFilename = makeURLfromFileInCwd(mediaFileName, tmpURL);
dataFile.dataFormat = ContainerAAF;
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (External AAF Essence)" << endl;
hr = CreateAudioAAFFile(metadataFileName, fileKind, rawStorageType, productID,
&dataFile, testStandardCalls, kAAFCODEC_AIFC, kAAFDataDef_Sound);
}
if(hr == AAFRESULT_SUCCESS)
{
cout << " ReadSamples (External AAF Essence)" << endl;
hr = ReadAAFFile(metadataFileName, testStandardCalls, kAAFCODEC_AIFC);
}
if (SUCCEEDED(hr))
{
cout << " Internal Essence (JPEG):" << endl;
}
GenerateTestFileName( L"EssenceAccessJPEG", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (compression disabled, RGB)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionDisable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, kAAFDataDef_Picture, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression disabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression enabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionEnable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
GenerateTestFileName( L"EssenceAccessJPEGLegacy", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (compression disabled, RGB) (Legacy DDEF_Picture)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionDisable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, DDEF_Picture, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression disabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
GenerateTestFileName( L"EssenceAccessJPEGComp", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (compression enabled, RGB)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionEnable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, kAAFDataDef_Picture, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression disabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression enabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionEnable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
GenerateTestFileName( L"EssenceAccessJPEGMulti", fileKind, fileNameBufLen, metadataFileName );
cout << " WriteMultiSamples (compression disabled, RGB)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionDisable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, kAAFDataDef_Picture, testMultiCalls, NIL_UID);
if (AAFRESULT_INVALID_OP_CODEC == hr)
{
cout << " Codec does not support interleaved data." << endl;
hr = AAFRESULT_SUCCESS;
}
else
{
if (SUCCEEDED(hr))
{
cout << " ReadMultiSamples (compression disabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testMultiCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadMultiSamples (compression enabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionEnable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testMultiCalls, NIL_UID);
}
}
}
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
GenerateTestFileName( L"EssenceAccessJPEGMultiComp", fileKind, fileNameBufLen, metadataFileName );
cout << " WriteMultiSamples (compression enabled, RGB)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionEnable, kAAFColorSpaceRGB,1,
kAAFCodecJPEG, kAAFDataDef_Picture, testMultiCalls, NIL_UID);
if (AAFRESULT_INVALID_OP_CODEC == hr)
{
cout << " Codec does not support interleaved data." << endl;
hr = AAFRESULT_SUCCESS;
}
else
{
if (SUCCEEDED(hr))
{
cout << " ReadMultiSamples (compression disabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testMultiCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadMultiSamples (compression enabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionEnable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testMultiCalls, NIL_UID);
}
}
}
GenerateTestFileName( L"EssenceAccessJPEGCompYUV", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (compression enabled, YUV)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionEnable, kAAFColorSpaceYUV, 1,
kAAFCodecJPEG, kAAFDataDef_Picture, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression disabled, YUV)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceYUV, 1,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression enabled, YUV)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionEnable, kAAFColorSpaceYUV, 1,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression enabled, RGB)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionEnable, kAAFColorSpaceRGB, 1,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
GenerateTestFileName( L"EssenceAccessJPEGCompYUV422", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (compression enabled, YUV 4-2-2)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionEnable, kAAFColorSpaceYUV, 2,
kAAFCodecJPEG, kAAFDataDef_Picture, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression disabled, YUV)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceYUV, 2,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (compression enabled, YUV 4-2-2)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionEnable, kAAFColorSpaceYUV, 2,
kAAFCodecJPEG, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " Internal Static Essence (JPEG)" << endl;
}
GenerateTestFileName( L"StaticEssenceAccessJPEG", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples" << endl;
hr = CreateStaticEssenceAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, testStandardCalls, kAAFCodecJPEG, kAAFDataDef_Picture);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples" << endl;
hr = ReadStaticEssenceAAFFile(metadataFileName, testStandardCalls, kAAFCodecJPEG);
}
GenerateTestFileName( L"StaticEssenceAccessJPEGLegacy", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (Legacy DDEF_Picture)" << endl;
hr = CreateStaticEssenceAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, testStandardCalls, kAAFCodecJPEG, DDEF_Picture);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples" << endl;
hr = ReadStaticEssenceAAFFile(metadataFileName, testStandardCalls, kAAFCodecJPEG);
}
//
// CDCI Codec
//
if (SUCCEEDED(hr))
{
cout << " Internal Essence (CDCI):" << endl;
}
GenerateTestFileName( L"EssenceAccessCDCICompYUV", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (YUV)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionDisable, kAAFColorSpaceYUV, 1,
kAAFCodecCDCI, kAAFDataDef_Picture, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (YUV)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceYUV, 1,
kAAFCodecCDCI, testStandardCalls, NIL_UID);
}
GenerateTestFileName( L"EssenceAccessCDCICompYUVLegacy", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (YUV) (Legacy DDEF_Picture)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionDisable, kAAFColorSpaceYUV, 1,
kAAFCodecCDCI, DDEF_Picture, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (YUV)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceYUV, 1,
kAAFCodecCDCI, testStandardCalls, NIL_UID);
}
GenerateTestFileName( L"EssenceAccessCDCICompYUV422", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (YUV 4-2-2)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionDisable, kAAFColorSpaceYUV, 2,
kAAFCodecCDCI, kAAFDataDef_Picture, testStandardCalls, NIL_UID);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (YUV 4-2-2)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceYUV, 2,
kAAFCodecCDCI, testStandardCalls, NIL_UID);
}
GenerateTestFileName( L"EssenceAccessCDCI_DV", fileKind, fileNameBufLen, metadataFileName );
if(hr == AAFRESULT_SUCCESS && mode == kAAFUnitTestReadWrite)
{
cout << " WriteSamples (DV CompressionDisable)" << endl;
hr = CreateVideoAAFFile(metadataFileName, fileKind, rawStorageType, productID,
NULL, kAAFCompressionDisable, kAAFColorSpaceYUV, 2,
kAAFCodecCDCI, kAAFDataDef_Picture, testStandardCalls, kAAFCompressionDef_LegacyDV);
}
if (SUCCEEDED(hr))
{
cout << " ReadSamples (DV CompressionDisable)" << endl;
hr = ReadVideoAAFFile(metadataFileName, kAAFCompressionDisable, kAAFColorSpaceYUV, 2,
kAAFCodecCDCI, testStandardCalls, kAAFCompressionDef_LegacyDV);
}
if(SUCCEEDED(hr))
{
// Global variable hrSetTransformParameters gives the result of calling
// SetTransformParameters() within CreateAAFFile(). At the time this
// test code was written, SetTransformParameters() was not part of the
// current version of the reference implementation. Therefore, as long as
// this method returns AAFRESULT_NOT_IN_CURRENT_VERSION, it does not
// need to be tested, and our test can return full success. If, at some
// point, this method returns some other result, that means it has been
// implemented and should be tested, in which case our test can only
// return partial success.
if(hr == AAFRESULT_SUCCESS)
hr = AAFRESULT_NOT_IN_CURRENT_VERSION;
// if(hrSetTransformParameters!=AAFRESULT_NOT_IN_CURRENT_VERSION)
// {
// cout << "The following IAAFEssenceAccess methods have not been tested:"
// << endl;
// cout << " SetTransformParameters" << endl;
// hr = AAFRESULT_TEST_PARTIAL_SUCCESS;
// }
}
return(hr);
}
| 33.032035 | 149 | 0.707976 | [
"object"
] |
1be7eaced236cfd65c433eca4bd676e53a94ca99 | 2,054 | cpp | C++ | clmasks.cpp | ben-8409/CamBaCali-ImageProcessing | 590d8d8ecfbea56bc8c67d11a3350b1bdd55e8ee | [
"MIT"
] | null | null | null | clmasks.cpp | ben-8409/CamBaCali-ImageProcessing | 590d8d8ecfbea56bc8c67d11a3350b1bdd55e8ee | [
"MIT"
] | null | null | null | clmasks.cpp | ben-8409/CamBaCali-ImageProcessing | 590d8d8ecfbea56bc8c67d11a3350b1bdd55e8ee | [
"MIT"
] | null | null | null | /**
* Creation of masks for calibration tool measurements
*/
#include <string>
// POCO
#include <Poco/Exception.h>
#include <Poco/Path.h>
// Local thirdparty includes
#include "tclap/CmdLine.h"
#include "tclap/ValueArg.h"
// Local original includes
#include "serveraccess.hpp"
#include "utils.hpp"
using namespace std;
// Program properties //TODO: replace with macro
const string version = "0.1.0";
// arguments
string server;
// global variables
std::vector<string> screenIds;
Poco::Path path;
int main(int argc, char const *argv[]) {
//Utility
Utils utils;
//Command line arguments
try {
TCLAP::CmdLine cmd("clmasks processes a set of pictures to the physical displays on a picture for later use.", ' ' , version);
// required
TCLAP::ValueArg<string> serverArg("a", "server_address", "HTTP Address and port of the control server server. Example: http://kallisto:3000", true, "", "SERVERADDRESS");
cmd.add(serverArg);
TCLAP::ValueArg<std::string> pathArg("p", "path", "Path to input images (masks will be saved in a subdirectory). Uses current dir if not set.", false, Poco::Path::current(), "PATH");
cmd.add(pathArg);
//Parse!
cmd.parse(argc, argv);
//Load arguments
server = serverArg.getValue();
path = Poco::Path(pathArg.getValue());
if(!path.isDirectory()) path.makeDirectory();
} catch (TCLAP::ArgException &e) {
std::cout << "error: " << e.error() << " for arg " << e.argId() << std::endl;
return 1;
}
// Verify user supplied arguments
// Check if Path exists and is accessible
if(!utils.existsAndExecutable(path)) {
cout << "Working directory dir does not exist or is not accessible." << endl;
return 1;
}
/* code */
// Get list of screen names
try {
//setup server access
ServerAccess serverAccess(server);
//get screen list
screenIds = serverAccess.getScreenIds();
} catch (Poco::Exception &e) {
std::cout << "Error while connecting to server: " << e.what() << std::endl;
return 1;
}
return 0;
}
| 27.756757 | 186 | 0.659688 | [
"vector"
] |
1bea67c2429f72ad460ee79f646f25551164877c | 7,487 | cpp | C++ | week10/Library.cpp | colbertz2/CS161 | b2d05c4cc6603e7900983ba6eea754a70bad4e59 | [
"MIT"
] | null | null | null | week10/Library.cpp | colbertz2/CS161 | b2d05c4cc6603e7900983ba6eea754a70bad4e59 | [
"MIT"
] | null | null | null | week10/Library.cpp | colbertz2/CS161 | b2d05c4cc6603e7900983ba6eea754a70bad4e59 | [
"MIT"
] | null | null | null | /*********************************************************************
** Author: Zach Colbert
** Date: 30 November 2017
** Description: Library class
*********************************************************************/
/*********************************************************************
** Includes
*********************************************************************/
#include "Library.hpp"
/*********************************************************************
** Description:
*********************************************************************/
Library::Library()
{
// Initialize the relative date of the library
currentDate = 0;
}
/*********************************************************************
** Description:
*********************************************************************/
void Library::addBook(Book* newBook)
{
// vector::push_back will add Book* to the end of the vector
holdings.push_back(newBook);
// Set location to ON_SHELF
(*newBook).setLocation(ON_SHELF);
}
/*********************************************************************
** Description:
*********************************************************************/
void Library::addPatron(Patron* newPatron)
{
// vector::push_back will add Patron* to the end of the vector
members.push_back(newPatron);
}
/*********************************************************************
** Description:
*********************************************************************/
std::string Library::checkOutBook(std::string pID, std::string bID)
{
// if the specified Book is not in the Library, return "book not found"
Book* chkBook = getBook(bID);
if (chkBook == nullptr)
{
return "book not found";
}
// if the specified Patron is not in the Library, return "patron not found"
Patron* chkPatron = getPatron(pID);
if(chkPatron == nullptr)
{
return "patron not found";
}
// if the specified Book is already checked out, return "book already checked out"
if ((*chkBook).getCheckedOutBy() != nullptr)
{
return "book already checked out";
}
// if the specified Book is on hold by another Patron, return "book on hold by other patron"
if ((*chkBook).getRequestedBy() != chkPatron && (*chkBook).getRequestedBy() != nullptr)
{
return "book on hold by other patron";
}
// otherwise update the Book's checkedOutBy, dateCheckedOut and Location; if the Book was on hold for this Patron, update requestedBy; update the Patron's checkedOutBooks; return "check out successful"
(*chkBook).setCheckedOutBy(chkPatron);
(*chkBook).setDateCheckedOut(currentDate);
(*chkBook).setLocation(CHECKED_OUT);
if ((*chkBook).getRequestedBy() == (*chkBook).getCheckedOutBy())
{
(*chkBook).setRequestedBy(nullptr);
}
(*chkPatron).addBook(chkBook);
return "check out successful";
}
/*********************************************************************
** Description:
*********************************************************************/
std::string Library::returnBook(std::string bID)
{
// if the specified Book is not in the Library, return "book not found"
Book* chkBook = getBook(bID);
if (chkBook == nullptr)
{
return "book not found";
}
// if the Book is not checked out, return "book already in library"
if ((*chkBook).getCheckedOutBy() == nullptr)
{
return "book already in library";
}
// update the Patron's checkedOutBooks; update the Book's location depending on whether another Patron has requested it; update the Book's checkedOutBy; return "return successful"
(*(*chkBook).getCheckedOutBy()).removeBook(chkBook);
// If the book is not on hold, location goes to ON_SHELF
if ((*chkBook).getRequestedBy() == nullptr)
{
(*chkBook).setLocation(ON_SHELF);
}
// Otherwise, it is on hold and goes to ON_HOLD_SHELF
else
{
(*chkBook).setLocation(ON_HOLD_SHELF);
}
(*chkBook).setCheckedOutBy(nullptr);
return "return successful";
}
/*********************************************************************
** Description:
*********************************************************************/
std::string Library::requestBook(std::string pID, std::string bID)
{
// if the specified Book is not in the Library, return "book not found"
Book* chkBook = getBook(bID);
if (chkBook == nullptr)
{
return "book not found";
}
// if the specified Patron is not in the Library, return "patron not found"
Patron* chkPatron = getPatron(pID);
if (chkPatron == nullptr)
{
return "patron not found";
}
// if the specified Book is already requested, return "book already on hold"
if ((*chkBook).getRequestedBy() != nullptr)
{
return "book already on hold";
}
// update the Book's requestedBy; if the Book is on the shelf, update its location to on hold; return "request successful"
(*chkBook).setRequestedBy(chkPatron);
if ((*chkBook).getLocation() == ON_SHELF)
{
(*chkBook).setLocation(ON_HOLD_SHELF);
}
return "request successful";
}
/*********************************************************************
** Description:
*********************************************************************/
std::string Library::payFine(std::string pID, double payment)
{
// takes as a parameter the amount that is being paid (not the negative of that amount)
if (payment < 0)
{
return "invalid payment amount";
}
// if the specified Patron is not in the Library, return "patron not found"
Patron* chkPatron = getPatron(pID);
if (chkPatron == nullptr)
{
return "patron not found";
}
// use amendFine to update the Patron's fine; return "payment successful"
(*chkPatron).amendFine(-1.0 * payment);
return "payment successful";
}
/*********************************************************************
** Description:
*********************************************************************/
void Library::incrementCurrentDate()
{
currentDate++;
// For each patron of the library
for (Patron* chkPatron : members)
{
// For each of the patron's checked out books
for (Book* chkBook : (*chkPatron).getCheckedOutBooks())
{
// If the book is overdue
if (currentDate - (*chkBook).getDateCheckedOut() > 21)
{
// Add a 10 cent fine
(*chkPatron).amendFine(0.1);
}
}
}
}
// Description
Patron* Library::getPatron(std::string pID)
{
bool patronFound = false;
int patronIndex = -1;
for (Patron* chkPatron : members)
{
patronIndex++;
if ((*chkPatron).getIdNum() == pID)
{
patronFound = true;
break;
}
}
if (patronFound == false)
{
return nullptr;
}
else
{
return members[patronIndex];
}
}
// Description
Book* Library::getBook(std::string bID)
{
bool bookFound = false;
int bookIndex = -1;
for (Book* chkBook : holdings)
{
bookIndex++;
if ((*chkBook).getIdCode() == bID)
{
bookFound = true;
break;
}
}
if (bookFound == false)
{
return nullptr;
}
else
{
return holdings[bookIndex];
}
} | 26.45583 | 205 | 0.4998 | [
"vector"
] |
1bebd89b134528ef1bdfad903b6a6a6327c68908 | 7,480 | cpp | C++ | Sample/Sample002.cpp | Ashitagachan/Gachan | 63b5410e128628222447c837a7209162487aa246 | [
"MIT"
] | 1 | 2020-10-14T03:50:35.000Z | 2020-10-14T03:50:35.000Z | Sample/Sample002.cpp | Ashitagachan/Gachan | 63b5410e128628222447c837a7209162487aa246 | [
"MIT"
] | null | null | null | Sample/Sample002.cpp | Ashitagachan/Gachan | 63b5410e128628222447c837a7209162487aa246 | [
"MIT"
] | null | null | null | //
// Sample002.cpp
// UTF-8 CRLF format/形式
//
// Copyright (c) 2019 Ashitagachan
// See LICENSE.txt for licensing information.
//
#include "Gachan.h"
//SAMPLE002.cppをビルドするにはGachanNameSpace.hのNAMESPACE定義をSAMPLE002に置き換えてください。
//To build SAMPLE002.cpp, Replace NAMESPACE definition at GachanNameSpace.h with SAMPLE002.
//Gachanサンプル紹介000-003 Introduction to Sample000-003
//https://youtu.be/TByp95BtHJA
namespace Sample002
{
class MyMissile
{
public:
GachanGameObject object;
int state;
void Clear()
{
object.Clear();
object.SetObject(GachanGameObject::OBJECT::MISSILE);
object.SetRotation(ROTATIONORDER::XYZ, 0, RADIAN(180), 0);
object.SetScale(2, 2, 2);
object.SetColor(GachanGame::COLOR::WHITE);
state = 0;
}
bool Shot(Vec shippos)
{
if (state == 0) {
object.SetPosition(shippos);
state = 1;
return true;
}
return false;
}
void Exec()
{
if (state) {
Vec pos = object.GetPosition();
pos.z += 1;
object.SetPosition(pos);
if (pos.z > 40) {
state = 0;
}
}
}
void Draw()
{
if (state) {
object.Draw();
}
}
};
class Gachan
{
public:
GachanGame game;
GachanGameKeyboard keyboard;
GachanGameCamera camera;
Vec cameraposition;
GachanGameLightAmbient lightambient;
GachanGameLightDirection lightdirection;
GachanGameObject ship;
Vec shiptarget;
MyMissile missile[8];
GachanGameObject enemy[16];
GachanGameObject unkochan;
};
static Gachan* gachan;
void Initialize()
{
}
static void ResetEnemy(GachanGameObject* obj)
{
obj->Clear();
GachanGameObject::OBJECT object = (GachanGameObject::OBJECT)
RandomInt(GachanGameObject::OBJECT::GRID10x10,
GachanGameObject::OBJECT::BRICKA);
obj->SetObject(object);
Vec randompos;
randompos.x = RandomVal(-10, 10);
randompos.y = RandomVal(-10, 10);
randompos.z = RandomVal(20, 80);
obj->SetPosition(randompos);
GachanGame::COLOR color = (GachanGame::COLOR)
RandomInt(GachanGame::COLOR::WHITE,
GachanGame::COLOR::MAGENTA);
obj->SetColor(color);
}
void Create()
{
gachan = new Gachan;
gachan->game.SetBackgroundColor(0, 0, 0);
gachan->camera.SetTarget(0, 0, 0);
gachan->camera.SetAngle(RADIAN(45));
gachan->lightambient.SetColor(0.4, 0.4, 0.4);
gachan->lightdirection.SetColor(0.4, 0.4, 0.4);
gachan->lightdirection.SetDirection(-0.5, -0.6, 0.7);
gachan->ship.Clear();
gachan->ship.SetObject(GachanGameObject::OBJECT::ROCKET);
gachan->ship.SetPosition(0, 0, -5);
gachan->ship.SetRotation(ROTATIONORDER::XYZ, 0, RADIAN(180), 0);
gachan->ship.SetScale(2, 2, 2);
gachan->ship.SetColor(GachanGame::COLOR::WHITE);
gachan->shiptarget = gachan->ship.GetPosition();
gachan->cameraposition.Set(0, 3, -8);
gachan->camera.SetPosition(gachan->ship.GetPosition() + gachan->cameraposition);
for (int i = 0; i < 8; i++) {
gachan->missile[i].Clear();
}
for (int i = 0; i < 16; i++) {
ResetEnemy(&gachan->enemy[i]);
}
gachan->unkochan.Clear();
gachan->unkochan.SetObject(GachanGameObject::OBJECT::UNKOCHAN);
gachan->unkochan.SetPosition(0, -20, 200);
gachan->unkochan.SetRotation(ROTATIONORDER::XYZ, 0, RADIAN(180), 0);
gachan->unkochan.SetScale(120, 120, 120);
gachan->unkochan.SetColor(0.1, 0.1, 0.1);
}
static void Missile()
{
for (int i = 0; i < 8; i++) {
if (gachan->missile[i].Shot(gachan->ship.GetPosition())) {
break;
}
}
}
void Update()
{
{
//--------------------------
//キーボードの入力処理 Keyboard Input
//--------------------------
if (gachan->keyboard.GetSystemKey(GachanGameKeyboard::KEY::UP)) {
gachan->shiptarget.y += 1;
}
if (gachan->keyboard.GetSystemKey(GachanGameKeyboard::KEY::DOWN)) {
gachan->shiptarget.y -= 1;
}
if (gachan->keyboard.GetSystemKey(GachanGameKeyboard::KEY::LEFT)) {
gachan->shiptarget.x -= 1;
}
if (gachan->keyboard.GetSystemKey(GachanGameKeyboard::KEY::RIGHT)) {
gachan->shiptarget.x += 1;
}
Vec shippos = gachan->ship.GetPosition();
//-----------------------------------------------
//超簡単スムース移動 Super Simple Smooth Movement
//解説はこちら。 Explanation is here.
// https://youtu.be/ncpIfvq3I98
//-----------------------------------------------
shippos += (gachan->shiptarget - shippos) * 0.1;
gachan->ship.SetPosition(shippos);
Vec campos = gachan->camera.GetPosition();
//-----------------------------------------------
//超簡単スムース移動 Super Simple Smooth Movement
//解説はこちら。 Explanation is here.
// https://youtu.be/ncpIfvq3I98
//-----------------------------------------------
campos += (shippos + gachan->cameraposition - campos) * 0.05;
gachan->camera.SetPosition(campos);
shippos.z += 10;
gachan->camera.SetTarget(shippos);
//スペースキーを押すとミサイル発射 Press the space bar to launch a missile
if (gachan->keyboard.GetSystemKey(GachanGameKeyboard::KEY::SPACE)) {
Missile();
}
for (int i = 0; i < 8; i++) {
gachan->missile[i].Exec();
}
for (int i = 0; i < 16; i++) {
Vec enemypos = gachan->enemy[i].GetPosition();
enemypos.z -= 0.1;
gachan->enemy[i].SetPosition(enemypos);
if (enemypos.z < -20) {
ResetEnemy(&gachan->enemy[i]);
}
}
}
}
void Render()
{
gachan->camera.SetCamera();
gachan->lightambient.SetLight();
gachan->lightdirection.SetLight();
gachan->ship.Draw();
for (int i = 0; i < 8; i++) {
gachan->missile[i].Draw();
}
for (int i = 0; i < 16; i++) {
gachan->enemy[i].Draw();
}
gachan->unkochan.Draw();
}
void Release()
{
delete gachan;
}
void Finalize()
{
}
}
| 29.800797 | 92 | 0.464572 | [
"render",
"object"
] |
1beed4718bf40c9504707d764748bc366942759d | 1,823 | hpp | C++ | pulsar/modulemanager/PySupermoduleLoader.hpp | pulsar-chem/BPModule | f8e64e04fdb01947708f098e833600c459c2ff0e | [
"BSD-3-Clause"
] | null | null | null | pulsar/modulemanager/PySupermoduleLoader.hpp | pulsar-chem/BPModule | f8e64e04fdb01947708f098e833600c459c2ff0e | [
"BSD-3-Clause"
] | null | null | null | pulsar/modulemanager/PySupermoduleLoader.hpp | pulsar-chem/BPModule | f8e64e04fdb01947708f098e833600c459c2ff0e | [
"BSD-3-Clause"
] | null | null | null | /*! \file
*
* \brief Loading and storing of Python supermodules (header)
* \author Benjamin Pritchard (ben@bennyp.org)
*/
#ifndef PULSAR_GUARD_MODULEMANAGER__PYSUPERMODULELOADER_HPP_
#define PULSAR_GUARD_MODULEMANAGER__PYSUPERMODULELOADER_HPP_
#include <unordered_map>
#include "pulsar/modulemanager/SupermoduleLoaderBase.hpp"
#include "pulsar/modulemanager/ModuleCreationFuncs.hpp"
#include "pulsar/util/Pybind11.hpp"
namespace pulsar{
/*! \brief Loads python supermodules
*
* This loader loads supermodules for python supermodule (a python module
* directory containing * a __init__.py file).
* Module objects and creation functions are cached
* and deleted/closed at destruction.
*/
class PySupermoduleLoader : public SupermoduleLoaderBase
{
public:
PySupermoduleLoader() = default;
/*! Destructor
*
* Deletes all objects and closes all creation functions
*/
~PySupermoduleLoader();
PySupermoduleLoader(const PySupermoduleLoader &) = delete;
PySupermoduleLoader & operator=(const PySupermoduleLoader &) = delete;
PySupermoduleLoader(PySupermoduleLoader &&) = default;
PySupermoduleLoader & operator=(PySupermoduleLoader &&) = default;
virtual const ModuleCreationFuncs & load_supermodule(const std::string & spath);
private:
//! Holds information about a python supermodule
struct PyModInfo
{
pybind11::module mod; //!< Actual python module object
ModuleCreationFuncs creators; //! Creator functions in that supermodule
};
//! Stores all the info about already-opened supermodules
std::unordered_map<std::string, PyModInfo> objmap_;
};
} // close namespace pulsar
#endif
| 27.208955 | 88 | 0.69062 | [
"object"
] |
1bf0a04a7d06448bbb9f2467122d84cc134c9ac2 | 454 | cpp | C++ | LeetCode/First Missing Positive.cpp | aaditkamat/competitive-programming | d0b8f30d3cb3411d2467b98363c12d75d852e245 | [
"MIT"
] | null | null | null | LeetCode/First Missing Positive.cpp | aaditkamat/competitive-programming | d0b8f30d3cb3411d2467b98363c12d75d852e245 | [
"MIT"
] | 3 | 2019-02-24T11:42:28.000Z | 2019-06-03T14:15:46.000Z | LeetCode/First Missing Positive.cpp | aaditkamat/online-judge-submissions | d0b8f30d3cb3411d2467b98363c12d75d852e245 | [
"MIT"
] | null | null | null | // Title: First Missing Positive
// Runtime: 4 ms
// Memory: 1.5 MB
class Solution {
public:
int firstMissingPositive(vector<int>& nums) {
if (nums.size() == 0) {
return 1;
}
int max = *max_element(nums.begin(), nums.end());
for (int i = 1; i <= max + 1; i++) {
if (find(nums.begin(), nums.end(), i) == nums.end()) {
return i;
}
}
return 0;
}
}; | 23.894737 | 66 | 0.460352 | [
"vector"
] |
1bf30a818dbfd35d6c805ae1e6258996e203b584 | 2,148 | cpp | C++ | code-forces/644 Div 3/E.cpp | ErickJoestar/competitive-programming | 76afb766dbc18e16315559c863fbff19a955a569 | [
"MIT"
] | 1 | 2020-04-23T00:35:38.000Z | 2020-04-23T00:35:38.000Z | code-forces/644 Div 3/E.cpp | ErickJoestar/competitive-programming | 76afb766dbc18e16315559c863fbff19a955a569 | [
"MIT"
] | null | null | null | code-forces/644 Div 3/E.cpp | ErickJoestar/competitive-programming | 76afb766dbc18e16315559c863fbff19a955a569 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
#define ENDL '\n'
#define deb(u) cout << #u " : " << (u) << ENDL;
#define deba(alias, u) cout << alias << ": " << (u) << ENDL;
#define debp(u, v) cout << u << " : " << v << ENDL;
#define pb push_back
#define F first
#define S second
#define lli long long
#define pii pair<int, int>
#define pll pair<lli, lli>
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define FORN(i, a, n) for (int i = (a - 1); i >= n; --i)
#define IO \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0)
using namespace std;
int n;
int movX[4] = {0, -1};
int movY[4] = {-1, 0};
bool isValidPos(pii pos)
{
if (pos.F >= n || pos.F < 0 || pos.S >= n || pos.S < 0)
return false;
return true;
}
int main()
{
IO;
int t;
cin >> t;
while (t--)
{
cin >> n;
vector<string> v(n);
FOR(i, 0, n)
cin >> v[i];
queue<pii> bfs;
FOR(i, 0, n)
{
if (v[i][n - 1] == '1')
bfs.emplace(make_pair(i, n - 1));
if (v[n - 1][i] == '1')
bfs.emplace(make_pair(n - 1, i));
}
vector<vector<bool>> visited(n, vector<bool>(n, false)),
ans(n, vector<bool>(n, false));
while (!bfs.empty())
{
pii pos = bfs.front();
ans[pos.F][pos.S] = true;
// debp(pos.F, pos.S);
bfs.pop();
if (!visited[pos.F][pos.S])
{
FOR(i, 0, 2)
{
pii newPos = pos;
newPos.F += movY[i];
newPos.S += movX[i];
if (isValidPos(newPos) && v[newPos.F][newPos.S] == '1')
{
bfs.emplace(newPos);
}
}
}
visited[pos.F][pos.S] = true;
}
bool ok = true;
FOR(i, 0, n)
{
FOR(j, 0, n)
{
// cout << ans[i][j] ? "1" : "0";
if (v[i][j] == '1')
{
if (!ans[i][j])
{
ok = false;
// break;
}
}
}
// cout << ENDL;
}
if (ok)
cout << "YES" << ENDL;
else
cout << "NO" << ENDL;
}
return 0;
} | 21.267327 | 65 | 0.42784 | [
"vector"
] |
1bf8c5c0b20914c90ace5bbb2793e50931c9807b | 87,864 | cpp | C++ | Sources/Elastos/LibCore/tests/bak/Utility/ArraysTest/test.cpp | xiaoweiruby/Elastos.RT | 238e9b747f70fc129769ae7850def4362c43e443 | [
"Apache-2.0"
] | 1 | 2019-04-15T13:08:56.000Z | 2019-04-15T13:08:56.000Z | Sources/Elastos/LibCore/tests/bak/Utility/ArraysTest/test.cpp | xiaoweiruby/Elastos.RT | 238e9b747f70fc129769ae7850def4362c43e443 | [
"Apache-2.0"
] | null | null | null | Sources/Elastos/LibCore/tests/bak/Utility/ArraysTest/test.cpp | xiaoweiruby/Elastos.RT | 238e9b747f70fc129769ae7850def4362c43e443 | [
"Apache-2.0"
] | null | null | null |
#include "test.h"
#include "elastos/core/Math.h"
using Elastos::Utility::Arrays;
using Elastos::Utility::IList;
using Elastos::Utility::ILinkedList;
using Elastos::Utility::CLinkedList;
using Elastos::Core::Math;
Int32 CTest::ReversedIntegerComparator::Compare(IInterface* o1, IInterface* o2)
{
// return -(((Integer) o1).compareTo((Integer) o2));
return 0;
}
Boolean CTest::ReversedIntegerComparator::Equals(IInterface* o1, IInterface* o2)
{
// return ((Integer) o1).compareTo((Integer) o2) == 0;
return 0;
}
Int32 CTest::arraySize = 100;
CTest::CTest()
{
setUp();
}
CTest::~CTest()
{
tearDown();
}
//NOT_IMPLEMENT
int CTest::test_asList_Ljava_lang_Object(int argc, char* argv[])
{
// // Test for method java.util.List
// // java.util.Arrays.asList(java.lang.Object [])
// List convertedList = Arrays.asList(objectArray);
// for (Int32 counter = 0; counter < arraySize; counter++) {
// assertTrue(
// "Array and List converted from array do not contain identical elements",
// convertedList.get(counter) == (*objectArray)[counter]);
// }
// convertedList.set(50, new Integer(1000));
// assertTrue("set/get did not work on coverted list", convertedList.get(
// 50).equals(new Integer(1000)));
// convertedList.set(50, new Integer(50));
// new Support_UnmodifiableCollectionTest("", convertedList).runTest();
// Object[] myArray = (Object[]) (objectArray.clone());
// myArray[30] = NULL;
// myArray[60] = NULL;
// convertedList = Arrays.asList(myArray);
// for (Int32 counter = 0; counter < arraySize; counter++) {
// assertTrue(
// "Array and List converted from array do not contain identical elements",
// convertedList.get(counter) == myArray[counter]);
// }
// try {
// Arrays.asList((Object[])NULL);
// fail("asList with null arg didn't throw NPE");
// } catch (NullPointerException e) {
// // Expected
// }
return 0;
}
// test 1
int CTest::test_binarySearch_BB(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(byte [], byte)
for (Byte counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(byteArray, counter, &index);
assert(index == counter);
}
ec = Arrays::BinarySearch(byteArray, (Byte) -1, &index);
printf("ec = %d index = %d\n", ec, index);
// assert(index == -1);
ec = Arrays::BinarySearch(byteArray, (Byte) arraySize, &index);
assert(index == -(arraySize + 1));
for (Byte counter = 0; counter < arraySize; counter++) {
byteArray->Set(counter, (*byteArray)[counter]-50);
}
for (Byte counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(byteArray, (Byte) (counter - 50), &index);
// assert(index == counter);
}
return ec;
}
// test 2
int CTest::test_binarySearch_CC(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(char [], char)
for (Char32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(charArray, counter + 1, &index);
assert(index == counter);
}
ec = Arrays::BinarySearch(charArray, 0x0000, &index);
assert(index == -1);
ec = Arrays::BinarySearch(charArray, arraySize + 1, &index);
assert(index == -(arraySize + 1));
return ec;
}
// test 3
/**
* java.util.Arrays#binarySearch(double[], double)
*/
int CTest::test_binarySearch_DD(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(double [], double)
for (Int32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(doubleArray, counter, &index);
assert(index == counter);
}
ec = Arrays::BinarySearch(doubleArray, -1, &index);
assert(index == -1);
ec = Arrays::BinarySearch(doubleArray, arraySize, &index);
assert(index == -(arraySize + 1));
for (Int32 counter = 0; counter < arraySize; counter++) {
doubleArray->Set(counter, (*doubleArray)[counter] - 50);
}
for (Int32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(doubleArray, (Double) (counter - 50), &index);
assert(index == (Double) counter);
}
AutoPtr<ArrayOf<Double> > specials = ArrayOf<Double>::Alloc(11);
specials->Set(0, Elastos::Core::Math::DOUBLE_NEGATIVE_INFINITY);
specials->Set(1, -Elastos::Core::Math::DOUBLE_MAX_VALUE);
specials->Set(2, -2.0);
specials->Set(3, -Elastos::Core::Math::DOUBLE_MIN_VALUE);
specials->Set(4, -0.0);
specials->Set(5, 0.0);
specials->Set(6, Elastos::Core::Math::DOUBLE_MIN_VALUE);
specials->Set(7, 2.0);
specials->Set(8, Elastos::Core::Math::DOUBLE_MAX_VALUE);
specials->Set(9, Elastos::Core::Math::DOUBLE_POSITIVE_INFINITY);
specials->Set(10, Elastos::Core::Math::DOUBLE_NAN);
for (Int32 i = 0; i < specials->GetLength(); i++) {
ec = Arrays::BinarySearch(specials, (*specials)[i], &index);
assert(index == i);
}
ec = Arrays::BinarySearch(specials, -1, &index);
assert(index == -4);
ec = Arrays::BinarySearch(specials, 1, &index);
assert(index == -8);
return ec;
}
// test 4
int CTest::test_binarySearch_FF(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(float [], float)
for (Int32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(floatArray, counter, &index);
assert(index == counter);
}
ec = Arrays::BinarySearch(floatArray, -1, &index);
assert(index == -1);
ec = Arrays::BinarySearch(floatArray, arraySize, &index);
assert(index == -(arraySize + 1));
for (Int32 counter = 0; counter < arraySize; counter++) {
floatArray->Set(counter, (*floatArray)[counter] - 50);
}
for (Int32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(floatArray, counter - 50, &index);
assert(index == counter);
}
AutoPtr<ArrayOf<Float> > specials = ArrayOf<Float>::Alloc(11);
specials->Set(0, Elastos::Core::Math::FLOAT_NEGATIVE_INFINITY);
specials->Set(1, -Elastos::Core::Math::FLOAT_MAX_VALUE);
specials->Set(2, -2.0);
specials->Set(3, -Elastos::Core::Math::FLOAT_MIN_VALUE);
specials->Set(4, -0.0);
specials->Set(5, 0.0);
specials->Set(6, Elastos::Core::Math::FLOAT_MIN_VALUE);
specials->Set(7, 2.0);
specials->Set(8, Elastos::Core::Math::FLOAT_MAX_VALUE);
specials->Set(9, Elastos::Core::Math::FLOAT_POSITIVE_INFINITY);
specials->Set(10, Elastos::Core::Math::FLOAT_NAN);
for (Int32 i = 0; i < specials->GetLength(); i++) {
Int32 result;
ec = Arrays::BinarySearch(specials, (*specials)[i], &result);
assert(result == i);
}
ec = Arrays::BinarySearch(specials, -1.0, &index);
assert(index == -4);
ec = Arrays::BinarySearch(specials, 1.0, &index);
assert(index == -8);
return ec;
}
// test 5
int CTest::test_binarySearch_II(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(int [], int)
for (Int32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(intArray, counter, &index);
assert(index == counter);
}
ec = Arrays::BinarySearch(intArray, -1, &index);
assert(index == -1);
ec = Arrays::BinarySearch(intArray, arraySize, &index);
assert(index == -(arraySize + 1));
for (Int32 counter = 0; counter < arraySize; counter++) {
intArray->Set(counter, (*intArray)[counter] - 50);
}
for (Int32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(intArray, counter - 50, &index);
assert(index == counter);
}
return ec;
}
// test 6
int CTest::test_binarySearch_JJ(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(long [], long)
for (Int64 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(longArray, counter, &index);
assert(index == counter);
}
ec = Arrays::BinarySearch(longArray, -1, &index);
assert(index == -1);
ec = Arrays::BinarySearch(longArray, arraySize, &index);
assert(index == -(arraySize + 1));
for (Int64 counter = 0; counter < arraySize; counter++) {
longArray->Set((Int32)counter, (*longArray)[(Int32) counter] - 50);
}
for (Int64 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(longArray, counter - (Int64) 50, &index);
assert(index == counter);
}
return ec;
}
// test 7
int CTest::test_binarySearch_Ljava_lang_ObjectLjava_lang_Object(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(java.lang.Object
// [], java.lang.Object)
AutoPtr<ArrayOf<IInterface*> > arr = ArrayOf<IInterface*>::Alloc(0);
AutoPtr<IInterface> obj;
ec = Arrays::BinarySearch(arr, obj, &index);
assert(-1 == index);
AutoPtr<IInteger32> num1;
CInteger32::New(-1, (IInteger32**)&num1);
ec = Arrays::BinarySearch(arr, num1, &index);
assert(-1 == index);
for (Int32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(objectArray, (*objArray)[counter], &index);
assert(index == counter);
}
ec = Arrays::BinarySearch(objectArray, num1, &index);
assert(-1 == index);
AutoPtr<IInteger32> num2;
CInteger32::New(arraySize, (IInteger32**)&num2);
ec = Arrays::BinarySearch(objectArray, num2, &index);
assert(index == -(arraySize + 1));
AutoPtr<ArrayOf<IInterface*> > oArray = ArrayOf<IInterface*>::Alloc(5);
AutoPtr<ICharSequence> str1;
CString::New(String("1"), (ICharSequence**)&str1);
AutoPtr<ICharSequence> str2;
CString::New(String("2"), (ICharSequence**)&str2);
AutoPtr<ICharSequence> str3;
CString::New(String("3"), (ICharSequence**)&str3);
AutoPtr<ICharSequence> str4;
CString::New(String("4"), (ICharSequence**)&str4);
AutoPtr<ICharSequence> str5;
CString::New(String(""), (ICharSequence**)&str5);
oArray->Set(0, str1);
oArray->Set(1, str2);
oArray->Set(2, str3);
oArray->Set(3, str4);
oArray->Set(4, str5);
AutoPtr<IInteger32> num3;
CInteger32::New(10, (IInteger32**)&num3);
ec = Arrays::BinarySearch(oArray, num3, &index);
assert(ec != NOERROR);
return ec;
}
//IComparator NOT_IMPLEMENT
int CTest::test_binarySearch_Ljava_lang_ObjectLjava_lang_ObjectLjava_util_Comparator(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(java.lang.Object
// [], java.lang.Object, java.util.Comparator)
AutoPtr<IComparator> comp/* = new ReversedIntegerComparator()*/;
for (Int32 counter = 0; counter < arraySize; counter++)
objectArray->Set(counter, (*objArray)[arraySize - counter - 1]);
AutoPtr<IInteger32> num1;
CInteger32::New(-1, (IInteger32**)&num1);
ec = Arrays::BinarySearch(objectArray, num1, comp, &index);
assert(-(arraySize + 1) == index);
AutoPtr<IInteger32> num2;
CInteger32::New(arraySize, (IInteger32**)&num2);
ec = Arrays::BinarySearch(objectArray, num2, comp, &index);
assert(-1 == index);
for (Int32 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(objectArray, (*objArray)[counter], comp, &index);
assert(arraySize - counter - 1 == index);
}
return ec;
}
// test 8
int CTest::test_binarySearch_SS(int argc, char* argv[])
{
Int32 index = -1;
ECode ec = 0;
// Test for method int java.util.Arrays.binarySearch(short [], short)
for (Int16 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(shortArray, counter, &index);
assert(index == counter);
ec = Arrays::BinarySearch(intArray, (Int16) -1, &index);
assert(index == -1);
ec = Arrays::BinarySearch(intArray, (Int16) arraySize, &index);
assert(index == -(arraySize + 1));
}
for (Int16 counter = 0; counter < arraySize; counter++) {
shortArray->Set(counter, (*shortArray)[counter] - 50);
}
for (Int16 counter = 0; counter < arraySize; counter++) {
ec = Arrays::BinarySearch(shortArray, (Int16) (counter - 50), &index);
assert(index == counter);
}
return ec;
}
// test 9
int CTest::test_fill_BB(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(byte [], byte)
AutoPtr<ArrayOf<Byte> > d = ArrayOf<Byte>::Alloc(1000);
ec = Arrays::Fill(d, Elastos::Core::Math::BYTE_MAX_VALUE);
for (Int32 i = 0; i < d->GetLength(); i++) {
assert((*d)[i] == Elastos::Core::Math::BYTE_MAX_VALUE);
}
return ec;
}
// test 10
int CTest::test_fill_BIIB(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(byte [], int, int, byte)
Byte val = Elastos::Core::Math::BYTE_MAX_VALUE;
AutoPtr<ArrayOf<Byte> > d = ArrayOf<Byte>::Alloc(1000);
ec = Arrays::Fill(d, 400, d->GetLength(), val);
for (Int32 i = 0; i < 400; i++) {
assert(!((*d)[i] == val));
}
for (Int32 i = 400; i < d->GetLength(); i++) {
assert((*d)[i] == val);
}
AutoPtr<ArrayOf<Byte> > b1 = ArrayOf<Byte>::Alloc(2);
ec = Arrays::Fill(b1, 2, 1, (Byte) 27);
assert( ec == E_ILLEGAL_ARGUMENT_EXCEPTION );
AutoPtr<ArrayOf<Byte> > b2 = ArrayOf<Byte>::Alloc(2);
ec = Arrays::Fill(b2, -1, 1, (Byte) 27);
assert( ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION );
AutoPtr<ArrayOf<Byte> > b3 = ArrayOf<Byte>::Alloc(2);
ec = Arrays::Fill(b3, 1, 4, (Byte) 27);
assert( ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION );
return ec;
}
// test 11
int CTest::test_fill_SS(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(short [], short)
AutoPtr<ArrayOf<Int16> > d = ArrayOf<Int16>::Alloc(1000);
ec = Arrays::Fill(d, Elastos::Core::Math::INT16_MAX_VALUE);
for (Int32 i = 0; i < d->GetLength(); i++) {
assert((*d)[i] == Elastos::Core::Math::INT16_MAX_VALUE);
}
return ec;
}
// test 12
int CTest::test_fill_SIIS(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(short [], int, int, short)
Int16 val = Elastos::Core::Math::INT16_MAX_VALUE;
AutoPtr<ArrayOf<Int16> > d = ArrayOf<Int16>::Alloc(1000);
ec = Arrays::Fill(d, 400, d->GetLength(), val);
for (Int32 i = 0; i < 400; i++) {
assert(!((*d)[i] == val));
}
for (Int32 i = 400; i < d->GetLength(); i++) {
assert((*d)[i] == val);
}
ec = Arrays::Fill(d, 10, 0, val);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::Fill(d, -10, 0, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::Fill(d, 10, d->GetLength()+1, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
// test 13
int CTest::test_fill_CC(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(char [], char)
AutoPtr<ArrayOf<Char32> > d = ArrayOf<Char32>::Alloc(1000);
ec = Arrays::Fill(d, 'V');
for (Int32 i = 0; i < d->GetLength(); i++) {
assert('V' == (*d)[i]);
}
return ec;
}
// test 14
int CTest::test_fill_CIIC(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(char [], int, int, char)
Char32 val = 'T';
AutoPtr<ArrayOf<Char32> > d = ArrayOf<Char32>::Alloc(1000);
ec = Arrays::Fill(d, 400, d->GetLength(), val);
for (Int32 i = 0; i < 400; i++) {
assert(!((*d)[i] == val));
}
for (Int32 i = 400; i < d->GetLength(); i++)
assert((*d)[i] == val);
ec = Arrays::Fill(d, 10, 0, val);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::Fill(d, -10, 0, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::Fill(d, 10, d->GetLength()+1, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
// test 15
int CTest::test_fill_II(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(int [], int)
AutoPtr<ArrayOf<Int32> > d = ArrayOf<Int32>::Alloc(1000);
ec = Arrays::Fill(d, Elastos::Core::Math::INT32_MAX_VALUE);
for (Int32 i = 0; i < d->GetLength(); i++) {
assert((*d)[i] == Elastos::Core::Math::INT32_MAX_VALUE);
}
return ec;
}
// test 16
int CTest::test_fill_IIII(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(int [], int, int, int)
Int32 val = Elastos::Core::Math::INT32_MAX_VALUE;
AutoPtr<ArrayOf<Int32> > d = ArrayOf<Int32>::Alloc(1000);
ec = Arrays::Fill(d, 400, d->GetLength(), val);
for (Int32 i = 0; i < 400; i++) {
assert(!((*d)[i] == val));
}
for (Int32 i = 400; i < d->GetLength(); i++) {
assert((*d)[i] == val);
}
ec = Arrays::Fill(d, 10, 0, val);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::Fill(d, -10, 0, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::Fill(d, 10, d->GetLength()+1, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
// test 17
int CTest::test_fill_JJ(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(long [], long)
AutoPtr<ArrayOf<Int64> > d = ArrayOf<Int64>::Alloc(1000);
ec = Arrays::Fill(d, Elastos::Core::Math::INT64_MAX_VALUE);
for (Int32 i = 0; i < d->GetLength(); i++) {
assert((*d)[i] == Elastos::Core::Math::INT64_MAX_VALUE);
}
return ec;
}
// test 18
int CTest::test_fill_JIIJ(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(long [], int, int, long)
AutoPtr<ArrayOf<Int64> > d = ArrayOf<Int64>::Alloc(1000);
ec = Arrays::Fill(d, 400, d->GetLength(), Elastos::Core::Math::INT64_MAX_VALUE);
for (Int32 i = 0; i < 400; i++) {
assert(!((*d)[i] == Elastos::Core::Math::INT64_MAX_VALUE));
}
for (Int32 i = 400; i < d->GetLength(); i++) {
assert((*d)[i] == Elastos::Core::Math::INT64_MAX_VALUE);
}
ec = Arrays::Fill(d, 10, 0, Elastos::Core::Math::INT64_MIN_VALUE);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::Fill(d, -10, 0, Elastos::Core::Math::INT64_MAX_VALUE);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::Fill(d, 10, d->GetLength()+1, Elastos::Core::Math::INT64_MAX_VALUE);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
// test 19
int CTest::test_fill_FF(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(float [], float)
AutoPtr<ArrayOf<Float> > d = ArrayOf<Float>::Alloc(1000);
ec = Arrays::FillFloat(d, Elastos::Core::Math::FLOAT_MAX_VALUE);
for (Int32 i = 0; i < d->GetLength(); i++) {
assert((*d)[i] == Elastos::Core::Math::FLOAT_MAX_VALUE);
}
return ec;
}
// test 20
int CTest::test_fill_FIIF(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(float [], int, int, float)
Float val = Elastos::Core::Math::FLOAT_MAX_VALUE;
AutoPtr<ArrayOf<Float> > d = ArrayOf<Float>::Alloc(1000);
ec = Arrays::FillFloatEx(d, 400, d->GetLength(), val);
for (Int32 i = 0; i < 400; i++) {
assert(!((*d)[i] == val));
}
for (Int32 i = 400; i < d->GetLength(); i++) {
assert((*d)[i] == val);
}
ec = Arrays::FillFloatEx(d, 10, 0, val);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::FillFloatEx(d, -10, 0, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::FillFloatEx(d, 10, d->GetLength()+1, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
// test 21
int CTest::test_fill_DD(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(double [], double)
AutoPtr<ArrayOf<Double> > d = ArrayOf<Double>::Alloc(1000);
ec = Arrays::FillDouble(d, Elastos::Core::Math::DOUBLE_MAX_VALUE);
for (Int32 i = 0; i < d->GetLength(); i++) {
assert((*d)[i] == Elastos::Core::Math::DOUBLE_MAX_VALUE);
}
return ec;
}
// test 22
int CTest::test_fill_DIID(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(double [], int, int,
// double)
Double val = Elastos::Core::Math::DOUBLE_MAX_VALUE;
AutoPtr<ArrayOf<Double> > d = ArrayOf<Double>::Alloc(1000);
ec = Arrays::FillDoubleEx(d, 400, d->GetLength(), val);
for (Int32 i = 0; i < 400; i++) {
assert(!((*d)[i] == val));
}
for (Int32 i = 400; i < d->GetLength(); i++) {
assert((*d)[i] == val);
}
ec = Arrays::FillDoubleEx(d, 10, 0, val);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::FillDoubleEx(d, -10, 0, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::FillDoubleEx(d, 10, d->GetLength()+1, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
// test 23
int CTest::test_fill_ZZ(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(boolean [], boolean)
AutoPtr<ArrayOf<Boolean> > d = ArrayOf<Boolean>::Alloc(1000);
ec = Arrays::FillBoolean(d, TRUE);
for (Int32 i = 0; i < d->GetLength(); i++) {
assert((*d)[i] == TRUE);
}
return ec;
}
// test 24
int CTest::test_fill_ZIIZ(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(boolean [], int, int,
// boolean)
Boolean val = TRUE;
AutoPtr<ArrayOf<Boolean> > d = ArrayOf<Boolean>::Alloc(1000);
ec = Arrays::FillBooleanEx(d, 400, d->GetLength(), val);
for (Int32 i = 0; i < 400; i++) {
assert(!((*d)[i] == val));
}
for (Int32 i = 400; i < d->GetLength(); i++) {
assert((*d)[i] == val);
}
ec = Arrays::FillBooleanEx(d, 10, 0, val);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::FillBooleanEx(d, -10, 0, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::FillBooleanEx(d, 10, d->GetLength()+1, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
// test 25
int CTest::test_fill_Ljava_lang_ObjectLjava_lang_Object(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(java.lang.Object [],
// java.lang.Object)
AutoPtr<IInterface> val;
AutoPtr<ArrayOf<IInterface*> > d = ArrayOf<IInterface*>::Alloc(1000);
ec = Arrays::FillObjectEx(d, 0, d->GetLength(), val);
for (Int32 i = 0; i < d->GetLength(); i++)
assert((*d)[i] == val);
return ec;
}
// test 26
int CTest::test_fill_Ljava_lang_ObjectIILjava_lang_Object(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.fill(java.lang.Object [], int,
// int, java.lang.Object)
AutoPtr<IInterface> val;
CInteger32::New(99, (IInteger32**)&val);
AutoPtr<ArrayOf<IInterface*> > d = ArrayOf<IInterface*>::Alloc(1000);
ec = Arrays::FillObjectEx(d, 400, d->GetLength(), val);
for (Int32 i = 0; i < 400; i++)
{
assert(!((*d)[i] == val));
}
for (Int32 i = 400; i < d->GetLength(); i++)
assert((*d)[i] == val);
ec = Arrays::FillObjectEx(d, 400, d->GetLength(), NULL);
for (Int32 i = 400; i < d->GetLength(); i++)
assert((*d)[i] == NULL);
ec = Arrays::FillObjectEx(d, 10, 0, val);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::FillObjectEx(d, -10, 0, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::FillObjectEx(d, 10, d->GetLength()+1, val);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
// test 27
int CTest::test_equals_BB(int argc, char* argv[])
{
ECode ec = 0;
// Test for method boolean java.util.Arrays.equals(byte [], byte [])
AutoPtr<ArrayOf<Byte> > d = ArrayOf<Byte>::Alloc(1000);
AutoPtr<ArrayOf<Byte> > x = ArrayOf<Byte>::Alloc(1000);
ec = Arrays::Fill(d, Elastos::Core::Math::BYTE_MAX_VALUE);
ec = Arrays::Fill(x, Elastos::Core::Math::BYTE_MIN_VALUE);
Boolean result;
ec = Arrays::EqualsByte(d, x, &result);
assert(!result);
ec = Arrays::Fill(x, Elastos::Core::Math::BYTE_MAX_VALUE);
ec = Arrays::EqualsByte(d, x, &result);
assert(result);
return ec;
}
// test 28
int CTest::test_equals_SS(int argc, char* argv[])
{
ECode ec = 0;
// Test for method boolean java.util.Arrays.equals(short [], short [])
AutoPtr<ArrayOf<Int16> > d = ArrayOf<Int16>::Alloc(1000);
AutoPtr<ArrayOf<Int16> > x = ArrayOf<Int16>::Alloc(1000);
ec = Arrays::Fill(d, Elastos::Core::Math::INT16_MAX_VALUE);
ec = Arrays::Fill(x, Elastos::Core::Math::INT16_MIN_VALUE);
Boolean result;
ec = Arrays::EqualsInt16(d, x, &result);
assert(!result);
ec = Arrays::Fill(x, Elastos::Core::Math::INT16_MAX_VALUE);
ec = Arrays::EqualsInt16(d, x, &result);
assert(result);
return ec;
}
// test 29
int CTest::test_equals_CC(int argc, char* argv[])
{
ECode ec = 0;
// Test for method boolean java.util.Arrays.equals(char [], char [])
AutoPtr<ArrayOf<Char32> > d = ArrayOf<Char32>::Alloc(1000);
AutoPtr<ArrayOf<Char32> > x = ArrayOf<Char32>::Alloc(1000);
Char32 c = 'T';
ec = Arrays::Fill(d, c);
ec = Arrays::Fill(x, 'L');
Boolean result = FALSE;
ec = Arrays::EqualsChar32(d, x, &result);
assert(!result);
ec = Arrays::Fill(x, c);
ec = Arrays::EqualsChar32(d, x, &result);
assert(result);
return ec;
}
// test 30
int CTest::test_equals_II(int argc, char* argv[])
{
ECode ec = 0;
// Test for method boolean java.util.Arrays.equals(int [], int [])
AutoPtr<ArrayOf<Int32> > d = ArrayOf<Int32>::Alloc(1000);
AutoPtr<ArrayOf<Int32> > x = ArrayOf<Int32>::Alloc(1000);
ec = Arrays::Fill(d, Elastos::Core::Math::INT32_MAX_VALUE);
ec = Arrays::Fill(x, Elastos::Core::Math::INT32_MIN_VALUE);
Boolean result;
ec = Arrays::EqualsInt32(d, x, &result);
assert(!result);
ec = Arrays::Fill(x, Elastos::Core::Math::INT32_MAX_VALUE);
ec = Arrays::EqualsInt32(d, x, &result);
assert(result);
AutoPtr<ArrayOf<Int32> > it1 = ArrayOf<Int32>::Alloc(2);
ec = Arrays::EqualsInt32(it1, NULL, &result);
assert(!result);
AutoPtr<ArrayOf<Int32> > it2 = ArrayOf<Int32>::Alloc(2);
ec = Arrays::EqualsInt32(NULL, it2, &result);
assert(!result);
return ec;
}
// test 31
int CTest::test_equals_JJ(int argc, char* argv[])
{
ECode ec = 0;
// Test for method boolean java.util.Arrays.equals(long [], long [])
AutoPtr<ArrayOf<Int64> > d = ArrayOf<Int64>::Alloc(1000);
AutoPtr<ArrayOf<Int64> > x = ArrayOf<Int64>::Alloc(1000);
ec = Arrays::Fill(d, Elastos::Core::Math::INT64_MAX_VALUE);
ec = Arrays::Fill(x, Elastos::Core::Math::INT64_MIN_VALUE);
Boolean result;
ec = Arrays::EqualsInt64(d, x, &result);
assert(!result);
ec = Arrays::Fill(x, Elastos::Core::Math::INT64_MAX_VALUE);
ec = Arrays::EqualsInt64(d, x, &result);
assert(result);
AutoPtr<ArrayOf<Int64> > l1 = ArrayOf<Int64>::Alloc(1);
l1->Set(0, 0x100000000L);
AutoPtr<ArrayOf<Int64> > l2 = ArrayOf<Int64>::Alloc(1);
l2->Set(0, 0x200000000L);
ec = Arrays::EqualsInt64(l1, l2, &result);
assert(!result);
return ec;
}
// test 32
int CTest::test_equals_FF(int argc, char* argv[])
{
ECode ec = 0;
// Test for method boolean java.util.Arrays.equals(float [], float [])
AutoPtr<ArrayOf<Float> > d = ArrayOf<Float>::Alloc(1000);
AutoPtr<ArrayOf<Float> > x = ArrayOf<Float>::Alloc(1000);
ec = Arrays::FillFloat(d, Elastos::Core::Math::FLOAT_MAX_VALUE);
ec = Arrays::FillFloat(x, Elastos::Core::Math::FLOAT_MIN_VALUE);
Boolean result;
ec = Arrays::EqualsFloat(d, x, &result);
assert(!result);
ec = Arrays::FillFloat(x, Elastos::Core::Math::FLOAT_MAX_VALUE);
ec = Arrays::EqualsFloat(d, x, &result);
assert(result);
AutoPtr<ArrayOf<Float> > f1 = ArrayOf<Float>::Alloc(1);
f1->Set(0, Elastos::Core::Math::FLOAT_NAN);
AutoPtr<ArrayOf<Float> > f2 = ArrayOf<Float>::Alloc(1);
f2->Set(0, Elastos::Core::Math::FLOAT_NAN);
ec = Arrays::EqualsFloat(f1, f2, &result);
assert(result);
AutoPtr<ArrayOf<Float> > f3 = ArrayOf<Float>::Alloc(1);
f3->Set(0, 0.0);
AutoPtr<ArrayOf<Float> > f4 = ArrayOf<Float>::Alloc(1);
f4->Set(0, -0.0);
ec = Arrays::EqualsFloat(f3, f4, &result);
assert(!result);
return ec;
}
// test 33
int CTest::test_equals_DD(int argc, char* argv[])
{
ECode ec = 0;
// Test for method boolean java.util.Arrays.equals(double [], double [])
AutoPtr<ArrayOf<Double> > d = ArrayOf<Double>::Alloc(1000);
AutoPtr<ArrayOf<Double> > x = ArrayOf<Double>::Alloc(1000);
ec = Arrays::FillDouble(d, Elastos::Core::Math::DOUBLE_MAX_VALUE);
ec = Arrays::FillDouble(x, Elastos::Core::Math::DOUBLE_MIN_VALUE);
Boolean result;
ec = Arrays::EqualsDouble(d, x, &result);
assert(!result);
ec = Arrays::FillDouble(x, Elastos::Core::Math::DOUBLE_MAX_VALUE);
ec = Arrays::EqualsDouble(d, x, &result);
assert(result);
AutoPtr<ArrayOf<Double> > dl1 = ArrayOf<Double>::Alloc(1);
dl1->Set(0, 1.0);
AutoPtr<ArrayOf<Double> > dl2 = ArrayOf<Double>::Alloc(1);
dl2->Set(0, 2.0);
ec = Arrays::EqualsDouble(dl1, dl2, &result);
assert(!result);
dl1->Set(0, Elastos::Core::Math::DOUBLE_NAN);
dl2->Set(0, Elastos::Core::Math::DOUBLE_NAN);
ec = Arrays::EqualsDouble(dl1, dl2, &result);
assert(result);
dl1->Set(0, 0.0);
dl2->Set(0, -0.0);
ec = Arrays::EqualsDouble(dl1, dl2, &result);
assert(!result);
return ec;
}
// test 34
int CTest::test_equals_ZZ(int argc, char* argv[])
{
ECode ec = 0;
// Test for method boolean java.util.Arrays.equals(boolean [], boolean
// [])
AutoPtr<ArrayOf<Boolean> > d = ArrayOf<Boolean>::Alloc(1000);
AutoPtr<ArrayOf<Boolean> > x = ArrayOf<Boolean>::Alloc(1000);
ec = Arrays::FillBoolean(d, TRUE);
ec = Arrays::FillBoolean(x, FALSE);
Boolean result;
ec = Arrays::EqualsBoolean(d, x, &result);
assert(!result);
ec = Arrays::FillBoolean(x, TRUE);
ec = Arrays::EqualsBoolean(d, x, &result);
assert(result);
return ec;
}
// test 35
int CTest::test_equals_Ljava_lang_Object_Ljava_lang_Object(int argc, char* argv[])
{
ECode ec = 0;
Boolean result;
// Test for method boolean java.util.Arrays.equals(java.lang.Object [],
// java.lang.Object [])
AutoPtr<ArrayOf<IInterface*> > d = ArrayOf<IInterface*>::Alloc(1000);
AutoPtr<ArrayOf<IInterface*> > x = ArrayOf<IInterface*>::Alloc(1000);
AutoPtr<IInterface> o;
CInteger32::New(0, (IInteger32**)&o);
ec = Arrays::FillObject(d, o);
AutoPtr<IInterface> elem;
CInteger32::New(0, (IInteger32**)&elem);
ec = Arrays::FillObject(x, elem);
ec = Arrays::Equals(d, x, &result);
assert(!result);
ec = Arrays::FillObject(x, o);
d->Set(50, NULL);
x->Set(50, NULL);
ec = Arrays::Equals(d, x, &result);
assert(result == TRUE);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_B(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(byte [])
AutoPtr<ArrayOf<Byte> > reversedArray = ArrayOf<Byte>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, (Byte) (arraySize - counter - 1));
}
ec = Arrays::SortByte(reversedArray);
for (Int32 counter = 0; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (Byte) counter);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_BII(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(byte [], int, int)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
AutoPtr<ArrayOf<Byte> > reversedArray = ArrayOf<Byte>::Alloc(arraySize);
AutoPtr<ArrayOf<Byte> > originalReversedArray = ArrayOf<Byte>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, (Byte) (arraySize - counter - 1));
originalReversedArray->Set(counter, (*reversedArray)[counter]);
}
Arrays::SortByteEx(reversedArray, startIndex, endIndex);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
assert((*reversedArray)[counter] <= (*reversedArray)[counter + 1]);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
//exception testing
ec = Arrays::SortByteEx(reversedArray, startIndex + 1, startIndex);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::SortByteEx(reversedArray, -1, startIndex);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::SortByteEx(reversedArray, startIndex, reversedArray->GetLength() + 1);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_C(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(char [])
AutoPtr<ArrayOf<Char32> > reversedArray = ArrayOf<Char32>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++)
reversedArray->Set(counter, (Char32) (arraySize - counter - 1));
Arrays::SortChar32(reversedArray);
for (Int32 counter = 0; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (Char32) counter);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_CII(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(char [], int, int)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
AutoPtr<ArrayOf<Char32> > reversedArray = ArrayOf<Char32>::Alloc(arraySize);
AutoPtr<ArrayOf<Char32> > originalReversedArray = ArrayOf<Char32>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, (Char32) (arraySize - counter - 1));
originalReversedArray->Set(counter, (*reversedArray)[counter]);
}
Arrays::SortChar32Ex(reversedArray, startIndex, endIndex);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
assert((*reversedArray)[counter] <= (*reversedArray)[counter + 1]);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
//exception testing
ec = Arrays::SortChar32Ex(reversedArray, startIndex + 1, startIndex);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::SortChar32Ex(reversedArray, -1, startIndex);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::SortChar32Ex(reversedArray, startIndex, reversedArray->GetLength() + 1);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_D(int argc, char* argv[])
{
ECode ec = 0;
Boolean result;
// Test for method void java.util.Arrays.sort(double [])
AutoPtr<ArrayOf<Double> > reversedArray = ArrayOf<Double>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++)
reversedArray->Set(counter, (Double) (arraySize - counter - 1));
ec = Arrays::SortDouble(reversedArray);
for (Int32 counter = 0; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (Double) counter);
AutoPtr<ArrayOf<Double> > specials1 = ArrayOf<Double>::Alloc(7);
specials1->Set(0, Elastos::Core::Math::DOUBLE_NAN);
specials1->Set(1, Elastos::Core::Math::DOUBLE_MAX_VALUE);
specials1->Set(2, Elastos::Core::Math::DOUBLE_MIN_VALUE);
specials1->Set(3, 0);
specials1->Set(4, -0);
specials1->Set(5, Elastos::Core::Math::DOUBLE_POSITIVE_INFINITY);
specials1->Set(6, Elastos::Core::Math::DOUBLE_NEGATIVE_INFINITY);
AutoPtr<ArrayOf<Double> > specials2 = ArrayOf<Double>::Alloc(7);
specials2->Set(0, 0);
specials2->Set(1, Elastos::Core::Math::DOUBLE_POSITIVE_INFINITY);
specials2->Set(2, -0);
specials2->Set(3, Elastos::Core::Math::DOUBLE_NEGATIVE_INFINITY);
specials2->Set(4, Elastos::Core::Math::DOUBLE_MIN_VALUE);
specials2->Set(5, Elastos::Core::Math::DOUBLE_NAN);
specials2->Set(6, Elastos::Core::Math::DOUBLE_MAX_VALUE);
AutoPtr<ArrayOf<Double> > answer = ArrayOf<Double>::Alloc(7);
answer->Set(0, Elastos::Core::Math::DOUBLE_NEGATIVE_INFINITY);
answer->Set(1, 0);
answer->Set(2, -0);
answer->Set(3, Elastos::Core::Math::DOUBLE_MIN_VALUE);
answer->Set(4, Elastos::Core::Math::DOUBLE_MAX_VALUE);
answer->Set(5, Elastos::Core::Math::DOUBLE_POSITIVE_INFINITY);
answer->Set(6, Elastos::Core::Math::DOUBLE_NAN);
ec = Arrays::SortDouble(specials1);
AutoPtr<ArrayOf<IInterface*> > print1 = ArrayOf<IInterface*>::Alloc(specials1->GetLength());
for (Int32 i = 0; i < specials1->GetLength(); i++) {
AutoPtr<IDouble> elem;
CDouble::New((*specials1)[i], (IDouble**)&elem);
print1->Set(i, elem);
}
ec = Arrays::EqualsDouble(specials1, answer, &result);
assert(result == TRUE);
ec = Arrays::SortDouble(specials2);
AutoPtr<ArrayOf<IInterface*> > print2 = ArrayOf<IInterface*>::Alloc(specials2->GetLength());
for (Int32 i = 0; i < specials2->GetLength(); i++) {
AutoPtr<IDouble> elem;
CDouble::New((*specials2)[i], (IDouble**)&elem);
print2->Set(i, elem);
}
ec = Arrays::EqualsDouble(specials2, answer, &result);
assert(result == TRUE);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_DII(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(double [], int, int)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
AutoPtr<ArrayOf<Double> > reversedArray = ArrayOf<Double>::Alloc(arraySize);
AutoPtr<ArrayOf<Double> > originalReversedArray = ArrayOf<Double>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, (Double) (arraySize - counter - 1));
originalReversedArray->Set(counter, (*reversedArray)[counter]);
}
ec = Arrays::SortDoubleEx(reversedArray, startIndex, endIndex);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
assert((*reversedArray)[counter] <= (*reversedArray)[counter + 1]);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
//exception testing
ec = Arrays::SortDoubleEx(reversedArray, startIndex + 1, startIndex);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::SortDoubleEx(reversedArray, -1, startIndex);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::SortDoubleEx(reversedArray, startIndex, reversedArray->GetLength() + 1);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_F(int argc, char* argv[])
{
ECode ec = 0;
Boolean result;
// Test for method void java.util.Arrays.sort(float [])
AutoPtr<ArrayOf<Float> > reversedArray = ArrayOf<Float>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++)
reversedArray->Set(counter, (Float) (arraySize - counter - 1));
ec = Arrays::SortFloat(reversedArray);
for (Int32 counter = 0; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (Float) counter);
AutoPtr<ArrayOf<Float> > specials1 = ArrayOf<Float>::Alloc(7);
specials1->Set(0, Elastos::Core::Math::FLOAT_NAN);
specials1->Set(1, Elastos::Core::Math::FLOAT_MAX_VALUE);
specials1->Set(2, Elastos::Core::Math::FLOAT_MIN_VALUE);
specials1->Set(3, 0);
specials1->Set(4, -0);
specials1->Set(5, Elastos::Core::Math::FLOAT_POSITIVE_INFINITY);
specials1->Set(6, Elastos::Core::Math::FLOAT_NEGATIVE_INFINITY);
AutoPtr<ArrayOf<Float> > specials2 = ArrayOf<Float>::Alloc(7);
specials2->Set(0, 0);
specials2->Set(1, Elastos::Core::Math::FLOAT_POSITIVE_INFINITY);
specials2->Set(2, -0);
specials2->Set(3, Elastos::Core::Math::FLOAT_NEGATIVE_INFINITY);
specials2->Set(4, Elastos::Core::Math::FLOAT_MIN_VALUE);
specials2->Set(5, Elastos::Core::Math::FLOAT_NAN);
specials2->Set(6, Elastos::Core::Math::FLOAT_MAX_VALUE);
AutoPtr<ArrayOf<Float> > answer = ArrayOf<Float>::Alloc(7);
answer->Set(0, Elastos::Core::Math::FLOAT_NEGATIVE_INFINITY);
answer->Set(1, 0);
answer->Set(2, -0);
answer->Set(3, Elastos::Core::Math::FLOAT_MIN_VALUE);
answer->Set(4, Elastos::Core::Math::FLOAT_MAX_VALUE);
answer->Set(5, Elastos::Core::Math::FLOAT_POSITIVE_INFINITY);
answer->Set(6, Elastos::Core::Math::FLOAT_NAN);
ec = Arrays::SortFloat(specials1);
AutoPtr<ArrayOf<IInterface*> > print1 = ArrayOf<IInterface*>::Alloc(specials1->GetLength());
for (Int32 i = 0; i < specials1->GetLength(); i++) {
AutoPtr<IFloat> elem;
CFloat::New((*specials1)[i], (IFloat**)&elem);
print1->Set(i, elem);
}
ec = Arrays::EqualsFloat(specials1, answer, &result);
assert(result == TRUE);
ec = Arrays::SortFloat(specials2);
AutoPtr<ArrayOf<IInterface*> > print2 = ArrayOf<IInterface*>::Alloc(specials2->GetLength());
for (Int32 i = 0; i < specials2->GetLength(); i++) {
AutoPtr<IFloat> elem;
CFloat::New((*specials2)[i], (IFloat**)&elem);
print2->Set(i, elem);
}
ec = Arrays::EqualsFloat(specials2, answer, &result);
assert(result == TRUE);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_FII(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(float [], int, int)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
AutoPtr<ArrayOf<Float> > reversedArray = ArrayOf<Float>::Alloc(arraySize);
AutoPtr<ArrayOf<Float> > originalReversedArray = ArrayOf<Float>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, (Float) (arraySize - counter - 1));
originalReversedArray->Set(counter, (*reversedArray)[counter]);
}
ec = Arrays::SortFloatEx(reversedArray, startIndex, endIndex);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
assert((*reversedArray)[counter] <= (*reversedArray)[counter + 1]);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
//exception testing
ec = Arrays::SortFloatEx(reversedArray, startIndex + 1, startIndex);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::SortFloatEx(reversedArray, -1, startIndex);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::SortFloatEx(reversedArray, startIndex, reversedArray->GetLength() + 1);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_I(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(int [])
AutoPtr<ArrayOf<Int32> > reversedArray = ArrayOf<Int32>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++)
reversedArray->Set(counter, arraySize - counter - 1);
ec = Arrays::SortInt32(reversedArray);
for (Int32 counter = 0; counter < arraySize; counter++)
assert((*reversedArray)[counter] == counter);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_III(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(int [], int, int)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
AutoPtr<ArrayOf<Int32> > reversedArray = ArrayOf<Int32>::Alloc(arraySize);
AutoPtr<ArrayOf<Int32> > originalReversedArray = ArrayOf<Int32>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, arraySize - counter - 1);
originalReversedArray->Set(counter, (*reversedArray)[counter]);
}
ec = Arrays::SortInt32Ex(reversedArray, startIndex, endIndex);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
assert((*reversedArray)[counter] <= (*reversedArray)[counter + 1]);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
//exception testing
ec = Arrays::SortInt32Ex(reversedArray, startIndex + 1, startIndex);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::SortInt32Ex(reversedArray, -1, startIndex);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::SortInt32Ex(reversedArray, startIndex, reversedArray->GetLength() + 1);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_J(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(long [])
AutoPtr<ArrayOf<Int64> > reversedArray = ArrayOf<Int64>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++)
reversedArray->Set(counter, (Int64) (arraySize - counter - 1));
ec = Arrays::SortInt64(reversedArray);
for (Int32 counter = 0; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (Int64) counter);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_JII(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(long [], int, int)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
AutoPtr<ArrayOf<Int64> > reversedArray = ArrayOf<Int64>::Alloc(arraySize);
AutoPtr<ArrayOf<Int64> > originalReversedArray = ArrayOf<Int64>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, (Int64) (arraySize - counter - 1));
originalReversedArray->Set(counter, (*reversedArray)[counter]);
}
ec = Arrays::SortInt64Ex(reversedArray, startIndex, endIndex);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
assert((*reversedArray)[counter] <= (*reversedArray)[counter + 1]);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
//exception testing
ec = Arrays::SortInt64Ex(reversedArray, startIndex + 1, startIndex);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::SortInt64Ex(reversedArray, -1, startIndex);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::SortInt64Ex(reversedArray, startIndex, reversedArray->GetLength() + 1);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_Ljava_lang_Object(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(java.lang.Object [])
AutoPtr<ArrayOf<IInterface*> > reversedArray = ArrayOf<IInterface*>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++)
reversedArray->Set(counter, (*objectArray)[arraySize - counter - 1]);
ec = Arrays::SortObject(reversedArray);
for (Int32 counter = 0; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*objectArray)[counter]);
AutoPtr<ICharSequence> str;
CString::New(String("String"), (ICharSequence**)&str);
ec = Arrays::FillObjectEx(reversedArray, 0, reversedArray->GetLength()/2, str);
AutoPtr<IInteger32> it;
CInteger32::New(1, (IInteger32**)&it);
ec = Arrays::FillObjectEx(reversedArray, reversedArray->GetLength()/2, reversedArray->GetLength(), it);
ec = Arrays::SortObject(reversedArray);
assert(ec != NOERROR);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_Ljava_lang_ObjectII(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(java.lang.Object [], int,
// int)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
AutoPtr<ArrayOf<IInterface*> > reversedArray = ArrayOf<IInterface*>::Alloc(arraySize);
AutoPtr<ArrayOf<IInterface*> > originalReversedArray = ArrayOf<IInterface*>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, (*objectArray)[arraySize - counter - 1]);
originalReversedArray->Set(counter, (*reversedArray)[counter]);
}
ec = Arrays::SortObjectEx(reversedArray, startIndex, endIndex);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
// assertTrue("Array not sorted within bounds",
// ((Comparable) reversedArray[counter])
// .compareTo(reversedArray[counter + 1]) <= 0);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
//exception testing
ec = Arrays::SortObjectEx(reversedArray, startIndex + 1, startIndex);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::SortObjectEx(reversedArray, -1, startIndex);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::SortObjectEx(reversedArray, startIndex, reversedArray->GetLength() + 1);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
AutoPtr<ICharSequence> str;
CString::New(String("String"), (ICharSequence**)&str);
ec = Arrays::FillObjectEx(reversedArray, 0, reversedArray->GetLength()/2, str);
AutoPtr<IInteger32> it;
CInteger32::New(1, (IInteger32**)&it);
ec = Arrays::FillObjectEx(reversedArray, reversedArray->GetLength()/2, reversedArray->GetLength(), it);
ec = Arrays::SortObjectEx(reversedArray, reversedArray->GetLength()/4, 3*reversedArray->GetLength()/4);
assert(ec != NOERROR);
ec = Arrays::SortObjectEx(reversedArray, 0, reversedArray->GetLength()/4);
ec = Arrays::SortObjectEx(reversedArray, 3*reversedArray->GetLength()/4, reversedArray->GetLength());
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_Ljava_lang_ObjectIILjava_util_Comparator(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(java.lang.Object [], int,
// int, java.util.Comparator)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
ReversedIntegerComparator* comp/* = new ReversedIntegerComparator()*/;
AutoPtr<ArrayOf<IInterface*> > originalArray = ArrayOf<IInterface*>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++)
originalArray->Set(counter, (*objectArray)[counter]);
//ec = Arrays::SortEx(objectArray, startIndex, endIndex, comp);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*objectArray)[counter] == (*originalArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
assert(comp->Compare((*objectArray)[counter], (*objectArray)[counter + 1]) <= 0);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*objectArray)[counter] == (*originalArray)[counter]);
AutoPtr<ICharSequence> str;
CString::New(String("String"), (ICharSequence**)&str);
ec = Arrays::FillObjectEx(originalArray, 0, originalArray->GetLength()/2, str);
AutoPtr<IInteger32> it;
CInteger32::New(1, (IInteger32**)&it);
ec = Arrays::FillObjectEx(originalArray, originalArray->GetLength()/2, originalArray->GetLength(), it);
//ec = Arrays::Sort(originalArray, startIndex, endIndex, comp);
//assert(ec != NOERROR);
// ec = Arrays::SortEx(originalArray, endIndex, originalArray->GetLength(), comp);
// ec = Arrays::SortEx(originalArray, endIndex, originalArray->GetLength() + 1, comp);
// assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
// ec = Arrays::SortEx(originalArray, -1, startIndex, comp);
// assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
// ec = Arrays::SortEx(originalArray, originalArray->GetLength(), endIndex, comp);
// assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_Ljava_lang_ObjectLjava_util_Comparator(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(java.lang.Object [],
// java.util.Comparator)
ReversedIntegerComparator* comp/* = new ReversedIntegerComparator()*/;
//ec = Arrays::Sort(objectArray, comp);
for (Int32 counter = 0; counter < arraySize - 1; counter++)
assert(comp->Compare((*objectArray)[counter],
(*objectArray)[counter + 1]) <= 0);
AutoPtr<ICharSequence> str;
CString::New(String("String"), (ICharSequence**)&str);
ec = Arrays::FillObjectEx(objectArray, 0, objectArray->GetLength()/2, str);
AutoPtr<IInteger32> it;
CInteger32::New(1, (IInteger32**)&it);
ec = Arrays::FillObjectEx(objectArray, objectArray->GetLength()/2, objectArray->GetLength(), it);
//ec = Arrays::Sort(objectArray, comp);
//assert(ec != NOERROR);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_S(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(short [])
AutoPtr<ArrayOf<Int16> > reversedArray = ArrayOf<Int16>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++)
reversedArray->Set(counter, (Int16) (arraySize - counter - 1));
ec = Arrays::SortInt16(reversedArray);
for (Int32 counter = 0; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (Int16) counter);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_sort_SII(int argc, char* argv[])
{
ECode ec = 0;
// Test for method void java.util.Arrays.sort(short [], int, int)
Int32 startIndex = arraySize / 4;
Int32 endIndex = 3 * arraySize / 4;
AutoPtr<ArrayOf<Int16> > reversedArray = ArrayOf<Int16>::Alloc(arraySize);
AutoPtr<ArrayOf<Int16> > originalReversedArray = ArrayOf<Int16>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
reversedArray->Set(counter, (Int16) (arraySize - counter - 1));
originalReversedArray->Set(counter, (*reversedArray)[counter]);
}
ec = Arrays::SortInt16Ex(reversedArray, startIndex, endIndex);
for (Int32 counter = 0; counter < startIndex; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
for (Int32 counter = startIndex; counter < endIndex - 1; counter++)
assert((*reversedArray)[counter] <= (*reversedArray)[counter + 1]);
for (Int32 counter = endIndex; counter < arraySize; counter++)
assert((*reversedArray)[counter] == (*originalReversedArray)[counter]);
//exception testing
ec = Arrays::SortInt16Ex(reversedArray, startIndex + 1, startIndex);
assert(ec == E_ILLEGAL_ARGUMENT_EXCEPTION);
ec = Arrays::SortInt16Ex(reversedArray, -1, startIndex);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
ec = Arrays::SortInt16Ex(reversedArray, startIndex, reversedArray->GetLength() + 1);
assert(ec == E_INDEX_OUT_OF_BOUNDS_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_java_util_Arrays_sort_byte_array_NPE(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<ArrayOf<Byte> > byte_array_null = NULL;
ec = Arrays::SortByte(byte_array_null);
assert(ec == E_NULL_POINTER_EXCEPTION);
// Regression for HARMONY-378
ec = Arrays::SortByteEx(byte_array_null, (Int32) -1, (Int32) 1);
assert(ec == E_NULL_POINTER_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_java_util_Arrays_sort_char_array_NPE(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<ArrayOf<Char32> > char_array_null = NULL;
ec = Arrays::SortChar32(char_array_null);
assert(ec == E_NULL_POINTER_EXCEPTION);
// Regression for HARMONY-378
ec = Arrays::SortChar32Ex(char_array_null, -1, 1);
assert(ec == E_NULL_POINTER_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_java_util_Arrays_sort_double_array_NPE(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<ArrayOf<Double> > double_array_null = NULL;
ec = Arrays::SortDouble(double_array_null);
assert(ec == E_NULL_POINTER_EXCEPTION);
// Regression for HARMONY-378
ec = Arrays::SortDoubleEx(double_array_null, -1, 1);
assert(ec == E_NULL_POINTER_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_java_util_Arrays_sort_float_array_NPE(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<ArrayOf<Float> > float_array_null = NULL;
ec = Arrays::SortFloat(float_array_null);
assert(ec == E_NULL_POINTER_EXCEPTION);
// Regression for HARMONY-378
ec = Arrays::SortFloatEx(float_array_null, -1, 1);
assert(ec == E_NULL_POINTER_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_java_util_Arrays_sort_int_array_NPE(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<ArrayOf<Int32> > int_array_null = NULL;
ec = Arrays::SortInt32(int_array_null);
assert(ec == E_NULL_POINTER_EXCEPTION);
// Regression for HARMONY-378
ec = Arrays::SortInt32Ex(int_array_null, -1, 1);
assert(ec == E_NULL_POINTER_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_java_util_Arrays_sort_object_array_NPE(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<ArrayOf<IInterface*> > object_array_null = NULL;
ec = Arrays::SortObject(object_array_null);
assert(ec == E_NULL_POINTER_EXCEPTION);
// Regression for HARMONY-378
ec = Arrays::SortObjectEx(object_array_null, (Int32) -1, (Int32) 1);
assert(ec == E_NULL_POINTER_EXCEPTION);
// Regression for HARMONY-378
ec = Arrays::SortEx(object_array_null, (Int32) -1, (Int32) 1, NULL);
assert(ec == E_NULL_POINTER_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_java_util_Arrays_sort_long_array_NPE(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<ArrayOf<Int64> > long_array_null = NULL;
ec = Arrays::SortInt64(long_array_null);
assert(ec == E_NULL_POINTER_EXCEPTION);
// Regression for HARMONY-378
ec = Arrays::SortInt64Ex(long_array_null, -1, 1);
assert(ec == E_NULL_POINTER_EXCEPTION);
return ec;
}
//NOT_IMPLEMENTED
int CTest::test_java_util_Arrays_sort_short_array_NPE(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<ArrayOf<Int16> > short_array_null = NULL;
ec = Arrays::SortInt16(short_array_null);
assert(ec != NOERROR);
// Regression for HARMONY-378
ec = Arrays::SortInt16Ex(short_array_null, (Int32) -1, (Int32) 1);
assert(ec != NOERROR);
return ec;
}
//AutoPtr<ArrayOf<Int32> > CTest::LENGTHS = { 0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 100, 1000, 10000 };
//NOT_IMPLEMENTED
int CTest::test_sort(int argc, char* argv[])
{
// AutoPtr<IArrays> ars;
// CArrays::AcquireSingleton((IArrays**)&ars);
// ECode ec = 0;
// for (Int32 len = 0; len < LENGTHS; len++) {
// PrimitiveTypeArrayBuilder.reset();
// AutoPtr<ArrayOf<Int32> > golden = ArrayOf::Alloc(len);
// for (Int32 m = 1; m < 2 * len; m *= 2) {
// for (PrimitiveTypeArrayBuilder builder : PrimitiveTypeArrayBuilder.values()) {
// builder.build(golden, m);
// Int32[] test = golden.clone();
// for (PrimitiveTypeConverter converter : PrimitiveTypeConverter.values()) {
// Object convertedGolden = converter.convert(golden);
// Object convertedTest = converter.convert(test);
// sort(convertedTest);
// checkSorted(convertedTest);
// assert(checkSum(convertedGolden) == checkSum(convertedTest));
// }
// }
// }
// }
return 0;
}
//NOT_IMPLEMENTED
void CTest::sort(IInterface* array)
{
// AutoPtr<IArrays> ars;
// CArrays::AcquireSingleton((IArrays**)&ars);
// ECode ec = 0;
// if (array instanceof Int32[]) {
// Arrays.sort((Int32[]) array);
// }
// else if (array instanceof Int64[]) {
// Arrays.sort((Int64[]) array);
// }
// else if (array instanceof short[]) {
// Arrays.sort((short[]) array);
// }
// else if (array instanceof Byte[]) {
// Arrays.sort((Byte[]) array);
// }
// else if (array instanceof char[]) {
// Arrays.sort((char[]) array);
// }
// else if (array instanceof Float[]) {
// Arrays.sort((Float[]) array);
// }
// else if (array instanceof Double[]) {
// Arrays.sort((Double[]) array);
// }
// else {
// fail("Unknow type of array: " + array.getClass());
// }
}
//NOT_IMPLEMENTED
void CTest::checkSorted(IInterface* array)
{
// if (array instanceof Int32[]) {
// checkSorted((Int32[]) array);
// }
// else if (array instanceof Int64[]) {
// checkSorted((Int64[]) array);
// }
// else if (array instanceof short[]) {
// checkSorted((short[]) array);
// }
// else if (array instanceof Byte[]) {
// checkSorted((Byte[]) array);
// }
// else if (array instanceof char[]) {
// checkSorted((char[]) array);
// }
// else if (array instanceof Float[]) {
// checkSorted((Float[]) array);
// }
// else if (array instanceof Double[]) {
// checkSorted((Double[]) array);
// }
// else {
// fail("Unknow type of array: " + array.getClass());
// }
}
//NOT_IMPLEMENTED
void CTest::checkSorted(ArrayOf<Int32>* a)
{
for (Int32 i = 0; i < a->GetLength() - 1; i++) {
if ((*a)[i] > (*a)[i + 1]) {
//orderFail(i, "" + (*a)[i], "" + (*a)[i + 1]);
assert(FALSE);
}
}
}
//NOT_IMPLEMENTED
void CTest::checkSorted(ArrayOf<Int64>* a)
{
for (Int32 i = 0; i < a->GetLength() - 1; i++) {
if ((*a)[i] > (*a)[i + 1]) {
//orderFail(i, "" + (*a)[i], "" + (*a)[i + 1]);
assert(FALSE);
}
}
}
//NOT_IMPLEMENTED
void CTest::checkSorted(ArrayOf<Int16>* a)
{
for (Int32 i = 0; i < a->GetLength() - 1; i++) {
if ((*a)[i] > (*a)[i + 1]) {
//orderFail(i, "" + (*a)[i], "" + (*a)[i + 1]);
assert(FALSE);
}
}
}
//NOT_IMPLEMENTED
void CTest::checkSorted(ArrayOf<Byte>* a)
{
for (Int32 i = 0; i < a->GetLength() - 1; i++) {
if ((*a)[i] > (*a)[i + 1]) {
//orderFail(i, "" + (*a)[i], "" + (*a)[i + 1]);
assert(FALSE);
}
}
}
//NOT_IMPLEMENTED
void CTest::checkSorted(ArrayOf<Char32>* a)
{
for (Int32 i = 0; i < a->GetLength() - 1; i++) {
if ((*a)[i] > (*a)[i + 1]) {
//orderFail(i, "" + (*a)[i], "" + (*a)[i + 1]);
assert(FALSE);
}
}
}
//NOT_IMPLEMENTED
void CTest::checkSorted(ArrayOf<Float>* a)
{
for (Int32 i = 0; i < a->GetLength() - 1; i++) {
if ((*a)[i] > (*a)[i + 1]) {
assert(FALSE);
}
}
}
//NOT_IMPLEMENTED
void CTest::checkSorted(ArrayOf<Double>* a)
{
for (Int32 i = 0; i < a->GetLength() - 1; i++) {
if ((*a)[i] > (*a)[i + 1]) {
//orderFail(i, "" + (*a)[i], "" + (*a)[i + 1]);
assert(FALSE);
}
}
}
//NOT_IMPLEMENTED
void CTest::orderFail(Int32 index, String value1, String value2)
{
//fail("Array is not sorted at " + index + "-th position: " + value1 + " and " + value2);
}
Int32 CTest::checkSum(IInterface* array)
{
// if (array instanceof Int32[]) {
// return checkSum((Int32[]) array);
// }
// else if (array instanceof Int64[]) {
// return checkSum((Int64[]) array);
// }
// else if (array instanceof short[]) {
// return checkSum((Int16[]) array);
// }
// else if (array instanceof Byte[]) {
// return checkSum((Byte[]) array);
// }
// else if (array instanceof char[]) {
// return checkSum((Char32[]) array);
// }
// else if (array instanceof Float[]) {
// return checkSum((Float[]) array);
// }
// else if (array instanceof Double[]) {
// return checkSum((Double[]) array);
// }
// else {
// fail("Unknow type of array: " + array.getClass());
// }
// throw new AssertionError(); // Needed to shut up compiler
return 0;
}
Int32 CTest::checkSum(ArrayOf<Int32>* a)
{
Int32 checkSum = 0;
for (Int32 i = 0;i < a->GetLength();i++) {
Int32 e = (*a)[i];
checkSum ^= e; // xor
}
return checkSum;
}
Int32 CTest::checkSum(ArrayOf<Int64>* a)
{
Int64 checkSum = 0;
for (Int32 i = 0;i < a->GetLength();i++) {
Int64 e = (*a)[i];
checkSum ^= e; // xor
}
return (Int32) checkSum;
}
Int32 CTest::checkSum(ArrayOf<Int16>* a)
{
Int16 checkSum = 0;
for (Int32 i = 0;i < a->GetLength();i++) {
Int16 e = (*a)[i];
checkSum ^= e; // xor
}
return (Int32) checkSum;
}
Int32 CTest::checkSum(ArrayOf<Byte>* a)
{
Byte checkSum = 0;
for (Int32 i = 0;i < a->GetLength();i++) {
Byte e = (*a)[i];
checkSum ^= e; // xor
}
return (Int32) checkSum;
}
Int32 CTest::checkSum(ArrayOf<Char32>* a)
{
Float checkSum = 0;
for (Int32 i = 0;i < a->GetLength();i++) {
Char32 e = (*a)[i];
checkSum = (Int32) checkSum ^ e; // xor
}
return (Int32) checkSum;
}
Int32 CTest::checkSum(ArrayOf<Float>* a)
{
Int32 checkSum = 0;
for (Int32 i = 0;i < a->GetLength();i++) {
Float e = (*a)[i];
checkSum ^= (Int32) e; // xor
}
return checkSum;
}
Int32 CTest::checkSum(ArrayOf<Double>* a)
{
Int32 checkSum = 0;
for (Int32 i = 0;i < a->GetLength();i++) {
Double e = (*a)[i];
checkSum ^= (Int32) e; // xor
}
return checkSum;
}
// private enum PrimitiveTypeArrayBuilder {
// RANDOM {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = ourRandom.nextInt();
// }
// }
// },
// ASCENDING {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = m + i;
// }
// }
// },
// DESCENDING {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = a->GetLength() - m - i;
// }
// }
// },
// ALL_EQUAL {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = m;
// }
// }
// },
// SAW {
// void build(Int32[] a, Int32 m) {
// Int32 incCount = 1;
// Int32 decCount = a->GetLength();
// Int32 i = 0;
// Int32 period = m;
// m--;
// while (true) {
// for (Int32 k = 1; k <= period; k++) {
// if (i >= a->GetLength()) {
// return;
// }
// a[i++] = incCount++;
// }
// period += m;
// for (Int32 k = 1; k <= period; k++) {
// if (i >= a->GetLength()) {
// return;
// }
// a[i++] = decCount--;
// }
// period += m;
// }
// }
// },
// REPEATED {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = i % m;
// }
// }
// },
// DUPLICATED {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = ourRandom.nextInt(m);
// }
// }
// },
// ORGAN_PIPES {
// void build(Int32[] a, Int32 m) {
// Int32 middle = a->GetLength() / (m + 1);
// for (Int32 i = 0; i < middle; i++) {
// a[i] = i;
// }
// for (Int32 i = middle; i < a->GetLength() ; i++) {
// a[i] = a->GetLength() - i - 1;
// }
// }
// },
// STAGGER {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = (i * m + i) % a->GetLength();
// }
// }
// },
// PLATEAU {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = Math.min(i, m);
// }
// }
// },
// SHUFFLE {
// void build(Int32[] a, Int32 m) {
// for (Int32 i = 0; i < a->GetLength(); i++) {
// a[i] = ourRandom.nextBoolean() ? (ourFirst += 2) : (ourSecond += 2);
// }
// }
// };
// abstract void build(Int32[] a, Int32 m);
// static void reset() {
// ourRandom = new Random(666);
// ourFirst = 0;
// ourSecond = 0;
// }
// @Override
// public String toString() {
// String name = name();
// for (Int32 i = name->GetLength()(); i < 12; i++) {
// name += " " ;
// }
// return name;
// }
// private static Int32 ourFirst;
// private static Int32 ourSecond;
// private static Random ourRandom = new Random(666);
// }
// private enum PrimitiveTypeConverter {
// INT {
// Object convert(Int32[] a) {
// return a;
// }
// },
// LONG {
// Object convert(Int32[] a) {
// Int64[] b = new Int64[a->GetLength()];
// for (Int32 i = 0; i < a->GetLength(); i++) {
// b[i] = (Int32) a[i];
// }
// return b;
// }
// },
// BYTE {
// Object convert(Int32[] a) {
// Byte[] b = new Byte[a->GetLength()];
// for (Int32 i = 0; i < a->GetLength(); i++) {
// b[i] = (Byte) a[i];
// }
// return b;
// }
// },
// SHORT {
// Object convert(Int32[] a) {
// short[] b = new short[a->GetLength()];
// for (Int32 i = 0; i < a->GetLength(); i++) {
// b[i] = (short) a[i];
// }
// return b;
// }
// },
// CHAR {
// Object convert(Int32[] a) {
// char[] b = new char[a->GetLength()];
// for (Int32 i = 0; i < a->GetLength(); i++) {
// b[i] = (char) a[i];
// }
// return b;
// }
// },
// FLOAT {
// Object convert(Int32[] a) {
// Float[] b = new Float[a->GetLength()];
// for (Int32 i = 0; i < a->GetLength(); i++) {
// b[i] = (Float) a[i];
// }
// return b;
// }
// },
// DOUBLE {
// Object convert(Int32[] a) {
// Double[] b = new Double[a->GetLength()];
// for (Int32 i = 0; i < a->GetLength(); i++) {
// b[i] = (Double) a[i];
// }
// return b;
// }
// };
// abstract Object convert(Int32[] a);
// public String toString() {
// String name = name();
// for (Int32 i = name->GetLength()(); i < 9; i++) {
// name += " " ;
// }
// return name;
// }
// }
// test 36
int CTest::test_deepEquals_Ljava_lang_ObjectLjava_lang_Object(int argc, char* argv[])
{
ECode ec = 0;
Boolean result;
AutoPtr<IArrayOf> a1;
CArrayOf::New(EIID_IInteger32, 3, (IArrayOf**)&a1);
AutoPtr<IInteger32> num0;
CInteger32::New(1, (IInteger32**)&num0);
AutoPtr<IInteger32> num1;
CInteger32::New(2, (IInteger32**)&num1);
AutoPtr<IInteger32> num2;
CInteger32::New(3, (IInteger32**)&num2);
a1->Put(0, num0);
a1->Put(1, num1);
a1->Put(2, num2);
AutoPtr<IArrayOf> a2;
CArrayOf::New(EIID_IInteger16, 2, (IArrayOf**)&a2);
AutoPtr<IInteger16> num3;
CInteger16::New(0, (IInteger16**)&num3);
AutoPtr<IInteger16> num4;
CInteger16::New(1, (IInteger16**)&num4);
a2->Put(0, num3);
a2->Put(1, num4);
AutoPtr<IInteger32> num5;
CInteger32::New(1, (IInteger32**)&num5);
AutoPtr<IArrayOf> a3;
CArrayOf::New(EIID_IInterface, 2, (IArrayOf**)&a3);
a3->Put(0, num5);
a3->Put(1, a2);
AutoPtr<IArrayOf> a4;
CArrayOf::New(EIID_IInteger32, 3, (IArrayOf**)&a4);
AutoPtr<IInteger32> num6;
CInteger32::New(6, (IInteger32**)&num6);
AutoPtr<IInteger32> num7;
CInteger32::New(5, (IInteger32**)&num7);
AutoPtr<IInteger32> num8;
CInteger32::New(4, (IInteger32**)&num8);
a4->Put(0, num6);
a4->Put(1, num7);
a4->Put(2, num8);
AutoPtr<IArrayOf> b1;
CArrayOf::New(EIID_IInteger32, 3, (IArrayOf**)&b1);
AutoPtr<IInteger32> num9;
CInteger32::New(1, (IInteger32**)&num9);
AutoPtr<IInteger32> num10;
CInteger32::New(2, (IInteger32**)&num10);
AutoPtr<IInteger32> num11;
CInteger32::New(3, (IInteger32**)&num11);
b1->Put(0, num9);
b1->Put(1, num10);
b1->Put(2, num11);
AutoPtr<IArrayOf> b2;
CArrayOf::New(EIID_IInteger16, 2, (IArrayOf**)&b2);
AutoPtr<IInteger16> num12;
CInteger16::New(0, (IInteger16**)&num12);
AutoPtr<IInteger16> num13;
CInteger16::New(1, (IInteger16**)&num13);
b2->Put(0, num12);
b2->Put(1, num13);
AutoPtr<IArrayOf> b3;
CArrayOf::New(EIID_IInterface, 2, (IArrayOf**)&b3);
b3->Put(0, num5);
b3->Put(1, b2);
AutoPtr<ArrayOf<IInterface*> > a = ArrayOf<IInterface*>::Alloc(3);
a->Set(0, a1);
a->Set(1, a2);
a->Set(2, a3);
AutoPtr<ArrayOf<IInterface*> > b = ArrayOf<IInterface*>::Alloc(3);
b->Set(0, b1);
b->Set(1, b2);
b->Set(2, b3);
ec = Arrays::Equals(a, b, &result);
assert(result == FALSE);
ec = Arrays::DeepEquals(a, b, &result);
assert(result == TRUE);
a->Set(2, a4);
ec = Arrays::DeepEquals(a, b, &result);
assert(result == FALSE);
return ec;
}
// test 37
int CTest::test_deepHashCode_Ljava_lang_Object(int argc, char* argv[])
{
ECode ec = 0;
AutoPtr<IArrayOf> a1;
CArrayOf::New(EIID_IInteger32, 3, (IArrayOf**)&a1);
AutoPtr<IInteger32> num0;
CInteger32::New(1, (IInteger32**)&num0);
AutoPtr<IInteger32> num1;
CInteger32::New(2, (IInteger32**)&num1);
AutoPtr<IInteger32> num2;
CInteger32::New(3, (IInteger32**)&num2);
a1->Put(0, num0);
a1->Put(1, num1);
a1->Put(2, num2);
AutoPtr<IArrayOf> a2;
CArrayOf::New(EIID_IInteger16, 2, (IArrayOf**)&a2);
AutoPtr<IInteger16> num3;
CInteger16::New(0, (IInteger16**)&num3);
AutoPtr<IInteger16> num4;
CInteger16::New(1, (IInteger16**)&num4);
a2->Put(0, num3);
a2->Put(1, num4);
AutoPtr<IInteger32> num5;
CInteger32::New(1, (IInteger32**)&num5);
AutoPtr<IArrayOf> a3;
CArrayOf::New(EIID_IInterface, 2, (IArrayOf**)&a3);
a3->Put(0, num5);
a3->Put(1, a2);
AutoPtr<IArrayOf> b1;
CArrayOf::New(EIID_IInteger32, 3, (IArrayOf**)&b1);
AutoPtr<IInteger32> num9;
CInteger32::New(1, (IInteger32**)&num9);
AutoPtr<IInteger32> num10;
CInteger32::New(2, (IInteger32**)&num10);
AutoPtr<IInteger32> num11;
CInteger32::New(3, (IInteger32**)&num11);
b1->Put(0, num9);
b1->Put(1, num10);
b1->Put(2, num11);
AutoPtr<IArrayOf> b2;
CArrayOf::New(EIID_IInteger16, 2, (IArrayOf**)&b2);
AutoPtr<IInteger16> num12;
CInteger16::New(0, (IInteger16**)&num12);
AutoPtr<IInteger16> num13;
CInteger16::New(1, (IInteger16**)&num13);
b2->Put(0, num12);
b2->Put(1, num13);
AutoPtr<IArrayOf> b3;
CArrayOf::New(EIID_IInterface, 2, (IArrayOf**)&b3);
b3->Put(0, num5);
b3->Put(1, b2);
AutoPtr<ArrayOf<IInterface*> > a = ArrayOf<IInterface*>::Alloc(3);
a->Set(0, a1);
a->Set(1, a2);
a->Set(2, a3);
AutoPtr<ArrayOf<IInterface*> > b = ArrayOf<IInterface*>::Alloc(3);
b->Set(0, b1);
b->Set(1, b2);
b->Set(2, b3);
Int32 deep_hash_a;
Arrays::DeepHashCode(a, &deep_hash_a);
Int32 deep_hash_b;
Arrays::DeepHashCode(b, &deep_hash_b);
assert(deep_hash_a == deep_hash_b);
return ec;
}
// test 38
int CTest::test_hashCode_LZ(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<Boolean> > boolArr = ArrayOf<Boolean>::Alloc(5);
boolArr->Set(0, TRUE);
boolArr->Set(1, FALSE);
boolArr->Set(2, FALSE);
boolArr->Set(3, TRUE);
boolArr->Set(4, FALSE);
AutoPtr<IList> listOfBoolean;
CLinkedList::New((ILinkedList**)&listOfBoolean);
for (Int32 i = 0; i < boolArr->GetLength(); i++) {
AutoPtr<IBoolean> num;
CBoolean::New((*boolArr)[i], (IBoolean**)&num);
Boolean result = FALSE;
ec = listOfBoolean->Add(num, &result);
assert(result);
}
ec = listOfBoolean->GetHashCode(&listHashCode);
ec = Arrays::GetHashCode(boolArr, &arrayHashCode);
assert(listHashCode == arrayHashCode);
return ec;
}
// test 39
int CTest::test_hashCode_LI(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<Int32> > intArr = ArrayOf<Int32>::Alloc(5);
intArr->Set(0, 10);
intArr->Set(1, 5);
intArr->Set(2, 134);
intArr->Set(3, 7);
intArr->Set(4, 19);
AutoPtr<IList> listOfInteger;
CLinkedList::New((ILinkedList**)&listOfInteger);
for (Int32 i = 0; i < intArr->GetLength(); i++) {
AutoPtr<IInteger32> num;
CInteger32::New((*intArr)[i], (IInteger32**)&num);
Boolean result = FALSE;
ec = listOfInteger->Add(num, &result);
assert(result);
}
ec = listOfInteger->GetHashCode(&listHashCode);
ec = Arrays::GetHashCode(intArr, &arrayHashCode);
assert(listHashCode == arrayHashCode);
AutoPtr<ArrayOf<Int32> > intArr2 = ArrayOf<Int32>::Alloc(5);
intArr2->Set(0, 10);
intArr2->Set(1, 5);
intArr2->Set(2, 134);
intArr2->Set(3, 7);
intArr2->Set(4, 19);
Int32 codeArr2, codeArr;
ec = Arrays::GetHashCode(intArr2, &codeArr2);
ec = Arrays::GetHashCode(intArr, &codeArr);
assert(codeArr2 == codeArr);
return ec;
}
// test 40
int CTest::test_hashCode_LC(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<Char32> > charArr = ArrayOf<Char32>::Alloc(5);
charArr->Set(0, 'a');
charArr->Set(1, 'g');
charArr->Set(2, 'x');
charArr->Set(3, 'c');
charArr->Set(4, 'm');
AutoPtr<IList> listOfCharacter;
CLinkedList::New((ILinkedList**)&listOfCharacter);
for (Int32 i = 0; i < charArr->GetLength(); i++) {
AutoPtr<IChar32> num;
CChar32::New((*charArr)[i], (IChar32**)&num);
Boolean result = FALSE;
ec = listOfCharacter->Add(num, &result);
assert(result);
}
ec = listOfCharacter->GetHashCode(&listHashCode);
ec = Arrays::GetHashCode(charArr, &arrayHashCode);
assert(listHashCode == arrayHashCode);
return ec;
}
// test 41
int CTest::test_hashCode_LB(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<Byte> > byteArr = ArrayOf<Byte>::Alloc(5);
byteArr->Set(0, 5);
byteArr->Set(1, 9);
byteArr->Set(2, 7);
byteArr->Set(3, 6);
byteArr->Set(4, 17);
AutoPtr<IList> listOfByte;
CLinkedList::New((ILinkedList**)&listOfByte);
for (Int32 i = 0; i < byteArr->GetLength(); i++) {
AutoPtr<IByte> num;
CByte::New((*byteArr)[i], (IByte**)&num);
Boolean result = FALSE;
ec = listOfByte->Add(num, &result);
assert(result);
}
ec = listOfByte->GetHashCode(&listHashCode);
ec = Arrays::GetHashCode(byteArr, &arrayHashCode);
assert(listHashCode == arrayHashCode);
return ec;
}
// test 42
int CTest::test_hashCode_LJ(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<Int64> > longArr = ArrayOf<Int64>::Alloc(5);
longArr->Set(0, 67890234512l);
longArr->Set(1, 97587236923425l);
longArr->Set(2, 257421912912l);
longArr->Set(3, 6754268100l);
longArr->Set(4, 5);
AutoPtr<IList> listOfLong;
CLinkedList::New((ILinkedList**)&listOfLong);
for (Int32 i = 0; i < longArr->GetLength(); i++) {
AutoPtr<IInteger64> num;
CInteger64::New((*longArr)[i], (IInteger64**)&num);
Boolean result = FALSE;
ec = listOfLong->Add(num, &result);
assert(result);
}
ec = listOfLong->GetHashCode(&listHashCode);
ec = Arrays::GetHashCode(longArr, &arrayHashCode);
assert(listHashCode == arrayHashCode);
return ec;
}
// test 43
int CTest::test_hashCode_LF(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<Float> > floatArr = ArrayOf<Float>::Alloc(5);
floatArr->Set(0, 0.13497f);
floatArr->Set(1, 0.268934f);
floatArr->Set(2, 12e-5f);
floatArr->Set(3, -3e+2f);
floatArr->Set(4, 10e-4f);
AutoPtr<IList> listOfFloat;
CLinkedList::New((ILinkedList**)&listOfFloat);
for (Int32 i = 0; i < floatArr->GetLength(); i++) {
AutoPtr<IFloat> num;
CFloat::New((*floatArr)[i], (IFloat**)&num);
Boolean result = FALSE;
ec = listOfFloat->Add(num, &result);
assert(result);
}
ec = listOfFloat->GetHashCode(&listHashCode);
ec = Arrays::GetHashCode(floatArr, &arrayHashCode);
assert(listHashCode == arrayHashCode);
AutoPtr<ArrayOf<Float> > floatArr2 = ArrayOf<Float>::Alloc(5);
floatArr->Set(0, 0.13497f);
floatArr->Set(1, 0.268934f);
floatArr->Set(2, 12e-5f);
floatArr->Set(3, -3e+2f);
floatArr->Set(4, 10e-4f);
Int32 codeArr2, codeArr;
ec = Arrays::GetHashCode(floatArr2, &codeArr2);
ec = Arrays::GetHashCode(floatArr, &codeArr);
assert(codeArr2 == codeArr);
return ec;
}
// test 44
int CTest::test_hashCode_LD(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<Double> > doubleArr = ArrayOf<Double>::Alloc(5);
doubleArr->Set(0, 0.134945657);
doubleArr->Set(1, 0.0038754);
doubleArr->Set(2, 11e-150);
doubleArr->Set(3, -30e-300);
doubleArr->Set(4, 10e-4);
AutoPtr<IList> listOfDouble;
CLinkedList::New((ILinkedList**)&listOfDouble);
for (Int32 i = 0; i < doubleArr->GetLength(); i++) {
AutoPtr<IDouble> num;
CDouble::New((*doubleArr)[i], (IDouble**)&num);
Boolean result = FALSE;
ec = listOfDouble->Add(num, &result);
assert(result);
}
ec = listOfDouble->GetHashCode(&listHashCode);
ec = Arrays::GetHashCode(doubleArr, &arrayHashCode);
assert(listHashCode == arrayHashCode);
return ec;
}
// test 45
int CTest::test_hashCode_LS(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<Int16> > shortArr = ArrayOf<Int16>::Alloc(5);
shortArr->Set(0, 35);
shortArr->Set(1, 13);
shortArr->Set(2, 45);
shortArr->Set(3, 2);
shortArr->Set(4, 91);
AutoPtr<IList> listOfShort;
CLinkedList::New((ILinkedList**)&listOfShort);
for (Int32 i = 0; i < shortArr->GetLength(); i++) {
AutoPtr<IInteger16> num;
CInteger16::New((*shortArr)[i], (IInteger16**)&num);
Boolean result = FALSE;
ec = listOfShort->Add(num, &result);
assert(result);
}
ec = listOfShort->GetHashCode(&listHashCode);
ec = Arrays::GetHashCode(shortArr, &arrayHashCode);
assert(listHashCode == arrayHashCode);
return ec;
}
// test 46
int CTest::test_hashCode_Ljava_lang_Object(int argc, char* argv[])
{
ECode ec = 0;
Int32 listHashCode;
Int32 arrayHashCode;
AutoPtr<ArrayOf<IInterface*> > objectArr = ArrayOf<IInterface*>::Alloc(3);
AutoPtr<IInteger32> mem1;
CInteger32::New(1, (IInteger32**)&mem1);
AutoPtr<IFloat> mem2;
CFloat::New(10e-12f, (IFloat**)&mem2);
objectArr->Set(0, mem1);
objectArr->Set(1, mem2);
objectArr->Set(2, NULL);
AutoPtr<IList> listOfObject;
CLinkedList::New((ILinkedList**)&listOfObject);
Boolean result;
ec = listOfObject->Add(mem1, &result);
assert(result);
ec = listOfObject->Add(mem2, &result);
assert(result);
ec = listOfObject->Add(NULL, &result);
assert(result);
ec = listOfObject->GetHashCode(&listHashCode);
arrayHashCode = Arrays::Get>HashCode(objectArr);
assert(listHashCode == arrayHashCode);
return ec;
}
void CTest::setUp()
{
objArray = ArrayOf<IInterface*>::Alloc(arraySize);
for (Int32 i = 0; i < objArray->GetLength(); i++) {
AutoPtr<IInteger32> num;
CInteger32::New(i, (IInteger32**)&num);
objArray->Set(i, num);
}
booleanArray = ArrayOf<Boolean>::Alloc(arraySize);
byteArray = ArrayOf<Byte>::Alloc(arraySize);
charArray = ArrayOf<Char32>::Alloc(arraySize);
doubleArray = ArrayOf<Double>::Alloc(arraySize);
floatArray = ArrayOf<Float>::Alloc(arraySize);
intArray = ArrayOf<Int32>::Alloc(arraySize);
longArray = ArrayOf<Int64>::Alloc(arraySize);
objectArray = ArrayOf<IInterface*>::Alloc(arraySize);
shortArray = ArrayOf<Int16>::Alloc(arraySize);
for (Int32 counter = 0; counter < arraySize; counter++) {
byteArray->Set(counter, (Byte) counter);
charArray->Set(counter, (Char32) (counter + 1));
doubleArray->Set(counter, counter);
floatArray->Set(counter, counter);
intArray->Set(counter, counter);
longArray->Set(counter, counter);
objectArray->Set(counter, (*objArray)[counter]);
shortArray->Set(counter, (Int16) counter);
}
for (Int32 counter = 0; counter < arraySize; counter += 2) {
booleanArray->Set(counter, FALSE);
booleanArray->Set(counter + 1, TRUE);
}
}
void CTest::tearDown()
{
objArray = NULL;
booleanArray = NULL;
byteArray = NULL;
charArray = NULL;
doubleArray = NULL;
floatArray = NULL;
intArray = NULL;
longArray = NULL;
objectArray = NULL;
shortArray = NULL;
}
| 33.937428 | 108 | 0.606813 | [
"object"
] |
4000da1b0c664cbd3c89fb92a58b1de8eff453ea | 754 | hpp | C++ | codegen_acc.hpp | realincubus/pluto_codegen_cxx | 349ec88a52f92f151abe84d5a12d67198f794f4b | [
"MIT"
] | null | null | null | codegen_acc.hpp | realincubus/pluto_codegen_cxx | 349ec88a52f92f151abe84d5a12d67198f794f4b | [
"MIT"
] | null | null | null | codegen_acc.hpp | realincubus/pluto_codegen_cxx | 349ec88a52f92f151abe84d5a12d67198f794f4b | [
"MIT"
] | null | null | null | #pragma once
#include "codegen.hpp"
class CodeGenAcc : public CodeGen {
public:
CodeGenAcc (
std::stringstream& _output,
CloogOptions* _options,
std::vector<std::string>& _statement_texts,
std::map<std::string,std::string>& _call_texts,
std::set<std::string>& _header_includes,
bool _print_guards
) :
CodeGen(
_output,
_options,
_statement_texts,
_call_texts,
_header_includes,
_print_guards
)
{
}
virtual ~CodeGenAcc () {}
protected:
virtual void pprint_for(struct cloogoptions *options, int indent, struct clast_for *f);
virtual void pprint_for_loop_preamble( struct clast_for* f, int indent );
};
| 21.542857 | 91 | 0.616711 | [
"vector"
] |
40020dd4701ef59b54af1eb98d336494fb641b47 | 5,121 | cpp | C++ | src/blas_wrapper/dgekv.cpp | Samthos/MC-MPn-Direct | cdf05c7ce7b33bf1b86b80f57f800634822c9cc6 | [
"MIT"
] | 1 | 2021-04-06T05:01:47.000Z | 2021-04-06T05:01:47.000Z | src/blas_wrapper/dgekv.cpp | spec-org/MC-MPn-Direct | cdf05c7ce7b33bf1b86b80f57f800634822c9cc6 | [
"MIT"
] | null | null | null | src/blas_wrapper/dgekv.cpp | spec-org/MC-MPn-Direct | cdf05c7ce7b33bf1b86b80f57f800634822c9cc6 | [
"MIT"
] | 3 | 2020-06-09T23:53:28.000Z | 2022-03-02T05:44:55.000Z | #include "blas_wrapper.h"
template <template <typename, typename> typename Container, template <typename> typename Allocator>
void Blas_Wrapper<Container, Allocator>::dgekv(
size_t m,
double alpha,
const vector_type& A, size_t inc_a,
const vector_type& B, size_t inc_b,
double beta,
vector_type& C, size_t inc_c) {
this->dgekv(
m,
alpha,
A, 0, inc_a,
B, 0, inc_b,
beta,
C, 0, inc_c);
}
template <>
void Blas_Wrapper<std::vector, std::allocator>::dgekv(
size_t m,
double alpha,
const vector_type& A, size_t offset_a, size_t inc_a,
const vector_type& B, size_t offset_b, size_t inc_b,
double beta,
vector_type& C, size_t offset_c, size_t inc_c) {
const double* a_ptr = A.data() + offset_a;
const double* b_ptr = B.data() + offset_b;
double* c_ptr = C.data() + offset_c;
if (0.0 == beta) {
if (alpha == 1.0) {
for (size_t idx = 0; idx < m; idx++) {
c_ptr[idx * inc_c] = a_ptr[idx * inc_a] * b_ptr[idx * inc_b];
}
} else {
for (size_t idx = 0; idx < m; idx++) {
c_ptr[idx * inc_c] = alpha * a_ptr[idx * inc_a] * b_ptr[idx * inc_b];
}
}
} else if (1.0 == beta) {
if (alpha == 1.0) {
for (size_t idx = 0; idx < m; idx++) {
c_ptr[idx * inc_c] = a_ptr[idx * inc_a] * b_ptr[idx * inc_b] + c_ptr[idx * inc_c];
}
} else {
for (size_t idx = 0; idx < m; idx++) {
c_ptr[idx * inc_c] = alpha * a_ptr[idx * inc_a] * b_ptr[idx * inc_b] + c_ptr[idx * inc_c];
}
}
} else {
if (alpha == 1.0) {
for (size_t idx = 0; idx < m; idx++) {
c_ptr[idx * inc_c] = a_ptr[idx * inc_a] * b_ptr[idx * inc_b] + beta * c_ptr[idx * inc_c];
}
} else {
for (size_t idx = 0; idx < m; idx++) {
c_ptr[idx * inc_c] = alpha * a_ptr[idx * inc_a] * b_ptr[idx * inc_b] + beta * c_ptr[idx * inc_c];
}
}
}
}
#ifdef HAVE_CUDA
__global__ void dgekv_kernel(size_t m,
double alpha,
const double* A, size_t inc_a,
const double* B, size_t inc_b,
double beta,
double* C, size_t inc_c) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < m) {
C[idx * inc_c] = alpha * A[idx * inc_a] * B[idx * inc_b] + beta * C[idx * inc_c];
}
}
__global__ void dgekv_kernel_0b(size_t m,
double alpha,
const double* A, size_t inc_a,
const double* B, size_t inc_b,
double* C, size_t inc_c) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < m) {
C[idx * inc_c] = alpha * A[idx * inc_a] * B[idx * inc_b];
}
}
__global__ void dgekv_kernel_1b(size_t m,
double alpha,
const double* A, size_t inc_a,
const double* B, size_t inc_b,
double* C, size_t inc_c) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < m) {
C[idx * inc_c] = alpha * A[idx * inc_a] * B[idx * inc_b] + C[idx * inc_c];
}
}
__global__ void dgekv_kernel_1a(size_t m,
const double* A, size_t inc_a,
const double* B, size_t inc_b,
double beta,
double* C, size_t inc_c) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < m) {
C[idx * inc_c] = A[idx * inc_a] * B[idx * inc_b] + beta * C[idx * inc_c];
}
}
__global__ void dgekv_kernel_1a_0b(size_t m,
const double* A, size_t inc_a,
const double* B, size_t inc_b,
double* C, size_t inc_c) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < m) {
C[idx * inc_c] = A[idx * inc_a] * B[idx * inc_b];
}
}
__global__ void dgekv_kernel_1a_1b(size_t m,
const double* A, size_t inc_a,
const double* B, size_t inc_b,
double* C, size_t inc_c) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < m) {
C[idx * inc_c] = A[idx * inc_a] * B[idx * inc_b] + C[idx * inc_c];
}
}
template <>
void Blas_Wrapper<thrust::device_vector, thrust::device_allocator>::dgekv(size_t m,
double alpha,
const vector_type& A, size_t offset_a, size_t inc_a,
const vector_type& B, size_t offset_b, size_t inc_b,
double beta,
vector_type& C, size_t offset_c, size_t inc_c) {
const double* a_ptr = A.data().get() + offset_a;
const double* b_ptr = B.data().get() + offset_b;
double* c_ptr = C.data().get() + offset_c;
dim3 blockSize(128, 1, 1);
dim3 gridSize((m + blockSize.x - 1) / blockSize.x, 1, 1);
if (0.0 == beta) {
if (alpha == 1.0) {
dgekv_kernel_1a_0b<<<gridSize, blockSize>>>(m, a_ptr, inc_a, b_ptr, inc_b, c_ptr, inc_c);
} else {
dgekv_kernel_0b<<<gridSize, blockSize>>>(m, alpha, a_ptr, inc_a, b_ptr, inc_b, c_ptr, inc_c);
}
} else if (beta == 1.0) {
if (alpha == 1.0) {
dgekv_kernel_1a_1b<<<gridSize, blockSize>>>(m, a_ptr, inc_a, b_ptr, inc_b, c_ptr, inc_c);
} else {
dgekv_kernel_1b<<<gridSize, blockSize>>>(m, alpha, a_ptr, inc_a, b_ptr, inc_b, c_ptr, inc_c);
}
} else {
if (alpha == 1.0) {
dgekv_kernel_1a<<<gridSize, blockSize>>>(m, a_ptr, inc_a, b_ptr, inc_b, beta, c_ptr, inc_c);
} else {
dgekv_kernel<<<gridSize, blockSize>>>(m, alpha, a_ptr, inc_a, b_ptr, inc_b, beta, c_ptr, inc_c);
}
}
cudaDeviceSynchronize();
}
#endif
| 31.22561 | 105 | 0.595392 | [
"vector"
] |
400307fad034b49f299336eb09bb21316ee27089 | 3,932 | hpp | C++ | src/ecore/ecore/src_gen/ecore/impl/EClassifierImpl.hpp | MDE4CPP/MDE4CPP | 9db9352dd3b1ae26a5f640e614ed3925499b93f1 | [
"MIT"
] | 12 | 2017-02-17T10:33:51.000Z | 2022-03-01T02:48:10.000Z | src/ecore/ecore/src_gen/ecore/impl/EClassifierImpl.hpp | ndongmo/MDE4CPP | 9db9352dd3b1ae26a5f640e614ed3925499b93f1 | [
"MIT"
] | 28 | 2017-10-17T20:23:52.000Z | 2021-03-04T16:07:13.000Z | src/ecore/ecore/src_gen/ecore/impl/EClassifierImpl.hpp | ndongmo/MDE4CPP | 9db9352dd3b1ae26a5f640e614ed3925499b93f1 | [
"MIT"
] | 22 | 2017-03-24T19:03:58.000Z | 2022-03-31T12:10:07.000Z | //********************************************************************
//*
//* Warning: This file was generated by ecore4CPP Generator
//*
//********************************************************************
#ifndef ECORE_ECLASSIFIERECLASSIFIERIMPL_HPP
#define ECORE_ECLASSIFIERECLASSIFIERIMPL_HPP
//*********************************
// generated Includes
//Model includes
#include "../EClassifier.hpp"
#include "ecore/impl/ENamedElementImpl.hpp"
//*********************************
namespace ecore
{
class EClassifierImpl : virtual public ENamedElementImpl, virtual public EClassifier
{
public:
EClassifierImpl(const EClassifierImpl & obj);
virtual std::shared_ptr<ecore::EObject> copy() const;
private:
EClassifierImpl& operator=(EClassifierImpl const&) = delete;
protected:
friend class ecoreFactoryImpl;
EClassifierImpl();
virtual std::shared_ptr<EClassifier> getThisEClassifierPtr() const;
virtual void setThisEClassifierPtr(std::weak_ptr<EClassifier> thisEClassifierPtr);
//Additional constructors for the containments back reference
EClassifierImpl(std::weak_ptr<ecore::EObject > par_eContainer);
//Additional constructors for the containments back reference
EClassifierImpl(std::weak_ptr<ecore::EPackage > par_ePackage);
public:
//destructor
virtual ~EClassifierImpl();
//*********************************
// Operations
//*********************************
virtual int getClassifierID() ;
virtual bool isInstance(Any object) const ;
//*********************************
// Attributes Getter Setter
//*********************************
virtual Any getDefaultValue() const ;
virtual void setDefaultValue (Any _defaultValue);
virtual void * getInstanceClass() const ;
virtual std::string getInstanceClassName() const ;
virtual void setInstanceClassName (std::string _instanceClassName);
virtual std::string getInstanceTypeName() const ;
virtual void setInstanceTypeName (std::string _instanceTypeName);
//*********************************
// Reference
//*********************************
virtual std::weak_ptr<ecore::EPackage > getEPackage() const ;
virtual std::shared_ptr<Bag<ecore::ETypeParameter>> getETypeParameters() const ;
//*********************************
// Union Getter
//*********************************
virtual std::shared_ptr<Union<ecore::EObject>> getEContens() const ;
//*********************************
// Structural Feature Getter/Setter
//*********************************
virtual std::shared_ptr<ecore::EObject> eContainer() const ;
//*********************************
// Persistence Functions
//*********************************
virtual void load(std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler) ;
virtual void loadAttributes(std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler, std::map<std::string, std::string> attr_list);
virtual void loadNode(std::string nodeName, std::shared_ptr<persistence::interfaces::XLoadHandler> loadHandler);
virtual void resolveReferences(const int featureID, std::list<std::shared_ptr<EObject> > references) ;
virtual void save(std::shared_ptr<persistence::interfaces::XSaveHandler> saveHandler) const ;
virtual void saveContent(std::shared_ptr<persistence::interfaces::XSaveHandler> saveHandler) const;
protected:
virtual std::shared_ptr<EClass> eStaticClass() const;
virtual Any eGet(int featureID, bool resolve, bool coreType) const ;
virtual bool internalEIsSet(int featureID) const ;
virtual bool eSet(int featureID, Any newValue) ;
private:
std::weak_ptr<EClassifier> m_thisEClassifierPtr;
};
}
#endif /* end of include guard: ECORE_ECLASSIFIERECLASSIFIERIMPL_HPP */
| 29.56391 | 145 | 0.600712 | [
"object",
"model"
] |
40043e6117b17e36eff5eb8a947b38771c1f77e2 | 1,741 | cc | C++ | mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/repeat_node.cc | dongkcs/mindspore | cd7df6dbf463ff3128e9181e9d0c779cecb81320 | [
"Apache-2.0"
] | 2 | 2020-11-23T13:46:37.000Z | 2020-12-20T02:02:38.000Z | mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/repeat_node.cc | dongkcs/mindspore | cd7df6dbf463ff3128e9181e9d0c779cecb81320 | [
"Apache-2.0"
] | null | null | null | mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/repeat_node.cc | dongkcs/mindspore | cd7df6dbf463ff3128e9181e9d0c779cecb81320 | [
"Apache-2.0"
] | 1 | 2021-01-01T08:35:01.000Z | 2021-01-01T08:35:01.000Z | /**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* 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 "minddata/dataset/engine/ir/datasetops/repeat_node.h"
#include <memory>
#include <string>
#include <vector>
#include "minddata/dataset/engine/datasetops/repeat_op.h"
#include "minddata/dataset/util/status.h"
namespace mindspore {
namespace dataset {
namespace api {
RepeatNode::RepeatNode(std::shared_ptr<Dataset> child, int32_t count) : repeat_count_(count) {
this->children.push_back(child);
}
std::vector<std::shared_ptr<DatasetOp>> RepeatNode::Build() {
// A vector containing shared pointer to the Dataset Ops that this object will create
std::vector<std::shared_ptr<DatasetOp>> node_ops;
node_ops.push_back(std::make_shared<RepeatOp>(repeat_count_));
return node_ops;
}
Status RepeatNode::ValidateParams() {
if (repeat_count_ <= 0 && repeat_count_ != -1) {
std::string err_msg = "RepeatNode: repeat_count should be either -1 or positive integer, repeat_count_: " +
std::to_string(repeat_count_);
MS_LOG(ERROR) << err_msg;
RETURN_STATUS_SYNTAX_ERROR(err_msg);
}
return Status::OK();
}
} // namespace api
} // namespace dataset
} // namespace mindspore
| 31.654545 | 111 | 0.729466 | [
"object",
"vector"
] |
401aeb851378c961fac7599782f54fa7e5f46b79 | 20,631 | cpp | C++ | xconv/xconvDlg.cpp | scattering-central/CCP13 | e78440d34d0ac80d2294b131ca17dddcf7505b01 | [
"BSD-3-Clause"
] | null | null | null | xconv/xconvDlg.cpp | scattering-central/CCP13 | e78440d34d0ac80d2294b131ca17dddcf7505b01 | [
"BSD-3-Clause"
] | null | null | null | xconv/xconvDlg.cpp | scattering-central/CCP13 | e78440d34d0ac80d2294b131ca17dddcf7505b01 | [
"BSD-3-Clause"
] | 3 | 2017-09-05T15:15:22.000Z | 2021-01-15T11:13:45.000Z | // xconvDlg.cpp : implementation file
//
#include "stdafx.h"
#include "xconv.h"
#include "xconvDlg.h"
#include <string.h>
#include<iostream>
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
extern void Mainw( CString ,CString ,CString,CString ,CString ,int ,int, int,int,int,int,int,int\
,float,float, int,int );
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CxconvDlg dialog
CxconvDlg::CxconvDlg(CWnd* pParent /*=NULL*/)
: CDialog(CxconvDlg::IDD, pParent)
, InFileName(_T(""))
, OutFileName(_T(""))
, aspectratio(1.0)
, first(1)
, last(1)
, inc(1)
, Headbyte(0)
//,outFileType("bsl_out")
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CxconvDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_INFILE, InFileName);
DDX_Text(pDX, IDC_OUTFILE, OutFileName);
DDX_Control(pDX, IDC_INFILETYPE, InFileType);
DDX_Control(pDX, IDC_OUTTYPE, OutType);
DDX_Text(pDX, IDC_ASPECT, aspectratio);
DDX_Control(pDX, IDC_COMBO1, Dtype);
DDX_Control(pDX, IDC_FIRST, Cfirst);
DDX_Control(pDX, IDC_CHECK1, swapbyte);
DDX_Control(pDX, IDC_LAST, Clast);
DDX_Control(pDX, IDC_INC, Cinc);
DDX_Control(pDX, IDC_INPIX, Cinpix);
DDX_Control(pDX, IDC_OUTPIX, OutPix);
DDX_Control(pDX, IDC_OUTRAST, OutRast);
DDX_Text(pDX, IDC_FIRST, first);
DDX_Text(pDX, IDC_LAST, last);
DDX_Text(pDX, IDC_INC, inc);
DDX_Control(pDX, IDC_INRAST, Cinrast);
DDX_Control(pDX, IDC_HEADBYTE, Cheadbyte);
DDV_MinMaxInt(pDX, Headbyte, 0, 10000000);
DDX_Control(pDX, IDC_ASPECT, Caspect);
DDX_Control(pDX, IDC_DYNAMIC, Cdynamic);
DDX_Control(pDX, IDC_HEAD1, Chead1);
DDX_Control(pDX, IDC_HEAD2, Chead2);
}
BEGIN_MESSAGE_MAP(CxconvDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_CBN_SELCHANGE(IDC_INFILETYPE, OnCbnSelchangeInfiletype)
ON_EN_CHANGE(IDC_INFILE, OnEnChangeInfile)
ON_BN_CLICKED(IDC_BROWES2, OnBnClickedBrowes2)
ON_BN_CLICKED(IDC_RUN, OnBnClickedRun)
ON_BN_CLICKED(IDC_BROWSEIN, OnBnClickedBrowsein)
ON_EN_CHANGE(IDC_OUTFILE, OnEnChangeOutfile)
ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
ON_CBN_SELCHANGE(IDC_OUTTYPE, OnCbnSelchangeOuttype)
ON_EN_CHANGE(IDC_FIRST, OnEnChangeFirst)
ON_EN_CHANGE(IDC_LAST, OnEnChangeLast)
ON_EN_CHANGE(IDC_INC, OnEnChangeInc)
ON_BN_CLICKED(IDHELP, OnBnClickedHelp)
ON_BN_CLICKED(IDC_About, OnBnClickedAbout)
END_MESSAGE_MAP()
// CxconvDlg message handlers
BOOL CxconvDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
InFileType.SetCurSel(3);
OutType.SetCurSel(0);
Dtype.SetCurSel(0);
Cheadbyte.SetWindowText("0");
outdtype=0;
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CxconvDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CxconvDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CxconvDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CxconvDlg::OnCbnSelchangeInfiletype()
{
UpdateData(true);
FieldsEditable( );
UpdateData(false);
}
void CxconvDlg::OnEnChangeInfile()
{
UpdateData(true);
ChangeInfile();
UpdateData(false);
}
void CxconvDlg::OnBnClickedBrowes2()
{
UpdateData(TRUE);
CFileDialog fileDlg (FALSE, "", "",
OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, "BSL Files (*000.****)|*000.*|TiffFiles (*.tif)|*.tif|TxtFiles (*.txt)|*.txt|All Files (*.*)|*.*||", this);
if( fileDlg.DoModal ()==IDOK )
{
CString pathName = fileDlg.GetPathName();
OutFileName.Format("%s",pathName);
}
UpdateData(FALSE);
}
void CxconvDlg::OnBnClickedBrowsein()
{
UpdateData(TRUE);
CFileDialog fileDlg (TRUE, "", "",
OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, "All Files (*.*)|*.*|TiffFiles (*.tif)|*.tif|BSL Files (*000.***)|*000.*||", this);
if( fileDlg.DoModal ()==IDOK )
{
CString pathName = fileDlg.GetPathName();
InFileName.Format("%s",pathName);
this->outFileType.SetString("tif");
outFieldsEditable();
}
ChangeInfile();
UpdateData(FALSE);
}
void CxconvDlg::ChangeInfile()
{
if (strchr( InFileName, '#')||strchr( InFileName, '%'))
{
Cfirst.SetReadOnly(false);
Clast.SetReadOnly(false);
Cinc.SetReadOnly(false);
}
else
{
Cfirst.SetReadOnly(true);
Clast.SetReadOnly(true);
Cinc.SetReadOnly(true);
first=1;
last=1;
inc=1;
}
char *sptr;
int i,ilen;
sptr=InFileName.GetBuffer();
ilen=(int)strlen(sptr);
for(i=0;i<ilen;i++)
{
if(strstr(sptr,".tif")!=NULL||strstr(sptr,".tiff")!=NULL||strstr(sptr,".TIF")!=NULL)
{
InFileType.SetCurSel(12);
break;
}
if(strstr(sptr,".mar1200")!=NULL||strstr(sptr,".mar1600")!=NULL||strstr(sptr,".mar1800")!=NULL||\
strstr(sptr,".mar2400")!=NULL||strstr(sptr,".mar2000")!=NULL||strstr(sptr,".mar3000")!=NULL||\
strstr(sptr,".mar2300")!=NULL||strstr(sptr,".mar3450")!=NULL)
{
InFileType.SetCurSel(20);
break;
}
if(strstr(sptr,".smv")!=NULL||strstr(sptr,".SMV")!=NULL)
{
InFileType.SetCurSel(17);
break;
}
if(strstr(sptr,".Q")!=NULL||strstr(sptr,".QQ")!=NULL)
{
InFileType.SetCurSel(15);
break;
}
if(strstr(sptr,".LQA")!=NULL)
{
InFileType.SetCurSel(16);
break;
}
if(strstr(sptr,".gfrm")!=NULL)
{
InFileType.SetCurSel(19);
break;
}
if(strstr(sptr,".osc")!=NULL)
{
InFileType.SetCurSel(9);
break;
}
if(Legalbslname(InFileName))//strstr(sptr,"000.")!=NULL)
{
InFileType.SetCurSel(13);
break;
}
sptr++;
}
FieldsEditable( );
}
void CxconvDlg::OnBnClickedRun()
{
if(GetParams())
{
InFileType.GetWindowText(InputFileType);
Mainw( OutFileName, InFileName,Head1,Head2,InputFileType \
,InPixel,InRast, Swap,nOutPix, nOutRast,first,last,inc, aspectratio,
dynamicrange, Headbyte,outdtype);
}
UpdateData(FALSE);
}
bool CxconvDlg::Legalbslname(CString FileName )
{
char *fptr, *sptr;
fptr=FileName.GetBuffer();
sptr=strrchr(fptr,'\\');
if(sptr!=NULL)
{
fptr=++sptr;
}
/*if(strlen(fptr)!=10)
{
return(FALSE);
}*/
if( isalnum((int)fptr[0])
&& isdigit((int)fptr[1])
&& isdigit((int)fptr[2]))
{
if (strstr(fptr,"000.")!=fptr+3)
{
return(FALSE);
}
}
else
{
return(FALSE);
}
if(isalnum((int)fptr[7]) && isalnum((int)fptr[8]) && isalnum((int)fptr[9]))
{
return(TRUE);
}
else
{
return(FALSE);
}
}
int CxconvDlg::GetParams()
{
CString tmp;
char *sptr;
int i,iflag;
// **********************************************************************
// Check that input files have been specified
// **********************************************************************
if(InFileName.GetLength()==0)
{
AfxMessageBox("Input file not specified");
return 0;
}
// **********************************************************************
// Check that input files have been specified and are readable
// **********************************************************************
if(OutFileName.GetLength()==0)
{
AfxMessageBox("Output file not specified");
return 0;
}
OutType.GetWindowText(tmp);
if (strcmp(tmp,"BSL")==0)
{
if(!Legalbslname(OutFileName))
{
AfxMessageBox(" Invalid BSL Output header filename");
return 0;
}
}
// **********************************************************************
// Convert characters in output filename to uppercase
// **********************************************************************
// **********************************************************************
// Check input and output pixels,rasters
// **********************************************************************
InFileType.GetWindowText(tmp);
if((strcmp(tmp,"riso")!=0)&&
(strcmp(tmp,"esrf_id2(klora)")!=0)&&
(strcmp(tmp,"bsl")!=0)&&
(strcmp(tmp,"tiff")!=0)&&
(strcmp(tmp,"esrf_id3")!=0)&&
(strcmp(tmp,"smv")!=0)&&
(strcmp(tmp,"loq1d")!=0)&&
(strcmp(tmp,"loq2d")!=0)&&
(strcmp(tmp,"bruker")!=0)&&
(strcmp(tmp,"ILL_SANS")!=0)&&
(strcmp(tmp,"mar345")!=0))
{
Cinpix.GetWindowText(tmp);
tmp.Trim();
sptr=tmp.GetBuffer();
InPixel=atoi(sptr);
if(tmp.GetLength()==0)
{
AfxMessageBox("Number of input pixels not specified");
return 0;
}
else
{
for( i=0;i<tmp.GetLength();i++)
{
if(sptr[i]=='.')
{
AfxMessageBox("Input pixels: Integer value expected");
return 0;
}
else if(!isdigit(sptr[i])||InPixel<=0)
{
AfxMessageBox("Invalid number of input pixels");
return 0;
}
}
}
Cinrast.GetWindowText(tmp);
tmp.Trim();
sptr=tmp.GetBuffer();
InRast=atoi(sptr);
if(strlen(sptr)==0)
{
AfxMessageBox("Number of input rasters not specified");
return 0;
}
else
{
for(i=0;i<(int)strlen(sptr);i++)
{
if(sptr[i]=='.')
{
AfxMessageBox("Input rasters: Integer value expected");
return 0;
}
else if(!isdigit(sptr[i])||InRast<=0)
{
AfxMessageBox("Invalid number of input rasters");
return 0;
}
}
}
}
else
{
InPixel=0;
InRast=0;
}
OutPix.GetWindowText(tmp);
tmp.Trim();
sptr=tmp.GetBuffer();
nOutPix=atoi(sptr);
if(strlen(sptr)==0)
{
nOutPix=InPixel;
}
else
{
for(i=0;i<(int)strlen(sptr);i++)
{
if(sptr[i]=='.')
{
AfxMessageBox("Output pixels: Integer value expected");
return 0;
}
else if(!isdigit(sptr[i])||nOutPix<=0)
{
AfxMessageBox("Invalid number of output pixels");
return 0;
}
}
}
OutRast.GetWindowText(tmp);
tmp.Trim();
nOutRast=atoi(tmp);
nOutRast=atoi(sptr);
sptr=tmp.GetBuffer();
if(strlen(sptr)==0)
{
nOutRast=InRast;
}
else
{
for(i=0;i<(int)strlen(sptr);i++)
{
if(sptr[i]=='.')
{
AfxMessageBox("Output rasters: Integer value expected");
return 0;
}
else if(!isdigit(sptr[i])||nOutRast<=0)
{
AfxMessageBox("Invalid number of output rasters");
return 0;
}
}
}
InFileType.GetWindowText(tmp);
if((strcmp(tmp,"fuji")==0))
{
Cdynamic.GetWindowText(tmp);
tmp.Trim();
dynamicrange=(float)atof(sptr);
sptr=tmp.GetBuffer();
if(strlen(sptr)==0)
{
AfxMessageBox("Dynamic range not specified");
return 0;
}
else if (dynamicrange<=0.)
{
AfxMessageBox("Invalid dynamic range");
return 0;
}
else
{
iflag=0;
for(i=0;i<(int)strlen(sptr);i++)
{
if(!isdigit(sptr[i]))
{
if(sptr[i]="."&&!iflag)
iflag=1;
else
{
AfxMessageBox("Invalid dynamic range");
return 0;
}
}
}
}
}
else
dynamicrange=0.;
if (swapbyte.GetCheck())
Swap=1;
else
Swap=0;
Chead1.GetWindowText(Head1);
Chead2.GetWindowText(Head2);
outFieldsEditable();
return 1;
}
void CxconvDlg::OnEnChangeOutfile()
{
UpdateData(true);
UpdateData(false);
}
void CxconvDlg::FieldsEditable( )
{ CString tmp;
InFileType.GetWindowText(tmp);
if((strcmp(tmp,"esrf_id2(klora)")==0)||
(strcmp(tmp,"bsl")==0)||
(strcmp(tmp,"tiff")==0)||
(strcmp(tmp,"esrf_id3")==0)||
(strcmp(tmp,"smv")==0)||
(strcmp(tmp,"loq1d")==0)||
(strcmp(tmp,"loq2d")==0)||
(strcmp(tmp,"bruker")==0)||
(strcmp(tmp,"ILL_SANS")==0)||
(strcmp(tmp,"mar345")==0))
{
Cinpix.SetWindowText("");
Cinrast.SetWindowText("");
Cheadbyte.SetWindowText("0");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("");
swapbyte.EnableWindow(false);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(false);
if((strcmp(tmp,"bsl")==0)||
(strcmp(tmp,"loq1d")==0)||
(strcmp(tmp,"loq2d")==0))
{
Cfirst.SetReadOnly(true);
Clast.SetReadOnly(true);
Cinc.SetReadOnly(true);
first=1;
last=1;
inc=1;
}
}
else if(strcmp(tmp,"riso")==0)
{
Cinpix.SetWindowText("");
Cinrast.SetWindowText("");
Cheadbyte.SetWindowText("0");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(false);
}
else if(strcmp(tmp,"smar")==0)
{
Cinpix.SetWindowText("1200");
Cinrast.SetWindowText("1200");
Cheadbyte.SetWindowText("2400");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(false);
}
else if(strcmp(tmp,"bmar")==0)
{
Cinpix.SetWindowText("2000");
Cinrast.SetWindowText("2000");
Cheadbyte.SetWindowText("4000");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(false);
}
else if(strcmp(tmp,"fuji")==0)
{
Cinpix.SetWindowText("2048");
Cinrast.SetWindowText("4096");
Cheadbyte.SetWindowText("8192");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("4.0");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(true);
}
else if(strcmp(tmp,"fuji2500")==0)
{
Cinpix.SetWindowText("2000");
Cinrast.SetWindowText("2500");
Cheadbyte.SetWindowText("0");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("5.0");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(false);
}
else if(strcmp(tmp,"rax2")==0)
{
Cinpix.SetWindowText("400");
Cinrast.SetWindowText("1");
Cheadbyte.SetWindowText("0");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(false);
}
else if(strcmp(tmp,"rax4")==0)
{
Cinpix.SetWindowText("3000");
Cinrast.SetWindowText("3000");
Cheadbyte.SetWindowText("6000");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(false);
}
else if(strcmp(tmp,"psci")==0)
{
Cinpix.SetWindowText("768");
Cinrast.SetWindowText("576");
Cheadbyte.SetWindowText("0");
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(false);
Cinrast.EnableWindow(false);
Cheadbyte.EnableWindow(false);
Caspect.EnableWindow(false);
Cdynamic.EnableWindow(false);
}
else
{
Caspect.SetWindowText("1.0");
Cdynamic.SetWindowText("");
swapbyte.EnableWindow(true);
Cinpix.EnableWindow(true);
Cinrast.EnableWindow(true);
Cheadbyte.EnableWindow(true);
Caspect.EnableWindow(true);
Cdynamic.EnableWindow(false);
}
}
void CxconvDlg::OnCbnSelchangeCombo1()
{
CString tmp;
Dtype.GetWindowText(tmp);
if(strcmp(tmp,"float32")==0)
outdtype=0;
else if(strcmp(tmp,"float64")==0)
outdtype=9;
else if(strcmp(tmp,"int16")==0)
outdtype=3;
else if(strcmp(tmp,"uint16")==0)
outdtype=4;
else if(strcmp(tmp,"int32")==0)
outdtype=5;
else if(strcmp(tmp,"uint32")==0)
outdtype=6;
else if(strcmp(tmp,"int64")==0)
outdtype=7;
else if(strcmp(tmp,"uint64")==0)
outdtype=8;
else if(strcmp(tmp,"char8")==0)
outdtype=1;
else if(strcmp(tmp,"uchar8")==0)
outdtype=2;
}
void CxconvDlg::OnCbnSelchangeOuttype()
{
outFieldsEditable();
}
void CxconvDlg::outFieldsEditable()
{ CString tmp;
OutType.GetWindowText(tmp);
if(strcmp(tmp,"Tiff16bit")==0)
{
outdtype=12;
//outFileType="tiff16";
Chead1.EnableWindow(false);
Chead2.EnableWindow(false);
Dtype.EnableWindow(false);
}
else if(strcmp(tmp,"Tiff8bit")==0)
{
outdtype=11;
//outFileType="tiff8";
Chead1.EnableWindow(false);
Chead2.EnableWindow(false);
Dtype.EnableWindow(false);
}
else if(strcmp(tmp,"txt")==0)
{
outdtype=10;
// outFileType="txt";
Chead1.EnableWindow(false);
Chead2.EnableWindow(false);
Dtype.EnableWindow(false);
}
else if(strcmp(tmp,"BSL")==0)
{ //outdtype=0;
// outFileType="bsl_out";
//Dtype.SetCurSel(0);
Chead1.EnableWindow(true);
Chead2.EnableWindow(true);
Dtype.EnableWindow(true);
}
}
void CxconvDlg::OnEnChangeFirst()
{
UpdateData(true);
UpdateData(false);
}
void CxconvDlg::OnEnChangeLast()
{
UpdateData(true);
UpdateData(false);
}
void CxconvDlg::OnEnChangeInc()
{
UpdateData(true);
UpdateData(false);
}
void CxconvDlg::OnBnClickedHelp()
{
if((32 >= (int)ShellExecute(NULL, "open", "../doc/xconv.html", NULL, NULL, SW_SHOWNORMAL)))
(32 >= (int)ShellExecute(NULL, "open", "http://www.ccp13.ac.uk/software/program/xconv6.html", NULL, NULL, SW_SHOWNORMAL));
}
/*
CFILE
int CxconvDlg::SaveProfile( )
{
const char* pptr;
if((pptr=strrchr(gotFile.data(),(int)'/'))==NULL)
pptr=gotFile.data();
else
pptr++;
ofstream out_profile(gotFile.data(),ios::out);
if(out_profile.bad())
{
AfxMessageBox("Error opening output file");
return 0;
}
else
{
out_profile<<"Xconv v 1.0 profile"<<endl;
<<pptr<<endl;
<<sType.data()<<endl;
if(InPixel>0)
out_profile<<InPixel<<endl;
else
out_profile<<endl;
if(InRast>0)
out_profile<<InRast<<endl;
else
out_profile<<endl;
if(Headbyte>0)
out_profile<<Headbyte<<endl;
else
out_profile<<endl;
if(aspectratio>0)
out_profile<<aspectratio<<endl;
else
out_profile<<endl;
if(dynamicrange)
out_profile<<dynamicrange<<endl;
else
out_profile<<endl;
if(nOutPix>0)
out_profile<<nOutPix<<endl;
else
out_profile<<endl;
if(nOutRast)
out_profile<<nOutRast<<endl;
else
out_profile<<endl;
if(Swap>0)
out_profile<<1<<endl;
else
out_profile<<0<<endl;
return 1;
}
#endif
}
*/
void CxconvDlg::OnBnClickedAbout()
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
| 21.854873 | 150 | 0.632931 | [
"model"
] |
401fc07272bc73dac923b96482506dcfcc4e0bc9 | 379 | cc | C++ | topcoder/CodeProcessor.cc | metaflow/contests | 5e9ffcb72c3e7da54b5e0818b1afa59f5778ffa2 | [
"MIT"
] | 1 | 2019-05-12T23:41:00.000Z | 2019-05-12T23:41:00.000Z | topcoder/CodeProcessor.cc | metaflow/contests | 5e9ffcb72c3e7da54b5e0818b1afa59f5778ffa2 | [
"MIT"
] | null | null | null | topcoder/CodeProcessor.cc | metaflow/contests | 5e9ffcb72c3e7da54b5e0818b1afa59f5778ffa2 | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ii = pair<int,int>;
using ll = long long;
using llu = unsigned long long;
const int INF = numeric_limits<int>::max();
class $CLASSNAME$ {
public:
$RC$ $METHODNAME$($METHODPARMS$) {
}
$TESTCODE$;
};
// BEGIN CUT HERE
int main() {
$CLASSNAME$ ___test;
___test.run_test(-1);
}
// END CUT HERE
| 15.791667 | 43 | 0.654354 | [
"vector"
] |
4025a84446d9cc7f7b2adf4f4a62796e2a918838 | 2,378 | hpp | C++ | include/aikido/distance/JointAvoidanceConfigurationRanker.hpp | personalrobotics/r3 | 1303e3f3ef99a0c2249abc7415d19113f0026565 | [
"BSD-3-Clause"
] | 181 | 2016-04-22T15:11:23.000Z | 2022-03-26T12:51:08.000Z | include/aikido/distance/JointAvoidanceConfigurationRanker.hpp | personalrobotics/r3 | 1303e3f3ef99a0c2249abc7415d19113f0026565 | [
"BSD-3-Clause"
] | 514 | 2016-04-20T04:29:51.000Z | 2022-02-10T19:46:21.000Z | include/aikido/distance/JointAvoidanceConfigurationRanker.hpp | personalrobotics/r3 | 1303e3f3ef99a0c2249abc7415d19113f0026565 | [
"BSD-3-Clause"
] | 31 | 2017-03-17T09:53:02.000Z | 2022-03-23T10:35:05.000Z | #ifndef AIKIDO_DISTANCE_JOINTAVOIDANCECONFIGURATIONRANKER_HPP_
#define AIKIDO_DISTANCE_JOINTAVOIDANCECONFIGURATIONRANKER_HPP_
#include "aikido/distance/ConfigurationRanker.hpp"
namespace aikido {
namespace distance {
/// Ranks configurations by their distance from joint limits. Configurations
/// further away from the limits are ranked higher. Only finite joint limits
/// are considered for distance computation.
class JointAvoidanceConfigurationRanker : public ConfigurationRanker
{
public:
/// Constructor
///
/// \param[in] metaSkeletonStateSpace Statespace of the skeleton.
/// \param[in] metaSkeleton Metaskeleton of the robot.
/// \param[in] weights Weights over joints to compute distance.
/// Defaults to unit vector.
JointAvoidanceConfigurationRanker(
statespace::dart::ConstMetaSkeletonStateSpacePtr metaSkeletonStateSpace,
::dart::dynamics::ConstMetaSkeletonPtr metaSkeleton,
std::vector<double> weights = std::vector<double>());
protected:
/// Set limits appropriately to account for infinite limits.
void setupJointLimits();
/// Returns cost as negative of distance from position limits.
double evaluateConfiguration(
const statespace::dart::MetaSkeletonStateSpace::State* solution)
const override;
/// Vector of indices corresponding to unbounded lower position limits.
std::vector<std::size_t> mUnboundedLowerLimitsIndices;
/// Vector of indices corresponding to unbounded upper position limits.
std::vector<std::size_t> mUnboundedUpperLimitsIndices;
/// (Modified) State corresponding to the lower position limits.
/// The positions at the indices in \c mUnboundedLowerLimitsIndices are
/// modified to match those in the input state to \c evaluateConfiguration()
/// to compute the distance from finite lower joint limits only.
statespace::dart::MetaSkeletonStateSpace::ScopedState mLowerLimitsState;
/// (Modified) State corresponding to the upper position limits.
/// The positions at the indices in \c mUnboundedUpperLimitsIndices are
/// modified to match those in the input state to \c evaluateConfiguration()
/// to compute the distance from finite upper joint limits only.
statespace::dart::MetaSkeletonStateSpace::ScopedState mUpperLimitsState;
};
} // namespace distance
} // namespace aikido
#endif // AIKIDO_DISTANCE_JOINTAVOIDANCECONFIGURATIONRANKER_HPP_
| 41 | 78 | 0.780067 | [
"vector"
] |
40263d997e33570acbef7a800aa459696000f105 | 4,520 | cpp | C++ | 044_Scattering (light)/Renders/Shader.cpp | HansWord/HansMemory | ae74b8d4f5ebc749508ce43250a604e364950203 | [
"MIT"
] | null | null | null | 044_Scattering (light)/Renders/Shader.cpp | HansWord/HansMemory | ae74b8d4f5ebc749508ce43250a604e364950203 | [
"MIT"
] | null | null | null | 044_Scattering (light)/Renders/Shader.cpp | HansWord/HansMemory | ae74b8d4f5ebc749508ce43250a604e364950203 | [
"MIT"
] | null | null | null | #include "stdafx.h"
#include "Shader.h"
void Shader::Render()
{
D3D::GetDC()->IASetInputLayout(inputLayout);
D3D::GetDC()->VSSetShader(vertexShader, NULL, 0);
D3D::GetDC()->PSSetShader(pixelShader, NULL, 0);
}
Shader::Shader(wstring shaderFile, string vsName, string psName)
: shaderFile(shaderFile), vsName(vsName), psName(psName)
{
CreateVertexShader();
CreatePixelShader();
CreateInputLayout();
}
Shader::~Shader()
{
SAFE_RELEASE(reflection);
SAFE_RELEASE(inputLayout);
SAFE_RELEASE(vertexBlob);
SAFE_RELEASE(vertexShader);
SAFE_RELEASE(pixelBlob);
SAFE_RELEASE(pixelShader);
}
void Shader::CreateVertexShader()
{
ID3D10Blob* error;
HRESULT hr = D3DX11CompileFromFile
(
shaderFile.c_str(), NULL, NULL, vsName.c_str(), "vs_5_0"
, D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL
, &vertexBlob, &error, NULL
);
CheckShaderError(hr, error);
hr = D3D::GetDevice()->CreateVertexShader
(
vertexBlob->GetBufferPointer()
, vertexBlob->GetBufferSize()
, NULL
, &vertexShader
);
assert(SUCCEEDED(hr));
}
void Shader::CreatePixelShader()
{
ID3D10Blob* error;
HRESULT hr = D3DX11CompileFromFile
(
shaderFile.c_str(), NULL, NULL, psName.c_str(), "ps_5_0"
, D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL
, &pixelBlob, &error, NULL
);
CheckShaderError(hr, error);
hr = D3D::GetDevice()->CreatePixelShader
(
pixelBlob->GetBufferPointer()
, pixelBlob->GetBufferSize()
, NULL
, &pixelShader
);
assert(SUCCEEDED(hr));
}
void Shader::CheckShaderError(HRESULT hr, ID3DBlob * error)
{
if (FAILED(hr))
{
if (error != NULL)
{
string str = (const char *)error->GetBufferPointer();
MessageBoxA(NULL, str.c_str(), "Shader Error", MB_OK);
}
assert(false);
}
}
void Shader::CreateInputLayout()
{
HRESULT hr;
hr = D3DReflect
(
vertexBlob->GetBufferPointer()
, vertexBlob->GetBufferSize()
, IID_ID3D11ShaderReflection
, (void**)&reflection
);
assert(SUCCEEDED(hr));
D3D11_SHADER_DESC shaderDesc;
reflection->GetDesc(&shaderDesc);
std::vector<D3D11_INPUT_ELEMENT_DESC> inputLayoutDesc;
for (UINT i = 0; i< shaderDesc.InputParameters; i++)
{
D3D11_SIGNATURE_PARAMETER_DESC paramDesc;
reflection->GetInputParameterDesc(i, ¶mDesc);
D3D11_INPUT_ELEMENT_DESC elementDesc;
elementDesc.SemanticName = paramDesc.SemanticName;
elementDesc.SemanticIndex = paramDesc.SemanticIndex;
elementDesc.InputSlot = 0;
elementDesc.AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
elementDesc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
elementDesc.InstanceDataStepRate = 0;
if (paramDesc.Mask == 1)
{
if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_UINT32)
elementDesc.Format = DXGI_FORMAT_R32_UINT;
else if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_SINT32)
elementDesc.Format = DXGI_FORMAT_R32_SINT;
else if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32)
elementDesc.Format = DXGI_FORMAT_R32_FLOAT;
}
else if (paramDesc.Mask <= 3)
{
if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_UINT32)
elementDesc.Format = DXGI_FORMAT_R32G32_UINT;
else if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_SINT32)
elementDesc.Format = DXGI_FORMAT_R32G32_SINT;
else if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32)
elementDesc.Format = DXGI_FORMAT_R32G32_FLOAT;
}
else if (paramDesc.Mask <= 7)
{
if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_UINT32)
elementDesc.Format = DXGI_FORMAT_R32G32B32_UINT;
else if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_SINT32)
elementDesc.Format = DXGI_FORMAT_R32G32B32_SINT;
else if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32)
elementDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
}
else if (paramDesc.Mask <= 15)
{
if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_UINT32)
elementDesc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
else if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_SINT32)
elementDesc.Format = DXGI_FORMAT_R32G32B32A32_SINT;
else if (paramDesc.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32)
elementDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
}
string temp = paramDesc.SemanticName;
if (temp == "POSITION")
elementDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
inputLayoutDesc.push_back(elementDesc);
}
hr = D3D::GetDevice()->CreateInputLayout
(
&inputLayoutDesc[0]
, inputLayoutDesc.size()
, vertexBlob->GetBufferPointer()
, vertexBlob->GetBufferSize()
, &inputLayout
);
assert(SUCCEEDED(hr));
}
| 26.745562 | 70 | 0.74823 | [
"render",
"vector"
] |
402a5982fe433743639579da6fc1a6c1e4280333 | 5,050 | cpp | C++ | qt-solutions/qtwinmigrate/examples/mfc/step1/qtmfc.cpp | privet56/qDesktopSearch | 702aac770a11895e19180bd4ed2279c7a8ab64be | [
"Apache-2.0"
] | 10 | 2016-04-15T15:31:08.000Z | 2019-10-02T01:19:48.000Z | qt-solutions/qtwinmigrate/examples/mfc/step1/qtmfc.cpp | privet56/qDesktopSearch | 702aac770a11895e19180bd4ed2279c7a8ab64be | [
"Apache-2.0"
] | null | null | null | qt-solutions/qtwinmigrate/examples/mfc/step1/qtmfc.cpp | privet56/qDesktopSearch | 702aac770a11895e19180bd4ed2279c7a8ab64be | [
"Apache-2.0"
] | 5 | 2016-04-15T15:31:10.000Z | 2022-02-22T02:00:06.000Z | /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "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 of Digia Plc and its Subsidiary(-ies) 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
** 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."
**
** $QT_END_LICENSE$
**
****************************************************************************/
// QtMfc.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "qtmfc.h"
#include "mainframe.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// WindowsApp
BEGIN_MESSAGE_MAP(WindowsApp, CWinApp)
//{{AFX_MSG_MAP(WindowsApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// WindowsApp construction
WindowsApp::WindowsApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// The one and only WindowsApp object
WindowsApp theApp;
/////////////////////////////////////////////////////////////////////////////
// WindowsApp initialization
BOOL WindowsApp::InitInstance()
{
// Standard initialization
#if _MFC_VER < 0x0700
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
#endif
// Change the registry key under which our settings are stored.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
MainFrame* pFrame = new MainFrame;
m_pMainWnd = pFrame;
// create and load the frame with its resources
pFrame->LoadFrame(IDR_MAINFRAME,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
NULL);
pFrame->ShowWindow(SW_SHOW);
pFrame->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// WindowsApp message handlers
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void WindowsApp::OnAppAbout()
{
HMODULE mod = LoadLibrary( "qtdialog.dll" );
if ( mod ) {
typedef BOOL(*pShowDialog)(HWND parent);
pShowDialog showDialog = (pShowDialog)GetProcAddress( mod, "showDialog" );
if ( showDialog )
showDialog( theApp.m_pMainWnd->m_hWnd );
FreeLibrary( mod );
} else {
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
}
/////////////////////////////////////////////////////////////////////////////
// WindowsApp message handlers
| 27.150538 | 77 | 0.634851 | [
"object"
] |
402d095cdfdd90819112336c43c395e4ee1aa05d | 377,870 | cpp | C++ | Unity-Project/App-HL2/Il2CppOutputProject/Source/il2cppOutput/Il2CppCCWs75.cpp | JBrentJ/mslearn-mixed-reality-and-azure-digital-twins-in-unity | 6e13b31a0b053443b9c93267d8f174f1554e79dd | [
"CC-BY-4.0",
"MIT"
] | 1 | 2021-06-01T19:33:53.000Z | 2021-06-01T19:33:53.000Z | Unity-Project/App-HL2/Il2CppOutputProject/Source/il2cppOutput/Il2CppCCWs75.cpp | JBrentJ/mslearn-mixed-reality-and-azure-digital-twins-in-unity | 6e13b31a0b053443b9c93267d8f174f1554e79dd | [
"CC-BY-4.0",
"MIT"
] | null | null | null | Unity-Project/App-HL2/Il2CppOutputProject/Source/il2cppOutput/Il2CppCCWs75.cpp | JBrentJ/mslearn-mixed-reality-and-azure-digital-twins-in-unity | 6e13b31a0b053443b9c93267d8f174f1554e79dd | [
"CC-BY-4.0",
"MIT"
] | null | null | null | #include "pch-cpp.hpp"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include <limits>
#include "vm/CachedCCWBase.h"
#include "utils/New.h"
// System.Collections.Generic.Dictionary`2<Microsoft.MixedReality.Toolkit.Input.IMixedRealityController,UnityEngine.Vector3>
struct Dictionary_2_t82EFBA5BED7334BA275A9DC2B6853A1FF1E144DF;
// System.Collections.Generic.Dictionary`2<Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSource,System.Collections.Generic.HashSet`1<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer>>
struct Dictionary_2_t73AEE8CD779C2018D0F0973839D5393A28F5D864;
// System.Collections.Generic.Dictionary`2<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,System.UInt32>
struct Dictionary_2_tB877F46A6C20A56DEA8ED6DC3E004A3171647E3B;
// System.Collections.Generic.Dictionary`2<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,Microsoft.MixedReality.Toolkit.Input.DefaultPrimaryPointerSelector/PointerInfo>
struct Dictionary_2_t04AC434CE21791B15ED9D0D082374590F171F906;
// System.Collections.Generic.Dictionary`2<Microsoft.MixedReality.Toolkit.IMixedRealityServiceRegistrar,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.IMixedRealityService>>
struct Dictionary_2_t7187A6A24F531A0D383C66CB8EECF4ADF08C1936;
// System.Collections.Generic.Dictionary`2<Microsoft.Maps.Unity.IPinnable,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<Microsoft.Maps.Unity.IPinnable,#=zFJNgcUMHoa_Yk4GHbEi4cN5X6lRg>>
struct Dictionary_2_t0DFDC32555434202BEC88887C3A9F082D232835D;
// System.Collections.Generic.Dictionary`2<Microsoft.Maps.Unity.IPinnable,#=z6UMRWVfM7f7EZMpR0PVFMnePcr3V>
struct Dictionary_2_t406093774BE556AAEDDA18B680D0EE5B65A2FDAB;
// System.Collections.Generic.Dictionary`2<Microsoft.MixedReality.Toolkit.UI.BoundsControl.IProximityEffectObjectProvider,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.UI.BoundsControl.ProximityEffect/ObjectProximityInfo>>
struct Dictionary_2_t5D40BF3C845FC123FB1A832B9D26992DEAC7EEA4;
// System.Collections.Generic.Dictionary`2<UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation,UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider/InternalOp>
struct Dictionary_2_t07098E642DC6AF03BF35F4782BB31A441FA8E0D8;
// System.Collections.Generic.Dictionary`2<UnityEngine.XR.InputDevice,Microsoft.MixedReality.Toolkit.XRSDK.Input.GenericXRSDKController>
struct Dictionary_2_t2FB6B87AE845471F5ACC7900099F9B8BFE071E0E;
// System.Collections.Generic.Dictionary`2<System.Int32,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<System.Int32,#=zGRtJz6WENVqAmTaN8b1aEoPKPEQQgilT_gsQzcTCsuSO>>
struct Dictionary_2_t097150F49EDC34E200BF50B861C5BF66AB89D9CA;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Collections.Generic.HashSet`1<System.Int32>>
struct Dictionary_2_t6431821EA0C996A318CFB028504B2F54E0732139;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Collections.Generic.List`1<System.Object>>
struct Dictionary_2_t105FF7824240354B82616D121D7FF93B6882DEDE;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Collections.Generic.List`1<System.WeakReference>>
struct Dictionary_2_tCBFADFB0DA6360308C8BF88F72963B47106EBD52;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Tuple`2<Microsoft.MixedReality.Toolkit.Input.KeyBinding/KeyType,System.Int32>>
struct Dictionary_2_tB89818A1F8664493A3991E55D0E01B673F0119A5;
// System.Collections.Generic.Dictionary`2<System.Int32,#=znKxlCsVUPWmIVVaz3zPzqB_WSnzlbbWEo8WedU4i9t_p>
struct Dictionary_2_tCAC2D96457C0F5A4207EAFFAACAB66D7BC9A406D;
// System.Collections.Generic.Dictionary`2<System.Int32,#=ztxDTO7OPn0rNRWKdXA==>
struct Dictionary_2_tB430A29232B180122225E2DC22C97B1EC8BDB863;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Boolean>
struct Dictionary_2_t446D8FCE66ED404E00855B46A520AB382A69EFF1;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Char>
struct Dictionary_2_tB8FA8FEFBC38630BF40B59A6B474816F30D29B23;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Globalization.CultureInfo>
struct Dictionary_2_t5B8303F2C9869A39ED3E03C0FBB09F817E479402;
// System.Collections.Generic.Dictionary`2<System.Int32,UnityEngine.ResourceManagement.Diagnostics.DiagnosticEvent>
struct Dictionary_2_tA132562C0B2CCFC639D9417B39DC61A33EBA00D8;
// System.Collections.Generic.Dictionary`2<System.Int32,UnityEngine.AddressableAssets.Utility.DiagnosticInfo>
struct Dictionary_2_tBD7E4B2FABEA96AC727F92679C396FDAD5FBB436;
// System.Collections.Generic.Dictionary`2<System.Int32,UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation>
struct Dictionary_2_tDB75C4D4D0B723B1109A640F97124956AA33BC66;
// System.Collections.Generic.Dictionary`2<System.Int32,UnityEngine.ResourceManagement.ResourceProviders.IResourceProvider>
struct Dictionary_2_t1B2F62A5CB01E356B3C3FDEBB20B967EE7C405C9;
// System.Collections.Generic.Dictionary`2<System.Int32,UnityEngine.InputSystem.InputDevice>
struct Dictionary_2_t3D9A2E4B61740D2FF9C269DA70E17270A366C986;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Int32>
struct Dictionary_2_t49CB072CAA9184D326107FA696BB354C43EB5E08;
// System.Collections.Generic.Dictionary`2<System.Int32,System.Int64>
struct Dictionary_2_t9AE0BA863BA88FABCBFC4CA835E0A6E00D948984;
// System.Collections.Generic.Dictionary`2<System.Int32,UnityEngine.Material>
struct Dictionary_2_tE3F17FC57643708975DF2782661AFB9CB1687991;
// System.Collections.Generic.Dictionary`2<System.Int32,UnityEngine.EventSystems.PointerEventData>
struct Dictionary_2_t52ECB6047A9EDAD198D0CC53F331CDEAAA83BED8;
// System.Collections.Generic.Dictionary`2<System.Int32,Microsoft.MixedReality.Toolkit.SpatialAwareness.SpatialAwarenessMeshObject>
struct Dictionary_2_t80F7BDB2A022368F818AE566739AE78D92D2C0DC;
// System.Collections.Generic.Dictionary`2<System.Int32,System.String>
struct Dictionary_2_t0ACB62D0885C7AB376463C70665400A39808C5FB;
// System.Collections.Generic.Dictionary`2<System.Int32,Microsoft.Maps.Unity.Style>
struct Dictionary_2_tB78A990AC3609ABFB6119281443E6FB991DF77FE;
// System.Collections.Generic.Dictionary`2<System.Int32,TMPro.TMP_ColorGradient>
struct Dictionary_2_t83EDCEFCBB12C89A61745514957F522FEF34EAE1;
// System.Collections.Generic.Dictionary`2<System.Int32,TMPro.TMP_FontAsset>
struct Dictionary_2_tAB557C4BCEBDF7E2339209187287588CF6C63579;
// System.Collections.Generic.ICollection`1<Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol>
struct ICollection_1_t51127E83E5DE10315EFE83C47327A303D71C8520;
// System.Collections.Generic.ICollection`1<Microsoft.MixedReality.Toolkit.Input.IMixedRealityController>
struct ICollection_1_tE3BCB416FD8F1666771F806BC77A3DFEECAAF223;
// System.Collections.Generic.ICollection`1<Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSource>
struct ICollection_1_t2775134D4DB96BD541CD00899E067F80FB038EBF;
// System.Collections.Generic.ICollection`1<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer>
struct ICollection_1_t7F2D2F2A3C2F6D8AE85A6B626D7BA54970D4E10D;
// System.Collections.Generic.ICollection`1<Microsoft.MixedReality.Toolkit.IMixedRealityServiceRegistrar>
struct ICollection_1_t8177CB446453F3BC4169BA5445C0D1AC796D41F1;
// System.Collections.Generic.ICollection`1<Microsoft.Maps.Unity.IPinnable>
struct ICollection_1_tD2EC8CF91E7FA521CC633874FF02C23D1BBA986F;
// System.Collections.Generic.ICollection`1<Microsoft.MixedReality.Toolkit.UI.BoundsControl.IProximityEffectObjectProvider>
struct ICollection_1_t1ED20AC726BD7449D5EC938B7DA267026AE85A53;
// System.Collections.Generic.ICollection`1<UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation>
struct ICollection_1_t11A712125B3862757906E01853A29E53CDBB6B40;
// System.Collections.Generic.ICollection`1<UnityEngine.XR.InputDevice>
struct ICollection_1_tC8E4BFBBF03EB0CD60BA05F664A6B391B5BFE943;
// System.Collections.Generic.ICollection`1<System.Int32>
struct ICollection_1_t1C0C51B19916511E9D525272F055515334C93525;
struct IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB;
struct IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C;
IL2CPP_EXTERN_C_BEGIN
IL2CPP_EXTERN_C_END
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// Windows.Foundation.Collections.IIterable`1<System.Int32>
struct NOVTABLE IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050 : Il2CppIInspectable
{
static const Il2CppGuid IID;
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) = 0;
};
// Windows.UI.Xaml.Interop.IBindableIterable
struct NOVTABLE IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8 : Il2CppIInspectable
{
static const Il2CppGuid IID;
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) = 0;
};
// System.Object
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol,System.ReadOnlyMemory`1<System.Byte>>
struct KeyCollection_t025D75274DC35849871E082D579E71065DA83893 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t025D75274DC35849871E082D579E71065DA83893, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t025D75274DC35849871E082D579E71065DA83893, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityController,UnityEngine.Vector3>
struct KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t82EFBA5BED7334BA275A9DC2B6853A1FF1E144DF * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F, ___dictionary_0)); }
inline Dictionary_2_t82EFBA5BED7334BA275A9DC2B6853A1FF1E144DF * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t82EFBA5BED7334BA275A9DC2B6853A1FF1E144DF ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t82EFBA5BED7334BA275A9DC2B6853A1FF1E144DF * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityController,UnityEngine.Vector3>
struct KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSource,System.Collections.Generic.HashSet`1<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer>>
struct KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t73AEE8CD779C2018D0F0973839D5393A28F5D864 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51, ___dictionary_0)); }
inline Dictionary_2_t73AEE8CD779C2018D0F0973839D5393A28F5D864 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t73AEE8CD779C2018D0F0973839D5393A28F5D864 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t73AEE8CD779C2018D0F0973839D5393A28F5D864 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSource,System.Collections.Generic.HashSet`1<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer>>
struct KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,System.UInt32>
struct KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tB877F46A6C20A56DEA8ED6DC3E004A3171647E3B * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC, ___dictionary_0)); }
inline Dictionary_2_tB877F46A6C20A56DEA8ED6DC3E004A3171647E3B * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tB877F46A6C20A56DEA8ED6DC3E004A3171647E3B ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tB877F46A6C20A56DEA8ED6DC3E004A3171647E3B * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,System.UInt32>
struct KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,Microsoft.MixedReality.Toolkit.Input.DefaultPrimaryPointerSelector/PointerInfo>
struct KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t04AC434CE21791B15ED9D0D082374590F171F906 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C, ___dictionary_0)); }
inline Dictionary_2_t04AC434CE21791B15ED9D0D082374590F171F906 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t04AC434CE21791B15ED9D0D082374590F171F906 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t04AC434CE21791B15ED9D0D082374590F171F906 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,Microsoft.MixedReality.Toolkit.Input.DefaultPrimaryPointerSelector/PointerInfo>
struct KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.IMixedRealityServiceRegistrar,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.IMixedRealityService>>
struct KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t7187A6A24F531A0D383C66CB8EECF4ADF08C1936 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487, ___dictionary_0)); }
inline Dictionary_2_t7187A6A24F531A0D383C66CB8EECF4ADF08C1936 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t7187A6A24F531A0D383C66CB8EECF4ADF08C1936 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t7187A6A24F531A0D383C66CB8EECF4ADF08C1936 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.IMixedRealityServiceRegistrar,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.IMixedRealityService>>
struct KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.Maps.Unity.IPinnable,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<Microsoft.Maps.Unity.IPinnable,#=zFJNgcUMHoa_Yk4GHbEi4cN5X6lRg>>
struct KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t0DFDC32555434202BEC88887C3A9F082D232835D * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E, ___dictionary_0)); }
inline Dictionary_2_t0DFDC32555434202BEC88887C3A9F082D232835D * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t0DFDC32555434202BEC88887C3A9F082D232835D ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t0DFDC32555434202BEC88887C3A9F082D232835D * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.Maps.Unity.IPinnable,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<Microsoft.Maps.Unity.IPinnable,#=zFJNgcUMHoa_Yk4GHbEi4cN5X6lRg>>
struct KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.Maps.Unity.IPinnable,#=z6UMRWVfM7f7EZMpR0PVFMnePcr3V>
struct KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t406093774BE556AAEDDA18B680D0EE5B65A2FDAB * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A, ___dictionary_0)); }
inline Dictionary_2_t406093774BE556AAEDDA18B680D0EE5B65A2FDAB * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t406093774BE556AAEDDA18B680D0EE5B65A2FDAB ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t406093774BE556AAEDDA18B680D0EE5B65A2FDAB * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.Maps.Unity.IPinnable,#=z6UMRWVfM7f7EZMpR0PVFMnePcr3V>
struct KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.UI.BoundsControl.IProximityEffectObjectProvider,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.UI.BoundsControl.ProximityEffect/ObjectProximityInfo>>
struct KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t5D40BF3C845FC123FB1A832B9D26992DEAC7EEA4 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2, ___dictionary_0)); }
inline Dictionary_2_t5D40BF3C845FC123FB1A832B9D26992DEAC7EEA4 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t5D40BF3C845FC123FB1A832B9D26992DEAC7EEA4 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t5D40BF3C845FC123FB1A832B9D26992DEAC7EEA4 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.UI.BoundsControl.IProximityEffectObjectProvider,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.UI.BoundsControl.ProximityEffect/ObjectProximityInfo>>
struct KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation,UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider/InternalOp>
struct KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t07098E642DC6AF03BF35F4782BB31A441FA8E0D8 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9, ___dictionary_0)); }
inline Dictionary_2_t07098E642DC6AF03BF35F4782BB31A441FA8E0D8 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t07098E642DC6AF03BF35F4782BB31A441FA8E0D8 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t07098E642DC6AF03BF35F4782BB31A441FA8E0D8 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation,UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider/InternalOp>
struct KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<UnityEngine.XR.InputDevice,Microsoft.MixedReality.Toolkit.XRSDK.Input.GenericXRSDKController>
struct KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t2FB6B87AE845471F5ACC7900099F9B8BFE071E0E * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7, ___dictionary_0)); }
inline Dictionary_2_t2FB6B87AE845471F5ACC7900099F9B8BFE071E0E * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t2FB6B87AE845471F5ACC7900099F9B8BFE071E0E ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t2FB6B87AE845471F5ACC7900099F9B8BFE071E0E * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<UnityEngine.XR.InputDevice,Microsoft.MixedReality.Toolkit.XRSDK.Input.GenericXRSDKController>
struct KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<System.Int32,#=zGRtJz6WENVqAmTaN8b1aEoPKPEQQgilT_gsQzcTCsuSO>>
struct KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t097150F49EDC34E200BF50B861C5BF66AB89D9CA * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD, ___dictionary_0)); }
inline Dictionary_2_t097150F49EDC34E200BF50B861C5BF66AB89D9CA * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t097150F49EDC34E200BF50B861C5BF66AB89D9CA ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t097150F49EDC34E200BF50B861C5BF66AB89D9CA * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<System.Int32,#=zGRtJz6WENVqAmTaN8b1aEoPKPEQQgilT_gsQzcTCsuSO>>
struct KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Collections.Generic.Dictionary`2<#=zz8ndOzmECaoaq$rgYTLAYqxbjX7h,System.Int32>>
struct KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Collections.Generic.HashSet`1<System.Int32>>
struct KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t6431821EA0C996A318CFB028504B2F54E0732139 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB, ___dictionary_0)); }
inline Dictionary_2_t6431821EA0C996A318CFB028504B2F54E0732139 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t6431821EA0C996A318CFB028504B2F54E0732139 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t6431821EA0C996A318CFB028504B2F54E0732139 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Collections.Generic.HashSet`1<System.Int32>>
struct KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Collections.Generic.List`1<System.Object>>
struct KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t105FF7824240354B82616D121D7FF93B6882DEDE * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4, ___dictionary_0)); }
inline Dictionary_2_t105FF7824240354B82616D121D7FF93B6882DEDE * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t105FF7824240354B82616D121D7FF93B6882DEDE ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t105FF7824240354B82616D121D7FF93B6882DEDE * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Collections.Generic.List`1<System.Object>>
struct KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Collections.Generic.List`1<System.WeakReference>>
struct KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tCBFADFB0DA6360308C8BF88F72963B47106EBD52 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448, ___dictionary_0)); }
inline Dictionary_2_tCBFADFB0DA6360308C8BF88F72963B47106EBD52 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tCBFADFB0DA6360308C8BF88F72963B47106EBD52 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tCBFADFB0DA6360308C8BF88F72963B47106EBD52 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Collections.Generic.List`1<System.WeakReference>>
struct KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Tuple`2<Microsoft.MixedReality.Toolkit.Input.KeyBinding/KeyType,System.Int32>>
struct KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tB89818A1F8664493A3991E55D0E01B673F0119A5 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF, ___dictionary_0)); }
inline Dictionary_2_tB89818A1F8664493A3991E55D0E01B673F0119A5 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tB89818A1F8664493A3991E55D0E01B673F0119A5 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tB89818A1F8664493A3991E55D0E01B673F0119A5 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Tuple`2<Microsoft.MixedReality.Toolkit.Input.KeyBinding/KeyType,System.Int32>>
struct KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,#=znKxlCsVUPWmIVVaz3zPzqB_WSnzlbbWEo8WedU4i9t_p>
struct KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tCAC2D96457C0F5A4207EAFFAACAB66D7BC9A406D * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE, ___dictionary_0)); }
inline Dictionary_2_tCAC2D96457C0F5A4207EAFFAACAB66D7BC9A406D * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tCAC2D96457C0F5A4207EAFFAACAB66D7BC9A406D ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tCAC2D96457C0F5A4207EAFFAACAB66D7BC9A406D * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,#=znKxlCsVUPWmIVVaz3zPzqB_WSnzlbbWEo8WedU4i9t_p>
struct KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,#=ztxDTO7OPn0rNRWKdXA==>
struct KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tB430A29232B180122225E2DC22C97B1EC8BDB863 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78, ___dictionary_0)); }
inline Dictionary_2_tB430A29232B180122225E2DC22C97B1EC8BDB863 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tB430A29232B180122225E2DC22C97B1EC8BDB863 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tB430A29232B180122225E2DC22C97B1EC8BDB863 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,#=ztxDTO7OPn0rNRWKdXA==>
struct KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Boolean>
struct KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t446D8FCE66ED404E00855B46A520AB382A69EFF1 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E, ___dictionary_0)); }
inline Dictionary_2_t446D8FCE66ED404E00855B46A520AB382A69EFF1 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t446D8FCE66ED404E00855B46A520AB382A69EFF1 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t446D8FCE66ED404E00855B46A520AB382A69EFF1 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Boolean>
struct KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Char>
struct KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tB8FA8FEFBC38630BF40B59A6B474816F30D29B23 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1, ___dictionary_0)); }
inline Dictionary_2_tB8FA8FEFBC38630BF40B59A6B474816F30D29B23 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tB8FA8FEFBC38630BF40B59A6B474816F30D29B23 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tB8FA8FEFBC38630BF40B59A6B474816F30D29B23 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Char>
struct KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Globalization.CultureInfo>
struct KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t5B8303F2C9869A39ED3E03C0FBB09F817E479402 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9, ___dictionary_0)); }
inline Dictionary_2_t5B8303F2C9869A39ED3E03C0FBB09F817E479402 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t5B8303F2C9869A39ED3E03C0FBB09F817E479402 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t5B8303F2C9869A39ED3E03C0FBB09F817E479402 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Globalization.CultureInfo>
struct KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.Diagnostics.DiagnosticEvent>
struct KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tA132562C0B2CCFC639D9417B39DC61A33EBA00D8 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F, ___dictionary_0)); }
inline Dictionary_2_tA132562C0B2CCFC639D9417B39DC61A33EBA00D8 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tA132562C0B2CCFC639D9417B39DC61A33EBA00D8 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tA132562C0B2CCFC639D9417B39DC61A33EBA00D8 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.Diagnostics.DiagnosticEvent>
struct KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.AddressableAssets.Utility.DiagnosticInfo>
struct KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tBD7E4B2FABEA96AC727F92679C396FDAD5FBB436 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E, ___dictionary_0)); }
inline Dictionary_2_tBD7E4B2FABEA96AC727F92679C396FDAD5FBB436 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tBD7E4B2FABEA96AC727F92679C396FDAD5FBB436 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tBD7E4B2FABEA96AC727F92679C396FDAD5FBB436 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.AddressableAssets.Utility.DiagnosticInfo>
struct KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation>
struct KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tDB75C4D4D0B723B1109A640F97124956AA33BC66 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650, ___dictionary_0)); }
inline Dictionary_2_tDB75C4D4D0B723B1109A640F97124956AA33BC66 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tDB75C4D4D0B723B1109A640F97124956AA33BC66 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tDB75C4D4D0B723B1109A640F97124956AA33BC66 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation>
struct KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.ResourceProviders.IResourceProvider>
struct KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t1B2F62A5CB01E356B3C3FDEBB20B967EE7C405C9 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036, ___dictionary_0)); }
inline Dictionary_2_t1B2F62A5CB01E356B3C3FDEBB20B967EE7C405C9 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t1B2F62A5CB01E356B3C3FDEBB20B967EE7C405C9 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t1B2F62A5CB01E356B3C3FDEBB20B967EE7C405C9 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.ResourceProviders.IResourceProvider>
struct KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.InputSystem.InputDevice>
struct KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t3D9A2E4B61740D2FF9C269DA70E17270A366C986 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120, ___dictionary_0)); }
inline Dictionary_2_t3D9A2E4B61740D2FF9C269DA70E17270A366C986 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t3D9A2E4B61740D2FF9C269DA70E17270A366C986 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t3D9A2E4B61740D2FF9C269DA70E17270A366C986 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.InputSystem.InputDevice>
struct KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Int32>
struct KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t49CB072CAA9184D326107FA696BB354C43EB5E08 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0, ___dictionary_0)); }
inline Dictionary_2_t49CB072CAA9184D326107FA696BB354C43EB5E08 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t49CB072CAA9184D326107FA696BB354C43EB5E08 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t49CB072CAA9184D326107FA696BB354C43EB5E08 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Int32>
struct KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Int64>
struct KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t9AE0BA863BA88FABCBFC4CA835E0A6E00D948984 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A, ___dictionary_0)); }
inline Dictionary_2_t9AE0BA863BA88FABCBFC4CA835E0A6E00D948984 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t9AE0BA863BA88FABCBFC4CA835E0A6E00D948984 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t9AE0BA863BA88FABCBFC4CA835E0A6E00D948984 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Int64>
struct KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.Material>
struct KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tE3F17FC57643708975DF2782661AFB9CB1687991 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D, ___dictionary_0)); }
inline Dictionary_2_tE3F17FC57643708975DF2782661AFB9CB1687991 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tE3F17FC57643708975DF2782661AFB9CB1687991 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tE3F17FC57643708975DF2782661AFB9CB1687991 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.Material>
struct KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.EventSystems.PointerEventData>
struct KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t52ECB6047A9EDAD198D0CC53F331CDEAAA83BED8 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212, ___dictionary_0)); }
inline Dictionary_2_t52ECB6047A9EDAD198D0CC53F331CDEAAA83BED8 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t52ECB6047A9EDAD198D0CC53F331CDEAAA83BED8 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t52ECB6047A9EDAD198D0CC53F331CDEAAA83BED8 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.EventSystems.PointerEventData>
struct KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,Microsoft.MixedReality.Toolkit.SpatialAwareness.SpatialAwarenessMeshObject>
struct KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t80F7BDB2A022368F818AE566739AE78D92D2C0DC * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C, ___dictionary_0)); }
inline Dictionary_2_t80F7BDB2A022368F818AE566739AE78D92D2C0DC * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t80F7BDB2A022368F818AE566739AE78D92D2C0DC ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t80F7BDB2A022368F818AE566739AE78D92D2C0DC * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,Microsoft.MixedReality.Toolkit.SpatialAwareness.SpatialAwarenessMeshObject>
struct KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.String>
struct KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t0ACB62D0885C7AB376463C70665400A39808C5FB * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1, ___dictionary_0)); }
inline Dictionary_2_t0ACB62D0885C7AB376463C70665400A39808C5FB * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t0ACB62D0885C7AB376463C70665400A39808C5FB ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t0ACB62D0885C7AB376463C70665400A39808C5FB * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.String>
struct KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,Microsoft.Maps.Unity.Style>
struct KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tB78A990AC3609ABFB6119281443E6FB991DF77FE * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757, ___dictionary_0)); }
inline Dictionary_2_tB78A990AC3609ABFB6119281443E6FB991DF77FE * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tB78A990AC3609ABFB6119281443E6FB991DF77FE ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tB78A990AC3609ABFB6119281443E6FB991DF77FE * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,Microsoft.Maps.Unity.Style>
struct KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,TMPro.TMP_ColorGradient>
struct KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981 : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_t83EDCEFCBB12C89A61745514957F522FEF34EAE1 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981, ___dictionary_0)); }
inline Dictionary_2_t83EDCEFCBB12C89A61745514957F522FEF34EAE1 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_t83EDCEFCBB12C89A61745514957F522FEF34EAE1 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_t83EDCEFCBB12C89A61745514957F522FEF34EAE1 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
// System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,TMPro.TMP_ColorGradient>
struct KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4 : public RuntimeObject
{
public:
// System.Collections.Generic.ICollection`1<TKey> System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_collection
RuntimeObject* ___m_collection_0;
// System.Object System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection::m_syncRoot
RuntimeObject * ___m_syncRoot_1;
public:
inline static int32_t get_offset_of_m_collection_0() { return static_cast<int32_t>(offsetof(KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4, ___m_collection_0)); }
inline RuntimeObject* get_m_collection_0() const { return ___m_collection_0; }
inline RuntimeObject** get_address_of_m_collection_0() { return &___m_collection_0; }
inline void set_m_collection_0(RuntimeObject* value)
{
___m_collection_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_collection_0), (void*)value);
}
inline static int32_t get_offset_of_m_syncRoot_1() { return static_cast<int32_t>(offsetof(KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4, ___m_syncRoot_1)); }
inline RuntimeObject * get_m_syncRoot_1() const { return ___m_syncRoot_1; }
inline RuntimeObject ** get_address_of_m_syncRoot_1() { return &___m_syncRoot_1; }
inline void set_m_syncRoot_1(RuntimeObject * value)
{
___m_syncRoot_1 = value;
Il2CppCodeGenWriteBarrier((void**)(&___m_syncRoot_1), (void*)value);
}
};
// System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,TMPro.TMP_FontAsset>
struct KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F : public RuntimeObject
{
public:
// System.Collections.Generic.Dictionary`2<TKey,TValue> System.Collections.Generic.Dictionary`2/KeyCollection::dictionary
Dictionary_2_tAB557C4BCEBDF7E2339209187287588CF6C63579 * ___dictionary_0;
public:
inline static int32_t get_offset_of_dictionary_0() { return static_cast<int32_t>(offsetof(KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F, ___dictionary_0)); }
inline Dictionary_2_tAB557C4BCEBDF7E2339209187287588CF6C63579 * get_dictionary_0() const { return ___dictionary_0; }
inline Dictionary_2_tAB557C4BCEBDF7E2339209187287588CF6C63579 ** get_address_of_dictionary_0() { return &___dictionary_0; }
inline void set_dictionary_0(Dictionary_2_tAB557C4BCEBDF7E2339209187287588CF6C63579 * value)
{
___dictionary_0 = value;
Il2CppCodeGenWriteBarrier((void**)(&___dictionary_0), (void*)value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
il2cpp_hresult_t IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(RuntimeObject* __this, IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue);
il2cpp_hresult_t IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(RuntimeObject* __this, IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue);
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.AspNetCore.SignalR.Protocol.IHubProtocol,System.ReadOnlyMemory`1<System.Byte>>
struct KeyCollection_t025D75274DC35849871E082D579E71065DA83893_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t025D75274DC35849871E082D579E71065DA83893_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t025D75274DC35849871E082D579E71065DA83893_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t025D75274DC35849871E082D579E71065DA83893_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t025D75274DC35849871E082D579E71065DA83893(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t025D75274DC35849871E082D579E71065DA83893_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t025D75274DC35849871E082D579E71065DA83893_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityController,UnityEngine.Vector3>
struct KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t97211909825F9C71C8F4EE1E0DD95DD76338414F_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityController,UnityEngine.Vector3>
struct KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tA879036C274FBC5C419DC49C9FB01BA7612B5A06_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSource,System.Collections.Generic.HashSet`1<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer>>
struct KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t3EFDAD5C5086B3032F6548BDE8D64D6F98EFCF51_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSource,System.Collections.Generic.HashSet`1<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer>>
struct KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t74F921EDE127E311C0EA7C59FADCEC8AAE43E71D_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,System.UInt32>
struct KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tB00829BE501BC9A82348EA82B770B3995B0FFECC_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,System.UInt32>
struct KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t2F4C6311FDACE5FC815326D10C8F275581E006DA_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,Microsoft.MixedReality.Toolkit.Input.DefaultPrimaryPointerSelector/PointerInfo>
struct KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t1331616E8EE5FE564E89C5A442075EFFE98EF93C_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.Input.IMixedRealityPointer,Microsoft.MixedReality.Toolkit.Input.DefaultPrimaryPointerSelector/PointerInfo>
struct KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t165A4BB6A5AEEB6CE2AE628F80BA2ECF218402EA_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.IMixedRealityServiceRegistrar,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.IMixedRealityService>>
struct KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t7583B9D6F15870E760B4A52FC2D0AC544D110487_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.IMixedRealityServiceRegistrar,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.IMixedRealityService>>
struct KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t1C2C722B1AF698950C3329ADE494D41976A45DD1_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.Maps.Unity.IPinnable,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<Microsoft.Maps.Unity.IPinnable,#=zFJNgcUMHoa_Yk4GHbEi4cN5X6lRg>>
struct KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t4AEF76DE7B43FD14E6BB9AB408D01554B8E8FE0E_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.Maps.Unity.IPinnable,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<Microsoft.Maps.Unity.IPinnable,#=zFJNgcUMHoa_Yk4GHbEi4cN5X6lRg>>
struct KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tCD4D8F0628782E7690E331D9D8E977915B5E75F5_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.Maps.Unity.IPinnable,#=z6UMRWVfM7f7EZMpR0PVFMnePcr3V>
struct KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tFAAFEEFA1D21507748B8BBBED92E32459017AB3A_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.Maps.Unity.IPinnable,#=z6UMRWVfM7f7EZMpR0PVFMnePcr3V>
struct KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t7D4E0D43CF813A37B318C976C22E38C84F932448_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.UI.BoundsControl.IProximityEffectObjectProvider,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.UI.BoundsControl.ProximityEffect/ObjectProximityInfo>>
struct KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tC5BD7B6FA4F272A1F2DABA5EF1C78305B43E36B2_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<Microsoft.MixedReality.Toolkit.UI.BoundsControl.IProximityEffectObjectProvider,System.Collections.Generic.List`1<Microsoft.MixedReality.Toolkit.UI.BoundsControl.ProximityEffect/ObjectProximityInfo>>
struct KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t23988CC60D31A759C4C411D8BBD46B462AE358CD_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation,UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider/InternalOp>
struct KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t2B34FECCA090181AD3457FB5EDAADE95E8205DC9_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation,UnityEngine.AddressableAssets.ResourceProviders.ContentCatalogProvider/InternalOp>
struct KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t46FFB285402D18333B1370911AEF2515DD32469A_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<UnityEngine.XR.InputDevice,Microsoft.MixedReality.Toolkit.XRSDK.Input.GenericXRSDKController>
struct KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t566C065B2521EABF9CF07D2F81BA75B295ABDDD7_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<UnityEngine.XR.InputDevice,Microsoft.MixedReality.Toolkit.XRSDK.Input.GenericXRSDKController>
struct KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A_ComCallableWrapper>, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(1);
interfaceIds[0] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 1;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tE422CFA1413DE9EA4A137EA2006FCE8BD33C908A_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<System.Int32,#=zGRtJz6WENVqAmTaN8b1aEoPKPEQQgilT_gsQzcTCsuSO>>
struct KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t1CF4895E22E8AA0B00ED5F9A0BFE737AE92BADFD_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,#=zfArgcJqS9Sn8SFlc3ZWqjwKZaNmQR0rmZw==<System.Int32,#=zGRtJz6WENVqAmTaN8b1aEoPKPEQQgilT_gsQzcTCsuSO>>
struct KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t9F4B70BF9331DAD89856AE4BBB88E58BCE569C34_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Collections.Generic.Dictionary`2<#=zz8ndOzmECaoaq$rgYTLAYqxbjX7h,System.Int32>>
struct KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tB14932DE9FC0C56C87B393A9FE93A7AC7EE091A0_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Collections.Generic.HashSet`1<System.Int32>>
struct KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tEE68C3504733D9FC39CE9ADA31E42E37910367EB_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Collections.Generic.HashSet`1<System.Int32>>
struct KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tFFBF85A4F8075560B4A01B2ECC314980853192BE_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Collections.Generic.List`1<System.Object>>
struct KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t963C35621D42B454258BAB085592DE6F3753ADA4_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Collections.Generic.List`1<System.Object>>
struct KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tF2D56A30AE7E6484CA42BD640571189CE11C5796_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Collections.Generic.List`1<System.WeakReference>>
struct KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t9012502920B26090298C1B61FCC1E6CFC360D448_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Collections.Generic.List`1<System.WeakReference>>
struct KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tDBB108D612082017AF162F4065AD1B2BDD80D359_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Tuple`2<Microsoft.MixedReality.Toolkit.Input.KeyBinding/KeyType,System.Int32>>
struct KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t7E7A70D8E970088EFCE7E829926CC6BDA16EB0EF_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Tuple`2<Microsoft.MixedReality.Toolkit.Input.KeyBinding/KeyType,System.Int32>>
struct KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tC118529A40F2251AC17BEA6C5192645242D64F7D_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,#=znKxlCsVUPWmIVVaz3zPzqB_WSnzlbbWEo8WedU4i9t_p>
struct KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tE57FB018766F5C71B6735A61A2E92E05F1A4F1BE_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,#=znKxlCsVUPWmIVVaz3zPzqB_WSnzlbbWEo8WedU4i9t_p>
struct KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tA05E173344F1650FDC7D0E68B73C4C536526FB5D_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,#=ztxDTO7OPn0rNRWKdXA==>
struct KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t53F562A7D35D32C4CE417E0DE18EA9E7B19CFA78_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,#=ztxDTO7OPn0rNRWKdXA==>
struct KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t94020CFFC0CA822EDBE5CD6E47D7A51CA450F6DD_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Boolean>
struct KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t1A4234C2733AA679CBD9BA87755956535D81647E_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Boolean>
struct KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tC152F08EF8CC08ADE84F34B3E1A3B65E6334851E_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Char>
struct KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tB6DA7BD3F3255AFC2FAD2CA9A291FBA43E5CD4B1_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Char>
struct KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t0ECA6CB1949FA275ECDB3D8F05460076C20C785A_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Globalization.CultureInfo>
struct KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tCF581C6F9BA00F467A3E8CB21DE2D310B5FD3CA9_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Globalization.CultureInfo>
struct KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t1120F859B0671105D509AC98AAB21F7CFC2049D4_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.Diagnostics.DiagnosticEvent>
struct KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t12E1C7389BD142DF3579D64851EF1CD3AD6AE18F_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.Diagnostics.DiagnosticEvent>
struct KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t579CB0568EF891F11AC7736FF87A518DBA89A5DB_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.AddressableAssets.Utility.DiagnosticInfo>
struct KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tD3A581462367572093D5727724EBEF0880DA028E_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.AddressableAssets.Utility.DiagnosticInfo>
struct KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t601B3DEB98EDF3E34FB48423D540ED11B3B0AE0B_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation>
struct KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tAF57F0ABAE941BA69FD7081463CDAD8C2FEFB650_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.AsyncOperations.IAsyncOperation>
struct KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tC58EC30064F199085676741FCA2169EA05A41650_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.ResourceProviders.IResourceProvider>
struct KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tB457AF7EFDAC5F475FAD47A38E549F1CB56FF036_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.ResourceManagement.ResourceProviders.IResourceProvider>
struct KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t008E21FE08698773C890F77E19E4C8B8B9D27877_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.InputSystem.InputDevice>
struct KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t5BE70A16AB71FB272DCD7E1DA7B387098D2B0120_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.InputSystem.InputDevice>
struct KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tF90CC73519167E400F056395F3C56187B4FFBD05_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Int32>
struct KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tDB6919EBDF36E83E708A483A6C4CF8065F62D1E0_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Int32>
struct KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tEB01E49AAD44CFB3D07C82E1566073576FAB2A80_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.Int64>
struct KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t6C75FA39C169AFB913CD046927B28E95AA96C54A_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.Int64>
struct KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t1EE17E2E96FCA88DA7F88AD27E77B687940AC6F0_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.Material>
struct KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t193AE2D2720028E6C67183D0B8776FC0C389765D_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.Material>
struct KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t3CE094E958DC2A4E1855D6EAC1A8BACE08E4FE5D_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,UnityEngine.EventSystems.PointerEventData>
struct KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tD2C5F600E93DE7B92ABF7BC7E8A932E27D940212_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,UnityEngine.EventSystems.PointerEventData>
struct KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t36E68F717226925CBAC6C90C1AB8AAB176DD2BB7_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,Microsoft.MixedReality.Toolkit.SpatialAwareness.SpatialAwarenessMeshObject>
struct KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t4EF3551FD26E4D36973B76C63A8D6E522B387B7C_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,Microsoft.MixedReality.Toolkit.SpatialAwareness.SpatialAwarenessMeshObject>
struct KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t0A51E3976392ADA1C76F17569E06E27D8B025780_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,System.String>
struct KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t95CEC57CA04600603C7E9067D11E724EE99AD7D1_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,System.String>
struct KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t6932AD9E99EA6C71F8A923A002967381B381BF53_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,Microsoft.Maps.Unity.Style>
struct KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t072B491F4ED4569FB434C6460500B20D7FDA5757_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,Microsoft.Maps.Unity.Style>
struct KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t76B52031E0E436D3B13D8AD9DA15E1352F110EAB_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,TMPro.TMP_ColorGradient>
struct KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tCE7752ED00F7F3D67E6F2360D066F92B47831981_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.ObjectModel.ReadOnlyDictionary`2/KeyCollection<System.Int32,TMPro.TMP_ColorGradient>
struct KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_tC74D8AF310675B9B8E60837F9E1812820ABD12B4_ComCallableWrapper(obj));
}
// COM Callable Wrapper for System.Collections.Generic.Dictionary`2/KeyCollection<System.Int32,TMPro.TMP_FontAsset>
struct KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F_ComCallableWrapper IL2CPP_FINAL : il2cpp::vm::CachedCCWBase<KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F_ComCallableWrapper>, IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050, IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8
{
inline KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F_ComCallableWrapper(RuntimeObject* obj) : il2cpp::vm::CachedCCWBase<KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F_ComCallableWrapper>(obj) {}
virtual il2cpp_hresult_t STDCALL QueryInterface(const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE
{
if (::memcmp(&iid, &Il2CppIUnknown::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIInspectable::IID, sizeof(Il2CppGuid)) == 0
|| ::memcmp(&iid, &Il2CppIAgileObject::IID, sizeof(Il2CppGuid)) == 0)
{
*object = GetIdentity();
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIManagedObjectHolder::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIManagedObjectHolder*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIMarshal::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIMarshal*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
if (::memcmp(&iid, &Il2CppIWeakReferenceSource::IID, sizeof(Il2CppGuid)) == 0)
{
*object = static_cast<Il2CppIWeakReferenceSource*>(this);
AddRefImpl();
return IL2CPP_S_OK;
}
*object = NULL;
return IL2CPP_E_NOINTERFACE;
}
virtual uint32_t STDCALL AddRef() IL2CPP_OVERRIDE
{
return AddRefImpl();
}
virtual uint32_t STDCALL Release() IL2CPP_OVERRIDE
{
return ReleaseImpl();
}
virtual il2cpp_hresult_t STDCALL GetIids(uint32_t* iidCount, Il2CppGuid** iids) IL2CPP_OVERRIDE
{
Il2CppGuid* interfaceIds = il2cpp_codegen_marshal_allocate_array<Il2CppGuid>(2);
interfaceIds[0] = IIterable_1_t3FD1FB01310262788B2A8868AA7395E023511050::IID;
interfaceIds[1] = IBindableIterable_tF6BD0C070562CD9C91E3C1B1A5F4667E9C3C74A8::IID;
*iidCount = 2;
*iids = interfaceIds;
return IL2CPP_S_OK;
}
virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE
{
return GetRuntimeClassNameImpl(className);
}
virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE
{
return ComObjectBase::GetTrustLevel(trustLevel);
}
virtual il2cpp_hresult_t STDCALL IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5(IIterator_1_tFF647CAD19D34FD0606CDD3425C431F82B94589C** comReturnValue) IL2CPP_OVERRIDE
{
return IIterable_1_First_mC1E90957AD904E68CE3F84D1EF22D5EFACE8C2D5_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
virtual il2cpp_hresult_t STDCALL IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7(IBindableIterator_tD7550F1144CFBE58090050457A2BE92B1CAEABBB** comReturnValue) IL2CPP_OVERRIDE
{
return IBindableIterable_First_m91EC6ED0173145266318FDB7F9074798CD766BD7_ComCallableWrapperProjectedMethod(GetManagedObjectInline(), comReturnValue);
}
};
IL2CPP_EXTERN_C Il2CppIUnknown* CreateComCallableWrapperFor_KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F(RuntimeObject* obj)
{
void* memory = il2cpp::utils::Memory::Malloc(sizeof(KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F_ComCallableWrapper));
if (memory == NULL)
{
il2cpp_codegen_raise_out_of_memory_exception();
}
return static_cast<Il2CppIManagedObjectHolder*>(new(memory) KeyCollection_t92992C87550862FBB154128E3752DD1AD1E7849F_ComCallableWrapper(obj));
}
| 41.911047 | 314 | 0.816498 | [
"object"
] |
402df2d9c753ec0280331f6ea0defd43db1373e1 | 700 | cpp | C++ | plugins/dinput/src/keyboard/make_info.cpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | 2 | 2016-01-27T13:18:14.000Z | 2018-05-11T01:11:32.000Z | plugins/dinput/src/keyboard/make_info.cpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | null | null | null | plugins/dinput/src/keyboard/make_info.cpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | 3 | 2018-05-11T01:11:34.000Z | 2021-04-24T19:47:45.000Z | // 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)
#include <sge/dinput/di.hpp>
#include <sge/dinput/device/enumerate_objects.hpp>
#include <sge/dinput/keyboard/enumerator.hpp>
#include <sge/dinput/keyboard/info.hpp>
#include <sge/dinput/keyboard/make_info.hpp>
sge::dinput::keyboard::info sge::dinput::keyboard::make_info(IDirectInputDevice8 &_device)
{
sge::dinput::keyboard::enumerator object;
sge::dinput::device::enumerate_objects(_device, object, DIDFT_ALL);
return sge::dinput::keyboard::info(object.key_map());
}
| 35 | 90 | 0.737143 | [
"object"
] |
40345353996541b3ab9b6a779a40c5e8f68e407d | 2,630 | cpp | C++ | Snake_SFML/Snake.cpp | Ra-V2/Snake_SFML | 6b31b6efdbb5a520336d924733943ee01d679c88 | [
"MIT"
] | null | null | null | Snake_SFML/Snake.cpp | Ra-V2/Snake_SFML | 6b31b6efdbb5a520336d924733943ee01d679c88 | [
"MIT"
] | null | null | null | Snake_SFML/Snake.cpp | Ra-V2/Snake_SFML | 6b31b6efdbb5a520336d924733943ee01d679c88 | [
"MIT"
] | null | null | null | #include "Snake.h"
#include "Game.h"
Snake::Snake() : length(3), sdir(direction::STOP)
{
shape.resize(101); //sets size of vectors
shapePosition.resize(101);
for (int i = 0; i < length; i++) //set up snake
{
shape[i].setSize(sf::Vector2f(Game::shapeSize,Game::shapeSize));
shape[i].setPosition(400, 500 + i*Game::movePixels);
shapePosition[i] = shape[i].getPosition();
}
shape[0].setFillColor(sf::Color::Color(140, 140, 140)); //set snake head color
}
void Snake::Control(sf::RenderWindow & window) //move snake
{
if (sdir != direction::STOP)
{
for (int i = length-1; i >= 0; i--)
{
shapePosition[i] = shape[i].getPosition();
switch (sdir)
{
case direction::UP:
{
if (i == 0)
{
shape[i].move(0.f, -Game::movePixels);
shapePosition[i] = shape[i].getPosition();
}
else if (i > 0)
{
shapePosition[i] = shapePosition[i - 1];
shape[i].setPosition(shapePosition[i]);
}
break;
}
case direction::DOWN:
{
if (i == 0)
{
shape[i].move(0.f, Game::movePixels);
shapePosition[i] = shape[i].getPosition();
}
else if (i > 0)
{
shapePosition[i] = shapePosition[i - 1];
shape[i].setPosition(shapePosition[i]);
}
break;
}
case direction::LEFT:
{
if (i == 0)
{
shape[i].move(-Game::movePixels, 0.f);
shapePosition[i] = shape[i].getPosition();
}
else if (i > 0)
{
shapePosition[i] = shapePosition[i - 1];
shape[i].setPosition(shapePosition[i]);
}
break;
}
case direction::RIGHT:
{
if (i == 0)
{
shape[i].move(Game::movePixels, 0.f);
shapePosition[i] = shape[i].getPosition();
}
else if (i > 0)
{
shapePosition[i] = shapePosition[i - 1];
shape[i].setPosition(shapePosition[i]);
}
break;
}
case direction::STOP:
{
break;
}
}
}
}
}
void Snake::Growth() //snake growth up
{
length++;
shape[length - 1].setSize(sf::Vector2f(Game::shapeSize, Game::shapeSize));
}
const bool Snake::CollisionFruit(const Fruit & fruit) //detect snake hit fruit
{
if (shapePosition[0] == fruit.fruitPosition)
return true;
else
return false;
}
const bool Snake::CollisionWall() //detect snake hit wall
{
if (shapePosition[0].x >= Game::winSizeX || shapePosition[0].x < 0)
return true;
else if (shapePosition[0].y >= Game::winSizeY || shapePosition[0].y < 0)
return true;
else
return false;
}
const bool Snake::CollisionSnake() //detect snake hit himself
{
for (int i = 1; i <= length; i++)
{
if (shapePosition[0] == shapePosition[i])
return true;
}
return false;
}
| 20.230769 | 79 | 0.592776 | [
"shape"
] |
4034ca347e7e342faee9939d7f2934fdb6783825 | 2,589 | cpp | C++ | Maths/Problem (Based on Inclusion Exclusion).cpp | Edith-3000/Algorithmic-Implementations | 7ff8cd615fd453a346b4e851606d47c26f05a084 | [
"MIT"
] | 8 | 2021-02-13T17:07:27.000Z | 2021-08-20T08:20:40.000Z | Maths/Problem (Based on Inclusion Exclusion).cpp | Edith-3000/Algorithmic-Implementations | 7ff8cd615fd453a346b4e851606d47c26f05a084 | [
"MIT"
] | null | null | null | Maths/Problem (Based on Inclusion Exclusion).cpp | Edith-3000/Algorithmic-Implementations | 7ff8cd615fd453a346b4e851606d47c26f05a084 | [
"MIT"
] | 5 | 2021-02-17T18:12:20.000Z | 2021-10-10T17:49:34.000Z | /* Problem description --->
After the release of Avengers, Ironman and Thor got into a fight and Ironman challenged Thor to find out the
number of numbers between 1 and n which are divisible by any of the prime numbers less than 20. Ironman being
great at maths quickly answered the question but then Thor asked him to write a program for it. Ironman however
found it quite difficult as he did not wanted to write so many lines of code. he knows that you are smart and
can code this up easily. Can you do it?
Input Format
The first line consists of number of test cases t. then follow t lines which consists of number n for each test case.
Constraints
1 <= test cases <= 10
1 <= n <= 10^18
Output Format
the answer to each test case each in different line
Sample Input
5
5
10
12
15
18
Sample Output
4
9
11
14
17
Explanation
for n = 5 2 and 4 are divisible by 2 and 3 is divisible by 3 and 5 by 5. hence ans = 4.
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vull> vvull;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
uniform_int_distribution<int> uid(0,lim-1);
return uid(rang);
}
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
vi v {2, 3, 5, 7, 11, 13, 17, 19};
ll GCD(ll a, ll b) {
return (b == 0) ? a : GCD(b, a % b);
}
void solve()
{
ll n; cin >> n;
ll res = 0;
for(ll mask = 1; mask < (1 << v.size()); mask++) {
ll lcm = 1; ll cnt = __builtin_popcountll(mask);
for(ll i = 0; i < v.size(); i++) {
if(mask & (1 << i)) lcm = (lcm * v[i]) / GCD(lcm, v[i]);
}
if(cnt & 1) res += (n / lcm);
else res -= (n / lcm);
}
cout << res << "\n";
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
srand(chrono::high_resolution_clock::now().time_since_epoch().count());
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int t = 1;
cin >> t;
while(t--) {
solve();
}
return 0;
} | 23.536364 | 117 | 0.643105 | [
"vector"
] |
40399a35f8d2c70827adec732c898a5be09cf69b | 3,912 | cc | C++ | chrome/browser/ui/libgtkui/app_indicator_icon_menu.cc | zipated/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | chrome/browser/ui/libgtkui/app_indicator_icon_menu.cc | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | chrome/browser/ui/libgtkui/app_indicator_icon_menu.cc | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/libgtkui/app_indicator_icon_menu.h"
#include <gtk/gtk.h>
#include "base/bind.h"
#include "base/debug/leak_annotations.h"
#include "chrome/browser/ui/libgtkui/menu_util.h"
#include "ui/base/models/menu_model.h"
namespace libgtkui {
AppIndicatorIconMenu::AppIndicatorIconMenu(ui::MenuModel* model)
: menu_model_(model),
click_action_replacement_menu_item_added_(false),
gtk_menu_(nullptr),
block_activation_(false) {
{
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/378770
gtk_menu_ = gtk_menu_new();
}
g_object_ref_sink(gtk_menu_);
if (menu_model_) {
BuildSubmenuFromModel(menu_model_,
gtk_menu_,
G_CALLBACK(OnMenuItemActivatedThunk),
&block_activation_,
this);
Refresh();
}
}
AppIndicatorIconMenu::~AppIndicatorIconMenu() {
gtk_widget_destroy(gtk_menu_);
g_object_unref(gtk_menu_);
}
void AppIndicatorIconMenu::UpdateClickActionReplacementMenuItem(
const char* label,
const base::Closure& callback) {
click_action_replacement_callback_ = callback;
if (click_action_replacement_menu_item_added_) {
GList* children = gtk_container_get_children(GTK_CONTAINER(gtk_menu_));
for (GList* child = children; child; child = g_list_next(child)) {
if (g_object_get_data(G_OBJECT(child->data), "click-action-item") !=
nullptr) {
gtk_menu_item_set_label(GTK_MENU_ITEM(child->data), label);
break;
}
}
g_list_free(children);
} else {
click_action_replacement_menu_item_added_ = true;
// If |menu_model_| is non empty, add a separator to separate the
// "click action replacement menu item" from the other menu items.
if (menu_model_ && menu_model_->GetItemCount() > 0) {
GtkWidget* menu_item = gtk_separator_menu_item_new();
gtk_widget_show(menu_item);
gtk_menu_shell_prepend(GTK_MENU_SHELL(gtk_menu_), menu_item);
}
GtkWidget* menu_item = gtk_menu_item_new_with_mnemonic(label);
g_object_set_data(
G_OBJECT(menu_item), "click-action-item", GINT_TO_POINTER(1));
g_signal_connect(menu_item,
"activate",
G_CALLBACK(OnClickActionReplacementMenuItemActivatedThunk),
this);
gtk_widget_show(menu_item);
gtk_menu_shell_prepend(GTK_MENU_SHELL(gtk_menu_), menu_item);
}
}
void AppIndicatorIconMenu::Refresh() {
gtk_container_foreach(
GTK_CONTAINER(gtk_menu_), SetMenuItemInfo, &block_activation_);
}
GtkMenu* AppIndicatorIconMenu::GetGtkMenu() {
return GTK_MENU(gtk_menu_);
}
void AppIndicatorIconMenu::OnClickActionReplacementMenuItemActivated(
GtkWidget* menu_item) {
click_action_replacement_callback_.Run();
}
void AppIndicatorIconMenu::OnMenuItemActivated(GtkWidget* menu_item) {
if (block_activation_)
return;
ui::MenuModel* model = ModelForMenuItem(GTK_MENU_ITEM(menu_item));
if (!model) {
// There won't be a model for "native" submenus like the "Input Methods"
// context menu. We don't need to handle activation messages for submenus
// anyway, so we can just return here.
DCHECK(gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_item)));
return;
}
// The activate signal is sent to radio items as they get deselected;
// ignore it in this case.
if (GTK_IS_RADIO_MENU_ITEM(menu_item) &&
!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_item))) {
return;
}
int id;
if (!GetMenuItemID(menu_item, &id))
return;
// The menu item can still be activated by hotkeys even if it is disabled.
if (menu_model_->IsEnabledAt(id))
ExecuteCommand(model, id);
}
} // namespace libgtkui
| 31.548387 | 80 | 0.706033 | [
"model"
] |
40407c0160255cc90caf78614c321b6bc6a51639 | 838 | cpp | C++ | SDL2_Engine/Projects/SDL2_Engine/src/UI/UIElements/UIPanel.cpp | MitchCroft/SDL2_Engine | 8f4bbb7ad914649de47cdeb19bd9956e0b9a8c5f | [
"MIT"
] | null | null | null | SDL2_Engine/Projects/SDL2_Engine/src/UI/UIElements/UIPanel.cpp | MitchCroft/SDL2_Engine | 8f4bbb7ad914649de47cdeb19bd9956e0b9a8c5f | [
"MIT"
] | null | null | null | SDL2_Engine/Projects/SDL2_Engine/src/UI/UIElements/UIPanel.cpp | MitchCroft/SDL2_Engine | 8f4bbb7ad914649de47cdeb19bd9956e0b9a8c5f | [
"MIT"
] | 1 | 2022-03-27T04:53:25.000Z | 2022-03-27T04:53:25.000Z | #include "UIPanel.hpp"
//! Include the SDL2_Engine objects
#include "../../Globals.hpp"
#include "../../Rendering/Renderer.hpp"
namespace SDL2_Engine {
namespace UI {
namespace UIElements {
/*
UIPanel : render - Function to facilitate the the rendering of images once per cycle
Created: 13/10/2017
Modified: 16/10/2017
*/
void UIPanel::render() {
//Get the renderer
Rendering::Renderer& rend = Globals::get<Rendering::Renderer>();
//Check if there is an image to draw
if (mImage) {
//Draw the texture
rend.drawTexture(mImage, *(SDL_Rect*)&mLocation, nullptr, mFilterColour);
//Outline the image
rend.drawRect(*(SDL_Rect*)&mLocation, mBorderColour);
}
//Draw the panel
else rend.drawRect(*(SDL_Rect*)&mLocation, mFillColour, true, &mBorderColour);
}
}
}
}
| 24.647059 | 88 | 0.661098 | [
"render"
] |
404544bd2f7875a9b721b6457b806aa074e530d2 | 1,014 | cpp | C++ | Hackerearth/mishki-playing-games.cpp | jceplaras/competitiveprogramming | d92cbedd31d9aa812a6084aea50e573886e5e6e4 | [
"MIT"
] | null | null | null | Hackerearth/mishki-playing-games.cpp | jceplaras/competitiveprogramming | d92cbedd31d9aa812a6084aea50e573886e5e6e4 | [
"MIT"
] | null | null | null | Hackerearth/mishki-playing-games.cpp | jceplaras/competitiveprogramming | d92cbedd31d9aa812a6084aea50e573886e5e6e4 | [
"MIT"
] | null | null | null | #include <algorithm>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define FORN(i,N) for (int i = 0; i < N; i++)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
int intLog2(int N) {
if(N == 0) return 0;
else return (int)log2(N);
}
int g(int N) {
if(N%2 == 0) return 1;
else return 0;
}
int A[1000001];
int main() {
int N,Q;
scanf("%d %d",&N,&Q);
FOR(i,1,N) {
int a;
scanf("%d",&a);
A[i] = g(intLog2(a));
}
A[0] = 0;
FOR(i,1,N)
A[i] ^= A[i-1];
FORN(i,Q) {
int L,R;
scanf("%d %d",&L,&R);
int temp = g(A[L-1])^g(A[R]);
if(temp != 0)
printf("Mishki\n");
else
printf("Hacker\n");
}
return 0;
}
| 14.485714 | 48 | 0.547337 | [
"vector"
] |
4046970a061e1bd9c4f33dd476da271498fdfa47 | 3,711 | cpp | C++ | Engine/Engine/Private/Engine.cpp | heretique/Atlas | 0981e7941b570ecfda1febf71b4669338ab81921 | [
"MIT"
] | 6 | 2016-11-09T08:40:10.000Z | 2021-10-06T09:47:05.000Z | Engine/Engine/Private/Engine.cpp | heretique/Atlas | 0981e7941b570ecfda1febf71b4669338ab81921 | [
"MIT"
] | null | null | null | Engine/Engine/Private/Engine.cpp | heretique/Atlas | 0981e7941b570ecfda1febf71b4669338ab81921 | [
"MIT"
] | 3 | 2016-11-09T08:38:59.000Z | 2021-12-24T16:03:59.000Z | #include "Engine/Engine.h"
#include "Geometry/Geometry.h"
#include "Materials/Material.h"
#include "Scripting/Script.h"
#include "Materials/Shader.h"
#include "Materials/Texture.h"
#include "Particles/ParticleEffect.h"
#include "Camera/Camera.h"
#include "Core/Component.h"
#include "Materials/MaterialComponent.h"
#include "Geometry/MeshComponent.h"
#include "Core/TransformComponent.h"
#include "Core/SimpleMeshVertex.h"
#include "Animation/AnimationSystem.h"
#include "Particles/ParticleSystem.h"
#include "Picking/PickingSystem.h"
#include "Rendering/RenderSystem.h"
#include "Plugins/PluginManager.h"
#include "UI/ImGuiSerializer.h"
#include "Hq/JsonSerializer.h"
#include "Hq/BinarySerializer.h"
#include "DebugDraw/DebugDraw.h"
#include "Core/MemoryManager.h"
#include <entt/entt.hpp>
#include <bgfx/c99/bgfx.h>
namespace atlas
{
enki::TaskScheduler* Engine::_jobManager = nullptr;
u32 Engine::_viewWidth = 0;
u32 Engine::_viewHeight = 0;
///////////// Bounds updates //////////////
void UpdateEntityBoundsFromMesh(entt::registry& registry, entt::entity entity)
{
if (registry.all_of<TransformComponent>(entity))
{
TransformComponent& transform = registry.get<TransformComponent>(entity);
transform.bbox = registry.get<MeshComponent>(entity).geometry->bounds();
}
else
{
TransformComponent& transform = registry.emplace<TransformComponent>(entity);
transform.bbox = registry.get<MeshComponent>(entity).geometry->bounds();
}
}
const bgfx_caps_t* Engine::bgfxCaps()
{
return bgfx_get_caps();
}
const bgfx_stats_t* Engine::bgfxStats()
{
return bgfx_get_stats();
}
bool Engine::init(u32 viewWidth, u32 viewHeight)
{
_viewWidth = viewWidth;
_viewHeight = viewHeight;
if (_jobManager == nullptr)
_jobManager = new enki::TaskScheduler();
initVertDecl();
registerDefaultAssetTypes();
registerComponentDependencies();
registerSystems();
jobs().Initialize();
DebugDraw::initialize();
return true;
}
void Engine::setViewSize(u32 width, u32 height)
{
_viewWidth = width;
_viewHeight = height;
}
u32 Engine::viewWidth()
{
return _viewWidth;
}
u32 Engine::viewHeight()
{
return _viewHeight;
}
void Engine::initVertDecl()
{
SimpleMeshVertex::init();
}
void Engine::registerComponentDependencies()
{
ecs().registry().on_construct<MeshComponent>().connect<&UpdateEntityBoundsFromMesh>();
}
void Engine::registerDefaultAssetTypes()
{
assets().registerAssetType(AssetTypes::Geometry, AssetNames::Geometry, GeometryAsset::factoryFunc);
assets().registerAssetType(AssetTypes::Code, AssetNames::Code, ScriptAsset::factoryFunc);
assets().registerAssetType(AssetTypes::Texture, AssetNames::Texture, TextureAsset::factoryFunc);
assets().registerAssetType(AssetTypes::Shader, AssetNames::Shader, ShaderAsset::factoryFunc);
assets().registerAssetType(AssetTypes::Material, AssetNames::Material, MaterialAsset::factoryFunc);
assets().registerAssetType(AssetTypes::ParticleEffect, AssetNames::ParticleEffect,
ParticleEffectAsset::factoryFunc);
}
void Engine::registerSystems()
{
ecs().registerUpdateSystem(std::move(std::make_unique<AnimationSystem>()));
ecs().registerUpdateSystem(std::move(std::make_unique<ParticleSystem>()));
ecs().registerVisualSystem(std::move(std::make_unique<RenderSystem>()));
}
void Engine::release()
{
jobs().WaitforAllAndShutdown();
delete _jobManager;
_jobManager = nullptr;
DebugDraw::release();
ui().release();
ecs().registry().clear();
assets().release();
}
} // namespace Atlas
| 27.087591 | 103 | 0.707087 | [
"geometry",
"transform"
] |
404b6f66df338163eefe4057ca0c31eb9e3cb8f0 | 10,220 | cpp | C++ | src/aggtest/shapes.cpp | symfund/microwindows | f267e5c368c5e5a49ac6b3907af9527b06a1c67f | [
"X11"
] | 1 | 2020-12-19T13:47:11.000Z | 2020-12-19T13:47:11.000Z | src/aggtest/shapes.cpp | symfund/microwindows | f267e5c368c5e5a49ac6b3907af9527b06a1c67f | [
"X11"
] | null | null | null | src/aggtest/shapes.cpp | symfund/microwindows | f267e5c368c5e5a49ac6b3907af9527b06a1c67f | [
"X11"
] | null | null | null | #include "agg_basics.h"
#include "agg_rendering_buffer.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_scanline_p.h"
#include "agg_renderer_scanline.h"
#include "agg_pixfmt_rgb.h"
#include "agg_ellipse.h"
#include "agg_rounded_rect.h"
#include "agg_conv_curve.h"
#include "agg_conv_stroke.h"
#include "agg_font_freetype.h"
#include "agg_scanline_u.h"
#include "agg_scanline_bin.h"
#include "agg_conv_contour.h"
#include "agg_renderer_primitives.h"
#include "platform/agg_platform_support.h"
#include "ctrl/agg_slider_ctrl.h"
#include "ctrl/agg_cbox_ctrl.h"
#include "pixel_formats.h"
//#define FONT "../fonts/truetype/timesi.ttf"
//#define FONT "../../../nuklear/extra_font/Roboto-Light.ttf"
#define FONT "../../../nuklear/extra_font/Roboto-Regular.ttf"
//#define FONT "../../../nuklear/extra_font/ProggyClean.ttf"
enum flip_y_e { flip_y = true };
bool font_flip_y = !flip_y;
class the_application : public agg::platform_support
{
double m_x[2];
double m_y[2];
double m_dx;
double m_dy;
int m_idx;
double m_offset;
agg::slider_ctrl<color_type> m_radius;
agg::slider_ctrl<color_type> m_thickness;
agg::cbox_ctrl<color_type> m_white_on_black;
typedef agg::renderer_base<pixfmt> base_ren_type;
typedef agg::renderer_scanline_aa_solid<base_ren_type> renderer_solid;
typedef agg::renderer_scanline_bin_solid<base_ren_type> renderer_bin;
typedef agg::font_engine_freetype_int32 font_engine_type;
typedef agg::font_cache_manager<font_engine_type> font_manager_type;
font_engine_type m_feng;
font_manager_type m_fman;
// Pipeline to process the vectors glyph paths (curves + contour)
agg::conv_curve<font_manager_type::path_adaptor_type> m_curves;
agg::conv_contour<agg::conv_curve<font_manager_type::path_adaptor_type> > m_contour;
public:
the_application(agg::pix_format_e format, bool flip_y) :
agg::platform_support(format, flip_y),
m_idx(-1),
m_offset(0.5),
m_radius(10, 10, 600-10, 19, !flip_y),
m_thickness(10, 10+20, 600-10, 19+20, !flip_y),
m_white_on_black(10, 10+40, "White on black"),
m_feng(),
m_fman(m_feng),
m_curves(m_fman.path_adaptor()),
m_contour(m_curves)
{
m_x[0] = 100; m_y[0] = 100;
m_x[1] = 500; m_y[1] = 350;
add_ctrl(m_radius);
add_ctrl(m_thickness);
add_ctrl(m_white_on_black);
m_radius.label("radius=%4.3f");
m_radius.range(0.0, 50.0);
m_radius.value(25.0);
m_thickness.label("thickness=%4.3f");
m_thickness.range(0.1, 20.0);
m_thickness.value(1.0);
m_white_on_black.text_color(agg::srgba8(127, 127, 127));
m_white_on_black.inactive_color(agg::srgba8(127, 127, 127));
m_curves.approximation_scale(2.0);
m_contour.auto_detect_orientation(false);
}
virtual void on_draw()
{
typedef agg::renderer_base<pixfmt> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
pixfmt pixf(rbuf_window());
renderer_base rb(pixf);
renderer_solid ren(rb);
renderer_bin ren_bin(rb);
rb.clear(m_white_on_black.status() ? agg::rgba(0,0,0) : agg::rgba(1,1,1));
agg::rasterizer_scanline_aa<> ras;
agg::scanline_p8 sl;
// Render two "control" circles
agg::ellipse c;
ren.color(agg::srgba8(127,127,127));
c.init(m_x[0], m_y[0], 3, 3, 16);
ras.add_path(c);
agg::render_scanlines(ras, sl, ren);
c.init(m_x[1], m_y[1], 3, 3, 16);
ras.add_path(c);
agg::render_scanlines(ras, sl, ren);
agg::path_storage path;
// Create a line
path.move_to(400, 200);
path.line_to(450, 250);
// Fill line
agg::conv_stroke<agg::path_storage> l(path);
l.width(m_thickness.value());
ras.add_path(l);
// Create a polygon
path.remove_all();
path.move_to(220, 60);
path.line_to(469, 170);
path.line_to(243, 310);
path.close_polygon();
// Fill polygon
agg::conv_stroke<agg::path_storage> o(path);
o.width(m_thickness.value());
ras.add_path(o);
// Creating a rounded rectangle
double d = m_offset;
agg::rounded_rect r(m_x[0]+d, m_y[0]+d, m_x[1]+d, m_y[1]+d, m_radius.value());
r.normalize_radius();
// Drawing as an outline
agg::conv_stroke<agg::rounded_rect> p(r);
p.width(m_thickness.value());
ras.add_path(p);
// Create ellipse
agg::ellipse e;
e.init(225, 225, 100, 100);
agg::conv_stroke<agg::ellipse> q(e);
q.width(m_thickness.value());
ras.add_path(q);
// Create bezier curve
agg::curve4 curve;
path.remove_all();
curve.approximation_method(agg::curve_inc);
curve.approximation_scale(1.0);
curve.angle_tolerance(15);
curve.cusp_limit(0);
//curve.init(300, 225, 350, 250, 250, 200, 400, 250);
curve.init(270, 424, 113, 86, 588, 423, 126, 333);
path.concat_path(curve);
agg::conv_stroke<agg::path_storage> stroke(path);
stroke.width(m_thickness.value());
stroke.line_cap(agg::butt_cap);
stroke.line_join(agg::miter_join);
stroke.inner_join(agg::inner_miter);
stroke.inner_miter_limit(1.01);
ras.add_path(stroke);
// Draw text
agg::glyph_rendering gren = agg::glyph_ren_native_gray8;
double m_height = 12.0;
double m_width = 12.0;
double m_weight = 0.0;
int m_kerning = 1;
m_contour.width(-m_weight * m_height * 0.05);
if(m_feng.load_font(full_file_name(FONT), 0, gren))
{
m_feng.hinting(1);
m_feng.height(m_height);
m_feng.width(m_width);
m_feng.flip_y(font_flip_y);
//agg::trans_affine mtx;
//mtx *= agg::trans_affine_rotation(agg::deg2rad(-4.0));
////mtx *= agg::trans_affine_skewing(-0.4, 0);
////mtx *= agg::trans_affine_translation(1, 0);
//m_feng.transform(mtx);
double x = 10.0;
double y0 = height() - m_height - 10.0;
double y = y0;
const char *p = "NodeEdit Source";
while(*p)
{
const agg::glyph_cache* glyph = m_fman.glyph(*p);
if(glyph)
{
if(m_kerning)
{
m_fman.add_kerning(&x, &y);
}
if(x >= width() - m_height)
{
x = 10.0;
y0 -= m_height;
//if(y0 <= 120) break;
y = y0;
}
m_fman.init_embedded_adaptors(glyph, x, y);
switch(glyph->data_type)
{
default: break;
case agg::glyph_data_mono:
//ren_bin.color(agg::srgba8(0, 0, 0));
ren_bin.color(agg::rgba(0.75,0.75,0.75));
agg::render_scanlines(m_fman.mono_adaptor(),
m_fman.mono_scanline(),
ren_bin);
break;
case agg::glyph_data_gray8:
//ren.color(agg::srgba8(0, 0, 0));
ren.color(agg::rgba(0.75,0.75,0.75));
agg::render_scanlines(m_fman.gray8_adaptor(),
m_fman.gray8_scanline(),
ren);
break;
case agg::glyph_data_outline:
ras.reset();
if(fabs(m_weight) <= 0.01)
{
// For the sake of efficiency skip the
// contour converter if the weight is about zero.
//-----------------------
ras.add_path(m_curves);
}
else
{
ras.add_path(m_contour);
}
//ren.color(agg::srgba8(0, 0, 0));
ren.color(agg::rgba(0.75,0.75,0.75));
agg::render_scanlines(ras, sl, ren);
//dump_path(m_fman.path_adaptor());
break;
}
// increment pen position
x += glyph->advance_x;
y += glyph->advance_y;
//++num_glyphs;
}
++p;
}
}
// Render paths
//ren.color(m_white_on_black.status() ? agg::rgba(1,1,1) : agg::rgba(0,0,0));
ren.color(agg::rgba(0.75,0.75,0.75));
agg::render_scanlines(ras, sl, ren);
// Render the controls
agg::render_ctrl(ras, sl, rb, m_radius);
agg::render_ctrl(ras, sl, rb, m_thickness);
agg::render_ctrl(ras, sl, rb, m_white_on_black);
}
virtual void on_mouse_button_down(int x, int y, unsigned flags)
{
if(flags & agg::mouse_left)
{
unsigned i;
for (i = 0; i < 2; i++)
{
if(sqrt( (x-m_x[i]) * (x-m_x[i]) + (y-m_y[i]) * (y-m_y[i]) ) < 5.0)
{
m_dx = x - m_x[i];
m_dy = y - m_y[i];
m_idx = i;
break;
}
}
}
}
virtual void on_mouse_move(int x, int y, unsigned flags)
{
if(flags & agg::mouse_left)
{
if(m_idx >= 0)
{
m_x[m_idx] = x - m_dx;
m_y[m_idx] = y - m_dy;
force_redraw();
}
}
else
{
on_mouse_button_up(x, y, flags);
}
}
virtual void on_mouse_button_up(int x, int y, unsigned flags)
{
m_idx = -1;
}
};
int agg_main(int argc, char* argv[])
{
the_application app(pix_format, flip_y);
app.caption("Nuklear Shapes");
if(app.init(600, 400, agg::window_resize))
{
return app.run();
}
return 1;
}
| 30.147493 | 88 | 0.534638 | [
"render",
"transform"
] |
405300e0751187b79a5b34d75feb35adf09a99ff | 31,986 | cpp | C++ | cornac/models/c2pf/cpp/cpp_c2pf.cpp | Andrew-DungLe/cornac | 199ab9181f8b6387cc8748ccf8ee3e5c9df087fb | [
"Apache-2.0"
] | null | null | null | cornac/models/c2pf/cpp/cpp_c2pf.cpp | Andrew-DungLe/cornac | 199ab9181f8b6387cc8748ccf8ee3e5c9df087fb | [
"Apache-2.0"
] | null | null | null | cornac/models/c2pf/cpp/cpp_c2pf.cpp | Andrew-DungLe/cornac | 199ab9181f8b6387cc8748ccf8ee3e5c9df087fb | [
"Apache-2.0"
] | null | null | null |
#include "./cpp_c2pf.h"
//Update the shape parameters of Gamma, contextual pf
void update_gamma_s_context(Mat &G_s, SpMat const& X, SpMat const&Lt, SpMat const&Lb, SpMat const&Lb2){
double eps = pow(2,-52);
for(int nz = 0;nz<X.outerSize();++nz)
{
for (SpMatiter x_(X,nz); x_; ++x_)
{
double dk = eps;
for(int k = 0;k<Lt.cols();++k)
{
dk += Lt.coeff(x_.row(),k)*(Lb.coeff(x_.col(),k)+Lb2.coeff(x_.col(),k));
}
for(int k = 0;k<G_s[0].size();++k)
{
G_s[x_.row()][k] += Lt.coeff(x_.row(),k)*(Lb.coeff(x_.col(),k)+Lb2.coeff(x_.col(),k))*X.coeff(x_.row(),x_.col())/dk;
//L_s.coeffRef(i_.col(),k) += Lt.coeff(i_.row(),k)*Lb.coeff(i_.col(),k)*X.coeff(i_.row(),i_.col())/dk;
}
}
}
}
void update_gamma_s_context_r(Mat &G_s, SpMat const& X, SpMat const&Lt, SpMat const&Lb2)
{
double eps = pow(2,-52);
for(int nz = 0;nz<X.outerSize();++nz)
{
for (SpMatiter x_(X,nz); x_; ++x_)
{
double dk = eps;
for(int k = 0;k<Lt.cols();++k)
{
dk += Lt.coeff(x_.row(),k)*Lb2.coeff(x_.col(),k);
}
for(int k = 0;k<G_s.size();++k)
{
G_s[x_.row()][k] += Lt.coeff(x_.row(),k)*Lb2.coeff(x_.col(),k)*X.coeff(x_.row(),x_.col())/dk;
//L_s.coeffRef(i_.col(),k) += Lt.coeff(i_.row(),k)*Lb.coeff(i_.col(),k)*X.coeff(i_.row(),i_.col())/dk;
}
}
}
}
//Update the shape parameters of Gamma, contextual pf
void update_lambda_s_context(Mat &L_s, SpMat const& X, SpMat const&Lt, SpMat const&Lb, SpMat const&Lb2)
{
double eps = pow(2,-52);
for(int nz = 0;nz<X.outerSize();++nz)
{
for (SpMatiter x_(X,nz); x_; ++x_)
{
double dk = eps;
for(int k = 0;k<Lt.cols();++k){
dk += Lt.coeff(x_.row(),k)*(Lb.coeff(x_.col(),k)+Lb2.coeff(x_.col(),k));
}
for(int k = 0;k<L_s[0].size();++k)
{
L_s[x_.col()][k] += Lt.coeff(x_.row(),k)*Lb.coeff(x_.col(),k)*X.coeff(x_.row(),x_.col())/dk;
}
}
}
}
//Update the shape parameters of Gamma, contextual pf
void update_gamma_s_context_2_n(Mat &L2_s, SpMat const& X, SpMat const& C, SpMat const&Lt,SpMat const&Lb,SpMat const&L2b,SpMat const&L3b, SpMat const&Lb2)
{
double eps = pow(2,-52);
SpMat Lb_u(X.cols(),L2_s[0].size());
for(int i = 0;i<X.cols();++i)
{
for(int k = 0;k<Lt.cols();++k)
{
Lb_u.coeffRef(i,k) = 0.0;
}
for(SpMatiter u_(X, i); u_; ++u_)
{
double dk = eps;
for(int k = 0;k<Lt.cols();++k)
{
dk += Lt.coeff(u_.row(),k)*(Lb.coeff(i,k)+Lb2.coeff(i,k));
}
for(int k = 0;k<Lt.cols();++k)
{
Lb_u.coeffRef(i,k) += X.coeff(u_.row(),i)*Lt.coeff(u_.row(),k)/dk;
}
}
for(SpMatiter j_(C, i); j_; ++j_)
{
for(int k = 0;k<Lt.cols();++k)
{
L2_s[j_.row()][k] += L2b.coeff(j_.row(),k)*L3b.coeff(i,j_.row())*Lb_u.coeff(i,k);
}
}
}
}
void update_gamma_s_context_2_n_r(Mat &L2_s,SpMat const& X, SpMat const& C, SpMat const&Lt, SpMat const&L2b, SpMat const&L3b, SpMat const&Lb2)
{
double eps = pow(2,-52);
SpMat Lb_u(X.cols(),L2_s[0].size());
for(int i = 0;i<X.cols();++i)
{
for(int k = 0;k<Lt.cols();++k)
{
Lb_u.coeffRef(i,k) = 0.0;
}
for(SpMatiter u_(X, i); u_; ++u_)
{
double dk = eps;
for(int k = 0;k<Lt.cols();++k)
{
dk += Lt.coeff(u_.row(),k)*Lb2.coeff(i,k);
}
for(int k = 0;k<Lt.cols();++k)
{
Lb_u.coeffRef(i,k) += X.coeff(u_.row(),i)*Lt.coeff(u_.row(),k)/dk;
}
}
for(SpMatiter j_(C, i); j_; ++j_)
{
for(int k = 0;k<Lt.cols();++k)
{
L2_s[j_.row()][k] += L2b.coeff(j_.row(),k)*L3b.coeff(i,j_.row())*Lb_u.coeff(i,k);
}
}
}
}
//Update the shape parameters of Gamma, contextual pf
void update_gamma_s_context_3_n(SpMat &L3_s, SpMat const& X, SpMat const& C, SpMat const&Lt,SpMat const&Lb,SpMat const&L2b,SpMat const&L3b, SpMat const&Lb2)
{
double eps = pow(2,-52);
SpMat Lb_u(X.cols(),Lt.cols());
for(int i = 0;i<X.cols();++i)
{
for(int k = 0;k<Lt.cols();++k)
{
Lb_u.coeffRef(i,k) = 0.0;
}
for(SpMatiter u_(X,i); u_; ++u_){
double dk = eps;
for(int k = 0;k<Lt.cols();++k)
{
dk += Lt.coeff(u_.row(),k)*(Lb.coeff(i,k)+Lb2.coeff(i,k));
}
for(int k = 0;k<Lt.cols();++k)
{
Lb_u.coeffRef(i,k) += X.coeff(u_.row(),i)*Lt.coeff(u_.row(),k)/dk;
}
}
for(SpMatiter j_(C,i); j_; ++j_)
{
for(int k = 0;k<Lt.cols();++k)
{
L3_s.coeffRef(i,j_.row()) += L2b.coeff(j_.row(),k)*L3b.coeff(i,j_.row())*Lb_u.coeff(i,k);
}
}
}
}
void update_gamma_s_context_3_n_r(SpMat &L3_s,SpMat const& X, SpMat const& C, SpMat const&Lt, SpMat const&L2b, SpMat const&L3b, SpMat const&Lb2)
{
double eps = pow(2,-52);
SpMat Lb_u(X.cols(),Lt.cols());
for(int i = 0;i<X.cols();++i)
{
for(int k = 0;k<Lt.cols();++k)
{
Lb_u.coeffRef(i,k) = 0.0;
}
for(SpMatiter u_(X,i); u_; ++u_)
{
double dk = eps;
for(int k = 0;k<Lt.cols();++k)
{
dk += Lt.coeff(u_.row(),k)*Lb2.coeff(i,k);
}
for(int k = 0;k<Lt.cols();++k)
{
Lb_u.coeffRef(i,k) += X.coeff(u_.row(),i)*Lt.coeff(u_.row(),k)/dk;
}
}
for(SpMatiter j_(C,i); j_; ++j_)
{
for(int k = 0;k<Lt.cols();++k)
{
L3_s.coeffRef(i,j_.row()) += L2b.coeff(j_.row(),k)*L3b.coeff(i,j_.row())*Lb_u.coeff(i,k);
}
}
}
}
//Update the shape parameters of Gamma, contextual pf
void update_gamma_s_context_2(MSpMat &L2_s,MSpMat const& X,MSpMat const& C, SpMat const&Lt,SpMat const&Lb,SpMat const&L2b, SpMat const&Lb2){
double eps = pow(2,-52);
SpMat Lb_u(X.cols(),L2_s.cols());
for(int i = 0;i<X.cols();++i){
for(int k = 0;k<Lt.cols();++k){
Lb_u.coeffRef(i,k) = 0.0;
}
for(InIterMat u_(X, i); u_; ++u_){
double dk = eps;
for(int k = 0;k<Lt.cols();++k){
//Lb_u.coeffRef(i,k) = 0.0;
dk += Lt.coeff(u_.row(),k)*(Lb.coeff(i,k)+Lb2.coeff(i,k));
}
for(int k = 0;k<Lt.cols();++k){
Lb_u.coeffRef(i,k) += X.coeff(u_.row(),i)*Lt.coeff(u_.row(),k)/dk;
}
}
for(InIterMat j_(C, i); j_; ++j_){
for(int k = 0;k<Lt.cols();++k){
L2_s.coeffRef(j_.row(),k) += L2b.coeff(j_.row(),k)*Lb_u.coeff(i,k);
}
}
}
}
//update the Gamma rate parameter, can be used to update Lambda rate parameter as well
void update_gamma_r_context(MSpMat &G_r, MSpMat &L_s,MSpMat &L_r, MSpMat &L2_s,MSpMat &L2_r, MSpMat &C, dVec &K_r, double k_s,double att){
for(int k = 0;k<G_r.cols();++k){
double Sk = 0.0;
for (InIterMat j_(L_r, k); j_; ++j_){
Sk += (L_s.coeff(j_.row(),k)/L_r.coeff(j_.row(),k));
for(InIterMat o_(C, j_.row()); o_; ++o_){
Sk += (L2_s.coeff(o_.row(),k)/L2_r.coeff(o_.row(),k));
}
}
for(int u = 0;u<G_r.rows();++u){
G_r.coeffRef(u,k) = att*k_s/K_r[u] + Sk;
}
}
}
//update the Gamma rate parameter
void update_gamma_r_context_n(Mat &G_r, Mat &L_s, Mat &L_r, Mat &L2_s, Mat &L2_r, SpMat &L3_s, SpMat &L3_r, SpMat &C, double k_s)
{
for(int k = 0;k<G_r[0].size();++k)
{
double Sk = 0.0;
for (int i_ = 0; i_<L_r.size(); ++i_)
{
if (L_r[i_][k]>0.0)
{
Sk += L_s[i_][k]/L_r[i_][k];
for(SpMatiter c_(C, i_); c_; ++c_)
{
Sk += (L2_s[c_.row()][k]/L2_r[c_.row()][k])*(L3_s.coeff(i_,c_.row())/L3_r.coeff(i_,c_.row()));
}
}
}
for(int u = 0;u<G_r.size();++u)
{
G_r[u][k] = k_s + Sk;
}
}
}
void update_gamma_r_context_n_r(Mat &G_r, Mat &L2_s, Mat &L2_r, SpMat &L3_s, SpMat &L3_r, SpMat const&C, double k_s)
{
for(int k = 0;k<G_r[0].size();++k)
{
double Sk = 0.0;
for(int i = 0; i<L2_s.size(); ++i)
{
for(SpMatiter c_(C, i); c_; ++c_)
{
Sk += (L2_s[c_.row()][k]/L2_r[c_.row()][k])*(L3_s.coeff(i,c_.row())/L3_r.coeff(i,c_.row()));
}
}
for(int u = 0;u<G_r.size();++u)
{
G_r[u][k] = k_s + Sk;
}
}
}
//update the Gamma rate parameter, can be used to update Lambda rate parameter as well
void update_gamma_r(Mat &G_r, Mat &L_s, Mat &L_r, double k_s)
{
for(int k = 0;k<G_r[0].size();++k)
{
double Sk = 0.0;
for (int j_ = 0; j_<L_r.size(); ++j_)
{
if(L_r[j_][k]>0.0)
Sk += L_s[j_][k]/L_r[j_][k];
}
for(int i = 0;i<G_r.size();++i)
{
G_r[i][k] = k_s + Sk;
}
}
}
//update the Gamma rate parameter, can be used to update Lambda rate parameter as well
void update_gamma_r_context_2(MSpMat &G_r, MSpMat &L_s,MSpMat &L_r,dVec &K_r, double k_s,dVec c_sum_c,double att){
for(int k = 0;k<G_r.cols();++k){
double Sk = 0.0;
for (InIterMat j_(L_r, k); j_; ++j_){
Sk += L_s.coeff(j_.row(),k)/L_r.coeff(j_.row(),k);
}
for(int i = 0;i<G_r.rows();++i){
G_r.coeffRef(i,k) = att*k_s/K_r[i] + c_sum_c[i]*Sk;
}
}
}
//update the Gamma rate parameter, can be used to update Lambda rate parameter as well
void update_gamma_r_context_2_n(Mat &L2_r, Mat &G_s,Mat &G_r, SpMat &L3_s, SpMat &L3_r, double k_s, SpMat &C)
{
for(int k = 0;k<G_r[0].size();++k)
{
double Sk = 0.0;
for (int u_ = 0; u_<G_r.size(); ++u_)
{
if(G_r[u_][k]>0)
Sk += G_s[u_][k]/G_r[u_][k];
}
for(int j = 0;j<L2_r.size();++j)
{
double Sj = 0.0;
for(SpMatiter i_(C, j); i_; ++i_)
{
Sj += (L3_s.coeff(i_.row(),j)/L3_r.coeff(i_.row(),j));
}
L2_r[j][k] = k_s + Sj*Sk;
}
}
}
//update the Gamma rate parameter, can be used to update Lambda rate parameter as well
void update_gamma_r_context_2_n_tied(Mat &L2_r, Mat &G_s, Mat &G_r, SpMat &L3_s, SpMat &L3_r, double k_s, SpMat &C)
{
update_gamma_r(L2_r,G_s,G_r,k_s);
for(int k = 0;k<G_r[0].size();++k)
{
double Sk = 0.0;
for (int u_ = 0; u_<G_r.size(); ++u_)
{
if(G_r[u_][k]>0)
Sk += G_s[u_][k]/G_r[u_][k];
}
for(int j = 0;j<L2_r.size();++j)
{
double Sj = 0.0;
for(SpMatiter i_(C, j); i_; ++i_)
{
Sj += (L3_s.coeff(i_.row(),j)/L3_r.coeff(i_.row(),j));
}
L2_r[j][k] += Sj*Sk;
}
}
}
// update the Gamma rate parameter, can be used to update Lambda rate parameter as well
void update_gamma_r_context_3_n(SpMat &L3_r, Mat &G_s, Mat &G_r, Mat &L2_s, Mat &L2_r, dVec &K_r, dVec &col_sum, double k_s, SpMat &C, SpMat &X, double att){
dVec Sk(G_r[0].size());
for(int k = 0;k<G_r[0].size();++k)
{
Sk[k] = 0.0;
for(int u_ = 0; u_<X.rows(); ++u_)
{
if(G_r[u_][k]>0.0)
Sk[k] += G_s[u_][k]/G_r[u_][k];
}
}
for(int j = 0;j<C.cols();++j)
{
double Sj = 0.0;
for(int k = 0;k<L2_r[0].size();++k)
{
if(L2_r[j][k]>0.0)
Sj += (L2_s[j][k]/L2_r[j][k])*Sk[k];
}
for(SpMatiter c_(C, j); c_; ++c_)
{
L3_r.coeffRef(c_.row(),j) = att*(k_s+att*col_sum[c_.row()])/K_r[c_.row()] + Sj;
//L3_r.coeffRef(c_.row(),j) =k_s/K_r[c_.row()] + Sj;
}
}
}
// update the Gamma rate parameter, can be used to update Lambda rate parameter as well
void update_gamma_r_context_3_n_2(SpMat &L3_r, Mat &G_s,Mat &G_r, Mat &L2_s, Mat &L2_r, dVec &K_r, dVec &col_sum, double k_s, SpMat &C, SpMat &X)
{
dVec Sk(G_r[0].size());
for(int k = 0;k<G_r[0].size();++k)
{
Sk[k] = 0.0;
for(int u_ = 0; u_<G_r.size(); ++u_)
{
if (G_r[u_][k]>0.0)
Sk[k] += G_s[u_][k]/G_r[u_][k];
}
}
for(int j = 0;j<L2_r.size();++j)
{
double Sj = 0.0;
for(int k = 0;k<L2_r[0].size();++k)
{
if(L2_r[j][k]>0.0)
Sj += (L2_s[j][k]/L2_r[j][k])*Sk[k];
}
for(SpMatiter c_(C, j); c_; ++c_)
{
L3_r.coeffRef(c_.row(),j) =k_s/K_r[c_.row()] + Sj;
}
}
}
void update_kappa_r_inv(dVec &K_r, MSpMat &G_s, MSpMat &G_r,double a_,double b_,double att){
for(int i = 0;i<K_r.size();++i){
double Sk = 0.0;
for(int k = 0;k<G_s.cols();++k){
Sk += G_s.coeff(i,k)/G_r.coeff(i,k);
}
K_r[i] = a_/b_ + att*Sk;
}
}
void update_kappa_r_inv_kappa(dVec &K_r, SpMat &L3_s, SpMat &L3_r, SpMat &C,double a_,double b_,double att){
for(int i = 0;i<L3_r.rows();++i)
{
double Si = 0.0;
for(SpMatiter j_(C, i); j_; ++j_)
{
Si += (L3_s.coeff(i,j_.row())/L3_r.coeff(i,j_.row()));
}
K_r[i] = a_/b_ + att*Si;
}
}
/************* Util functions *************/
void set_coeffs_to(Mat &L_s,double c_)
{
for(int j = 0;j<L_s.size();++j){
for(int k = 0;k<L_s[0].size();++k)
{
L_s[j][k] = c_;
}
}
}
// Set all entries of sparse matrix into a particular value
void set_coeffs_to_sparse(SpMat &L_s, double c_)
{
for(int nz = 0;nz<L_s.outerSize();++nz)
{
for (SpMatiter i_(L_s,nz); i_; ++i_)
{
L_s.coeffRef(i_.row(),i_.col()) = c_;
}
}
}
//Compute the expectation of a Sparse matrix contaning logGamma elements
SpMat E_SpMat_logGamma(Mat const& G_s, Mat const& G_r)
{
SpMat logG_r(G_r.size(),G_r[0].size());
SpMat digaG_s(G_s.size(),G_s[0].size());
for(int u = 0; u<G_s.size();++u)
{
for(int k = 0; k<G_s[0].size();++k)
{
if(G_r[u][k]>0.0)
logG_r.coeffRef(u,k) = G_r[u][k];
if(G_s[u][k]>0.0)
digaG_s.coeffRef(u,k) = G_s[u][k];
}
}
logG_r.prune(0.0);
digaG_s.prune(0.0);
logG_r.coeffs() = logG_r.coeffs().log();
digaG_s.coeffs() = digaG_s.coeffs().digamma();
return (digaG_s - logG_r);
}
SpMat E_SpMat_logGamma(SpMat const& G_s, SpMat const& G_r)
{
SpMat logG_r(G_r.rows(),G_r.cols());
logG_r = G_r;
logG_r.coeffs() = logG_r.coeffs().log();
SpMat digaG_s(G_s.rows(),G_s.cols());
digaG_s = G_s;
digaG_s.coeffs() = digaG_s.coeffs().digamma();
return (digaG_s - logG_r);
}
SpMat triplet_to_csc_sparse(Mat const& M, int n_row, int n_col)
{
SpMat spM(n_row, n_col);
for(int i = 0;i<M.size();++i)
{
spM.coeffRef(M[i][0],M[i][1]) = M[i][2];
}
return spM;
}
void csc_sparse_to_triplet(SpMat const&spM, Mat &M)
{
int i = 0;
for(int nz = 0;nz<spM.outerSize();++nz)
{
for (SpMatiter i_(spM,nz); i_; ++i_)
{
M[i][0] = i_.row();
M[i][1] = i_.col();
M[i][2] = spM.coeff(i_.row(),i_.col());
i+=1;
}
}
}
/*============================================================================================================*/
void c2pf_cpp(Mat const&tX, Mat const&tC, int const&g, Mat &G_s, Mat &G_r, Mat &L_s, Mat &L_r, Mat &L2_s, Mat &L2_r, Mat &tL3_s, Mat &tL3_r, dVec &T3_r, dVec &c_sum_c, dVec &util_sum, int maxiter, double at, double bt)
{
//data shape
int n = G_s.size();
int d = L_s.size();
int d2 = L2_s.size();
//create sparse matrices from triplet
SpMat X = triplet_to_csc_sparse(tX,n,d);
SpMat C = triplet_to_csc_sparse(tC,d,d2);
SpMat L3_s = triplet_to_csc_sparse(tL3_s,d,d2);
SpMat L3_r = triplet_to_csc_sparse(tL3_r,d,d2);
//Hyper parameter setting
double att = 1.0;
double aa = 0.3;
double a_ = 6.;
double a1_ = 5.;
double a_t = at;
double b_t = bt;
double cc = 0.3;
double c1 = 5.;
double c2 = 2.;
double b_ = 1.0;
double d_ = 1.0;
double ee = 0.3;
double e_ = 0.3;
//double k_s = a_ + g*a;
//double t_s = a1 + g*c;
double k_s = aa;
double t_s = aa;
double t2_s = t_s;
//Util variables declaration
SpMat Lt(n,g);
SpMat Lb(d,g);
SpMat L2b(d2,g);
SpMat Lb2(d,g);
SpMat L3b(d,d2);
//Rcout << "c2pf_cpp: " <<std::endl;
update_kappa_r_inv_kappa(T3_r,L3_s,L3_r,C,b_t,b_,a_t);
//Learning
Lt = E_SpMat_logGamma(G_s,G_r);
Lt.coeffs() = Lt.coeffs().exp();
Lb = E_SpMat_logGamma(L_s,L_r);
Lb.coeffs() = Lb.coeffs().exp();
L2b = E_SpMat_logGamma(L2_s,L2_r);
L2b.coeffs() = L2b.coeffs().exp();
L3b = E_SpMat_logGamma(L3_s,L3_r);
L3b.coeffs() = L3b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
for(int iter = 0;iter<maxiter;++iter)
{
///Update item influence factor kappa_ij///
//update Lambda_S for item influence factors
set_coeffs_to_sparse(L3_s,a_t);
update_gamma_s_context_3_n(L3_s,X,C,Lt,Lb,L2b,L3b,Lb2);
//update Lambda_R
//update_gamma_r_context_3_n(L3_r,G_s,G_r,L2_s,L2_r,T3_r,util_sum,b_t,C,X,att);
update_gamma_r_context_3_n(L3_r,G_s,G_r,L2_s,L2_r,T3_r,util_sum,a1_,C,X,a_t);
L3b = E_SpMat_logGamma(L3_s,L3_r);
L3b.coeffs() = L3b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k){
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
update_kappa_r_inv_kappa(T3_r,L3_s,L3_r,C,b_t,b_,a_t);
///Update user related parameters////
//updare Gamma_S
set_coeffs_to(G_s,aa);
update_gamma_s_context(G_s,X,Lt,Lb,Lb2);
//update Gamma_R
update_gamma_r_context_n(G_r,L_s,L_r,L2_s,L2_r,L3_s,L3_r,C,k_s);
Lt = E_SpMat_logGamma(G_s,G_r);
Lt.coeffs() = Lt.coeffs().exp();
///Update item related parameters///
//updare Lambda_S
set_coeffs_to(L_s,cc);
update_lambda_s_context(L_s,X,Lt,Lb,Lb2);
//update Lambda_R
update_gamma_r(L_r,G_s,G_r,t_s);
Lb = E_SpMat_logGamma(L_s,L_r);
Lb.coeffs() = Lb.coeffs().exp();
///Update items' context factors ///
//update Lambda_S for context items
set_coeffs_to(L2_s,ee);
update_gamma_s_context_2_n(L2_s,X,C,Lt,Lb,L2b,L3b,Lb2);
//update Lambda_R
update_gamma_r_context_2_n(L2_r,G_s,G_r,L3_s,L3_r,t2_s,C);
L2b = E_SpMat_logGamma(L2_s,L2_r);
L2b.coeffs() = L2b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
//if((iter%10)==0)
//Rcout << "iter: " << iter <<std::endl;
//////////////////////// End of learning ///////////////////////////
}
//update the triplet matrices, this step is necessary to capture the changes in python
csc_sparse_to_triplet(L3_s, tL3_s);
csc_sparse_to_triplet(L3_r, tL3_r);
//X = NULL;
//C = NULL;
//L3_s = NULL;
//L3_r = NULL;
}
void c2pf_cpp2(Mat const&tX, Mat const&tC, int const&g, Mat &G_s, Mat &G_r, Mat &L_s, Mat &L_r, Mat &L2_s, Mat &L2_r, Mat &tL3_s, Mat &tL3_r, dVec &T3_r, dVec &c_sum_c, dVec &util_sum, int maxiter,double at,double bt)
{
//data shape
int n = G_s.size();
int d = L_s.size();
int d2 = L2_s.size();
//create sparse matrices from triplet
SpMat X = triplet_to_csc_sparse(tX,n,d);
SpMat C = triplet_to_csc_sparse(tC,d,d2);
SpMat L3_s = triplet_to_csc_sparse(tL3_s,d,d2);
SpMat L3_r = triplet_to_csc_sparse(tL3_r,d,d2);
//Hyper parameter setting
double att = 1.0;
double aa = 0.3;
double a_ = 6.;
double a1_ = 5.;
double a_t = at;
double b_t = bt;
double cc = 0.3;
double c1 = 5.;
double c2 = 2.;
double b_ = 1.0;
double d_ = 1.0;
double ee = 0.3;
double e_ = 0.3;
//double k_s = a_ + g*a;
//double t_s = a1 + g*c;
double k_s = aa;
double t_s = aa;
double t2_s = t_s;
//Util variables declaration
SpMat Lt(n,g);
SpMat Lb(d,g);
SpMat L2b(d2,g);
SpMat Lb2(d,g);
SpMat L3b(d,d2);
//update_kappa_r_inv_kappa(T3_r,L3_s,L3_r,C,c2,b_,a_t);
//Learning
Lt = E_SpMat_logGamma(G_s,G_r);
Lt.coeffs() = Lt.coeffs().exp();
Lb = E_SpMat_logGamma(L_s,L_r);
Lb.coeffs() = Lb.coeffs().exp();
L2b = E_SpMat_logGamma(L2_s,L2_r);
L2b.coeffs() = L2b.coeffs().exp();
L3b = E_SpMat_logGamma(L3_s,L3_r);
L3b.coeffs() = L3b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
for(int iter = 0;iter<maxiter;++iter)
{
///Update item influence factor kappa_ij///
//update Lambda_S for item influence factors
set_coeffs_to_sparse(L3_s,a_t);
update_gamma_s_context_3_n(L3_s,X,C,Lt,Lb,L2b,L3b,Lb2);
//update Lambda_R
update_gamma_r_context_3_n_2(L3_r,G_s,G_r,L2_s,L2_r,T3_r,util_sum,b_t,C,X);
//update_gamma_r_context_3_n(L3_r,G_s,G_r,L2_s,L2_r,T3_r,util_sum,a1_,C,X,a_t);
L3b = E_SpMat_logGamma(L3_s,L3_r);
L3b.coeffs() = L3b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
//update_kappa_r_inv_kappa(T3_r,L3_s,L3_r,C,c2,b_,a_t);
///Update user related parameters////
//updare Gamma_S
set_coeffs_to(G_s, aa);
update_gamma_s_context(G_s,X,Lt,Lb,Lb2);
//update Gamma_R
update_gamma_r_context_n(G_r,L_s,L_r,L2_s,L2_r,L3_s,L3_r,C,k_s);
Lt = E_SpMat_logGamma(G_s,G_r);
Lt.coeffs() = Lt.coeffs().exp();
///Update item related parameters///
//updare Lambda_S
set_coeffs_to(L_s,cc);
update_lambda_s_context(L_s,X,Lt,Lb,Lb2);
//update Lambda_R
update_gamma_r(L_r,G_s,G_r,t_s);
Lb = E_SpMat_logGamma(L_s,L_r);
Lb.coeffs() = Lb.coeffs().exp();
///Update items' context factors ///
//update Lambda_S for context items
set_coeffs_to(L2_s,ee);
update_gamma_s_context_2_n(L2_s,X,C,Lt,Lb,L2b,L3b,Lb2);
//update Lambda_R
update_gamma_r_context_2_n(L2_r,G_s,G_r,L3_s,L3_r,t2_s,C);
L2b = E_SpMat_logGamma(L2_s,L2_r);
L2b.coeffs() = L2b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
//////////////////////// End of learning ///////////////////////////
}
//update the triplet matrices, this step is necessary to capture the changes in python
csc_sparse_to_triplet(L3_s, tL3_s);
csc_sparse_to_triplet(L3_r, tL3_r);
}
//tied-C2PF
void tc2pf_cpp(Mat const&tX, Mat const&tC, int const&g, Mat &G_s, Mat &G_r, Mat &L_s, Mat &L_r, Mat &tL3_s, Mat &tL3_r, dVec &T3_r, dVec &c_sum_c, dVec &util_sum, int maxiter, double at, double bt)
{
//data shape
int n = G_s.size();
int d = L_s.size();
int d2 = L_s.size();
//create sparse matrices from triplet
SpMat X = triplet_to_csc_sparse(tX,n,d);
SpMat C = triplet_to_csc_sparse(tC,d,d2);
SpMat L3_s = triplet_to_csc_sparse(tL3_s,d,d2);
SpMat L3_r = triplet_to_csc_sparse(tL3_r,d,d2);
//Hyper parameter setting
double aa = 0.3;
double a_ = 0.3;
double att = 1.;
double a_t = at;
double b_t = bt;
double cc = 0.3;
double c_ = 5.;
double b_ = 1.0;
double d_ = 1.0;
double ee = 0.3;
double k_s = a_;
double t_s = c_;
//double eps = pow(2.0,-52);
//Util variables declaration
SpMat Lt(n,g);
SpMat Lb(d,g);
SpMat Lb2(d,g);
SpMat L3b(d,d2);
//Learning
Lt = E_SpMat_logGamma(G_s,G_r);
Lt.coeffs() = Lt.coeffs().exp();
Lb = E_SpMat_logGamma(L_s,L_r);
Lb.coeffs() = Lb.coeffs().exp();
L3b = E_SpMat_logGamma(L3_s,L3_r);
L3b.coeffs() = L3b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= Lb.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
for(int iter = 0;iter<maxiter;++iter){
///Update item influence factor kappa_ij///
//update Lambda_S for item influence factors
set_coeffs_to_sparse(L3_s,a_t);
update_gamma_s_context_3_n(L3_s,X,C,Lt,Lb,Lb,L3b,Lb2);
//update Lambda_R
update_gamma_r_context_3_n_2(L3_r,G_s,G_r,L_s,L_r,T3_r,util_sum,b_t,C,X);
L3b = E_SpMat_logGamma(L3_s,L3_r);
L3b.coeffs() = L3b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= Lb.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
///Update user related parameters////
//updare Gamma_S
set_coeffs_to(G_s,aa);
update_gamma_s_context(G_s,X,Lt,Lb,Lb2);
//update Gamma_R
update_gamma_r_context_n(G_r,L_s,L_r,L_s,L_r,L3_s,L3_r,C,k_s);
Lt = E_SpMat_logGamma(G_s,G_r);
Lt.coeffs() = Lt.coeffs().exp();
///Update item related parameters///
//updare Lambda_S
set_coeffs_to(L_s,cc);
update_lambda_s_context(L_s,X,Lt,Lb,Lb2);
update_gamma_s_context_2_n(L_s,X,C,Lt,Lb,Lb,L3b,Lb2);
//update Lambda_R
update_gamma_r_context_2_n_tied(L_r,G_s,G_r,L3_s,L3_r,ee,C);
Lb = E_SpMat_logGamma(L_s,L_r);
Lb.coeffs() = Lb.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= Lb.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
//////////////////////// End of learning ///////////////////////////
}
//update the triplet matrices, this step is necessary to capture the changes in python
csc_sparse_to_triplet(L3_s, tL3_s);
csc_sparse_to_triplet(L3_r, tL3_r);
}
//reduced C2PF
void rc2pf_cpp(Mat const&tX, Mat const&tC, int const&g, Mat &G_s, Mat &G_r,Mat &L2_s, Mat &L2_r, Mat tL3_s, Mat tL3_r, dVec &T3_r, dVec &c_sum_c, dVec &util_sum, int maxiter, double at, double bt)
{
//data shape
int n = G_s.size();
int d = L2_s.size();
int d2 = L2_s.size();
//create sparse matrices from triplet
SpMat X = triplet_to_csc_sparse(tX,n,d);
SpMat C = triplet_to_csc_sparse(tC,d,d2);
SpMat L3_s = triplet_to_csc_sparse(tL3_s,d,d2);
SpMat L3_r = triplet_to_csc_sparse(tL3_r,d,d2);
//Hyper parameter setting
double att = 1.0;
double aa = 0.3;
double a_ = 3.;
double a_t = at;
double b_t = bt;
double cc = 0.3;
double c_ = 2.;
double b_ = 1.0;
double d_ = 1.0;
double ee = 0.3;
double e_ = 0.3;
//double k_s = a1 + g*a;
//double t_s = a1 + g*c;
double k_s = aa;
double t_s = cc;
//Util variables declaration
SpMat Lt(n,g);
SpMat L2b(d2,g);
SpMat Lb2(d,g);
SpMat L3b(d,d2);
//Learning
Lt = E_SpMat_logGamma(G_s,G_r);
Lt.coeffs() = Lt.coeffs().exp();
L2b = E_SpMat_logGamma(L2_s,L2_r);
L2b.coeffs() = L2b.coeffs().exp();
L3b = E_SpMat_logGamma(L3_s,L3_r);
L3b.coeffs() = L3b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
for(int iter = 0;iter<maxiter;++iter){
///Update item influence factor kappa_ij///
//update Lambda_S for item influence factors
set_coeffs_to_sparse(L3_s,a_t);
update_gamma_s_context_3_n_r(L3_s,X,C,Lt,L2b,L3b,Lb2);
//update Lambda_R
update_gamma_r_context_3_n_2(L3_r,G_s,G_r,L2_s,L2_r,T3_r,util_sum,b_t,C,X);
//update_gamma_r_context_3_n(L3_r,G_s,G_r,L2_s,L2_r,T3_r,util_sum,a_,C,X,a_t);
//update_kappa_r_inv_kappa(T3_r,L3_s,L3_r,C,c_,b_,at);
L3b = E_SpMat_logGamma(L3_s,L3_r);
L3b.coeffs() = L3b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
///Update user related parameters////
//updare Gamma_S
set_coeffs_to(G_s,aa);
update_gamma_s_context_r(G_s,X,Lt,Lb2);
//update Gamma_R
update_gamma_r_context_n_r(G_r,L2_s,L2_r,L3_s,L3_r,C,k_s);
Lt = E_SpMat_logGamma(G_s,G_r);
Lt.coeffs() = Lt.coeffs().exp();
///Update item related parameters///
//nothing to be done
///Update items' context factors ///
//update Lambda_S for context items
set_coeffs_to(L2_s,ee);
update_gamma_s_context_2_n_r(L2_s,X,C,Lt,L2b,L3b,Lb2);
//update Lambda_R
update_gamma_r_context_2_n(L2_r,G_s,G_r,L3_s,L3_r,t_s,C);
L2b = E_SpMat_logGamma(L2_s,L2_r);
L2b.coeffs() = L2b.coeffs().exp();
//compute agregated statistics of item context
for(int i = 0;i<d;++i)
{
for(int k=0;k<g;++k)
{
Lb2.coeffRef(i,k) = 0.0;
for(SpMatiter c_(C, i); c_; ++c_)
{
Lb2.coeffRef(i,k)+= L2b.coeff(c_.row(),k)*L3b.coeff(i,c_.row());
}
}
}
//////////////////////// End of learning ///////////////////////////
}
//update the triplet matrices, this step is necessary to capture the changes in python
csc_sparse_to_triplet(L3_s, tL3_s);
csc_sparse_to_triplet(L3_r, tL3_r);
} | 27.060914 | 220 | 0.521853 | [
"shape"
] |
40591241f7ae80c48a1bbba35d2c68e9b8f0cdf9 | 8,070 | cpp | C++ | tests/test_toolbox.cpp | miriammenzel/PLImig | d1ef5265368c2902b4fffea69dcaeb253e4c9a97 | [
"MIT"
] | null | null | null | tests/test_toolbox.cpp | miriammenzel/PLImig | d1ef5265368c2902b4fffea69dcaeb253e4c9a97 | [
"MIT"
] | null | null | null | tests/test_toolbox.cpp | miriammenzel/PLImig | d1ef5265368c2902b4fffea69dcaeb253e4c9a97 | [
"MIT"
] | 1 | 2022-02-13T03:59:40.000Z | 2022-02-13T03:59:40.000Z | //
// Created by jreuter on 27.11.20.
//
#include "gtest/gtest.h"
#include <cmath>
#include <memory>
#include <random>
#include "toolbox.h"
// Test function for histogram generation
void f(std::vector<float>& x) {
for(float & i : x) {
i = 10000.0f / (i+1.0f) + 1000.0f * std::pow(2.0f, -i/2.0f + 4.0f);
}
}
TEST(TestToolbox, TestRunCudaChecks) {
ASSERT_TRUE(PLImg::cuda::runCUDAchecks());
}
TEST(TestToolbox, TestHistogramPeakWidth) {
std::vector<float> test_arr = {0, 0, 0.5, 0.75, 0.8, 0.85, 0.9, 1};
cv::Mat test_img(test_arr.size(), 1, CV_32FC1);
test_img.data = (uchar*) test_arr.data();
int width = PLImg::Histogram::peakWidth(test_img, test_img.rows-1, -1);
ASSERT_EQ(width, 5);
test_arr = {1, 0.9, 0.85, 0.8, 0.75, 0.5, 0, 0};
test_img = cv::Mat(test_arr.size(), 1, CV_32FC1);
test_img.data = (uchar*) test_arr.data();
width = PLImg::Histogram::peakWidth(test_img, 0, 1);
ASSERT_EQ(width, 5);
}
TEST(TestToolbox, TestHistogramPlateauLeft) {
auto x = std::vector<float>(256 / 0.01);
for(unsigned long i = 0; i < x.size(); ++i) {
x.at(i) = float(i) * 0.01f;
}
auto y = std::vector<float>(256 / 0.01);
std::copy(x.begin(), x.end(), y.begin());
f(y);
int sum = int(std::accumulate(y.begin(), y.end(), 0.0f));
cv::Mat image(sum, 1, CV_32FC1);
// Fill image with random data
unsigned current_index = 0;
float current_sum = 0;
for(int i = 0; i < image.rows; ++i) {
image.at<float>(i) = x.at(current_index);
++current_sum;
if(current_sum > y.at(current_index)) {
++current_index;
current_sum = 0;
}
}
cv::normalize(image, image, 0, 1, cv::NORM_MINMAX);
// Generate histogram
int channels[] = {0};
float histBounds[] = {0.0f, 1.0f};
const float* histRange = { histBounds };
int histSize = MAX_NUMBER_OF_BINS;
// Generate histogram
cv::Mat hist(MAX_NUMBER_OF_BINS, 1, CV_32FC1);
cv::calcHist(&image, 1, channels, cv::Mat(), hist, 1, &histSize, &histRange, true, false);
cv::normalize(hist, hist, 0.0f, 1.0f, cv::NORM_MINMAX, CV_32FC1);
cv::Mat curvatureVal = PLImg::Histogram::curvature(hist, 0, 1);
int result = std::max_element(curvatureVal.begin<float>(), curvatureVal.begin<float>() + 20) - curvatureVal.begin<float>();
ASSERT_EQ(result, 15);
}
TEST(TestToolbox, TestHistogramPlateauRight) {
auto x = std::vector<float>(256 / 0.01);
for(unsigned long i = 0; i < x.size(); ++i) {
x.at(i) = i * 0.01;
}
auto y = std::vector<float>(256 / 0.01);
std::copy(x.begin(), x.end(), y.begin());
f(y);
int sum = int(std::accumulate(y.begin(), y.end(), 0.0f));
cv::Mat image(sum, 1, CV_32FC1);
// Fill image with random data
unsigned current_index = 0;
float current_sum = 0;
for(int i = 0; i < image.rows; ++i) {
image.at<float>(i) = x.at(current_index);
++current_sum;
if(current_sum > y.at(current_index)) {
++current_index;
current_sum = 0;
}
}
cv::normalize(image, image, 0, 1, cv::NORM_MINMAX);
// Generate histogram
int channels[] = {0};
float histBounds[] = {0.0f, 1.0f};
const float* histRange = { histBounds };
int histSize = MAX_NUMBER_OF_BINS;
// Generate histogram
cv::Mat hist(histSize, 1, CV_32FC1);
cv::calcHist(&image, 1, channels, cv::Mat(), hist, 1, &histSize, &histRange, true, false);
cv::normalize(hist, hist, 0, 1, cv::NORM_MINMAX);
std::reverse(hist.begin<float>(), hist.end<float>());
cv::Mat curvatureVal = PLImg::Histogram::curvature(hist, 0, 1);
int result = std::max_element(curvatureVal.end<float>() - 30, curvatureVal.end<float>()) - curvatureVal.begin<float>();
ASSERT_EQ(result, 240);
}
TEST(TestToolbox, TestImageRegionGrowing) {
cv::Mat test_retardation(100, 100, CV_32FC1);
cv::Mat test_transmittance(100, 100, CV_32FC1);
for(uint i = 0; i < 100; ++i) {
for(uint j = 0; j < 100; ++j) {
if(i > 10 && i < 20 && j > 10 && j < 15) {
test_retardation.at<float>(i, j) = 0.975f;
test_transmittance.at<float>(i, j) = 0.3456f;
} else {
test_retardation.at<float>(i, j) = 0.0f;
test_transmittance.at<float>(i, j) = 0.0f;
}
}
}
cv::Mat mask = PLImg::cuda::labeling::largestAreaConnectedComponents(test_retardation, cv::Mat());
for(uint i = 11; i < 20; ++i) {
for(uint j = 11; j < 15; ++j) {
ASSERT_TRUE(mask.at<bool>(i, j));
}
}
ASSERT_FLOAT_EQ(cv::mean(test_transmittance, mask)[0], 0.3456);
}
TEST(TestToolbox, TestMedianFilter) {
auto testImage = cv::imread("../../tests/files/median_filter/median_input.tiff", cv::IMREAD_ANYDEPTH);
auto expectedResult = cv::imread("../../tests/files/median_filter/median_"+std::to_string(MEDIAN_KERNEL_SIZE)+"_expected_result.tiff", cv::IMREAD_ANYDEPTH);
auto testImagePtr = std::make_shared<cv::Mat>(testImage);
auto medianFilterPtr = PLImg::cuda::filters::medianFilter(testImagePtr);
for(int i = 0; i < expectedResult.rows; ++i) {
for(int j = 0; j < expectedResult.cols; ++j) {
ASSERT_FLOAT_EQ(medianFilterPtr->at<float>(i, j), expectedResult.at<float>(i, j));
}
}
}
TEST(TestToolbox, TestMedianFilterMasked) {
// Not implemented yet!
ASSERT_TRUE(true);
}
TEST(TestToolbox, TestConnectedComponents) {
uint maxNumber;
cv::Mat exampleMask = (cv::Mat1s(7, 11) <<
1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1,
0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1,
1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1,
0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1);
exampleMask.convertTo(exampleMask, CV_8UC1);
cv::Mat resultMask = (cv::Mat1s(7, 11) <<
2, 2, 2, 0, 0, 0, 5, 0, 1, 1, 0,
2, 0, 0, 0, 4, 0, 5, 5, 0, 0, 0,
0, 0, 4, 4, 4, 0, 5, 0, 3, 3, 3,
0, 0, 4, 4, 4, 0, 5, 0, 0, 0, 0,
6, 0, 0, 0, 0, 0, 5, 0, 7, 0, 7,
6, 6, 6, 6, 6, 0, 0, 0, 7, 7, 7,
0, 0, 6, 6, 6, 0, 0, 0, 7, 7, 7);
resultMask.convertTo(resultMask, CV_32SC1);
cv::Mat result = PLImg::cuda::raw::labeling::CUDAConnectedComponents(exampleMask, &maxNumber);
cv::imwrite("output.tiff", result);
for(int x = 0; x < resultMask.cols; ++x) {
for(int y = 0; y < resultMask.rows; ++y) {
ASSERT_EQ(result.at<int>(y, x), resultMask.at<int>(y, x)) << x << "," << y;
}
}
ASSERT_EQ(maxNumber, 7);
}
TEST(TestToolbox, TestConnectedComponentsUF) {
uint maxNumber;
cv::Mat exampleMask = (cv::Mat1s(7, 11) <<
1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1,
0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1,
1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1,
0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1);
exampleMask.convertTo(exampleMask, CV_8UC1);
cv::Mat resultMask = (cv::Mat1s(7, 11) <<
1, 1, 1, 0, 0, 0, 2, 0, 2, 2, 0,
1, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0,
0, 0, 3, 3, 3, 0, 2, 0, 2, 2, 2,
0, 0, 3, 3, 3, 0, 2, 0, 0, 0, 0,
4, 0, 0, 0, 0, 0, 2, 0, 5, 0, 5,
4, 4, 4, 4, 4, 0, 0, 0, 5, 5, 5,
0, 0, 4, 4, 4, 0, 0, 0, 5, 5, 5);
resultMask.convertTo(resultMask, CV_32SC1);
cv::Mat result = PLImg::cuda::raw::labeling::CUDAConnectedComponentsUF(exampleMask, &maxNumber);
for(int x = 0; x < resultMask.cols; ++x) {
for(int y = 0; y < resultMask.rows; ++y) {
ASSERT_EQ(result.at<int>(y, x), resultMask.at<int>(y, x)) << x << "," << y;
}
}
ASSERT_EQ(maxNumber, 6);
}
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| 34.635193 | 160 | 0.543866 | [
"vector"
] |
4066836a54c827cecc6d1c9305e8f08143ef764b | 2,874 | cc | C++ | analytical_engine/java/grape-runtime/src/main/native/ffi_byte_vec_vector.cc | wuyueandrew/GraphScope | 9e2d77d83378f85f001b555d06e4dcbf9a6a4260 | [
"Apache-2.0"
] | 1 | 2021-12-30T02:55:16.000Z | 2021-12-30T02:55:16.000Z | analytical_engine/java/grape-runtime/src/main/native/ffi_byte_vec_vector.cc | lnfjpt/GraphScope | 917146f86d8387302a2e1de6963115e7568bf3ee | [
"Apache-2.0"
] | null | null | null | analytical_engine/java/grape-runtime/src/main/native/ffi_byte_vec_vector.cc | lnfjpt/GraphScope | 917146f86d8387302a2e1de6963115e7568bf3ee | [
"Apache-2.0"
] | null | null | null | /** Copyright 2020 Alibaba Group Holding Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef ENABLE_JAVA_SDK
#include <jni.h>
#include <new>
#include <string>
#include <vector>
#include "core/java/type_alias.h"
#ifdef __cplusplus
extern "C" {
#endif
// Common Stubs
// This file contains neccessary code enableing porting a
// std::vector<std::vector<char>> to a java byte vecvector, We don't generate
// these jni files since the generated Java FFIByteVector class has been
// modified for optimization.
JNIEXPORT
void JNICALL Java_com_alibaba_graphscope_stdcxx_FFIByteVecVector_nativeClear(
JNIEnv*, jclass, jlong ptr) {
reinterpret_cast<std::vector<std::vector<char>>*>(ptr)->clear();
}
JNIEXPORT
void JNICALL Java_com_alibaba_graphscope_stdcxx_FFIByteVecVector_nativeDelete(
JNIEnv*, jclass, jlong ptr) {
delete reinterpret_cast<std::vector<std::vector<char>>*>(ptr);
}
JNIEXPORT
void JNICALL
Java_com_alibaba_graphscope_stdcxx_FFIByteVecVector_nativePush_1back(
JNIEnv*, jclass, jlong ptr, jlong arg0 /* arg00 */) {
reinterpret_cast<std::vector<std::vector<char>>*>(ptr)->push_back(
*reinterpret_cast<std::vector<char>*>(arg0));
}
JNIEXPORT
void JNICALL Java_com_alibaba_graphscope_stdcxx_FFIByteVecVector_nativeReserve(
JNIEnv*, jclass, jlong ptr, jlong arg0 /* arg00 */) {
reinterpret_cast<std::vector<std::vector<char>>*>(ptr)->reserve(arg0);
}
JNIEXPORT
void JNICALL Java_com_alibaba_graphscope_stdcxx_FFIByteVecVector_nativeResize(
JNIEnv*, jclass, jlong ptr, jlong arg0 /* arg00 */) {
reinterpret_cast<std::vector<std::vector<char>>*>(ptr)->resize(arg0);
}
JNIEXPORT
void JNICALL Java_com_alibaba_graphscope_stdcxx_FFIByteVecVector_nativeSet(
JNIEnv*, jclass, jlong ptr, jlong arg0 /* arg00 */,
jlong arg1 /* arg11 */) {
(*reinterpret_cast<std::vector<std::vector<char>>*>(ptr))[arg0] =
*reinterpret_cast<std::vector<char>*>(arg1);
}
JNIEXPORT
jlong JNICALL Java_com_alibaba_graphscope_stdcxx_FFIByteVecVector_nativeSize(
JNIEnv*, jclass, jlong ptr) {
return (jlong)(
reinterpret_cast<std::vector<std::vector<char>>*>(ptr)->size());
}
JNIEXPORT
jlong JNICALL
Java_com_alibaba_graphscope_stdcxx_FFIByteVecVector_nativeCreateFactory0(
JNIEnv*, jclass) {
return reinterpret_cast<jlong>(new std::vector<std::vector<char>>());
}
#ifdef __cplusplus
}
#endif
#endif
| 31.933333 | 79 | 0.753653 | [
"vector"
] |
406f2ae224ff1be9dd6ca63bc17c676ec5835e78 | 4,676 | cpp | C++ | src/Resistor.cpp | coldlogix/JoSIM | 7b48068682b4e7bc459a5e9982d67571fac60885 | [
"MIT"
] | null | null | null | src/Resistor.cpp | coldlogix/JoSIM | 7b48068682b4e7bc459a5e9982d67571fac60885 | [
"MIT"
] | null | null | null | src/Resistor.cpp | coldlogix/JoSIM | 7b48068682b4e7bc459a5e9982d67571fac60885 | [
"MIT"
] | null | null | null | // Copyright (c) 2019 Johannes Delport
// This code is licensed under MIT license (see LICENSE for details)
#include "JoSIM/Resistor.hpp"
#include "JoSIM/Misc.hpp"
#include "JoSIM/Errors.hpp"
#include "JoSIM/Constants.hpp"
#include <utility>
using namespace JoSIM;
Resistor Resistor::create_resistor(
const std::pair<std::string, std::string> &s,
const std::unordered_map<std::string, int> &nm,
std::unordered_set<std::string> &lm,
std::vector<std::vector<std::pair<double, int>>> &nc,
const std::unordered_map<ParameterName, Parameter> &p,
const AnalysisType &antyp,
const double ×tep,
int &branchIndex) {
std::vector<std::string> tokens = Misc::tokenize_space(s.first);
Resistor temp;
temp.set_label(tokens.at(0), lm);
if(s.first.find("{") != std::string::npos) {
if(s.first.find("}") != std::string::npos) {
tokens.at(3) = s.first.substr(s.first.find("{")+1, s.first.find("}") - s.first.find("{"));
} else {
Errors::invalid_component_errors(ComponentErrors::INVALID_EXPR, s.first);
}
}
temp.set_value(std::make_pair(tokens.at(3), s.second), p, antyp, timestep);
temp.set_nonZeros_and_columnIndex(std::make_pair(tokens.at(1), tokens.at(2)), nm, s.first, branchIndex);
temp.set_indices(std::make_pair(tokens.at(1), tokens.at(2)), nm, nc, branchIndex);
temp.set_currentIndex(branchIndex - 1);
return temp;
}
void Resistor::set_label(const std::string &s, std::unordered_set<std::string> &lm) {
if(lm.count(s) != 0) {
Errors::invalid_component_errors(ComponentErrors::DUPLICATE_LABEL, s);
} else {
label_ = s;
lm.emplace(s);
}
}
void Resistor::set_nonZeros_and_columnIndex(const std::pair<std::string, std::string> &n, const std::unordered_map<std::string, int> &nm, const std::string &s, int &branchIndex) {
nonZeros_.clear();
columnIndex_.clear();
if(n.first != "0" && n.first.find("GND") == std::string::npos) {
if(nm.count(n.first) == 0) Errors::netlist_errors(NetlistErrors::NO_SUCH_NODE, n.first);
}
if(n.second != "0" && n.second.find("GND") == std::string::npos) {
if(nm.count(n.second) == 0) Errors::netlist_errors(NetlistErrors::NO_SUCH_NODE, n.second);
}
if(n.second.find("GND") != std::string::npos || n.second == "0") {
// 0 0
if(n.first.find("GND") != std::string::npos || n.first == "0") {
Errors::invalid_component_errors(ComponentErrors::BOTH_GROUND, s);
nonZeros_.emplace_back(-value_);
rowPointer_.emplace_back(1);
branchIndex++;
columnIndex_.emplace_back(branchIndex - 1);
// 1 0
} else {
nonZeros_.emplace_back(1);
nonZeros_.emplace_back(-value_);
rowPointer_.emplace_back(2);
branchIndex++;
columnIndex_.emplace_back(nm.at(n.first));
columnIndex_.emplace_back(branchIndex - 1);
}
// 0 1
} else if(n.first.find("GND") != std::string::npos || n.first == "0") {
nonZeros_.emplace_back(-1);
nonZeros_.emplace_back(-value_);
rowPointer_.emplace_back(2);
branchIndex++;
columnIndex_.emplace_back(nm.at(n.second));
columnIndex_.emplace_back(branchIndex - 1);
// 1 1
} else {
nonZeros_.emplace_back(1);
nonZeros_.emplace_back(-1);
nonZeros_.emplace_back(-value_);
rowPointer_.emplace_back(3);
branchIndex++;
columnIndex_.emplace_back(nm.at(n.first));
columnIndex_.emplace_back(nm.at(n.second));
columnIndex_.emplace_back(branchIndex - 1);
}
}
void Resistor::set_indices(const std::pair<std::string, std::string> &n, const std::unordered_map<std::string, int> &nm, std::vector<std::vector<std::pair<double, int>>> &nc, const int &branchIndex) {
if(n.second.find("GND") != std::string::npos || n.second == "0") {
posIndex_ = nm.at(n.first);
nc.at(nm.at(n.first)).emplace_back(std::make_pair(1, branchIndex - 1));
} else if(n.first.find("GND") != std::string::npos || n.first == "0") {
negIndex_ = nm.at(n.second);
nc.at(nm.at(n.second)).emplace_back(std::make_pair(-1, branchIndex - 1));
} else {
posIndex_ = nm.at(n.first);
negIndex_ = nm.at(n.second);
nc.at(nm.at(n.first)).emplace_back(std::make_pair(1, branchIndex - 1));
nc.at(nm.at(n.second)).emplace_back(std::make_pair(-1, branchIndex - 1));
}
}
void Resistor::set_value(const std::pair<std::string, std::string> &s,
const std::unordered_map<ParameterName, Parameter> &p,
const AnalysisType &antyp, const double ×tep) {
if (antyp == AnalysisType::Voltage) value_ = parse_param(s.first, p, s.second);
else if (antyp == AnalysisType::Phase) value_ = (timestep/(2 * Constants::SIGMA)) * parse_param(s.first, p, s.second);
} | 40.310345 | 200 | 0.656116 | [
"vector"
] |
40704896b7d34c403d93fc51aba8332b8a57951b | 656 | cpp | C++ | 0108_Convert_Sorted_Array_to_Binary_Search_Tree/solution.cpp | Heliovic/LeetCode_Solutions | 73d5a7aaffe62da9a9cd8a80288b260085fda08f | [
"MIT"
] | 2 | 2019-02-18T15:32:57.000Z | 2019-03-18T12:55:35.000Z | 0108_Convert_Sorted_Array_to_Binary_Search_Tree/solution.cpp | Heliovic/LeetCode_Solutions | 73d5a7aaffe62da9a9cd8a80288b260085fda08f | [
"MIT"
] | null | null | null | 0108_Convert_Sorted_Array_to_Binary_Search_Tree/solution.cpp | Heliovic/LeetCode_Solutions | 73d5a7aaffe62da9a9cd8a80288b260085fda08f | [
"MIT"
] | null | null | null | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode* construct(vector<int>& nums, int lp, int rp)
{
if (lp > rp)
return NULL;
int mid = (lp + rp) / 2;
TreeNode* r = new TreeNode(nums[mid]);
r->left = construct(nums, lp, mid - 1);
r->right = construct(nums, mid + 1, rp);
return r;
}
TreeNode* sortedArrayToBST(vector<int>& nums) {
return construct(nums, 0, nums.size() - 1);
}
};
| 23.428571 | 59 | 0.519817 | [
"vector"
] |
407e1c5eb5719f8bf19a1b6df1cbcade5b0c28b4 | 5,278 | cpp | C++ | src/Main/App/txn_handler.cpp | yoni-wolf/private-tranaction-families | 7203818e903720a789d95a9a5c0c1f3a7eea2cfb | [
"Apache-2.0"
] | null | null | null | src/Main/App/txn_handler.cpp | yoni-wolf/private-tranaction-families | 7203818e903720a789d95a9a5c0c1f3a7eea2cfb | [
"Apache-2.0"
] | null | null | null | src/Main/App/txn_handler.cpp | yoni-wolf/private-tranaction-families | 7203818e903720a789d95a9a5c0c1f3a7eea2cfb | [
"Apache-2.0"
] | null | null | null | /* Copyright 2018 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 <ctype.h>
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
#include "../build/proto/transaction.pb.h"
#include "exceptions.h"
#include "txn_handler.h"
#include "config.h"
#include "PrivateLedger.h"
#ifdef SGX_ENCLAVE
#include "enclave_log.h"
#else
#include "app_log.h"
#endif
#include "Enclave_u.h"
#include "ecall_wrapper.h"
extern sgx_enclave_id_t eid;
namespace txn_handler
{
sawtooth::GlobalStateUPtr contextPtr;
// utility function to provide copy conversion from stl string container
// that contains hex as string, to a vector of bytes.
std::vector<uint8_t> ToHexVector(const std::string &in)
{
unsigned int str_size = in.length();
for (unsigned int i = 0; i < str_size; i++)
{
if (!isxdigit(in[i]))
{
PRINT(ERROR, LISTENER, "ToHexVector accepts only hex characters\n");
return std::vector<uint8_t>();
}
}
std::vector<uint8_t> out;
out.reserve(str_size / 2);
for (unsigned int i = 0; i < str_size; i += 2)
{
out.push_back(0xff & std::stoi(in.substr(i, 2), nullptr, 16));
}
return out;
}
//---------------------------------------------------------
// PrivateApplicator
//---------------------------------------------------------
PrivateApplicator::PrivateApplicator(sawtooth::TransactionUPtr txn,
sawtooth::GlobalStateUPtr state) : TransactionApplicator(std::move(txn), std::move(state)) {}
void PrivateApplicator::Apply()
{
PRINT(INFO, LISTENER, "PrivateApplicator::Apply started\n");
//set current context
contextPtr = std::move(this->state);
// get transaction details
auto serialized_header = this->txn->header()->GetSerializedHeader();
auto nonce = this->txn->header()->GetValue(sawtooth::TransactionHeaderField::TransactionHeaderNonce);
auto pub_key = this->txn->header()->GetValue(sawtooth::TransactionHeaderField::TransactionHeaderSignerPublicKey);
auto payload_hash = this->txn->header()->GetValue(sawtooth::TransactionHeaderField::TransactionHeaderPayloadSha512);
auto signature = this->txn->signature();
auto payload = this->txn->payload();
std::vector<uint8_t> header_vec(serialized_header.begin(), serialized_header.end());
std::vector<uint8_t> signature_vec = ToHexVector(signature);
std::vector<uint8_t> payload_hash_vec = ToHexVector(payload_hash);
std::vector<uint8_t> payload_vec(payload.begin(), payload.end());
if (pub_key.size() != PUB_KEY_BYTE_LENGTH * 2 && pub_key.size() != UNCOMPRESSED_PUB_KEY_BYTE_LENGTH * 2)
{
throw sawtooth::InvalidTransaction(" signer public key size is not 33 or 67 bytes");
}
if (signature_vec.size() != 64)
{
throw sawtooth::InvalidTransaction(" signature size is not 64 bytes");
}
if (payload_hash_vec.size() != 64)
{
throw sawtooth::InvalidTransaction(" payload hash size is not 64 bytes");
}
sgx_status_t ret_val;
if (SGX_SUCCESS != ecall_wrapper(secure_apply, eid, &ret_val,
header_vec.data(),
header_vec.size(),
nonce.c_str(),
pub_key.c_str(),
signature_vec.data(),
payload_hash_vec.data(),
payload_vec.data(),
payload_vec.size()) ||
SGX_SUCCESS != ret_val)
{
std::string err_str(" Error while handling transaction, sgx error code is ");
err_str.append(std::to_string(ret_val));
throw sawtooth::InvalidTransaction(err_str);
}
PRINT(INFO, LISTENER, "PrivateApplicator::Apply completed\n");
}
//---------------------------------------------------------
// PrivateHandler
//---------------------------------------------------------
PrivateHandler::PrivateHandler() : namespacePrefix(config::get_prefix()) {}
PrivateHandler::~PrivateHandler()
{
}
std::string PrivateHandler::transaction_family_name() const
{
return config::get_namespace();
}
std::list<std::string> PrivateHandler::versions() const
{
return {config::get_version()};
}
std::list<std::string> PrivateHandler::namespaces() const
{
return {namespacePrefix};
}
sawtooth::TransactionApplicatorUPtr PrivateHandler::GetApplicator(
sawtooth::TransactionUPtr txn,
sawtooth::GlobalStateUPtr state)
{
return sawtooth::TransactionApplicatorUPtr(
new PrivateApplicator(std::move(txn), std::move(state)));
}
} // namespace txn_handler
| 35.422819 | 130 | 0.622205 | [
"vector"
] |
4080508fe689e14b37caee69965737e920e5b718 | 667 | hh | C++ | psdaq/drp/Wave8.hh | slac-lcls/pdsdata2 | 6e2ad4f830cadfe29764dbd280fa57f8f9edc451 | [
"BSD-3-Clause-LBNL"
] | null | null | null | psdaq/drp/Wave8.hh | slac-lcls/pdsdata2 | 6e2ad4f830cadfe29764dbd280fa57f8f9edc451 | [
"BSD-3-Clause-LBNL"
] | null | null | null | psdaq/drp/Wave8.hh | slac-lcls/pdsdata2 | 6e2ad4f830cadfe29764dbd280fa57f8f9edc451 | [
"BSD-3-Clause-LBNL"
] | null | null | null | #pragma once
#include "BEBDetector.hh"
#include "xtcdata/xtc/Xtc.hh"
#include "xtcdata/xtc/NamesId.hh"
#include "psalg/alloc/Allocator.hh"
namespace Drp {
class Wave8 : public BEBDetector
{
public:
Wave8(Parameters* para, MemPool* pool);
nlohmann::json connectionInfo() override;
private:
unsigned _configure(XtcData::Xtc&, const void* bufEnd, XtcData::ConfigIter&) override;
void _event (XtcData::Xtc&, const void* bufEnd,
std::vector< XtcData::Array<uint8_t> >&) override;
private:
XtcData::NamesId m_evtNamesRaw;
XtcData::NamesId m_evtNamesFex;
Heap m_allocator;
};
}
| 25.653846 | 96 | 0.655172 | [
"vector"
] |
40871620d072290c7a3a90f80bc62ded7f2688ef | 706 | cpp | C++ | Leetcode - Top Interview Questions/986. Interval List Intersections.cpp | kothariji/Competitive-Programming | c49f8b0135c8e9dd284ce8ab583e85ba3d809b8c | [
"MIT"
] | 1 | 2020-08-27T06:59:52.000Z | 2020-08-27T06:59:52.000Z | Leetcode - Top Interview Questions/986. Interval List Intersections.cpp | kothariji/Competitive-Programming | c49f8b0135c8e9dd284ce8ab583e85ba3d809b8c | [
"MIT"
] | null | null | null | Leetcode - Top Interview Questions/986. Interval List Intersections.cpp | kothariji/Competitive-Programming | c49f8b0135c8e9dd284ce8ab583e85ba3d809b8c | [
"MIT"
] | null | null | null | //link to Question->https://leetcode.com/problems/interval-list-intersections/
//solution
class Solution {
public:
vector<vector<int>> intervalIntersection(vector<vector<int>>& firstList, vector<vector<int>>& secondList) {
vector<vector<int>> v;
int i=0;
int j=0;
while(i<firstList.size() && j<secondList.size()){
int x=max(firstList[i][0],secondList[j][0]);
int y=min(firstList[i][1],secondList[j][1]);
if(x<=y){
v.push_back({x,y});
}
if(firstList[i][1]<secondList[j][1]){
i++;
}
else{
j++;
}
}
return v;
}
}; | 29.416667 | 111 | 0.492918 | [
"vector"
] |
4088bb523d0cf640cd63b266410287421fe8fd5f | 1,969 | cpp | C++ | 1480-C.cpp | ankiiitraj/questionsSolved | 8452b120935a9c3d808b45f27dcdc05700d902fc | [
"MIT"
] | null | null | null | 1480-C.cpp | ankiiitraj/questionsSolved | 8452b120935a9c3d808b45f27dcdc05700d902fc | [
"MIT"
] | 1 | 2020-02-24T19:45:57.000Z | 2020-02-24T19:45:57.000Z | 1480-C.cpp | ankiiitraj/questionsSolved | 8452b120935a9c3d808b45f27dcdc05700d902fc | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define mem(a, x) memset(a, x, sizeof a)
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/*
----------------------------------------------------------------------
Things to remember : check for coners n = 1, pass references instead
*/
/* -------------------------------Solution Sarted--------------------------------------*/
//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5
const int INF = 100000000000005; // 1e15 +5
vi a;
int bs(int low, int high, int n)
{
int mid = low + (high - low)/2, idx;
if(a[mid] == -1){
cout <<"? " << mid << endl;
cin >> idx;
a[mid] = idx;
}
int a1, a0;
if(a[mid -1] == -1){
cout <<"? " << mid -1 << endl;
cin >> a0;
a[mid -1] = a0;
}
if(a[mid +1] == -1){
cout <<"? " << mid +1 << endl;
cin >> a1;
a[mid +1] = a1;
}
if(a[mid] < a[mid +1] and a[mid] < a[mid -1]) return mid;
else if (mid > 0 && a[mid -1] < a[mid]) return bs(low, (mid -1), n);
return bs((mid + 1), high, n);
}
void solve(){
int n;
cin >> n;
a = vi(n +2, -1);
a[0] = a[n +1] = INF;
int idx = bs(0, n +1, n +1);
cout << "! " << idx << endl;
return;
}
signed main()
{
faster;
// #ifndef ONLINE_JUDGE
// freopen("ip.txt", "r", stdin);
// freopen("op.txt", "w", stdout);
// #endif
// int t; cin >> t; while(t--)
solve();
return 0;
}
//Problem Link :
/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs
dfs
fenwik - BIT
binary_search
segment_tree
*/
| 20.726316 | 89 | 0.524632 | [
"vector"
] |
408aa3d05043e3a70c33b1ae82f8558346d36c93 | 23,360 | cpp | C++ | external/openglcts/modules/gles31/es31cShaderImageSizeTests.cpp | iabernikhin/VK-GL-CTS | a3338eb2ded98b5befda64f9325db0d219095a00 | [
"Apache-2.0"
] | 354 | 2017-01-24T17:12:38.000Z | 2022-03-30T07:40:19.000Z | external/openglcts/modules/gles31/es31cShaderImageSizeTests.cpp | iabernikhin/VK-GL-CTS | a3338eb2ded98b5befda64f9325db0d219095a00 | [
"Apache-2.0"
] | 275 | 2017-01-24T20:10:36.000Z | 2022-03-24T16:24:50.000Z | external/openglcts/modules/gles31/es31cShaderImageSizeTests.cpp | iabernikhin/VK-GL-CTS | a3338eb2ded98b5befda64f9325db0d219095a00 | [
"Apache-2.0"
] | 190 | 2017-01-24T18:02:04.000Z | 2022-03-27T13:11:23.000Z | /*-------------------------------------------------------------------------
* OpenGL Conformance Test Suite
* -----------------------------
*
* Copyright (c) 2014-2016 The Khronos Group Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/ /*!
* \file
* \brief
*/ /*-------------------------------------------------------------------*/
#include "es31cShaderImageSizeTests.hpp"
#include "gluContextInfo.hpp"
#include "glwEnums.hpp"
#include "tcuMatrix.hpp"
#include "tcuRenderTarget.hpp"
#include "tcuVectorUtil.hpp"
#include <assert.h>
#include <cstdarg>
namespace glcts
{
using namespace glw;
namespace
{
typedef tcu::Vec2 vec2;
typedef tcu::Vec3 vec3;
typedef tcu::Vec4 vec4;
typedef tcu::IVec4 ivec4;
typedef tcu::UVec4 uvec4;
const char* const kGLSLVer =
"#version 310 es\n" NL "precision highp float;" NL "precision highp int;" NL "precision highp image2D;" NL
"precision highp image3D;" NL "precision highp imageCube;" NL "precision highp image2DArray;" NL
"precision highp iimage2D;" NL "precision highp iimage3D;" NL "precision highp iimageCube;" NL
"precision highp iimage2DArray;" NL "precision highp uimage2D;" NL "precision highp uimage3D;" NL
"precision highp uimageCube;" NL "precision highp uimage2DArray;";
class ShaderImageSizeBase : public glcts::SubcaseBase
{
public:
virtual std::string Title()
{
return NL "";
}
virtual std::string Purpose()
{
return NL "";
}
virtual std::string Method()
{
return NL "";
}
virtual std::string PassCriteria()
{
return NL "";
}
bool IsVSFSAvailable(int requiredVS, int requiredFS)
{
GLint imagesVS, imagesFS;
glGetIntegerv(GL_MAX_VERTEX_IMAGE_UNIFORMS, &imagesVS);
glGetIntegerv(GL_MAX_FRAGMENT_IMAGE_UNIFORMS, &imagesFS);
if (imagesVS >= requiredVS && imagesFS >= requiredFS)
return true;
else
{
std::ostringstream reason;
reason << "Required " << requiredVS << " VS storage blocks but only " << imagesVS << " available."
<< std::endl
<< "Required " << requiredFS << " FS storage blocks but only " << imagesFS << " available."
<< std::endl;
OutputNotSupported(reason.str());
return false;
}
}
};
template <typename T>
std::string ImageTypePrefix();
template <>
std::string ImageTypePrefix<vec4>()
{
return "";
}
template <>
std::string ImageTypePrefix<ivec4>()
{
return "i";
}
template <>
std::string ImageTypePrefix<uvec4>()
{
return "u";
}
template <typename T>
std::string ImageFormatPostfix();
template <>
std::string ImageFormatPostfix<vec4>()
{
return "f";
}
template <>
std::string ImageFormatPostfix<ivec4>()
{
return "i";
}
template <>
std::string ImageFormatPostfix<uvec4>()
{
return "ui";
}
template <typename T>
GLenum TexInternalFormat();
template <>
GLenum TexInternalFormat<vec4>()
{
return GL_RGBA32F;
}
template <>
GLenum TexInternalFormat<ivec4>()
{
return GL_RGBA32I;
}
template <>
GLenum TexInternalFormat<uvec4>()
{
return GL_RGBA32UI;
}
template <typename T>
GLenum TexType();
template <typename T>
GLenum TexFormat();
//=============================================================================
// ImageSizeMachine
//-----------------------------------------------------------------------------
class ImageSizeMachine : public glcts::GLWrapper
{
GLuint m_pipeline;
GLuint m_program[3];
GLuint m_vertex_array;
GLuint m_buffer;
bool pipeline;
GLuint m_xfb_id;
bool CheckProgram(GLuint program)
{
if (program == 0)
return true;
GLint status;
glGetProgramiv(program, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
{
GLint attached_shaders;
glGetProgramiv(program, GL_ATTACHED_SHADERS, &attached_shaders);
if (attached_shaders > 0)
{
std::vector<GLuint> shaders(attached_shaders);
glGetAttachedShaders(program, attached_shaders, NULL, &shaders[0]);
for (GLint i = 0; i < attached_shaders; ++i)
{
GLenum type;
glGetShaderiv(shaders[i], GL_SHADER_TYPE, reinterpret_cast<GLint*>(&type));
switch (type)
{
case GL_VERTEX_SHADER:
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "*** Vertex Shader ***" << tcu::TestLog::EndMessage;
break;
case GL_FRAGMENT_SHADER:
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "*** Fragment Shader ***" << tcu::TestLog::EndMessage;
break;
case GL_COMPUTE_SHADER:
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "*** Compute Shader ***" << tcu::TestLog::EndMessage;
break;
default:
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "*** Unknown Shader ***" << tcu::TestLog::EndMessage;
break;
}
GLint length;
glGetShaderiv(shaders[i], GL_SHADER_SOURCE_LENGTH, &length);
if (length > 0)
{
std::vector<GLchar> source(length);
glGetShaderSource(shaders[i], length, NULL, &source[0]);
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << &source[0] << tcu::TestLog::EndMessage;
}
glGetShaderiv(shaders[i], GL_INFO_LOG_LENGTH, &length);
if (length > 0)
{
std::vector<GLchar> log(length);
glGetShaderInfoLog(shaders[i], length, NULL, &log[0]);
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << &log[0] << tcu::TestLog::EndMessage;
}
}
}
GLint length;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
if (length > 0)
{
std::vector<GLchar> log(length);
glGetProgramInfoLog(program, length, NULL, &log[0]);
m_context.getTestContext().getLog() << tcu::TestLog::Message << &log[0] << tcu::TestLog::EndMessage;
}
}
return status == GL_TRUE ? true : false;
}
bool CompileShader(GLuint shader)
{
glCompileShader(shader);
GLint status;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE)
{
GLsizei length;
GLchar log[1024];
glGetShaderInfoLog(shader, sizeof(log), &length, log);
if (length > 1)
{
m_context.getTestContext().getLog() << tcu::TestLog::Message << "Shader Info Log:\n"
<< log << tcu::TestLog::EndMessage;
}
return false;
}
return true;
}
bool LinkProgram(GLuint program)
{
glLinkProgram(program);
GLint status;
glGetProgramiv(program, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
{
GLsizei length;
GLchar log[1024];
glGetProgramInfoLog(program, sizeof(log), &length, log);
if (length > 1)
{
m_context.getTestContext().getLog() << tcu::TestLog::Message << "Program Info Log:\n"
<< log << tcu::TestLog::EndMessage;
}
return false;
}
return true;
}
GLuint CreateComputeProgram(const std::string& cs)
{
const GLuint p = glCreateProgram();
if (!cs.empty())
{
const GLuint sh = glCreateShader(GL_COMPUTE_SHADER);
glAttachShader(p, sh);
glDeleteShader(sh);
const char* const src[2] = { kGLSLVer, cs.c_str() };
glShaderSource(sh, 2, src, NULL);
if (!CompileShader(sh))
{
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << src[0] << src[1] << tcu::TestLog::EndMessage;
return p;
}
}
if (!LinkProgram(p))
{
if (!cs.empty())
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << kGLSLVer << cs << tcu::TestLog::EndMessage;
return p;
}
return p;
}
GLuint BuildProgram(const char* src_vs, const char* src_fs, bool use_xfb, bool* result = NULL)
{
const GLuint p = glCreateProgram();
if (src_vs)
{
GLuint sh = glCreateShader(GL_VERTEX_SHADER);
glAttachShader(p, sh);
glDeleteShader(sh);
const char* const src[2] = { kGLSLVer, src_vs };
glShaderSource(sh, 2, src, NULL);
if (!CompileShader(sh))
{
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << src[0] << src[1] << tcu::TestLog::EndMessage;
if (result)
*result = false;
return p;
}
}
if (src_fs)
{
GLuint sh = glCreateShader(GL_FRAGMENT_SHADER);
glAttachShader(p, sh);
glDeleteShader(sh);
const char* const src[2] = { kGLSLVer, src_fs };
glShaderSource(sh, 2, src, NULL);
if (!CompileShader(sh))
{
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << src[0] << src[1] << tcu::TestLog::EndMessage;
if (result)
*result = false;
return p;
}
}
if (use_xfb)
SetupTransformFeedback(p);
if (!LinkProgram(p))
{
if (src_vs)
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << kGLSLVer << src_vs << tcu::TestLog::EndMessage;
if (src_fs)
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << kGLSLVer << src_fs << tcu::TestLog::EndMessage;
if (result)
*result = false;
return p;
}
return p;
}
void SetupTransformFeedback(GLuint program)
{
const char* const varying_name = "count";
glTransformFeedbackVaryings(program, 1, &varying_name, GL_INTERLEAVED_ATTRIBS);
}
inline bool Equal(const ivec4& result, const ivec4& expected)
{
if (expected[0] != result[0])
return false;
if (expected[1] != result[1])
return false;
if (expected[2] != result[2])
return false;
if (expected[3] != result[3])
return false;
return true;
}
template <typename T>
std::string GenShader(int stage)
{
std::ostringstream os;
os << NL "#define KSIZE 4";
if (stage == 0)
{ // VS uses transform feedback
os << NL "flat out ivec4 count[KSIZE];";
}
else
{ // CS + FS use SSBO
os << NL "layout(std430) buffer OutputBuffer {" NL " ivec4 count[KSIZE];" NL "};";
}
os << NL "layout(binding = 0, rgba32" << ImageFormatPostfix<T>() << ") readonly writeonly uniform highp "
<< ImageTypePrefix<T>() << "image2D g_image_2d;" NL "layout(binding = 1, rgba32" << ImageFormatPostfix<T>()
<< ") readonly writeonly uniform highp " << ImageTypePrefix<T>()
<< "image3D g_image_3d;" NL "layout(binding = 2, rgba32" << ImageFormatPostfix<T>()
<< ") readonly writeonly uniform highp " << ImageTypePrefix<T>()
<< "imageCube g_image_cube;" NL "layout(binding = 3, rgba32" << ImageFormatPostfix<T>()
<< ") readonly writeonly uniform highp " << ImageTypePrefix<T>() << "image2DArray g_image_2d_array;";
if (stage == 0)
{ // VS
os << NL "void main() {" NL " int coord = gl_VertexID;" NL "#ifdef GL_ES" NL " gl_PointSize = 1.0;" NL
"#endif";
}
else if (stage == 4)
{ // CS
os << NL "layout(local_size_x = 1) in;" NL "void main() {" NL " int coord = int(gl_GlobalInvocationID.x);";
}
else if (stage == 5)
{ // FS
os << NL "uniform int fakePrimitiveID;" NL "void main() {" NL " int coord = fakePrimitiveID;";
}
os << NL " count[coord + 0] = ivec4(imageSize(g_image_2d), 0, 0);" NL
" count[coord + 1] = ivec4(imageSize(g_image_3d), 0);" NL
" count[coord + 2] = ivec4(imageSize(g_image_cube), 0, 0);" NL
" count[coord + 3] = ivec4(imageSize(g_image_2d_array), 0);" NL "}";
return os.str();
}
public:
ImageSizeMachine() : pipeline(false)
{
if (pipeline)
glGenProgramPipelines(1, &m_pipeline);
memset(m_program, 0, sizeof(m_program));
glGenVertexArrays(1, &m_vertex_array);
glGenBuffers(1, &m_buffer);
glGenTransformFeedbacks(1, &m_xfb_id);
}
~ImageSizeMachine()
{
if (pipeline)
{
glDeleteProgramPipelines(1, &m_pipeline);
for (int i = 0; i < 3; ++i)
glDeleteProgram(m_program[i]);
}
else
{
glDeleteProgram(m_program[0]);
}
glDeleteVertexArrays(1, &m_vertex_array);
glDeleteBuffers(1, &m_buffer);
glDeleteTransformFeedbacks(1, &m_xfb_id);
}
template <typename T>
long Run(int stage, ivec4 expected_result[4])
{
const int kSize = 4;
if (stage == 0)
{ // VS
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, m_xfb_id);
const char* const glsl_fs = NL "void main() {" NL " discard;" NL "}";
std::string vs = GenShader<T>(stage);
const char* const glsl_vs = vs.c_str();
if (pipeline)
{
m_program[0] = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &glsl_vs);
m_program[1] = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &glsl_fs);
glUseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, m_program[0]);
glUseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, m_program[1]);
}
else
{
m_program[0] = BuildProgram(glsl_vs, glsl_fs, true);
}
}
else if (stage == 4)
{ // CS
std::string cs = GenShader<T>(stage);
const char* const glsl_cs = cs.c_str();
if (pipeline)
{
m_program[0] = glCreateShaderProgramv(GL_COMPUTE_SHADER, 1, &glsl_cs);
glUseProgramStages(m_pipeline, GL_COMPUTE_SHADER_BIT, m_program[0]);
}
else
{
m_program[0] = CreateComputeProgram(glsl_cs);
}
}
else if (stage == 5)
{ // FS
const char* const glsl_vs =
NL "layout(location = 0) in vec4 i_position;" NL "void main() {" NL " gl_Position = i_position;" NL
"#ifdef GL_ES" NL " gl_PointSize = 1.0;" NL "#endif" NL "}";
std::string fs = GenShader<T>(stage);
const char* const glsl_fs = fs.c_str();
if (pipeline)
{
m_program[0] = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &glsl_vs);
m_program[1] = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &glsl_fs);
glUseProgramStages(m_pipeline, GL_VERTEX_SHADER_BIT, m_program[0]);
glUseProgramStages(m_pipeline, GL_FRAGMENT_SHADER_BIT, m_program[1]);
}
else
{
m_program[0] = BuildProgram(glsl_vs, glsl_fs, false);
}
}
if (!CheckProgram(m_program[0]))
return ERROR;
if (pipeline)
if (!CheckProgram(m_program[1]))
return ERROR;
ivec4 data[kSize];
for (int i = 0; i < kSize; ++i)
data[i] = ivec4(100000);
GLenum output_buffer_type = (stage == 0) ? GL_TRANSFORM_FEEDBACK_BUFFER : GL_SHADER_STORAGE_BUFFER;
glBindBufferBase(output_buffer_type, 0, m_buffer);
glBufferData(output_buffer_type, kSize * 4 * 4, &data[0], GL_STATIC_DRAW);
if (pipeline)
glBindProgramPipeline(m_pipeline);
else
glUseProgram(m_program[0]);
glBindVertexArray(m_vertex_array);
if (stage == 0)
glBeginTransformFeedback(GL_POINTS);
if (stage == 4)
glDispatchCompute(1, 1, 1);
else
glDrawArrays(GL_POINTS, 0, 1);
glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
if (stage == 0)
glEndTransformFeedback();
ivec4* map_data = (ivec4*)glMapBufferRange(output_buffer_type, 0, kSize * 4 * 4, GL_MAP_READ_BIT);
for (int i = 0; i < kSize; ++i)
{
if (!Equal(map_data[i], expected_result[i]))
{
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "Returned value is: (" << map_data[i][0] << " " << map_data[i][1] << " "
<< map_data[i][2] << " " << map_data[i][3] << "). Expected value is: (" << expected_result[i][0]
<< " " << expected_result[i][1] << " " << expected_result[i][2] << " " << expected_result[i][3]
<< "). Image unit is: " << i << tcu::TestLog::EndMessage;
return ERROR;
}
}
glUnmapBuffer(output_buffer_type);
if (stage == 0)
glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
return NO_ERROR;
}
};
//=============================================================================
// 1.1.x.y BasicNonMS
//-----------------------------------------------------------------------------
template <typename T, int STAGE>
class BasicNonMS : public ShaderImageSizeBase
{
GLuint m_texture[4];
virtual long Setup()
{
glGenTextures(4, m_texture);
return NO_ERROR;
}
virtual long Run()
{
if (STAGE == 0 && !IsVSFSAvailable(4, 0))
return NOT_SUPPORTED;
if (STAGE == 5 && !IsVSFSAvailable(0, 4))
return NOT_SUPPORTED;
const GLenum target[4] = { GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_2D_ARRAY };
for (int i = 0; i < 4; ++i)
{
glBindTexture(target[i], m_texture[i]);
glTexParameteri(target[i], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target[i], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (i == 0)
{
glTexStorage2D(target[i], 10, TexInternalFormat<T>(), 512, 128);
glBindImageTexture(0, m_texture[i], 1, GL_FALSE, 0, GL_READ_ONLY, TexInternalFormat<T>());
}
else if (i == 1)
{
glTexStorage3D(target[i], 3, TexInternalFormat<T>(), 8, 8, 4);
glBindImageTexture(1, m_texture[i], 0, GL_TRUE, 0, GL_READ_ONLY, TexInternalFormat<T>());
}
else if (i == 2)
{
glTexStorage2D(target[i], 4, TexInternalFormat<T>(), 16, 16);
glBindImageTexture(2, m_texture[i], 0, GL_TRUE, 0, GL_READ_WRITE, TexInternalFormat<T>());
}
else if (i == 3)
{
glTexStorage3D(target[i], 3, TexInternalFormat<T>(), 127, 39, 12);
glBindImageTexture(3, m_texture[i], 2, GL_TRUE, 0, GL_READ_ONLY, TexInternalFormat<T>());
}
}
ImageSizeMachine machine;
ivec4 res[4] = { ivec4(256, 64, 0, 0), ivec4(8, 8, 4, 0), ivec4(16, 16, 0, 0), ivec4(31, 9, 12, 0) };
return machine.Run<T>(STAGE, res);
}
virtual long Cleanup()
{
glDeleteTextures(4, m_texture);
return NO_ERROR;
}
};
//=============================================================================
// 2.2.x.y AdvancedNonMS
//-----------------------------------------------------------------------------
template <typename T, int STAGE>
class AdvancedNonMS : public ShaderImageSizeBase
{
GLuint m_texture[4];
virtual long Setup()
{
glGenTextures(4, m_texture);
return NO_ERROR;
}
virtual long Run()
{
if (STAGE == 0 && !IsVSFSAvailable(4, 0))
return NOT_SUPPORTED;
if (STAGE == 5 && !IsVSFSAvailable(0, 4))
return NOT_SUPPORTED;
const GLenum target[4] = { GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_2D_ARRAY };
for (int i = 0; i < 4; ++i)
{
glBindTexture(target[i], m_texture[i]);
glTexParameteri(target[i], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target[i], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (i == 0)
{
glTexStorage3D(target[i], 2, TexInternalFormat<T>(), 2, 2, 7);
glBindImageTexture(0, m_texture[i], 1, GL_FALSE, 3, GL_READ_ONLY, TexInternalFormat<T>());
}
else if (i == 1)
{
glTexStorage3D(target[i], 3, TexInternalFormat<T>(), 4, 4, 2);
glBindImageTexture(1, m_texture[i], 1, GL_TRUE, 0, GL_READ_ONLY, TexInternalFormat<T>());
}
else if (i == 2)
{
glTexStorage2D(target[i], 2, TexInternalFormat<T>(), 2, 2);
glBindImageTexture(2, m_texture[i], 0, GL_TRUE, 0, GL_READ_WRITE, TexInternalFormat<T>());
}
else if (i == 3)
{
glTexStorage3D(target[i], 4, TexInternalFormat<T>(), 13, 7, 4);
glBindImageTexture(3, m_texture[i], 1, GL_TRUE, 0, GL_READ_ONLY, TexInternalFormat<T>());
}
}
ImageSizeMachine machine;
ivec4 res[4] = { ivec4(1, 1, 0, 0), ivec4(2, 2, 1, 0), ivec4(2, 2, 0, 0), ivec4(6, 3, 4, 0) };
return machine.Run<T>(STAGE, res);
}
virtual long Cleanup()
{
glDeleteTextures(4, m_texture);
return NO_ERROR;
}
};
//=============================================================================
// 4.1 NegativeCompileTime
//-----------------------------------------------------------------------------
class NegativeCompileTime : public ShaderImageSizeBase
{
virtual long Run()
{
if (!Compile( // imagesize return type check
"#version 310 es" NL "precision highp float;" NL "precision highp int;" NL
"layout(local_size_x = 1) in;" NL "layout(r32f) uniform image2D g_image;" NL
"layout(std430) buffer OutputBuffer { vec4 g_color; };" NL "void main() {" NL
" if (imageSize(g_image) == ivec3(5)) g_color = vec4(0, 1, 0, 1);" NL
" else g_color = vec4(1, 0, 0, 1);" NL "}"))
{
return ERROR;
}
if (!Compile( // imageSize(samplertype)
"#version 310 es" NL "precision highp float;" NL "precision highp int;" NL
"layout(local_size_x = 1) in;" NL "layout(r32f) uniform sampler2D g_image;" NL
"layout(std430) buffer OutputBuffer { vec4 g_color; };" NL "void main() {" NL
" if (imageSize(g_image) == ivec2(5)) g_color = vec4(0, 1, 0, 1);" NL
" else g_color = vec4(1, 0, 0, 1);" NL "}"))
{
return ERROR;
}
return NO_ERROR;
}
bool Compile(const std::string& source)
{
const GLuint sh = glCreateShader(GL_COMPUTE_SHADER);
const char* const src = source.c_str();
glShaderSource(sh, 1, &src, NULL);
glCompileShader(sh);
GLchar log[1024];
glGetShaderInfoLog(sh, sizeof(log), NULL, log);
m_context.getTestContext().getLog() << tcu::TestLog::Message << "Shader Info Log:\n"
<< log << tcu::TestLog::EndMessage;
GLint status;
glGetShaderiv(sh, GL_COMPILE_STATUS, &status);
glDeleteShader(sh);
if (status == GL_TRUE)
{
m_context.getTestContext().getLog()
<< tcu::TestLog::Message << "Compilation should fail." << tcu::TestLog::EndMessage;
return false;
}
return true;
}
};
} // anonymous namespace
ShaderImageSizeTests::ShaderImageSizeTests(glcts::Context& context) : TestCaseGroup(context, "shader_image_size", "")
{
}
ShaderImageSizeTests::~ShaderImageSizeTests(void)
{
}
void ShaderImageSizeTests::init()
{
using namespace glcts;
addChild(new TestSubcase(m_context, "basic-nonMS-vs-float", TestSubcase::Create<BasicNonMS<vec4, 0> >));
addChild(new TestSubcase(m_context, "basic-nonMS-vs-int", TestSubcase::Create<BasicNonMS<ivec4, 0> >));
addChild(new TestSubcase(m_context, "basic-nonMS-vs-uint", TestSubcase::Create<BasicNonMS<uvec4, 0> >));
addChild(new TestSubcase(m_context, "basic-nonMS-fs-float", TestSubcase::Create<BasicNonMS<vec4, 5> >));
addChild(new TestSubcase(m_context, "basic-nonMS-fs-int", TestSubcase::Create<BasicNonMS<ivec4, 5> >));
addChild(new TestSubcase(m_context, "basic-nonMS-fs-uint", TestSubcase::Create<BasicNonMS<uvec4, 5> >));
addChild(new TestSubcase(m_context, "basic-nonMS-cs-float", TestSubcase::Create<BasicNonMS<vec4, 4> >));
addChild(new TestSubcase(m_context, "basic-nonMS-cs-int", TestSubcase::Create<BasicNonMS<ivec4, 4> >));
addChild(new TestSubcase(m_context, "basic-nonMS-cs-uint", TestSubcase::Create<BasicNonMS<uvec4, 4> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-vs-float", TestSubcase::Create<AdvancedNonMS<vec4, 0> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-vs-int", TestSubcase::Create<AdvancedNonMS<ivec4, 0> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-vs-uint", TestSubcase::Create<AdvancedNonMS<uvec4, 0> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-fs-float", TestSubcase::Create<AdvancedNonMS<vec4, 5> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-fs-int", TestSubcase::Create<AdvancedNonMS<ivec4, 5> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-fs-uint", TestSubcase::Create<AdvancedNonMS<uvec4, 5> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-cs-float", TestSubcase::Create<AdvancedNonMS<vec4, 4> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-cs-int", TestSubcase::Create<AdvancedNonMS<ivec4, 4> >));
addChild(new TestSubcase(m_context, "advanced-nonMS-cs-uint", TestSubcase::Create<AdvancedNonMS<uvec4, 4> >));
addChild(new TestSubcase(m_context, "negative-compileTime", TestSubcase::Create<NegativeCompileTime>));
}
}
| 30.259067 | 117 | 0.641695 | [
"vector",
"transform"
] |
408ebd7690b276e0b33afebec80b35cba8165ac3 | 5,962 | cpp | C++ | Tests/tests.cpp | Diego999/Artificial-Neural-Network | 58e207501f37473fa161a46cd8e03e6b9bd24e5b | [
"MIT"
] | 2 | 2015-02-11T18:48:49.000Z | 2018-03-24T03:48:04.000Z | Tests/tests.cpp | Diego999/Artificial-Neural-Network | 58e207501f37473fa161a46cd8e03e6b9bd24e5b | [
"MIT"
] | null | null | null | Tests/tests.cpp | Diego999/Artificial-Neural-Network | 58e207501f37473fa161a46cd8e03e6b9bd24e5b | [
"MIT"
] | null | null | null | #include "tests.h"
#include "../NeuralNetwork/artificialneuralnetwork.h"
#include "../NeuralNetwork/anncontroller.h"
#include "../Utils/utils.h"
#include <string>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <utility>
struct TestSet{
std::string op;
double input1, input2;
double target;
};
void testsANN()
{
std::vector<TestSet> testSets;
testSets.push_back(TestSet{"AND",0,0,0.1});
testSets.push_back(TestSet{"AND",0,1,0.1});
testSets.push_back(TestSet{"AND",1,0,0.1});
testSets.push_back(TestSet{"AND",1,1,0.9});
testSets.push_back(TestSet{"NAND",0,0,0.9});
testSets.push_back(TestSet{"NAND",0,1,0.9});
testSets.push_back(TestSet{"NAND",1,0,0.9});
testSets.push_back(TestSet{"NAND",1,1,0.1});
testSets.push_back(TestSet{"OR",0,0,0.1});
testSets.push_back(TestSet{"OR",0,1,0.9});
testSets.push_back(TestSet{"OR",1,0,0.9});
testSets.push_back(TestSet{"OR",1,1,0.9});
testSets.push_back(TestSet{"NOR",0,0,0.9});
testSets.push_back(TestSet{"NOR",0,1,0.1});
testSets.push_back(TestSet{"NOR",1,0,0.1});
testSets.push_back(TestSet{"NOR",1,1,0.1});
testSets.push_back(TestSet{"XOR",0,0,0.1});
testSets.push_back(TestSet{"XOR",0,1,0.9});
testSets.push_back(TestSet{"XOR",1,0,0.9});
testSets.push_back(TestSet{"XOR",1,1,0.1});
testSets.push_back(TestSet{"NXOR",0,0,0.9});
testSets.push_back(TestSet{"NXOR",0,1,0.1});
testSets.push_back(TestSet{"NXOR",1,0,0.1});
testSets.push_back(TestSet{"NXOR",1,1,0.9});
int k = 0;
for(size_t i = 0; i < testSets.size(); i+=4)
{
ArtificialNeuralNetwork ann(2, 1, {3}, 0.1, 0.1);
double err = 0;
size_t j = 0;
k=0;
do
{
j = 0;
err = 0;
while(j++<4)
{
TestSet ts = testSets[i+j%4];
err += ann.train({ts.input1, ts.input2}, {ts.target});
}
++k;
}while(err >= 0.001);
for(j = i; j < i+4; ++j)
{
TestSet ts = testSets[j];
double out = ann.feedForward({ts.input1, ts.input2})[0];
std::cout << static_cast<int>(ts.input1) << " " << ts.op << " " << static_cast<int>(ts.input2) << " -> " << out << " (" << ts.target << ")" << std::endl;
assert(fabs(out-ts.target) < 0.4);
}
std::cout << "Error : " << err << std::endl << "iterations " << k << std::endl << std::endl;
}
}
void testsANNController()
{
std::string filepath = "testsANNController.ann";
std::vector<std::pair<std::vector<double>, std::vector<double>>> testSets;
testSets.push_back({{0,0},{0.1}});
testSets.push_back({{0,1},{0.9}});
testSets.push_back({{1,0},{0.9}});
testSets.push_back({{1,1},{0.1}});
ANNController* annc = new ANNController({3}, 0.5, 0.5,testSets, testSets);
annc->error(0.01);
std::cout << "Lambda function: " << std::endl;
std::function<void(long, double, double)> callback = [&](long iteration, double trainingError, double testingError)
{
std::cout << "iteration: " << iteration << " " << trainingError << " - " << testingError << std::endl;
};
std::function<void(void)> didFinish = [&](void)
{
std::cout << "[Training finished]" << std::endl;
};
std::vector<std::vector<double>> validationSets;
validationSets.push_back({0,0});
validationSets.push_back({0,1});
validationSets.push_back({1,0});
validationSets.push_back({1,1});
annc->train(callback, didFinish);
annc->exportANN(filepath);
for(auto& result : annc->feedForward(validationSets))
std::cout << result[0] << std::endl;
ANNController* annc2 = new ANNController(filepath);
for(auto& result : annc2->feedForward(validationSets))
std::cout << result[0] << std::endl;
std::cout << annc->log();
std::cout << annc2->log();
delete annc;
delete annc2;
}
void testMergeVector()
{
std::vector<int> v({1,2,3,4,5,6,7,8,9,10});
std::vector<std::vector<int>> v2({{11,12}, {13,14}, {15, 16, 17, 18, 19}, {20}});
ann_utils::mergeVectors(v, v2);
for(int i = 0; i < 20; ++i)
assert(v[i] == (i+1));
}
void testCreateSubSamples()
{
for(int s = 1; s <= 20; ++s)
{
std::vector<int> sets;
for(int ss = 1; ss <= s; ++ss)
sets.push_back(ss);
for(int k = 1; k <= s; ++k)
{
int i = 1;
for(auto& v:ann_utils::createSubSamples(sets, k))
{
assert(v.size() < 2*(sets.size()/k));
for(auto& vv:v)
assert(vv == i++);
}
}
}
}
void testKFoldCrossValidation()
{
std::vector<std::pair<std::vector<double>, std::vector<double>>> trainingSet;
trainingSet.push_back(std::pair<std::vector<double>, std::vector<double>>({0.0, 0.0}, {0.1}));
trainingSet.push_back(std::pair<std::vector<double>, std::vector<double>>({1.0, 1.0}, {0.1}));
std::vector<std::pair<std::vector<double>, std::vector<double>>> validationSet;
validationSet.push_back(std::pair<std::vector<double>, std::vector<double>>({1.0, 0.0}, {0.9}));
validationSet.push_back(std::pair<std::vector<double>, std::vector<double>>({0.0, 1.0}, {0.9}));
ANNController ann({3}, 0.1, 0.1, trainingSet, validationSet);
ann.kFoldCrossValidation(
[&](long i, std::vector<double> &errT, std::vector<double>& errV)
{
auto it1 = errT.begin();
auto it2 = errV.begin();
while(it1 != errT.end() && it2 != errV.end())
{
std::cout << i << " " << *it1 << " " << *it2 << std::endl;
++it1;
++it2;
}
},
[&](long i, double err)
{
std::cout << "\t" << i << " " << err << std::endl << std::endl;
},
2,
[&]()
{
std::cout << "Has finished" << std::endl;
}
);
}
| 31.378947 | 165 | 0.549648 | [
"vector"
] |
4090b22051295ef346d904874b89373f69d15613 | 2,462 | hpp | C++ | src/percept/function/internal/GenericFunction.hpp | jrood-nrel/percept | 363cdd0050443760d54162f140b2fb54ed9decf0 | [
"BSD-2-Clause"
] | 3 | 2017-08-08T21:06:02.000Z | 2020-01-08T13:23:36.000Z | src/percept/function/internal/GenericFunction.hpp | jrood-nrel/percept | 363cdd0050443760d54162f140b2fb54ed9decf0 | [
"BSD-2-Clause"
] | 2 | 2016-12-17T00:18:56.000Z | 2019-08-09T15:29:25.000Z | src/percept/function/internal/GenericFunction.hpp | jrood-nrel/percept | 363cdd0050443760d54162f140b2fb54ed9decf0 | [
"BSD-2-Clause"
] | 2 | 2017-11-30T07:02:41.000Z | 2019-08-05T17:07:04.000Z | // Copyright 2002 - 2008, 2010, 2011 National Technology Engineering
// Solutions of Sandia, LLC (NTESS). Under the terms of Contract
// DE-NA0003525 with NTESS, the U.S. Government retains certain rights
// in this software.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef stk_encr_GenericFunction_hpp
#define stk_encr_GenericFunction_hpp
#include <iostream>
#include <percept/function/MDArray.hpp>
#include <percept/function/internal/Dimensions.hpp>
namespace percept
{
class GenericFunction
{
public:
GenericFunction(Dimensions domain_dimensions = Dimensions(),
Dimensions codomain_dimensions = Dimensions()) :
m_domain_dimensions(domain_dimensions),
m_codomain_dimensions(codomain_dimensions), m_spatialOperator(false)
{
}
virtual ~GenericFunction() {}
/** Evaluate the function on it's domain returning result in codomain.
*/
virtual void operator()(MDArray& domain, MDArray& codomain, double time = 0.0)=0;
bool isSpatialOperator() { return m_spatialOperator; }
void setIsSpatialOperator(bool so) { m_spatialOperator=so; }
Dimensions getDomainDimensions() {return m_domain_dimensions; }
Dimensions getCodomainDimensions() { return m_codomain_dimensions; }
MDArray getNewDomain()
{
return Intrepid::FieldContainer<double>( Teuchos::Array<int>(m_domain_dimensions.begin(), m_domain_dimensions.end()));
}
MDArray getNewCodomain()
{
return Intrepid::FieldContainer<double>( Teuchos::Array<int>(m_codomain_dimensions.begin(), m_codomain_dimensions.end()));
}
MDArray getNewCodomain() const
{
return Intrepid::FieldContainer<double>( Teuchos::Array<int>(m_codomain_dimensions.begin(), m_codomain_dimensions.end()));
}
static MDArray getNewMDArray(const Dimensions dims)
{
return Intrepid::FieldContainer<double>( Teuchos::Array<int>(dims.begin(), dims.end()));
}
protected:
Dimensions m_domain_dimensions; // size() gives rank, each entry gives dimension, e.g. {3,3} for a rank-2 3D tensor
Dimensions m_codomain_dimensions;
bool m_spatialOperator;
};
#ifndef SWIG
std::ostream &operator<<(std::ostream& out, GenericFunction& func);
#endif
//class NodalOp : public GenericFunction {};
}
#endif
| 34.676056 | 131 | 0.689683 | [
"3d"
] |
40911408e7d713443e3b8e7030002f9b806a96a6 | 3,644 | cpp | C++ | engine/source/editor/ui/common/widgets/EnginePerformanceMonitor.cpp | yhyu13/Engine2021 | 6ded548caa45bf980d88e09bed59431b61f5337e | [
"MIT"
] | null | null | null | engine/source/editor/ui/common/widgets/EnginePerformanceMonitor.cpp | yhyu13/Engine2021 | 6ded548caa45bf980d88e09bed59431b61f5337e | [
"MIT"
] | null | null | null | engine/source/editor/ui/common/widgets/EnginePerformanceMonitor.cpp | yhyu13/Engine2021 | 6ded548caa45bf980d88e09bed59431b61f5337e | [
"MIT"
] | null | null | null | #include "engine-precompiled-header.h"
#include "EnginePerformanceMonitor.h"
#include "../BaseEngineWidgetManager.h"
#include <imgui/addons/implot/implot.h>
longmarch::EnginePerformanceMonitor::EnginePerformanceMonitor()
{
m_IsVisible = true;
m_Size = ScaleSize({ 500, 400 });
}
void longmarch::EnginePerformanceMonitor::Render()
{
WIDGET_TOGGLE(KEY_F11);
WIDGET_EARLY_QUIT();
// this is rendered in a table format
// col#1 col#2
// |------------|-------------------------------------------|
// |FPS | | // row#1
// | | graph widgets here occupy both rows |
// |FRAME TIME | | // row#2
// |--------------------------------------------------------|
auto manager = ServiceLocator::GetSingleton<BaseEngineWidgetManager>(ENG_WIG_MAN_NAME);
manager->PushWidgetStyle();
static bool showFPS = false;
static bool showFrameTime = false;
float frameTime = FramerateController::GetInstance()->GetFrameTime();
float frameRate = (1.0f / frameTime);
ImGui::Begin("Engine Performance");
ImGui::Columns(2); // table has two columns
ImGui::SetColumnWidth(-1, 220); // width of the first column
// column#1 | row#1 - starts
if (ImGui::RadioButton("##FPS", showFPS == true))
{
showFPS = true;
showFrameTime = false;
}
ImGui::SameLine();
ImGui::Text("FRAME RATE: %.2f fps", frameRate);
// column#1 | row#1 - ends
ImGui::Text(""); // spacing between two adjacent rows
// column#1 | row#2 - starts
if (ImGui::RadioButton("##FrameTime", showFrameTime == true))
{
showFrameTime = true;
showFPS = false;
}
ImGui::SameLine();
ImGui::Text("FRAME TIME: %.2f ms", frameTime * 1e3);
// column#1 | row#2 - ends
ImGui::NextColumn(); // next column starts here
// both graphs widgets occupy both rows (2nd column has only one row or rows are merged)
{
static ScrollingBuffer buffer;
static float t = 0;
t += ImGui::GetIO().DeltaTime;
buffer.AddPoint(t, frameRate);
if (showFPS) // render FPS
{
static float history = 10.0f;
ImGui::SliderFloat("History", &history, 1, 30, "%.1f s");
static ImPlotAxisFlags rt_axis = ImPlotAxisFlags_NoTickLabels;
ImPlot::SetNextPlotLimitsX(t - history, t, ImGuiCond_Always);
ImPlot::SetNextPlotLimitsY(0, 120);
if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, ImVec2(-1, 200), 0, ImPlotAxisFlags_NoTickLabels, ImPlotAxisFlags_LockMin)) {
ImPlot::PlotLine("FPS", &buffer.Data[0].x, &buffer.Data[0].y, buffer.Data.size(), buffer.Offset, 2 * sizeof(float));
ImPlot::EndPlot();
}
}
}
{
static ScrollingBuffer buffer;
static float t = 0;
t += ImGui::GetIO().DeltaTime;
buffer.AddPoint(t, frameTime * 1e3);
if (showFrameTime) // render frame-time
{
static float history = 10.0f;
ImGui::SliderFloat("History", &history, 1, 30, "%.1f s");
static ImPlotAxisFlags rt_axis = ImPlotAxisFlags_NoTickLabels;
ImPlot::SetNextPlotLimitsX(t - history, t, ImGuiCond_Always);
ImPlot::SetNextPlotLimitsY(0, 60);
if (ImPlot::BeginPlot("##Scrolling", NULL, NULL, ImVec2(-1, 200), 0, ImPlotAxisFlags_NoTickLabels, ImPlotAxisFlags_LockMin)) {
ImPlot::PlotLine("FRAME TIME", &buffer.Data[0].x, &buffer.Data[0].y, buffer.Data.size(), buffer.Offset, 2 * sizeof(float));
ImPlot::EndPlot();
}
}
}
ImGui::Columns(1); // resetting the number of columns to 1
manager->CaptureMouseAndKeyboardOnHover(true);
manager->PopWidgetStyle();
ImGui::End();
}
| 34.704762 | 130 | 0.615258 | [
"render"
] |
4099aa8b3cc6d5a7ca5661610ab041f7f9f59a13 | 1,389 | hpp | C++ | include/Customs/CentralLightScript1.hpp | fgagamedev/voID | 37cd56fe2878d036c36dafcf595e48ed85408d02 | [
"MIT"
] | null | null | null | include/Customs/CentralLightScript1.hpp | fgagamedev/voID | 37cd56fe2878d036c36dafcf595e48ed85408d02 | [
"MIT"
] | null | null | null | include/Customs/CentralLightScript1.hpp | fgagamedev/voID | 37cd56fe2878d036c36dafcf595e48ed85408d02 | [
"MIT"
] | null | null | null | /**
@file CentralLightScript1.hpp
@brief Responsible for the light animation during the menu screen.
@copyright MIT License.
*/
#ifndef __CENTRAL_LIGHT_SCRIPT1__
#define __CENTRAL_LIGHT_SCRIPT1__
#include "Engine/InputSystem.hpp"
#include "Engine/GameObject.hpp"
#include "Engine/SceneManager.hpp"
#include "Engine/Timer.hpp"
#include "Engine/GameController.hpp"
#include "Math/Vector.hpp"
#include "Components/Script.hpp"
#include "Components/Animator.hpp"
#include <string>
class CentralLightScript1 : public Script {
public:
CentralLightScript1(GameObject *owner);
std::string GetComponentName() override {
return "CentralLightScript1";
};
void FixedComponentUpdate() override;
void Start() override;
void Activate() {
active = true;
}
protected:
void ComponentUpdate() override;
private:
// Store if the script is active.
bool active = false;
// Store the time.
Timer time;
void CreateAnimations();
// Object for inputs in the central light script 1.
InputSystem *input = nullptr;
// Object for the inputs from the game controller.
GameController* gamecontroller = nullptr;
// Animator for the central light script 1.
Animator *animator = nullptr;
// Object that store positions in the game.
Vector *position = nullptr;
// Not used attribute.
int play = 0;
};
#endif
| 25.254545 | 67 | 0.708423 | [
"object",
"vector"
] |
409b02df46124a81a7534ab2620c544a72fa785b | 9,117 | cpp | C++ | src/GUI/mProplist.cpp | ArashMassoudieh/GIFMod_ | 1fa9eda21fab870fc3baf56462f79eb800d5154f | [
"MIT"
] | 5 | 2017-11-20T19:32:27.000Z | 2018-08-28T06:08:45.000Z | src/GUI/mProplist.cpp | ArashMassoudieh/GIFMod_ | 1fa9eda21fab870fc3baf56462f79eb800d5154f | [
"MIT"
] | 1 | 2017-07-04T05:40:30.000Z | 2017-07-04T05:43:37.000Z | src/GUI/mProplist.cpp | ArashMassoudieh/GIFMod_ | 1fa9eda21fab870fc3baf56462f79eb800d5154f | [
"MIT"
] | 2 | 2017-11-09T22:00:45.000Z | 2018-08-30T10:56:08.000Z | #include "mProplist.h"
//#include <iostream>
#include <fstream>
#include "StringOP.h"
#include <QDebug>
//#include <qlist.h>
//#include "qstring.h"
//#include <string>
#include "XString.h"
mPropList::mPropList(void)
{
}
mPropList::mPropList(QString filename)
{
if (List.size() == 0)
getconfigfromfile(filename);
}
mPropList& mPropList::operator= (const mPropList &CC)
{
List = CC.List;
return *this;
}
mPropList::mPropList(const mPropList &CC)
{
List = CC.List;
}
/*mListReadStatus mPropList::getconfigfromfile(QString filename, GraphWidget *GW)
{
mListReadStatus r = getconfigfromfile(filename);
// if (r == mListReadStatus::readSuccessfully) GW->mList = this;
return(r);
}*/
mListReadStatus mPropList::getconfigfromfile(QString filename)
{
if (!List.isEmpty()) return (mListReadStatus::readBefore);
ifstream file(filename.toStdString());
if (!file.good()) return (mListReadStatus::fileNotValid);
while (file.eof() == false)
{
string line;
getline(file, line);
int a = line.find_first_of('//');
if (a != 0)
{
// QStringList s = QSplit(QString::fromStdString(line), ',');
XString XS = QString::fromStdString(line);
QStringList s = XS.toQString().split(',');
if (s.size() >= 18)
{
QString QS;
QStringList QSL;
mProp mP;
for (int i = 0; i < s.size(); i++)
{
s[i] = (s[i] == "!") ? "" : s[i].trimmed();
while (s[i].indexOf(" ;") + s[i].indexOf("; ") != -2)
{
s[i].replace(" ;", ";");
s[i].replace("; ", ";");
}
}
mP.Model = s[0];
mP.GuiObject = s[1];
mP.ObjectType = s[2];
mP.SubType = s[3];
mP.Description = s[4];
mP.VariableName = s[5];
mP.VariableCode = s[6];
mP.VariableUnit = s[7];
mP.DefaultUnit = s[8];
mP.VariableType = s[9];
mP.setDefaultValues (s[10], mP.VariableUnit, mP.DefaultUnit);
mP.Delegate = s[11];
mP.Category = s[12];
mP.inputMethod = s[13];
mP.ExperimentDependent = s[14];
// mP.Value = QSplit(mP.DefaultValues, ':')[0];
// mP.Value = mP.DefaultValuesList()[0];
// mP.parent = this;
mP.DescriptionCode = s[15];
mP.Abbreviations = s[16].split(';');
if (s[17] != "") {
mP.Condition = s[17].split(';');
mP.error = s[18].split(';');
mP.errorDesc = s[19].split(';');
if ((mP.Condition.size() != mP.error.size()) || (mP.Condition.size() != mP.error.size()))
return (mListReadStatus::errorInContents);
}
List.append(mP);
}
}
}
if (List.size() == 0)
return (mListReadStatus::errorInContents);
else
{
return (mListReadStatus::readSuccessfully);
}
}
QStringList mPropList::Models(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].Model;
}
return(uniques(r));
}
QStringList mPropList::GuiObjects(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].GuiObject;
}
return(uniques(r));
}
QStringList mPropList::ObjectTypes(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].ObjectType;
}
return(uniques(r));
}
QStringList mPropList::SubTypes(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].SubType;
}
return(uniques(r));
}
QStringList mPropList::Descriptions(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].Description;
}
return(uniques(r));
}
QStringList mPropList::VariableNames(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].VariableName;
}
return(uniques(r));
}
QStringList mPropList::VariableNames_w_abv(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] /= mP) { r << List[i].VariableName; r << List[i].Abbreviations; }
}
return(uniques(r));
}
/*QStringList mPropList::VariableNames(const QList<mProp> objectTypes)const
{
QList<QStringList> r;
r.reserve(objectTypes.count());
QStringList finalList;
for (int j = 0; j < objectTypes.size(); j++)
{
QStringList temp;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == objectTypes[j]) temp << List[i].VariableName;
}
r[j] = uniques(temp);
}
for (int i = 0; i < r[0].size(); i++)
{
bool include = true;
for (int j = 1; j < objectTypes.count(); j++)
if (!r[j].contains(r[0][i]))
{
include = false;
break;
}
if (include)
finalList.append(r[0][i]);
}
return(finalList);
}*/
QStringList mPropList::VariableUnits(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].VariableUnit;
}
return(uniques(r));
}
QStringList mPropList::VariableTypes(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].VariableType;
}
return(uniques(r));
}
QList<QStringList> mPropList::DefaultValueLists(const mProp& mP)const
{
QList<QStringList> r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].DefaultValuesString().split(';');
}
return(r);
}
QStringList mPropList::Delegates(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].Delegate;
}
return(uniques(r));
}
QStringList mPropList::Categories(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].Category;
}
return(uniques(r));
}
QStringList mPropList::inputMethods(const mProp& mP)const
{
QStringList r;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) r << List[i].Model;
}
return(uniques(r));
}
mPropList mPropList::filter(const mProp &mP) const
{
static int counter = 0;
static mProp filter;
static mPropList r;
if (filter %= mP) return r;
filter = mP;
r = mPropList();
int n = List.size();
for (int i = 0; i < n; i++)
{
if (List[i] == mP) r.List.append(List[i]);
}
// //qDebug() << "filter:" << counter++;
return(r);
}
mPropList mPropList::filter_abv(const mProp &mP) const
{
static int counter = 0;
static mProp filter;
static mPropList r;
if (filter %= mP) return r;
filter = mP;
r = mPropList();
int n = List.size();
for (int i = 0; i < n; i++)
{
if (List[i] /= mP) r.List.append(List[i]);
}
// //qDebug() << "filter:" << counter++;
return(r);
}
QStringList mPropList::extract_props_for_type(QString s)
{
QStringList outlist;
for (int i = 0; i < List.size(); i++)
{
if (List[i].ObjectType.toLower() == s.toLower() || List[i].ObjectType == "*")
{
outlist.append(List[i].VariableName.toLower());
outlist.append(List[i].Abbreviations);
}
}
// //qDebug() << "filter:" << counter++;
return(outlist);
}
QString mPropList::get_proper_property(QString s, QString propname)
{
QStringList outlist;
for (int i = 0; i < List.size(); i++)
{
if (List[i].ObjectType.toLower() == s.toLower() || List[i].ObjectType == "*")
{
if (List[i].VariableName.toLower() == propname.toLower())
return List[i].VariableName;
if (List[i].Abbreviations.contains(propname))
return List[i].VariableName;
}
}
// //qDebug() << "filter:" << counter++;
return QString();
}
QStringList mPropList::extract_units_for_prop(QString type, QString property)
{
QStringList outlist;
for (int i = 0; i < List.size(); i++)
{
if (List[i].ObjectType == type.toLower() || List[i].ObjectType == "*")
if (List[i].VariableName.toQString() == property)
outlist.append(List[i].VariableUnit);
}
// //qDebug() << "filter:" << counter++;
return(outlist);
}
mPropList mPropList::filter(const QList<mProp> mP) const
{
static int counter = 0;
static QList<mProp> filter;
static mPropList r;
if (mProp::areTheSame(filter, mP)) return r;
filter = mP;
//find the intersection variable names
QList<QStringList> v;
for (int i = 0; i < mP.count(); i++)
v << QStringList();
QStringList variableNamesList;
for (int j = 0; j < mP.size(); j++)
{
QStringList temp;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP[j]) temp << List[i].VariableName;
}
v[j] = uniques(temp);
}
for (int i = 0; i < v[0].size(); i++)
{
bool include = true;
for (int j = 1; j < mP.count(); j++)
if (!v[j].contains(v[0][i]))
{
include = false;
break;
}
if (include)
variableNamesList.append(v[0][i]);
}
//
r = mPropList();
int n = List.size();
for (int i = 0; i < n; i++)
for (int j = 0; j < mP.count(); j++)
{
if (List[i] == mP[j])
if (variableNamesList.contains(List[i].VariableName))
r.List.append(List[i]);
}
return r;
}
int mPropList::setProp(const QString _PropertyName, const XString _Value, const mProp _Filter)
{/*
mProp mP = _Filter;
mP.VariableName = _PropertyName;
mP.Value = '*';
int r = 0;
for (int i = 0; i < List.size(); i++)
{
if (List[i] == mP) {
(_Value == "Set to Default") ?
List[i].Value = List[i].DefaultValuesList()[0]
:List[i].Value = _Value; r++; }
}
return(r);
*/
return 1;
}
| 22.290954 | 95 | 0.601404 | [
"model"
] |
409e91eb5c0025cf1622a360188998e549e93827 | 4,872 | cpp | C++ | test/Matuna.ConvNetLayerInterlockTest/ForthBackPropLayerTest.cpp | mihed/ATML | 242fb951eea7a55846b8a18dd6abcabb26e2a1cc | [
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null | test/Matuna.ConvNetLayerInterlockTest/ForthBackPropLayerTest.cpp | mihed/ATML | 242fb951eea7a55846b8a18dd6abcabb26e2a1cc | [
"BSL-1.0",
"BSD-3-Clause"
] | 3 | 2015-06-08T19:51:53.000Z | 2015-07-01T10:15:06.000Z | test/Matuna.ConvNetLayerInterlockTest/ForthBackPropLayerTest.cpp | mihed/ATML | 242fb951eea7a55846b8a18dd6abcabb26e2a1cc | [
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null | /*
* ForthBackPropLayerTest.cpp
*
* Created on: May 3, 2015
* Author: Mikael
*/
#include "ForthBackPropLayerTest.h"
#include <chrono>
#include <random>
using namespace std;
ForthBackPropLayerTest::ForthBackPropLayerTest(
const vector<LayerDataDescription>& inputLayerDescriptions,
MatunaActivationFunction backPropActivation,
const ForwardBackPropLayerConfig* config) :
ForwardBackPropLayer(inputLayerDescriptions, backPropActivation, config)
{
random_device tempDevice;
mt19937 generator(tempDevice());
uniform_int_distribution<int> unitGenerator(1, 100);
uniform_int_distribution<int> paddingGenerator(1, 40);
uniform_int_distribution<int> dimensionGenerator(1, 10000);
//Now we just need to initialize the in/out memory proposal as well as setting
//the output data descriptions.
//The layers is entirely responsible for calculating how the output from this module looks like.
//(This also defines the input of back prop module, which is the same of course - by definition!)
LayerDataDescription inBackPropDataDescription;
inBackPropDataDescription.Height = dimensionGenerator(generator);
inBackPropDataDescription.Width = dimensionGenerator(generator);
inBackPropDataDescription.Units = unitGenerator(generator);
inBackPropDataDescriptions.push_back(inBackPropDataDescription);
outForwardPropDataDescriptions = inBackPropDataDescriptions;
//Setting the outForwardProp proposal
LayerMemoryDescription outForwardPropMemoryProposal;
outForwardPropMemoryProposal.HeightOffset = paddingGenerator(generator);
outForwardPropMemoryProposal.Height =
outForwardPropDataDescriptions[0].Height
+ outForwardPropMemoryProposal.HeightOffset
+ paddingGenerator(generator);
outForwardPropMemoryProposal.WidthOffset = paddingGenerator(generator);
outForwardPropMemoryProposal.Width = outForwardPropDataDescriptions[0].Width
+ outForwardPropMemoryProposal.WidthOffset
+ paddingGenerator(generator);
outForwardPropMemoryProposal.UnitOffset = paddingGenerator(generator);
outForwardPropMemoryProposal.Units = outForwardPropDataDescriptions[0].Units
+ outForwardPropMemoryProposal.UnitOffset
+ paddingGenerator(generator);
outForwardPropMemoryProposals.push_back(outForwardPropMemoryProposal);
//Setting the inBackProp proposal
LayerMemoryDescription inBackPropMemoryProposal;
inBackPropMemoryProposal.HeightOffset = paddingGenerator(generator);
inBackPropMemoryProposal.Height = inBackPropDataDescription.Height
+ inBackPropMemoryProposal.HeightOffset
+ paddingGenerator(generator);
inBackPropMemoryProposal.WidthOffset = paddingGenerator(generator);
inBackPropMemoryProposal.Width = inBackPropDataDescription.Width
+ inBackPropMemoryProposal.WidthOffset
+ paddingGenerator(generator);
inBackPropMemoryProposal.UnitOffset = paddingGenerator(generator);
inBackPropMemoryProposal.Units = inBackPropDataDescription.Units
+ inBackPropMemoryProposal.UnitOffset + paddingGenerator(generator);
inBackPropMemoryProposals.push_back(inBackPropMemoryProposal);
//Setting the inForwardProp proposal
auto forwardInDataDescription = InForwardPropDataDescriptions();
LayerMemoryDescription inForwardPropMemoryProposal;
inForwardPropMemoryProposal.HeightOffset = paddingGenerator(generator);
inForwardPropMemoryProposal.Height = forwardInDataDescription[0].Height
+ inForwardPropMemoryProposal.HeightOffset
+ paddingGenerator(generator);
inForwardPropMemoryProposal.WidthOffset = paddingGenerator(generator);
inForwardPropMemoryProposal.Width = forwardInDataDescription[0].Width
+ inForwardPropMemoryProposal.WidthOffset
+ paddingGenerator(generator);
inForwardPropMemoryProposal.UnitOffset = paddingGenerator(generator);
inForwardPropMemoryProposal.Units = forwardInDataDescription[0].Units
+ inForwardPropMemoryProposal.UnitOffset
+ paddingGenerator(generator);
inForwardPropMemoryProposals.push_back(inForwardPropMemoryProposal);
//Setting the outBackProp proposal
LayerMemoryDescription outBackPropMemoryProposal;
outBackPropMemoryProposal.HeightOffset = paddingGenerator(generator);
outBackPropMemoryProposal.Height = forwardInDataDescription[0].Height
+ outBackPropMemoryProposal.HeightOffset
+ paddingGenerator(generator);
outBackPropMemoryProposal.WidthOffset = paddingGenerator(generator);
outBackPropMemoryProposal.Width = forwardInDataDescription[0].Width
+ outBackPropMemoryProposal.WidthOffset
+ paddingGenerator(generator);
outBackPropMemoryProposal.UnitOffset = paddingGenerator(generator);
outBackPropMemoryProposal.Units = forwardInDataDescription[0].Units
+ outBackPropMemoryProposal.UnitOffset
+ paddingGenerator(generator);
outBackPropMemoryProposals.push_back(outBackPropMemoryProposal);
}
void ForthBackPropLayerTest::InterlockFinalized()
{
}
ForthBackPropLayerTest::~ForthBackPropLayerTest()
{
}
| 35.05036 | 98 | 0.836823 | [
"vector"
] |
40a0bf352bdd513e8173efa7064378ce79a63f51 | 2,943 | cc | C++ | cinn/optim/eliminate_broadcast_in_forloop.cc | edithgogo/CINN | bed13f4752d80d01a3e1d96a4cc4f5aa56b1e292 | [
"Apache-2.0"
] | 1 | 2019-10-23T09:16:23.000Z | 2019-10-23T09:16:23.000Z | cinn/optim/eliminate_broadcast_in_forloop.cc | edithgogo/CINN | bed13f4752d80d01a3e1d96a4cc4f5aa56b1e292 | [
"Apache-2.0"
] | null | null | null | cinn/optim/eliminate_broadcast_in_forloop.cc | edithgogo/CINN | bed13f4752d80d01a3e1d96a4cc4f5aa56b1e292 | [
"Apache-2.0"
] | null | null | null | #include "cinn/optim/eliminate_broadcast_in_forloop.h"
#include <tuple>
#include <vector>
#include "cinn/ir/ir_mutator.h"
#include "cinn/ir/ir_printer.h"
#include "cinn/ir/ir_visitor.h"
#include "cinn/optim/ir_replace.h"
namespace cinn {
namespace optim {
namespace detail {
struct EliminateBroadcastInForloop : public ir::IRMutator<Expr*> {
void operator()(Expr* expr) { ir::IRMutator<>::Visit(expr, expr); }
void Visit(const ir::Store* op, Expr* expr) {
// TODO(Superjom) Support single one level of forloop.
if (forloop_stack.size() < 2) return;
auto* node = expr->As<ir::Store>();
auto broadcasts = ir::CollectIRNodes(node->value, [&](const Expr* expr) { return expr->As<ir::Broadcast>(); });
std::vector<Expr> let_exprs;
Var tmp;
Expr let_expr;
Var cur_level_loop_var = forloop_stack.back()->As<ir::For>() ? forloop_stack.back()->As<ir::For>()->loop_var
: forloop_stack.back()->As<ir::PolyFor>()->iterator;
for (Expr broadcast : broadcasts) {
if (ContainsLoopVar(broadcast, cur_level_loop_var)) continue;
VLOG(4) << "eliminating " << broadcast;
std::tie(let_expr, tmp) = CreateTmpLet(broadcast);
let_exprs.push_back(let_expr);
optim::IrReplace(expr, broadcast, tmp);
}
// insert the let expressions to the outer forloop.
Expr* outer_forloop = forloop_stack[forloop_stack.size() - 2];
auto& outer_forloop_body =
outer_forloop->As<ir::For>() ? outer_forloop->As<ir::For>()->body : outer_forloop->As<ir::PolyFor>()->body;
auto* outer_forloop_body_block = outer_forloop_body.As<ir::Block>();
if (outer_forloop_body_block) {
outer_forloop_body_block->stmts.insert(
std::begin(outer_forloop_body_block->stmts), let_exprs.begin(), let_exprs.end());
} else {
let_exprs.push_back(outer_forloop_body);
outer_forloop_body = ir::Block::Make(let_exprs);
}
}
bool ContainsLoopVar(Expr expr, Var loop_var) {
return !ir::CollectIRNodes(expr, [&](const Expr* e) -> bool {
return e->As<ir::_Var_>() && e->As<ir::_Var_>()->name == loop_var->name;
}).empty();
}
std::tuple<Expr, Var> CreateTmpLet(Expr body) {
Var tmp(Context::Global().NewName("tmp"), body.type());
Expr let_expr = ir::Let::Make(tmp, body);
return std::make_tuple(let_expr, tmp);
}
void Visit(const ir::For* op, Expr* expr) {
forloop_stack.push_back(expr);
ir::IRMutator<>::Visit(op, expr);
forloop_stack.pop_back();
}
void Visit(const ir::PolyFor* op, Expr* expr) {
forloop_stack.push_back(expr);
ir::IRMutator<>::Visit(op, expr);
forloop_stack.pop_back();
}
std::vector<Expr*> forloop_stack;
};
} // namespace detail
void EliminateBroadcastInForloop(Expr* expr) {
detail::EliminateBroadcastInForloop mutator;
mutator(expr);
}
} // namespace optim
} // namespace cinn
| 30.030612 | 117 | 0.648318 | [
"vector"
] |
40a54f49f3dddd3dace6e18b3fb85fab57147f96 | 5,373 | hpp | C++ | ThirdParty-mod/java2cpp/android/graphics/drawable/LevelListDrawable.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | 1 | 2019-04-03T01:53:28.000Z | 2019-04-03T01:53:28.000Z | ThirdParty-mod/java2cpp/android/graphics/drawable/LevelListDrawable.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | null | null | null | ThirdParty-mod/java2cpp/android/graphics/drawable/LevelListDrawable.hpp | kakashidinho/HQEngine | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | [
"MIT"
] | null | null | null | /*================================================================================
code generated by: java2cpp
author: Zoran Angelov, mailto://baldzar@gmail.com
class: android.graphics.drawable.LevelListDrawable
================================================================================*/
#ifndef J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ANDROID_GRAPHICS_DRAWABLE_LEVELLISTDRAWABLE_HPP_DECL
#define J2CPP_ANDROID_GRAPHICS_DRAWABLE_LEVELLISTDRAWABLE_HPP_DECL
namespace j2cpp { namespace org { namespace xmlpull { namespace v1 { class XmlPullParser; } } } }
namespace j2cpp { namespace android { namespace graphics { namespace drawable { class DrawableContainer; } } } }
namespace j2cpp { namespace android { namespace graphics { namespace drawable { class Drawable; } } } }
namespace j2cpp { namespace android { namespace content { namespace res { class Resources; } } } }
namespace j2cpp { namespace android { namespace util { class AttributeSet; } } }
#include <android/content/res/Resources.hpp>
#include <android/graphics/drawable/Drawable.hpp>
#include <android/graphics/drawable/DrawableContainer.hpp>
#include <android/util/AttributeSet.hpp>
#include <org/xmlpull/v1/XmlPullParser.hpp>
namespace j2cpp {
namespace android { namespace graphics { namespace drawable {
class LevelListDrawable;
class LevelListDrawable
: public object<LevelListDrawable>
{
public:
J2CPP_DECLARE_CLASS
J2CPP_DECLARE_METHOD(0)
J2CPP_DECLARE_METHOD(1)
J2CPP_DECLARE_METHOD(2)
J2CPP_DECLARE_METHOD(3)
J2CPP_DECLARE_METHOD(4)
explicit LevelListDrawable(jobject jobj)
: object<LevelListDrawable>(jobj)
{
}
operator local_ref<android::graphics::drawable::DrawableContainer>() const;
LevelListDrawable();
void addLevel(jint, jint, local_ref< android::graphics::drawable::Drawable > const&);
void inflate(local_ref< android::content::res::Resources > const&, local_ref< org::xmlpull::v1::XmlPullParser > const&, local_ref< android::util::AttributeSet > const&);
local_ref< android::graphics::drawable::Drawable > mutate();
}; //class LevelListDrawable
} //namespace drawable
} //namespace graphics
} //namespace android
} //namespace j2cpp
#endif //J2CPP_ANDROID_GRAPHICS_DRAWABLE_LEVELLISTDRAWABLE_HPP_DECL
#else //J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ANDROID_GRAPHICS_DRAWABLE_LEVELLISTDRAWABLE_HPP_IMPL
#define J2CPP_ANDROID_GRAPHICS_DRAWABLE_LEVELLISTDRAWABLE_HPP_IMPL
namespace j2cpp {
android::graphics::drawable::LevelListDrawable::operator local_ref<android::graphics::drawable::DrawableContainer>() const
{
return local_ref<android::graphics::drawable::DrawableContainer>(get_jobject());
}
android::graphics::drawable::LevelListDrawable::LevelListDrawable()
: object<android::graphics::drawable::LevelListDrawable>(
call_new_object<
android::graphics::drawable::LevelListDrawable::J2CPP_CLASS_NAME,
android::graphics::drawable::LevelListDrawable::J2CPP_METHOD_NAME(0),
android::graphics::drawable::LevelListDrawable::J2CPP_METHOD_SIGNATURE(0)
>()
)
{
}
void android::graphics::drawable::LevelListDrawable::addLevel(jint a0, jint a1, local_ref< android::graphics::drawable::Drawable > const &a2)
{
return call_method<
android::graphics::drawable::LevelListDrawable::J2CPP_CLASS_NAME,
android::graphics::drawable::LevelListDrawable::J2CPP_METHOD_NAME(1),
android::graphics::drawable::LevelListDrawable::J2CPP_METHOD_SIGNATURE(1),
void
>(get_jobject(), a0, a1, a2);
}
void android::graphics::drawable::LevelListDrawable::inflate(local_ref< android::content::res::Resources > const &a0, local_ref< org::xmlpull::v1::XmlPullParser > const &a1, local_ref< android::util::AttributeSet > const &a2)
{
return call_method<
android::graphics::drawable::LevelListDrawable::J2CPP_CLASS_NAME,
android::graphics::drawable::LevelListDrawable::J2CPP_METHOD_NAME(3),
android::graphics::drawable::LevelListDrawable::J2CPP_METHOD_SIGNATURE(3),
void
>(get_jobject(), a0, a1, a2);
}
local_ref< android::graphics::drawable::Drawable > android::graphics::drawable::LevelListDrawable::mutate()
{
return call_method<
android::graphics::drawable::LevelListDrawable::J2CPP_CLASS_NAME,
android::graphics::drawable::LevelListDrawable::J2CPP_METHOD_NAME(4),
android::graphics::drawable::LevelListDrawable::J2CPP_METHOD_SIGNATURE(4),
local_ref< android::graphics::drawable::Drawable >
>(get_jobject());
}
J2CPP_DEFINE_CLASS(android::graphics::drawable::LevelListDrawable,"android/graphics/drawable/LevelListDrawable")
J2CPP_DEFINE_METHOD(android::graphics::drawable::LevelListDrawable,0,"<init>","()V")
J2CPP_DEFINE_METHOD(android::graphics::drawable::LevelListDrawable,1,"addLevel","(IILandroid/graphics/drawable/Drawable;)V")
J2CPP_DEFINE_METHOD(android::graphics::drawable::LevelListDrawable,2,"onLevelChange","(I)Z")
J2CPP_DEFINE_METHOD(android::graphics::drawable::LevelListDrawable,3,"inflate","(Landroid/content/res/Resources;Lorg/xmlpull/v1/XmlPullParser;Landroid/util/AttributeSet;)V")
J2CPP_DEFINE_METHOD(android::graphics::drawable::LevelListDrawable,4,"mutate","()Landroid/graphics/drawable/Drawable;")
} //namespace j2cpp
#endif //J2CPP_ANDROID_GRAPHICS_DRAWABLE_LEVELLISTDRAWABLE_HPP_IMPL
#endif //J2CPP_INCLUDE_IMPLEMENTATION
| 38.654676 | 226 | 0.744835 | [
"object"
] |
40a6f46b2da2cb41bdbd196fa0bb5fc8fc2aaf6f | 66,317 | cc | C++ | src/serverFunctionalities/source/QuerySchedulerServer.cc | asu-cactus/pangea | 92efa7b124a23894485a900bb394670487051948 | [
"Apache-2.0"
] | 2 | 2021-07-30T23:38:22.000Z | 2021-08-24T11:16:10.000Z | src/serverFunctionalities/source/QuerySchedulerServer.cc | asu-cactus/lachesis | 92efa7b124a23894485a900bb394670487051948 | [
"Apache-2.0"
] | null | null | null | src/serverFunctionalities/source/QuerySchedulerServer.cc | asu-cactus/lachesis | 92efa7b124a23894485a900bb394670487051948 | [
"Apache-2.0"
] | 1 | 2020-09-28T22:46:16.000Z | 2020-09-28T22:46:16.000Z | #ifndef QUERY_SCHEDULER_SERVER_CC
#define QUERY_SCHEDULER_SERVER_CC
#include "PDBDebug.h"
#include "InterfaceFunctions.h"
#include "QuerySchedulerServer.h"
#include "DistributedStorageManagerClient.h"
#include "DistributedStorageManagerServer.h"
#include "QueryOutput.h"
#include "ResourceInfo.h"
#include "ShuffleInfo.h"
#include "ResourceManagerServer.h"
#include "SimpleSingleTableQueryProcessor.h"
#include "InterfaceFunctions.h"
#include "QueryBase.h"
#include "PDBVector.h"
#include "Handle.h"
#include "ExecuteQuery.h"
#include "TupleSetExecuteQuery.h"
#include "ExecuteComputation.h"
#include "RequestResources.h"
#include "SimpleRequestHandler.h"
#include "SimpleRequestResult.h"
#include "GenericWork.h"
#include "DataTypes.h"
#include "ScanUserSet.h"
#include "WriteUserSet.h"
#include "ClusterAggregateComp.h"
#include "QueryGraphAnalyzer.h"
#include "TCAPAnalyzer.h"
#include "Configuration.h"
#include "StorageCollectStats.h"
#include "StorageCollectStatsResponse.h"
#include "Configuration.h"
#include "SelfLearningServer.h"
#include "SelfLearningWrapperServer.h"
#include <vector>
#include <string>
#include <unordered_map>
#include <ctime>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <chrono>
#include <fcntl.h>
namespace pdb {
QuerySchedulerServer::~QuerySchedulerServer() {
pthread_mutex_destroy(&connection_mutex);
}
QuerySchedulerServer::QuerySchedulerServer(PDBLoggerPtr logger,
ConfigurationPtr conf,
bool pseudoClusterMode,
double partitionToCoreRatio,
bool isDynamicPlanning,
bool removeIntermediateDataEarly,
bool selfLearningOrNot) {
this->port = 8108;
this->logger = logger;
this->conf = conf;
this->pseudoClusterMode = pseudoClusterMode;
pthread_mutex_init(&connection_mutex, nullptr);
this->jobStageId = 0;
this->partitionToCoreRatio = partitionToCoreRatio;
this->dynamicPlanningOrNot = isDynamicPlanning;
this->earlyRemovingDataOrNot = removeIntermediateDataEarly;
this->statsForOptimization = nullptr;
this->initializeStats();
this->selfLearningOrNot = selfLearningOrNot;
}
QuerySchedulerServer::QuerySchedulerServer(int port,
PDBLoggerPtr logger,
ConfigurationPtr conf,
bool pseudoClusterMode,
double partitionToCoreRatio,
bool isDynamicPlanning,
bool removeIntermediateDataEarly,
bool selfLearningOrNot) {
this->port = port;
this->logger = logger;
this->conf = conf;
this->pseudoClusterMode = pseudoClusterMode;
pthread_mutex_init(&connection_mutex, nullptr);
this->jobStageId = 0;
this->partitionToCoreRatio = partitionToCoreRatio;
this->dynamicPlanningOrNot = isDynamicPlanning;
this->earlyRemovingDataOrNot = removeIntermediateDataEarly;
this->statsForOptimization = nullptr;
this->initializeStats();
this->selfLearningOrNot = selfLearningOrNot;
}
void QuerySchedulerServer::cleanup() {
delete this->standardResources;
this->standardResources = nullptr;
for (int i = 0; i < queryPlan.size(); i++) {
queryPlan[i] = nullptr;
}
this->queryPlan.clear();
for (int i = 0; i < interGlobalSets.size(); i++) {
interGlobalSets[i] = nullptr;
}
this->interGlobalSets.clear();
this->jobStageId = 0;
}
QuerySchedulerServer::QuerySchedulerServer(std::string resourceManagerIp,
int port,
PDBLoggerPtr logger,
ConfigurationPtr conf,
bool usePipelineNetwork,
double partitionToCoreRatio,
bool isDynamicPlanning,
bool removeIntermediateDataEarly,
bool selfLearningOrNot) {
this->resourceManagerIp = resourceManagerIp;
this->port = port;
this->conf = conf;
this->standardResources = nullptr;
this->logger = logger;
this->usePipelineNetwork = usePipelineNetwork;
this->jobStageId = 0;
this->partitionToCoreRatio = partitionToCoreRatio;
this->dynamicPlanningOrNot = isDynamicPlanning;
this->earlyRemovingDataOrNot = removeIntermediateDataEarly;
this->statsForOptimization = nullptr;
this->initializeStats();
this->selfLearningOrNot = selfLearningOrNot;
}
void QuerySchedulerServer::initialize(bool isRMRunAsServer) {
if (this->standardResources != nullptr) {
delete this->standardResources;
}
this->standardResources = new std::vector<StandardResourceInfoPtr>();
if (pseudoClusterMode == false) {
UseTemporaryAllocationBlock(2 * 1024 * 1024);
Handle<Vector<Handle<ResourceInfo>>> resourceObjects;
PDB_COUT << "To get the resource object from the resource manager" << std::endl;
if (isRMRunAsServer == true) {
resourceObjects = getFunctionality<ResourceManagerServer>().getAllResources();
} else {
ResourceManagerServer rm("conf/serverlist", 8108);
resourceObjects = rm.getAllResources();
}
// add and print out the resources
for (int i = 0; i < resourceObjects->size(); i++) {
PDB_COUT << i << ": address=" << (*(resourceObjects))[i]->getAddress()
<< ", port=" << (*(resourceObjects))[i]->getPort()
<< ", node=" << (*(resourceObjects))[i]->getNodeId()
<< ", numCores=" << (*(resourceObjects))[i]->getNumCores()
<< ", memSize=" << (*(resourceObjects))[i]->getMemSize() << std::endl;
StandardResourceInfoPtr currentResource = std::make_shared<StandardResourceInfo>(
(*(resourceObjects))[i]->getNumCores(),
(*(resourceObjects))[i]->getMemSize(),
(*(resourceObjects))[i]->getAddress().c_str(),
(*(resourceObjects))[i]->getPort(),
(*(resourceObjects))[i]->getNodeId());
this->standardResources->push_back(currentResource);
}
} else {
UseTemporaryAllocationBlock(2 * 1024 * 1024);
Handle<Vector<Handle<NodeDispatcherData>>> nodeObjects;
PDB_COUT << "To get the node object from the resource manager" << std::endl;
if (isRMRunAsServer == true) {
nodeObjects = getFunctionality<ResourceManagerServer>().getAllNodes();
} else {
ResourceManagerServer rm("conf/serverlist", 8108);
nodeObjects = rm.getAllNodes();
}
// add and print out the resources
for (int i = 0; i < nodeObjects->size(); i++) {
PDB_COUT << i << ": address=" << (*(nodeObjects))[i]->getAddress()
<< ", port=" << (*(nodeObjects))[i]->getPort()
<< ", node=" << (*(nodeObjects))[i]->getNodeId() << std::endl;
StandardResourceInfoPtr currentResource =
std::make_shared<StandardResourceInfo>(DEFAULT_NUM_CORES / (nodeObjects->size()),
DEFAULT_MEM_SIZE / (nodeObjects->size()),
(*(nodeObjects))[i]->getAddress().c_str(),
(*(nodeObjects))[i]->getPort(),
(*(nodeObjects))[i]->getNodeId());
this->standardResources->push_back(currentResource);
}
}
}
// collect the statistics that will be used for optimizer
// this needs the functionality of catalog and distributed storage manager
void QuerySchedulerServer::initializeStats() {
// TODO: to load stats from file
this->statsForOptimization = nullptr;
this->standardResources = nullptr;
return;
}
// return statsForOptimization
StatisticsPtr QuerySchedulerServer::getStats() {
return statsForOptimization;
}
// to schedule dynamic pipeline stages
// this must be invoked after initialize() and before cleanup()
void QuerySchedulerServer::scheduleStages(std::vector<Handle<AbstractJobStage>>& stagesToSchedule,
std::vector<Handle<SetIdentifier>>& intermediateSets,
std::shared_ptr<ShuffleInfo> shuffleInfo, long jobInstanceId) {
atomic_int counter;
counter = 0;
PDBBuzzerPtr tempBuzzer = make_shared<PDBBuzzer>([&](PDBAlarm myAlarm, atomic_int& counter) {
counter++;
PDB_COUT << "counter = " << counter << std::endl;
});
int numStages = stagesToSchedule.size();
for (int i = 0; i < numStages; i++) {
long jobInstanceStageId;
if (selfLearningOrNot == true) {
Handle<AbstractJobStage> curStage = stagesToSchedule[i];
int jobStageId = curStage->getStageId();
std::string stageType = curStage->getJobStageType();
std::string sourceType = "";
std::string sinkType = "";
std::string probeType = "";
Handle<Vector<String>> buildTheseTupleSets = nullptr;
int numPartitions = shuffleInfo->getNumHashPartitions();
std::string targetComputationSpecifier = "";
Handle<Computation> aggregationComputation = nullptr;
if (stageType == "TupleSetJobStage") {
Handle<TupleSetJobStage> curTupleSetJobStage =
unsafeCast<TupleSetJobStage, AbstractJobStage>(curStage);
buildTheseTupleSets = curTupleSetJobStage->getTupleSetsToBuildPipeline();
targetComputationSpecifier =
curTupleSetJobStage->getTargetComputationSpecifier();
//sourceType
if (curTupleSetJobStage->isInputAggHashOut()) {
sourceType = "Map";
} else if (curTupleSetJobStage->isJoinTupleSource()) {
sourceType = "JoinTuple";
} else {
sourceType = "Vector";
}
//sinkType
if (curTupleSetJobStage->isBroadcasting()) {
sinkType = "Broadcast";
} else if (curTupleSetJobStage->isRepartition()) {
if (curTupleSetJobStage->isRepartitionJoin()) {
sinkType = "Repartition";
} else {
sinkType = "Shuffle";
}
} else {
sinkType = "UserSet";
}
//probeType
if (curTupleSetJobStage->isProbing()) {
if (curTupleSetJobStage->isJoinTupleSource()) {
probeType = "PartitionedHashSet";
} else {
probeType = "HashSet";
}
} else {
probeType = "None";
}
} else if (stageType == "AggregationJobStage") {
sourceType = "Vector";
sinkType = "PartitionedHashSet";
probeType = "None";
Handle<AggregationJobStage> curAggregationJobStage =
unsafeCast<AggregationJobStage, AbstractJobStage>(curStage);
aggregationComputation = curAggregationJobStage->getAggComputation();
if (curAggregationJobStage->needsToMaterializeAggOut()) {
sinkType = "UserSet";
}
} else if (stageType == "HashPartitionedJoinBuildHTJobStage") {
sourceType = "Vector";
sinkType = "PartitionedHashSet";
probeType = "None";
Handle<HashPartitionedJoinBuildHTJobStage> curHashPartitionJobStage =
unsafeCast<HashPartitionedJoinBuildHTJobStage, AbstractJobStage>
(curStage);
targetComputationSpecifier =
curHashPartitionJobStage->getTargetComputationSpecifier();
buildTheseTupleSets = makeObject<Vector<String>>();
buildTheseTupleSets->push_back(curHashPartitionJobStage->getSourceTupleSetSpecifier());
buildTheseTupleSets->push_back(curHashPartitionJobStage->getTargetTupleSetSpecifier());
} else if (stageType == "BroadcastJoinBuildHTJobStage") {
sourceType = "Vector";
sinkType = "BroadcastHashSet";
probeType = "None";
Handle<BroadcastJoinBuildHTJobStage> curBroadcastJobStage =
unsafeCast<BroadcastJoinBuildHTJobStage, AbstractJobStage>
(curStage);
targetComputationSpecifier =
curBroadcastJobStage->getTargetComputationSpecifier();
buildTheseTupleSets = makeObject<Vector<String>>();
buildTheseTupleSets->push_back(curBroadcastJobStage->getSourceTupleSetSpecifier());
buildTheseTupleSets->push_back(curBroadcastJobStage->getTargetTupleSetSpecifier());
} else {
std::cout << "Unrecognized JobStage Type: " << stageType << std::endl;
}
//create a jobStage entry
getFunctionality<SelfLearningServer>().createJobStage (jobInstanceId, jobStageId,
stageType, "Running", sourceType, sinkType, probeType,
buildTheseTupleSets, numPartitions, targetComputationSpecifier,
aggregationComputation, jobInstanceStageId);
//to add data-stage mapping
if (stageType == "TupleSetJobStage") {
Handle<TupleSetJobStage> curTupleSetJobStage =
unsafeCast<TupleSetJobStage, AbstractJobStage>(curStage);
//source
Handle<SetIdentifier> sourceContext =
curTupleSetJobStage->getSourceContext();
//get id of set
long sourceDataId = getFunctionality<DistributedStorageManagerServer>().
getIdForData(sourceContext->getDatabase(), sourceContext->getSetName());
//add the entry to the DATA_JOB_STAGE
long sourceMappingId;
int indexInInputs = sourceContext->getIndexInInputs();
std::cout << "my input in index is " << indexInInputs << std::endl;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(sourceDataId, jobInstanceStageId, indexInInputs, "Source", sourceMappingId);
std::cout << "||||create data job stage mapping: " << sourceDataId << "=>" << jobInstanceStageId << std::endl;
//sink
Handle<SetIdentifier> sinkContext =
curTupleSetJobStage->getSinkContext();
//get id of set
long sinkDataId = getFunctionality<DistributedStorageManagerServer>().
getIdForData(sinkContext->getDatabase(), sinkContext->getSetName());
//add the entry to the DATA_JOB_STAGE
long sinkMappingId;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(sinkDataId, jobInstanceStageId, -1, "Sink", sinkMappingId);
std::cout << "||||create data job stage mapping: " << sinkDataId << "=>" << jobInstanceStageId << std::endl;
//probe
if (curTupleSetJobStage->isProbing()) {
std::string probeSetType;
if (curTupleSetJobStage->isJoinTupleSource()) {
probeSetType = "PartitionedHashSet";
} else {
probeSetType = "HashSet";
}
Handle<Map<String, String>> & probeSets = curTupleSetJobStage->getHashSets();
if (probeSets!= nullptr) {
PDBMapIterator<String, String> iter = probeSets->begin();
while (iter != probeSets->end()) {
String setName = (*iter).value;
//add set to DATA if it doesn't exist; and get the id of the set.
long curHashDataId = getFunctionality<DistributedStorageManagerServer>().
getIdForData("", setName);
if (curHashDataId < 0) {
getFunctionality<SelfLearningServer>().createData("", setName, curStage->getJobId(),
probeSetType, "IntermediateData", 8191, 0, -1, 1, curHashDataId);
}
//add the entry to the DATA_JOB_STAGE
long curMappingId;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(curHashDataId, jobInstanceStageId, -1, "Probe", curMappingId);
++iter;
}
}
}
} else if (stageType == "AggregationJobStage") {
Handle<AggregationJobStage> curAggregationJobStage =
unsafeCast<AggregationJobStage, AbstractJobStage>(curStage);
//source
Handle<SetIdentifier> sourceContext =
curAggregationJobStage->getSourceContext();
//get id of set
long sourceDataId = getFunctionality<DistributedStorageManagerServer>().
getIdForData(sourceContext->getDatabase(), sourceContext->getSetName());
//add the entry to the DATA_JOB_STAGE
long sourceMappingId;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(sourceDataId, jobInstanceStageId, 0, "Source", sourceMappingId);
std::cout << "||||create data job stage mapping: " << sourceDataId << "=>" << jobInstanceStageId << std::endl;
//sink
Handle<SetIdentifier> sinkContext =
curAggregationJobStage->getSinkContext();
//get id of set
long sinkDataId = getFunctionality<DistributedStorageManagerServer>().
getIdForData(sinkContext->getDatabase(), sinkContext->getSetName());
if (!curAggregationJobStage->needsToMaterializeAggOut()) {
std::string sinkSetType = "PartitionedHashSet";
getFunctionality<SelfLearningServer>().createData("", sinkContext->getDatabase() + ":"
+ sinkContext->getSetName(), curStage->getJobId(), sinkSetType, "IntermediateData", 8191,
0, -1, 1, sinkDataId);
}
//add the entry to the DATA_JOB_STAGE
long sinkMappingId;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(sinkDataId, jobInstanceStageId, -1, "Sink", sinkMappingId);
std::cout << "||||create data job stage mapping: " << sinkDataId << "=>" << jobInstanceStageId << std::endl;
} else if (stageType == "HashPartitionedJoinBuildHTJobStage") {
Handle<HashPartitionedJoinBuildHTJobStage> curHashPartitionJobStage =
unsafeCast<HashPartitionedJoinBuildHTJobStage, AbstractJobStage>
(curStage);
//source
Handle<SetIdentifier> sourceContext =
curHashPartitionJobStage->getSourceContext();
//get id of set
long sourceDataId = getFunctionality<DistributedStorageManagerServer>().
getIdForData(sourceContext->getDatabase(), sourceContext->getSetName());
//add the entry to the DATA_JOB_STAGE
long sourceMappingId;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(sourceDataId, jobInstanceStageId, -1, "Source", sourceMappingId);
std::cout << "||||create data job stage mapping: " << sourceDataId << "=>" << jobInstanceStageId << std::endl;
//sink
std::string sinkSetName = curHashPartitionJobStage->getHashSetName();
//get id of set
long sinkDataId;
std::string sinkSetType = "PartitionedHashSet";
getFunctionality<SelfLearningServer>().createData("", sinkSetName,
curStage->getJobId(), sinkSetType, "IntermediateData", 8191,
0, -1, 1, sinkDataId);
//add the entry to the DATA_JOB_STAGE
long sinkMappingId;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(sinkDataId, jobInstanceStageId, -1, "Sink", sinkMappingId);
std::cout << "||||create data job stage mapping: " << sinkDataId << "=>" << jobInstanceStageId << std::endl;
} else if (stageType == "BroadcastJoinBuildHTJobStage") {
Handle<BroadcastJoinBuildHTJobStage> curBroadcastJobStage =
unsafeCast<BroadcastJoinBuildHTJobStage, AbstractJobStage>
(curStage);
//source
Handle<SetIdentifier> sourceContext =
curBroadcastJobStage->getSourceContext();
//get id of set
long sourceDataId = getFunctionality<DistributedStorageManagerServer>().
getIdForData(sourceContext->getDatabase(), sourceContext->getSetName());
//add the entry to the DATA_JOB_STAGE
long sourceMappingId;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(sourceDataId, jobInstanceStageId, -1, "Source", sourceMappingId);
std::cout << "||||create data job stage mapping: " << sourceDataId << "=>" << jobInstanceStageId << std::endl;
//sink
std::string sinkSetName = curBroadcastJobStage->getHashSetName();
//get id of set
long sinkDataId;
std::string sinkSetType = "HashSet";
getFunctionality<SelfLearningServer>().createData("", sinkSetName,
curStage->getJobId(), sinkSetType, "IntermediateData", 8191,
0, -1, 1, sinkDataId);
//add the entry to the DATA_JOB_STAGE
long sinkMappingId;
getFunctionality<SelfLearningServer>().
createDataJobStageMapping(sinkDataId, jobInstanceStageId, -1, "Sink", sinkMappingId);
std::cout << "||||create data job stage mapping: " << sinkDataId << "=>" << jobInstanceStageId << std::endl;
} else {
std::cout << "Unrecognized JobStage Type: " << stageType << std::endl;
}
}
this->numHashKeys = 0;
for (int j = 0; j < shuffleInfo->getNumNodes(); j++) {
PDBWorkerPtr myWorker = getWorker();
PDBWorkPtr myWork = make_shared<GenericWork>([&, i, j, stagesToSchedule](PDBBuzzerPtr callerBuzzer) {
#ifdef PROFILING
auto scheduleBegin = std::chrono::high_resolution_clock::now();
#endif
const UseTemporaryAllocationBlock block(256 * 1024 * 1024);
int port = (*(this->standardResources))[j]->getPort();
PDB_COUT << "port:" << port << std::endl;
std::string ip = (*(this->standardResources))[j]->getAddress();
PDB_COUT << "ip:" << ip << std::endl;
size_t memory = (*(this->standardResources))[j]->getMemSize();
// create PDBCommunicator
pthread_mutex_lock(&connection_mutex);
PDB_COUT << "to connect to the remote node" << std::endl;
PDBCommunicatorPtr communicator = std::make_shared<PDBCommunicator>();
string errMsg;
bool success;
if (communicator->connectToInternetServer(logger, port, ip, errMsg)) {
success = false;
std::cout << errMsg << std::endl;
pthread_mutex_unlock(&connection_mutex);
callerBuzzer->buzz(PDBAlarm::GenericError, counter);
return;
}
pthread_mutex_unlock(&connection_mutex);
// get current stage to schedule
Handle<AbstractJobStage> stage = stagesToSchedule[i];
// schedule the stage
if (stage->getJobStageType() == "TupleSetJobStage") {
Handle<TupleSetJobStage> tupleSetStage =
unsafeCast<TupleSetJobStage, AbstractJobStage>(stage);
tupleSetStage->setTotalMemoryOnThisNode(memory);
success = scheduleStage(j, tupleSetStage, communicator, DeepCopy);
} else if (stage->getJobStageType() == "AggregationJobStage") {
Handle<AggregationJobStage> aggStage =
unsafeCast<AggregationJobStage, AbstractJobStage>(stage);
int numPartitionsOnThisNode =
(int)((double)(standardResources->at(j)->getNumCores()) *
partitionToCoreRatio);
if (numPartitionsOnThisNode == 0) {
numPartitionsOnThisNode = 1;
}
aggStage->setNumNodePartitions(numPartitionsOnThisNode);
aggStage->setAggTotalPartitions(shuffleInfo->getNumHashPartitions());
aggStage->setAggBatchSize(DEFAULT_BATCH_SIZE);
aggStage->setTotalMemoryOnThisNode(memory);
success = scheduleStage(j, aggStage, communicator, DeepCopy);
} else if (stage->getJobStageType() == "BroadcastJoinBuildHTJobStage") {
Handle<BroadcastJoinBuildHTJobStage> broadcastJoinStage =
unsafeCast<BroadcastJoinBuildHTJobStage, AbstractJobStage>(stage);
broadcastJoinStage->setTotalMemoryOnThisNode(memory);
success = scheduleStage(j, broadcastJoinStage, communicator, DeepCopy);
} else if (stage->getJobStageType() == "HashPartitionedJoinBuildHTJobStage") {
Handle<HashPartitionedJoinBuildHTJobStage> hashPartitionedJoinStage =
unsafeCast<HashPartitionedJoinBuildHTJobStage, AbstractJobStage>(stage);
int numPartitionsOnThisNode =
(int)((double)(standardResources->at(j)->getNumCores()) *
partitionToCoreRatio);
if (numPartitionsOnThisNode == 0) {
numPartitionsOnThisNode = 1;
}
hashPartitionedJoinStage->setNumNodePartitions(numPartitionsOnThisNode);
hashPartitionedJoinStage->setTotalMemoryOnThisNode(memory);
success = scheduleStage(j, hashPartitionedJoinStage, communicator, DeepCopy);
} else {
errMsg = "Unrecognized job stage";
std::cout << errMsg << std::endl;
success = false;
}
#ifdef PROFILING
auto scheduleEnd = std::chrono::high_resolution_clock::now();
std::cout << "Time Duration for Scheduling stage-" << stage->getStageId() << " on "
<< ip << ":"
<< std::chrono::duration_cast<std::chrono::duration<float>>(scheduleEnd -
scheduleBegin)
.count()
<< " seconds." << std::endl;
#endif
if (success == false) {
errMsg = std::string("Can't execute the ") + std::to_string(i) +
std::string("-th stage on the ") + std::to_string(j) +
std::string("-th node");
std::cout << errMsg << std::endl;
callerBuzzer->buzz(PDBAlarm::GenericError, counter);
return;
}
callerBuzzer->buzz(PDBAlarm::WorkAllDone, counter);
});
myWorker->execute(myWork, tempBuzzer);
}
while (counter < shuffleInfo->getNumNodes()) {
tempBuzzer->wait();
}
counter = 0;
if (selfLearningOrNot == true) {
//update the jobStage entry
getFunctionality<SelfLearningServer>().updateJobStageForCompletion(jobInstanceStageId, "Succeeded");
std::cout << "****NumHashKeys = " << numHashKeys << std::endl;
if (numHashKeys > 0) {
getFunctionality<SelfLearningServer>().updateJobStageForKeyDistribution(jobInstanceStageId-1, numHashKeys);
}
}
}
}
// JiaNote TODO: consolidate below three functions into a template function
// to replace: schedule(Handle<JobStage>& stage, PDBCommunicatorPtr communicator, ObjectCreationMode
// mode)
bool QuerySchedulerServer::scheduleStage(int index,
Handle<TupleSetJobStage>& stage,
PDBCommunicatorPtr communicator,
ObjectCreationMode mode) {
bool success;
std::string errMsg;
PDB_COUT << "to send the job stage with id=" << stage->getStageId() << " to the " << index
<< "-th remote node" << std::endl;
if (mode == DeepCopy) {
const UseTemporaryAllocationBlock block(256 * 1024 * 1024);
Handle<TupleSetJobStage> stageToSend =
deepCopyToCurrentAllocationBlock<TupleSetJobStage>(stage);
stageToSend->setNumNodes(this->shuffleInfo->getNumNodes());
stageToSend->setNumTotalPartitions(this->shuffleInfo->getNumHashPartitions());
Handle<Vector<Handle<Vector<HashPartitionID>>>> partitionIds =
makeObject<Vector<Handle<Vector<HashPartitionID>>>>();
std::vector<std::vector<HashPartitionID>> standardPartitionIds =
shuffleInfo->getPartitionIds();
for (unsigned int i = 0; i < standardPartitionIds.size(); i++) {
Handle<Vector<HashPartitionID>> nodePartitionIds =
makeObject<Vector<HashPartitionID>>();
for (unsigned int j = 0; j < standardPartitionIds[i].size(); j++) {
nodePartitionIds->push_back(standardPartitionIds[i][j]);
}
partitionIds->push_back(nodePartitionIds);
}
stageToSend->setNumPartitions(partitionIds);
Handle<Vector<String>> addresses = makeObject<Vector<String>>();
std::vector<std::string> standardAddresses = shuffleInfo->getAddresses();
for (unsigned int i = 0; i < standardAddresses.size(); i++) {
addresses->push_back(String(standardAddresses[i]));
}
stageToSend->setIPAddresses(addresses);
stageToSend->setNodeId(index);
success = communicator->sendObject<TupleSetJobStage>(stageToSend, errMsg);
if (!success) {
std::cout << errMsg << std::endl;
return false;
}
} else {
std::cout << "Error: No such object creation mode supported in query scheduler"
<< std::endl;
return false;
}
PDB_COUT << "to receive query response from the " << index << "-th remote node" << std::endl;
Handle<SetIdentifier> result = communicator->getNextObject<SetIdentifier>(success, errMsg);
if (result != nullptr) {
std::cout << "//////////update stats for TupleSetJobStage" << std::endl;
this->updateStats(result);
PDB_COUT << "TupleSetJobStage execute: wrote set:" << result->getDatabase() << ":"
<< result->getSetName() << std::endl;
} else {
PDB_COUT << "TupleSetJobStage execute failure: can't get results" << std::endl;
return false;
}
return true;
}
bool QuerySchedulerServer::scheduleStage(int index,
Handle<BroadcastJoinBuildHTJobStage>& stage,
PDBCommunicatorPtr communicator,
ObjectCreationMode mode) {
bool success;
std::string errMsg;
PDB_COUT << "to send the job stage with id=" << stage->getStageId() << " to the " << index
<< "-th remote node" << std::endl;
if (mode == Direct) {
success = communicator->sendObject<BroadcastJoinBuildHTJobStage>(stage, errMsg);
if (!success) {
std::cout << errMsg << std::endl;
return false;
}
} else if (mode == DeepCopy) {
Handle<BroadcastJoinBuildHTJobStage> stageToSend =
deepCopyToCurrentAllocationBlock<BroadcastJoinBuildHTJobStage>(stage);
stageToSend->nullifyComputePlanPointer();
success = communicator->sendObject<BroadcastJoinBuildHTJobStage>(stageToSend, errMsg);
if (!success) {
std::cout << errMsg << std::endl;
return false;
}
} else {
std::cout << "Error: No such object creation mode supported in query scheduler"
<< std::endl;
return false;
}
PDB_COUT << "to receive query response from the " << index << "-th remote node" << std::endl;
Handle<SetIdentifier> result = communicator->getNextObject<SetIdentifier>(success, errMsg);
if (result != nullptr) {
this->updateStats(result);
PDB_COUT << "BroadcastJoinBuildHTJobStage execute: wrote set:" << result->getDatabase()
<< ":" << result->getSetName() << std::endl;
} else {
PDB_COUT << "BroadcastJoinBuildHTJobStage execute failure: can't get results" << std::endl;
return false;
}
return true;
}
bool QuerySchedulerServer::scheduleStage(int index,
Handle<AggregationJobStage>& stage,
PDBCommunicatorPtr communicator,
ObjectCreationMode mode) {
bool success;
std::string errMsg;
PDB_COUT << "to send the job stage with id=" << stage->getStageId() << " to the " << index
<< "-th remote node" << std::endl;
if (mode == Direct) {
success = communicator->sendObject<AggregationJobStage>(stage, errMsg);
if (!success) {
std::cout << errMsg << std::endl;
return false;
}
} else if (mode == DeepCopy) {
Handle<AggregationJobStage> stageToSend =
deepCopyToCurrentAllocationBlock<AggregationJobStage>(stage);
success = communicator->sendObject<AggregationJobStage>(stageToSend, errMsg);
if (!success) {
std::cout << errMsg << std::endl;
return false;
}
} else {
std::cout << "Error: No such object creation mode supported in query scheduler"
<< std::endl;
return false;
}
PDB_COUT << "to receive query response from the " << index << "-th remote node" << std::endl;
Handle<SetIdentifier> result = communicator->getNextObject<SetIdentifier>(success, errMsg);
if (result != nullptr) {
this->updateStats(result);
pthread_mutex_lock(&connection_mutex);
this->numHashKeys += result->getNumHashKeys();
std::cout << "***result->getNumHashKeys()=" << result->getNumHashKeys() << std::endl;
std::cout << "***this->numHashKeys=" << this->numHashKeys << std::endl;
pthread_mutex_unlock(&connection_mutex);
PDB_COUT << "AggregationJobStage execute: wrote set:" << result->getDatabase() << ":"
<< result->getSetName() << std::endl;
} else {
PDB_COUT << "AggregationJobStage execute failure: can't get results" << std::endl;
return false;
}
return true;
}
bool QuerySchedulerServer::scheduleStage(int index,
Handle<HashPartitionedJoinBuildHTJobStage>& stage,
PDBCommunicatorPtr communicator,
ObjectCreationMode mode) {
bool success;
std::string errMsg;
PDB_COUT << "to send the job stage with id=" << stage->getStageId() << " to the " << index
<< "-th remote node" << std::endl;
if (mode == Direct) {
success = communicator->sendObject<HashPartitionedJoinBuildHTJobStage>(stage, errMsg);
if (!success) {
std::cout << errMsg << std::endl;
return false;
}
} else if (mode == DeepCopy) {
Handle<HashPartitionedJoinBuildHTJobStage> stageToSend =
deepCopyToCurrentAllocationBlock<HashPartitionedJoinBuildHTJobStage>(stage);
stageToSend->nullifyComputePlanPointer();
success = communicator->sendObject<HashPartitionedJoinBuildHTJobStage>(stageToSend, errMsg);
if (!success) {
std::cout << errMsg << std::endl;
return false;
}
} else {
std::cout << "Error: No such object creation mode supported in query scheduler"
<< std::endl;
return false;
}
PDB_COUT << "to receive query response from the " << index << "-th remote node" << std::endl;
Handle<SetIdentifier> result = communicator->getNextObject<SetIdentifier>(success, errMsg);
if (result != nullptr) {
this->updateStats(result);
pthread_mutex_lock(&connection_mutex);
this->numHashKeys += result->getNumHashKeys();
std::cout << "***result->getNumHashKeys()=" << result->getNumHashKeys() << std::endl;
std::cout << "***this->numHashKeys=" << this->numHashKeys << std::endl;
pthread_mutex_unlock(&connection_mutex);
PDB_COUT << "HashPartitionedJoinBuildHTJobStage execute: wrote set:"
<< result->getDatabase() << ":" << result->getSetName() << std::endl;
} else {
PDB_COUT << "HashPartitionedJoinBuildHTJobStage execute failure: can't get results"
<< std::endl;
return false;
}
return true;
}
bool QuerySchedulerServer::parseTCAPString(Handle<Vector<Handle<Computation>>> myComputations,
std::string myTCAPString) {
TCAPAnalyzer tcapAnalyzer(
this->jobId, myComputations, myTCAPString, this->logger, this->conf,
getFunctionality<SelfLearningServer>().getDB(), false);
return tcapAnalyzer.analyze(this->queryPlan, this->interGlobalSets);
}
// to replace: printCurrentPlan()
void QuerySchedulerServer::printStages() {
for (int i = 0; i < this->queryPlan.size(); i++) {
PDB_COUT << "#########The " << i << "-th Plan#############" << std::endl;
queryPlan[i]->print();
}
}
// to replace: schedule()
// this must be invoked after initialize() and before cleanup()
void QuerySchedulerServer::scheduleQuery() {
// query plan
int numStages = this->queryPlan.size();
if (numStages > 1) {
PDB_COUT << "#####################################" << std::endl;
PDB_COUT << "WARNING: GraphIr generates " << numStages << " stages" << std::endl;
PDB_COUT << "#####################################" << std::endl;
}
std::shared_ptr<ShuffleInfo> shuffleInfo =
std::make_shared<ShuffleInfo>(this->standardResources, this->partitionToCoreRatio);
scheduleStages(this->queryPlan, this->interGlobalSets, shuffleInfo);
}
void QuerySchedulerServer::collectStats() {
this->statsForOptimization = make_shared<Statistics>();
atomic_int counter;
counter = 0;
PDBBuzzerPtr tempBuzzer = make_shared<PDBBuzzer>([&](PDBAlarm myAlarm, atomic_int& counter) {
counter++;
PDB_COUT << "counter = " << counter << std::endl;
});
if (this->standardResources == nullptr) {
initialize(true);
}
for (int i = 0; i < this->standardResources->size(); i++) {
PDBWorkerPtr myWorker = getWorker();
PDBWorkPtr myWork = make_shared<GenericWork>([&, i](PDBBuzzerPtr callerBuzzer) {
const UseTemporaryAllocationBlock block(4 * 1024 * 1024);
PDB_COUT << "to collect stats on the " << i << "-th node" << std::endl;
int port = (*(this->standardResources))[i]->getPort();
PDB_COUT << "port:" << port << std::endl;
std::string ip = (*(this->standardResources))[i]->getAddress();
PDB_COUT << "ip:" << ip << std::endl;
// create PDBCommunicator
pthread_mutex_lock(&connection_mutex);
PDB_COUT << "to connect to the remote node" << std::endl;
PDBCommunicatorPtr communicator = std::make_shared<PDBCommunicator>();
string errMsg;
bool success;
if (communicator->connectToInternetServer(logger, port, ip, errMsg)) {
success = false;
std::cout << errMsg << std::endl;
pthread_mutex_unlock(&connection_mutex);
callerBuzzer->buzz(PDBAlarm::GenericError, counter);
return;
}
pthread_mutex_unlock(&connection_mutex);
// send StorageCollectStats to remote server
Handle<StorageCollectStats> collectStatsMsg = makeObject<StorageCollectStats>();
success = communicator->sendObject<StorageCollectStats>(collectStatsMsg, errMsg);
if (!success) {
std::cout << errMsg << std::endl;
callerBuzzer->buzz(PDBAlarm::GenericError, counter);
return;
}
// receive StorageCollectStatsResponse from remote server
PDB_COUT << "to receive response from the " << i << "-th remote node" << std::endl;
Handle<StorageCollectStatsResponse> result =
communicator->getNextObject<StorageCollectStatsResponse>(success, errMsg);
if (result != nullptr) {
// update stats
Handle<Vector<Handle<SetIdentifier>>> stats = result->getStats();
if (statsForOptimization == nullptr) {
statsForOptimization = make_shared<Statistics>();
}
for (int j = 0; j < stats->size(); j++) {
Handle<SetIdentifier> setToUpdateStats = (*stats)[j];
this->updateStats(setToUpdateStats);
}
} else {
errMsg = "Collect response execute failure: can't get results";
std::cout << errMsg << std::endl;
callerBuzzer->buzz(PDBAlarm::GenericError, counter);
return;
}
result = nullptr;
if (success == false) {
errMsg = std::string("Can't collect stats from node with id=") + std::to_string(i) +
std::string(" and ip=") + ip;
std::cout << errMsg << std::endl;
callerBuzzer->buzz(PDBAlarm::GenericError, counter);
return;
}
callerBuzzer->buzz(PDBAlarm::WorkAllDone, counter);
});
myWorker->execute(myWork, tempBuzzer);
}
while (counter < this->standardResources->size()) {
tempBuzzer->wait();
}
counter = 0;
}
void QuerySchedulerServer::updateStats(Handle<SetIdentifier> setToUpdateStats) {
std::string databaseName = setToUpdateStats->getDatabase();
std::string setName = setToUpdateStats->getSetName();
size_t numPages = setToUpdateStats->getNumPages();
statsForOptimization->incrementNumPages(databaseName, setName, numPages);
size_t pageSize = setToUpdateStats->getPageSize();
statsForOptimization->setPageSize(databaseName, setName, pageSize);
size_t numBytes = numPages * pageSize;
statsForOptimization->incrementNumBytes(databaseName, setName, numBytes);
std::cout << "to increment " << numBytes << " for size" << std::endl;
}
void QuerySchedulerServer::resetStats(Handle<SetIdentifier> setToResetStats) {
std::string databaseName = setToResetStats->getDatabase();
std::string setName = setToResetStats->getSetName();
statsForOptimization->setNumPages(databaseName, setName, 0);
statsForOptimization->setPageSize(databaseName, setName, 0);
statsForOptimization->setNumBytes(databaseName, setName, 0);
}
std::shared_ptr<ShuffleInfo> QuerySchedulerServer::getShuffleInfo () {
if (this->shuffleInfo == nullptr) {
initialize(true);
this->shuffleInfo = std::make_shared<ShuffleInfo>(
this->standardResources, this->partitionToCoreRatio);
}
return this->shuffleInfo;
}
void QuerySchedulerServer::registerHandlers(PDBServer& forMe) {
// handler to schedule a Computation-based query graph
forMe.registerHandler(
ExecuteComputation_TYPEID,
make_shared<SimpleRequestHandler<ExecuteComputation>>(
[&](Handle<ExecuteComputation> request, PDBCommunicatorPtr sendUsingMe) {
std::string errMsg;
bool success;
// parse the query
const UseTemporaryAllocationBlock block{256 * 1024 * 1024};
std::cout << "Got the ExecuteComputation object" << std::endl;
Handle<Vector<Handle<Computation>>> computations =
sendUsingMe->getNextObject<Vector<Handle<Computation>>>(success, errMsg);
std::string tcapString = request->getTCAPString();
this->jobId = this->getNextJobId();
long id = -1;
long instanceId = -1;
if (this->selfLearningOrNot == true) {
std::cout << "To create the Job if not existing" << std::endl;
bool ret = getFunctionality<SelfLearningServer>().createJob(request->getJobName(),
tcapString, computations, id);
if (ret == true) {
size_t numComputations = computations->size();
for (size_t i = 0; i < numComputations; i++) {
Handle<Computation> curComp = (*computations)[i];
std::cout << "check computation: " << curComp->getComputationName() << std::endl;
if((curComp->getComputationType() == "JoinComp")||(curComp->getComputationType() == "ClusterAggregationComp")) {
std::cout << "to populate lambdas" << std::endl;
curComp->populateLambdas(id, getFunctionality<SelfLearningWrapperServer>());
}
}
}
getFunctionality<SelfLearningServer>().createJobInstance (id,
this->jobId, instanceId);
}
DistributedStorageManagerClient dsmClient(this->port, "localhost", logger);
// create the database first
success = dsmClient.createDatabase(this->jobId, errMsg);
if (success == true) {
// we do not use dynamic planning
if (this->dynamicPlanningOrNot == false) {
success = parseTCAPString(computations, tcapString);
if (success == false) {
errMsg =
"FATAL ERROR in QuerySchedulerServer: can't parse TCAP string.\n" +
tcapString;
} else {
// create intermediate sets:
PDB_COUT << "to create intermediate sets" << std::endl;
if (success == true) {
for (int i = 0; i < this->interGlobalSets.size(); i++) {
std::string errMsg;
Handle<SetIdentifier> aggregationSet = this->interGlobalSets[i];
bool res =
dsmClient.createTempSet(aggregationSet->getDatabase(),
aggregationSet->getSetName(),
"IntermediateSet",
errMsg,
aggregationSet->getPageSize(),
this->jobId,
nullptr,
nullptr,
aggregationSet->getDesiredSize()
/*1*/
/*1000*/);
if (res != true) {
std::cout << "can't create temp set: " << errMsg
<< std::endl;
} else {
PDB_COUT << "Created set with database="
<< aggregationSet->getDatabase()
<< ", set=" << aggregationSet->getSetName()
<< std::endl;
}
}
getFunctionality<QuerySchedulerServer>().printStages();
PDB_COUT << "To get the resource object from the resource manager"
<< std::endl;
getFunctionality<QuerySchedulerServer>().initialize(true);
PDB_COUT << "To schedule the query to run on the cluster"
<< std::endl;
getFunctionality<QuerySchedulerServer>().scheduleQuery();
PDB_COUT << "to remove intermediate sets" << std::endl;
for (int i = 0; i < this->interGlobalSets.size(); i++) {
std::string errMsg;
Handle<SetIdentifier> intermediateSet =
this->interGlobalSets[i];
bool res =
dsmClient.removeTempSet(intermediateSet->getDatabase(),
intermediateSet->getSetName(),
"IntermediateData",
errMsg);
if (res != true) {
std::cout << "can't remove temp set: " << errMsg
<< std::endl;
} else {
PDB_COUT << "Removed set with database="
<< intermediateSet->getDatabase()
<< ", set=" << intermediateSet->getSetName()
<< std::endl;
}
}
}
}
} else {
// analyze resources
PDB_COUT << "To get the resource object from the resource manager"
<< std::endl;
getFunctionality<QuerySchedulerServer>().initialize(true);
this->shuffleInfo = std::make_shared<ShuffleInfo>(
this->standardResources, this->partitionToCoreRatio);
if (this->statsForOptimization == nullptr) {
this->collectStats();
}
// dyanmic planning
// initialize tcapAnalyzer
this->tcapAnalyzerPtr = make_shared<TCAPAnalyzer>(
jobId, computations, tcapString, this->logger, this->conf,
getFunctionality<SelfLearningServer>().getDB(), true);
this->tcapAnalyzerPtr->setNumNodes(this->standardResources->size());
int jobStageId = 0;
while (this->tcapAnalyzerPtr->getNumSources() > 0) {
std::vector<Handle<AbstractJobStage>> jobStages;
std::vector<Handle<SetIdentifier>> intermediateSets;
#ifdef PROFILING
auto dynamicPlanBegin = std::chrono::high_resolution_clock::now();
std::cout << "JobStageId " << jobStageId << "============>";
#endif
while ((jobStages.size() == 0) &&
(this->tcapAnalyzerPtr->getNumSources() > 0)) {
// analyze all sources and select a source based on cost model
int indexOfBestSource = this->tcapAnalyzerPtr->getBestSource(
this->statsForOptimization);
// get the job stages and intermediate data sets for this source
std::string sourceName =
this->tcapAnalyzerPtr->getSourceSetName(indexOfBestSource);
std::cout << "best source is " << sourceName << std::endl;
Handle<SetIdentifier> sourceSet =
this->tcapAnalyzerPtr->getSourceSetIdentifier(sourceName);
AtomicComputationPtr sourceAtomicComp =
this->tcapAnalyzerPtr->getSourceComputation(sourceName);
unsigned int sourceConsumerIndex =
this->tcapAnalyzerPtr->getNextConsumerIndex(sourceName);
bool hasConsumers = this->tcapAnalyzerPtr->getNextStagesOptimized(
jobStages,
intermediateSets,
sourceAtomicComp,
sourceSet,
sourceConsumerIndex,
jobStageId);
if (jobStages.size() > 0) {
this->tcapAnalyzerPtr->incrementConsumerIndex(sourceName);
break;
} else {
if (hasConsumers == false) {
std::cout << "we didn't meet a penalized set and we remove "
"source "
<< sourceName << std::endl;
this->tcapAnalyzerPtr->removeSource(sourceName);
}
}
}
this->statsForOptimization->clearPenalizedCosts();
#ifdef PROFILING
auto dynamicPlanEnd = std::chrono::high_resolution_clock::now();
std::cout << "Time Duration for Dynamic Planning: "
<< std::chrono::duration_cast<std::chrono::duration<float>>(
dynamicPlanEnd - dynamicPlanBegin)
.count()
<< " seconds." << std::endl;
auto createSetBegin = std::chrono::high_resolution_clock::now();
#endif
// create intermediate sets
for (int i = 0; i < intermediateSets.size(); i++) {
std::string errMsg;
Handle<SetIdentifier> intermediateSet = intermediateSets[i];
bool res = dsmClient.createTempSet(intermediateSet->getDatabase(),
intermediateSet->getSetName(),
"IntermediateData",
errMsg,
intermediateSet->getPageSize(),
this->jobId,
nullptr,
nullptr,
intermediateSet->getDesiredSize()
/*1*/
/*1000*/);
if (res != true) {
std::cout << "can't create temp set: " << errMsg << std::endl;
} else {
PDB_COUT << "Created set with database="
<< intermediateSet->getDatabase()
<< ", set=" << intermediateSet->getSetName()
<< std::endl;
}
}
#ifdef PROFILING
auto createSetEnd = std::chrono::high_resolution_clock::now();
std::cout << "Time Duration for Creating intermdiate sets: "
<< std::chrono::duration_cast<std::chrono::duration<float>>(
createSetEnd - createSetBegin)
.count()
<< " seconds." << std::endl;
auto scheduleBegin = std::chrono::high_resolution_clock::now();
#endif
// schedule this job stages
PDB_COUT << "To schedule the query to run on the cluster" << std::endl;
getFunctionality<QuerySchedulerServer>().scheduleStages(
jobStages, intermediateSets, shuffleInfo, instanceId);
#ifdef PROFILING
auto scheduleEnd = std::chrono::high_resolution_clock::now();
std::cout << "Time Duration for Scheduling stages: "
<< std::chrono::duration_cast<std::chrono::duration<float>>(
scheduleEnd - scheduleBegin)
.count()
<< " seonds." << std::endl;
auto removeSetBegin = std::chrono::high_resolution_clock::now();
#endif
// to remove the intermediate sets:
for (int i = 0; i < intermediateSets.size(); i++) {
std::string errMsg;
Handle<SetIdentifier> intermediateSet = intermediateSets[i];
// check whether intermediateSet is a source set and has consumer
// number > 0
std::string key = intermediateSet->getDatabase() + ":" +
intermediateSet->getSetName();
unsigned int numConsumers =
this->tcapAnalyzerPtr->getNumConsumers(key);
if (numConsumers > 0) {
// to remember this set
this->interGlobalSets.push_back(intermediateSet);
} else {
if (selfLearningOrNot == true) {
// to get the id of the set
long id = getFunctionality<DistributedStorageManagerServer>().getIdForData(
intermediateSet->getDatabase(), intermediateSet->getSetName());
std::cout <<"///////////id for " << intermediateSet->getDatabase() << ":" << intermediateSet->getSetName()
<<" is " << id << std::endl;
// to get the size of the set
size_t size = this->statsForOptimization->getNumBytes(
intermediateSet->getDatabase(), intermediateSet->getSetName());
// update the size of the set
getFunctionality<SelfLearningServer>().updateDataForSize(id, size);
std::cout <<"///////////to update data with id=" << id << " for size=" << size << std::endl;
}
bool res =
dsmClient.removeTempSet(intermediateSet->getDatabase(),
intermediateSet->getSetName(),
"IntermediateData",
errMsg);
if (res != true) {
std::cout << "can't remove temp set: " << errMsg
<< std::endl;
} else {
std::cout << "Removed set with database="
<< intermediateSet->getDatabase()
<< ", set=" << intermediateSet->getSetName()
<< std::endl;
}
}
}
#ifdef PROFILING
auto removeSetEnd = std::chrono::high_resolution_clock::now();
std::cout << "Time Duration for Removing intermediate sets: "
<< std::chrono::duration_cast<std::chrono::duration<float>>(
removeSetEnd - removeSetBegin)
.count()
<< " seconds." << std::endl;
#endif
}
// to remove remaining intermediate sets:
PDB_COUT << "to remove intermediate sets" << std::endl;
for (int i = 0; i < this->interGlobalSets.size(); i++) {
std::string errMsg;
Handle<SetIdentifier> intermediateSet = this->interGlobalSets[i];
bool res = dsmClient.removeTempSet(intermediateSet->getDatabase(),
intermediateSet->getSetName(),
"IntermediateData",
errMsg);
if (res != true) {
std::cout << "can't remove temp set: " << errMsg << std::endl;
} else {
PDB_COUT << "Removed set with database="
<< intermediateSet->getDatabase()
<< ", set=" << intermediateSet->getSetName() << std::endl;
}
}
}
}
if (selfLearningOrNot == true) {
std::string status;
if (success == true) {
status = "Succeeded";
} else {
status = "Failed";
}
getFunctionality<SelfLearningServer>().updateJobInstanceForCompletion (instanceId, status);
}
PDB_COUT << "To send back response to client" << std::endl;
Handle<SimpleRequestResult> result =
makeObject<SimpleRequestResult>(success, errMsg);
if (!sendUsingMe->sendObject(result, errMsg)) {
PDB_COUT << "to cleanup" << std::endl;
getFunctionality<QuerySchedulerServer>().cleanup();
return std::make_pair(false, errMsg);
}
PDB_COUT << "to cleanup" << std::endl;
getFunctionality<QuerySchedulerServer>().cleanup();
return std::make_pair(true, errMsg);
}
));
}
}
#endif
| 49.975132 | 147 | 0.511724 | [
"object",
"vector",
"model"
] |
40b474e4c8d9ab645c629e1f4407de526aa41d05 | 456 | cpp | C++ | 08_03_thread/src/libs/libserver/console_cmd_thread.cpp | Thanalan/GameBookServer-master | 506b4fe1eece1a3c0bd1100fe14764b63885b2bf | [
"MIT"
] | 83 | 2019-12-03T08:42:15.000Z | 2022-03-30T13:22:37.000Z | 08_03_thread/src/libs/libserver/console_cmd_thread.cpp | Thanalan/GameBookServer-master | 506b4fe1eece1a3c0bd1100fe14764b63885b2bf | [
"MIT"
] | 1 | 2021-08-06T10:40:57.000Z | 2021-08-09T06:33:43.000Z | 08_03_thread/src/libs/libserver/console_cmd_thread.cpp | Thanalan/GameBookServer-master | 506b4fe1eece1a3c0bd1100fe14764b63885b2bf | [
"MIT"
] | 45 | 2020-05-29T03:22:48.000Z | 2022-03-21T16:19:01.000Z | #include "console_cmd_thread.h"
#include "message_system_help.h"
void ConsoleCmdThread::RegisterHandler()
{
OnRegisterHandler("-entity", BindFunP1(this, &ConsoleCmdThread::HandleEntity));
}
void ConsoleCmdThread::HandleHelp()
{
std::cout << "\t-entity.\t\tshow all thread's entity." << std::endl;
}
void ConsoleCmdThread::HandleEntity(std::vector<std::string>& params)
{
MessageSystemHelp::DispatchPacket(Proto::MsgId::MI_CmdShowThreadEntites, 0);
}
| 25.333333 | 80 | 0.758772 | [
"vector"
] |
40b5b8dda5834a79707cbcb1d593ae239c1ed4b6 | 843 | hpp | C++ | include/JSON.hpp | Gustafsson88/lab01 | 6af40b0b0876deb39808315ccaf1958970e66a52 | [
"MIT"
] | null | null | null | include/JSON.hpp | Gustafsson88/lab01 | 6af40b0b0876deb39808315ccaf1958970e66a52 | [
"MIT"
] | null | null | null | include/JSON.hpp | Gustafsson88/lab01 | 6af40b0b0876deb39808315ccaf1958970e66a52 | [
"MIT"
] | null | null | null | // Copyright 2021 Alexsand Guchkov <firer.a45@gmail.com>
#pragma once
#include <iostream>
#include <string>
#include <nlohmann/json.hpp>
#include <vector>
#include <iomanip>
#include <fstream>
#include <any>
using nlohmann::json;
struct Students
{
std::string name;
std::any group;
std::any avg;
std::vector<std::any> debt;
int len_name;
int len_group;
int len_avg;
int len_debt;
};
class JSON {
public:
explicit JSON(std::string &j);
JSON();
void create_vec(json &j);
json get_js();
~JSON();
void read_file(std::string &path);
void out();
void len_all();
void get_length();
void length_max();
int len_name_max = 0;
int len_group_max = 0;
int len_avg_max = 7;
int len_debt_max = 0;
private:
json _j;
std::vector<Students> all_students;
int _size_vector = 0;
std::string str = "";
};
| 16.86 | 56 | 0.666667 | [
"vector"
] |
8adb6ce060bbc8a93560e38606920657b38e528a | 128,234 | cpp | C++ | lib/Conversion/TorchToLinalg/TorchToLinalg.cpp | Yutyrannus/torch-mlir | 05c4dd8e3905ad5c457922fb5bed70bccb8b2081 | [
"Apache-2.0"
] | null | null | null | lib/Conversion/TorchToLinalg/TorchToLinalg.cpp | Yutyrannus/torch-mlir | 05c4dd8e3905ad5c457922fb5bed70bccb8b2081 | [
"Apache-2.0"
] | null | null | null | lib/Conversion/TorchToLinalg/TorchToLinalg.cpp | Yutyrannus/torch-mlir | 05c4dd8e3905ad5c457922fb5bed70bccb8b2081 | [
"Apache-2.0"
] | null | null | null | //===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Also available under a BSD-style license. See LICENSE.
//
//===----------------------------------------------------------------------===//
#include "torch-mlir/Conversion/TorchToLinalg/TorchToLinalg.h"
#include "../PassDetail.h"
#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Traits.h"
#include "mlir/IR/Matchers.h"
#include "mlir/Transforms/DialectConversion.h"
#include "torch-mlir/Dialect/Torch/IR/TorchOps.h"
#include "torch-mlir/Dialect/Torch/Utils/Utils.h"
#include "torch-mlir/Dialect/TorchConversion/IR/TorchConversionDialect.h"
#include "torch-mlir/Dialect/TorchConversion/Transforms/BackendTypeConversion.h"
using namespace mlir;
using namespace mlir::torch;
using namespace mlir::torch::Torch;
// -----------------------------------------------------------------------------
// Patterns (as this grows, it should be organized into multiple files)
// -----------------------------------------------------------------------------
// This is going to eventually be O(#aten ops), which is in the 100s.
//
// Most of these patterns consist of:
// 1. Checking that the operand/result types and other static properties are
// good-enough to create a valid linalg op (such as operands being of
// ranks/dtypes acceptable to the linalg op).
// 2. Creating dynamic error guards, usually checking a predicate on the
// compatibility of operand shapes.
// 3. Creating init tensors for the computation op. Usually this involves
// reifying IR for a shape transfer function based on the operand shapes.
// 4. Creating a named linalg op to replace the original op.
//
// TODO: Use linalg OpDSL to autogenerate at least 1)/2)/3) such
// that these patterns become mostly mechanical associations of
// "aten.foo -> linalg.foo".
static LogicalResult verifyLinalgCompatibleTypes(Operation *op,
PatternRewriter &rewriter) {
// Check the value tensor is ranked as expected by Linalg.
// TODO: Remove this check but use a separate verification pass to verify the
// invariants expected by later passes.
auto isValidLinalgType = [](Type type) {
auto tensor = type.dyn_cast<ValueTensorType>();
return !tensor ||
tensor.toBuiltinTensor().dyn_cast_or_null<RankedTensorType>();
};
bool valid = llvm::all_of(op->getOperandTypes(), isValidLinalgType) &&
llvm::all_of(op->getResultTypes(), isValidLinalgType);
if (!valid)
return rewriter.notifyMatchFailure(op, "type cannot be lowered to linalg");
return success();
}
static LogicalResult checkNotNone(PatternRewriter &rewriter, Operation *op,
Value v) {
Type type = v.getType();
if (type.isa<OptionalType>() || type.isa<Torch::NoneType>() ||
type.isa<mlir::NoneType>())
return rewriter.notifyMatchFailure(op, "unimplemented None type arg");
return success();
}
// Generate IR: dim = dim >= 0 ? dim : dim + inputRank
static Value toPositiveDimDynamic(OpBuilder &b, Location loc, Value dim,
Value inputRank) {
assert(dim.getType().isa<IntegerType>() &&
"dim arg of toPositiveDim must be integer type");
Value dimAddInputRank = b.create<arith::AddIOp>(loc, dim, inputRank);
Value cst0 =
b.create<arith::ConstantOp>(loc, b.getZeroAttr(inputRank.getType()));
Value predDimGEZero =
b.create<arith::CmpIOp>(loc, arith::CmpIPredicate::sge, dim, cst0);
Value dimInt = b.create<SelectOp>(loc, predDimGEZero, dim, dimAddInputRank);
return dimInt;
}
// Generate IR: assert(dim >= 0 && dim < inputRank)
static void assertIsValidDim(OpBuilder &b, Location loc, Value dim,
Value inputRank) {
assert(dim.getType().isa<IntegerType>() &&
"dim arg of assertIsValidDim must be integer type");
Value cst0 =
b.create<arith::ConstantOp>(loc, b.getZeroAttr(inputRank.getType()));
Value predGEZero =
b.create<arith::CmpIOp>(loc, arith::CmpIPredicate::sge, dim, cst0);
b.create<AssertOp>(loc, predGEZero,
b.getStringAttr("dim must be greater or equal to zero"));
Value predLTInputRank =
b.create<arith::CmpIOp>(loc, arith::CmpIPredicate::slt, dim, inputRank);
b.create<AssertOp>(loc, predLTInputRank,
b.getStringAttr("dim must be smaller than inputRank"));
}
// Hack to deal with the Torch list type arguments which is not supported end
// to end. Constant values can be be extracted directly and non constant
// list values are not supported.
// TODO: loose this constraint when properly support list type
static bool isConstantIntListMatching(Value value,
SmallVectorImpl<int64_t> &expects) {
SmallVector<int64_t> intValues;
if (!matchPattern(value, m_TorchConstantIntList(intValues)))
return false;
if (intValues.size() != expects.size())
return false;
for (auto it : llvm::zip(intValues, expects)) {
if (std::get<0>(it) != std::get<1>(it))
return false;
}
return true;
}
static Value castIntToIndex(OpBuilder &b, Location loc, Value v) {
assert(v.getType().isa<IntegerType>() && "must be called with integer type");
return b.create<arith::IndexCastOp>(loc, b.getIndexType(), v);
}
static Value castIndexToInt(OpBuilder &b, Location loc, Value idx) {
assert(idx.getType().isa<IndexType>() && "must be called with integer type");
return b.create<arith::IndexCastOp>(loc, b.getI64Type(), idx);
}
static Value getDimOp(OpBuilder &b, Location loc, Value v, int dimension) {
return b.create<tensor::DimOp>(loc, v, dimension);
}
static void checkDimEqualHelper(OpBuilder &b, Location loc, Value lhsDim,
Value rhsDim) {
Type lhsType = lhsDim.getType();
Type rhsType = rhsDim.getType();
auto checkIntOrIndex = [](Type type) {
assert(type.isa<IntegerType>() ||
type.isa<IndexType>() && "must be either integer or index type");
};
checkIntOrIndex(lhsType);
checkIntOrIndex(rhsType);
Value lhsDimInt = lhsType.isIndex() ? castIndexToInt(b, loc, lhsDim) : lhsDim;
Value rhsDimInt = rhsType.isIndex() ? castIndexToInt(b, loc, rhsDim) : rhsDim;
Value contractingDimEqual = b.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, lhsDimInt, rhsDimInt);
b.create<AssertOp>(loc, contractingDimEqual,
b.getStringAttr("mismatching contracting dimension"));
}
static SmallVector<Value> getTensorSizesUntilDim(OpBuilder &b, Location loc,
Value tensor, int dim) {
RankedTensorType type = tensor.getType().cast<RankedTensorType>();
assert(dim < type.getRank() &&
"The given dim must be smaller than tensor rank");
(void)type;
SmallVector<Value> sizes;
for (int i = 0; i <= dim; i++)
sizes.push_back(getDimOp(b, loc, tensor, i));
return sizes;
}
static SmallVector<Value> getTensorSizes(OpBuilder &b, Location loc,
Value tensor) {
RankedTensorType type = tensor.getType().cast<RankedTensorType>();
return getTensorSizesUntilDim(b, loc, tensor, type.getRank() - 1);
}
static Value createZeroInitTensor(OpBuilder &b, Location loc, ValueRange sizes,
Type elemTy) {
Value initTensor = b.create<linalg::InitTensorOp>(loc, sizes, elemTy);
RankedTensorType type = initTensor.getType().cast<RankedTensorType>();
Value c0 =
b.create<arith::ConstantOp>(loc, b.getZeroAttr(type.getElementType()));
return b.create<linalg::FillOp>(loc, c0, initTensor).getResult(0);
}
// Helper function to caculate the output tensor dims for convolution-like ops.
// Along each dim:
// dim_out =
// floor((dim_in + 2 * padding - dilation * (kernelSize - 1) - 1) / stride) + 1
static Value getOutputDimForConvOps(OpBuilder &b, Location loc, Value in,
Value paddingInt, Value dilationInt,
Value kernelSizeInt, Value strideInt) {
Value c1 = b.create<arith::ConstantOp>(loc, b.getI64IntegerAttr(1));
Value c2 = b.create<arith::ConstantOp>(loc, b.getI64IntegerAttr(2));
Value doublePadding = b.create<arith::MulIOp>(loc, paddingInt, c2);
// in + 2 * padding
Value inAddDoublePadding =
b.create<arith::AddIOp>(loc, castIndexToInt(b, loc, in), doublePadding);
// dilation * (kernelSize - 1)
Value kernelSizeSub1 = b.create<arith::SubIOp>(loc, kernelSizeInt, c1);
Value dilationTimesKernelSize =
b.create<arith::MulIOp>(loc, dilationInt, kernelSizeSub1);
Value temp =
b.create<arith::SubIOp>(loc, inAddDoublePadding, dilationTimesKernelSize);
Value dividend = b.create<arith::SubIOp>(loc, temp, c1);
Value division = b.create<arith::FloorDivSIOp>(loc, dividend, strideInt);
Value out = b.create<arith::AddIOp>(loc, division, c1);
return castIntToIndex(b, loc, out);
}
static SmallVector<Value>
getAsConstantIntValues(OpBuilder &b, Location loc,
SmallVectorImpl<int64_t> &ints) {
return llvm::to_vector<4>(llvm::map_range(ints, [&](int64_t val) -> Value {
return b.create<arith::ConstantOp>(loc,
b.getIntegerAttr(b.getI64Type(), val));
}));
}
static SmallVector<Value>
getAsConstantIndexValues(OpBuilder &b, Location loc,
SmallVectorImpl<int64_t> &ints) {
return llvm::to_vector<4>(llvm::map_range(ints, [&](int64_t val) -> Value {
return b.create<arith::ConstantOp>(loc, b.getIndexAttr(val));
}));
}
static SmallVector<OpFoldResult>
getAsOpFoldResult(OpBuilder &b, Location loc, SmallVectorImpl<int64_t> &ints) {
return llvm::to_vector<4>(llvm::map_range(
ints, [&](int64_t val) -> OpFoldResult { return b.getIndexAttr(val); }));
}
// This is a temporary solution to deal with types that are not fully supported
// like list, dict. For those container tyes, this helper can be used to
// convert their elements to valid target type.
// TODO: remove this when list gets full support.
static SmallVector<Value> getTypeConvertedValues(OpBuilder &b, Location loc,
TypeConverter *converter,
SmallVectorImpl<Value> &vs) {
return llvm::to_vector<4>(llvm::map_range(vs, [&](Value v) {
return converter->materializeTargetConversion(
b, loc, converter->convertType(v.getType()), v);
}));
}
// Helper function to get the padding tensor given the padding int values.
// It's assumed that the padding on the low end and high end are the same.
static Value getPaddedTensor(Operation *op, OpBuilder &b, Value &input,
SmallVectorImpl<int64_t> &paddingInts) {
assert(input.getType().isa<RankedTensorType>() &&
"input must be RankedTensorType");
Location loc = op->getLoc();
Value c0 = b.create<arith::ConstantOp>(
loc,
b.getZeroAttr(input.getType().cast<RankedTensorType>().getElementType()));
SmallVector<OpFoldResult> paddings = getAsOpFoldResult(b, loc, paddingInts);
Type ranked4DTensorType = linalg::PadTensorOp::inferResultType(
input.getType().cast<RankedTensorType>(), paddingInts, paddingInts);
Value paddedInput = linalg::PadTensorOp::createPadScalarOp(
ranked4DTensorType, input, c0, /*low=*/paddings, /*high=*/paddings,
/*packing=*/false, loc, b);
return paddedInput;
}
static Value buildNormalCdf(OpBuilder &b, Location &loc, Value x, Value mean,
Value sigma) {
Type elementType = x.getType();
Value xMinusMean = b.create<arith::SubFOp>(loc, x, mean);
Value two = b.create<arith::ConstantOp>(loc, FloatAttr::get(elementType, 2));
Value sqrt2 = b.create<math::SqrtOp>(loc, two);
Value erfArg = b.create<arith::DivFOp>(loc, xMinusMean, sqrt2);
Value erf = b.create<math::ErfOp>(loc, erfArg);
Value one = b.create<arith::ConstantOp>(loc, FloatAttr::get(elementType, 1));
Value erfPlus1 = b.create<arith::AddFOp>(loc, one, erf);
Value oneHalf =
b.create<arith::ConstantOp>(loc, FloatAttr::get(elementType, 0.5));
Value normalCdf = b.create<arith::MulFOp>(loc, oneHalf, erfPlus1);
return normalCdf;
}
static Value buildUnitNormalCdf(OpBuilder &b, Location &loc, Value x) {
Type elementType = x.getType();
Value zero = b.create<arith::ConstantOp>(loc, FloatAttr::get(elementType, 0));
Value one = b.create<arith::ConstantOp>(loc, FloatAttr::get(elementType, 1));
return buildNormalCdf(b, loc, x, zero, one);
}
namespace {
class ConvertAtenAdaptiveAvgPool2dOp
: public OpConversionPattern<AtenAdaptiveAvgPool2dOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenAdaptiveAvgPool2dOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
Location loc = op->getLoc();
MLIRContext *context = op->getContext();
AtenAdaptiveAvgPool2dOp::Adaptor adaptor(operands);
Value input = adaptor.self(); /* in form of N*C*H*W */
RankedTensorType inputType = input.getType().cast<RankedTensorType>();
Type elementType = inputType.getElementType();
if (!elementType.isa<mlir::FloatType>())
return op.emitError("unimplemented: non-floating point type");
auto inputRank = inputType.getRank();
if (inputRank != 4)
return rewriter.notifyMatchFailure(op, "input should be rank 4");
SmallVector<int64_t, 2> expects{1, 1};
// Pattern match against the op's original operands, because otherwise we
// will get the lowered version of the operands which is harder to pattern
// match.
if (!isConstantIntListMatching(op.output_size(), expects))
return rewriter.notifyMatchFailure(
op, "only support output_size with H and W both equal to constant 1");
Value N = getDimOp(rewriter, loc, input, 0);
Value C = getDimOp(rewriter, loc, input, 1);
Value initTensor = rewriter.create<linalg::InitTensorOp>(
loc, ValueRange{N, C}, elementType);
Value c0 = rewriter.create<arith::ConstantOp>(
loc, FloatAttr::get(elementType, 0.0));
Value initTensor0 =
rewriter.create<linalg::FillOp>(loc, c0, initTensor).getResult(0);
SmallVector<AffineExpr, 2> ncExprs;
ncExprs.push_back(mlir::getAffineDimExpr(0, context));
ncExprs.push_back(mlir::getAffineDimExpr(1, context));
auto ncIndexingMap = AffineMap::get(
/*dimCount=*/4,
/*symbolCount=*/0, ncExprs, context);
SmallVector<AffineMap, 2> indexingMaps = {
rewriter.getMultiDimIdentityMap(4), // input
ncIndexingMap, // output
};
SmallVector<StringRef, 4> iteratorTypesSum{"parallel", "parallel",
"reduction", "reduction"};
Value sumPool2d = rewriter
.create<linalg::GenericOp>(
loc, initTensor0.getType(), input, initTensor0,
/*indexingMaps=*/indexingMaps,
/*iteratorTypes=*/iteratorTypesSum,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value input = args[0], sum = args[1];
Value result = rewriter.create<arith::AddFOp>(
loc, sum, input);
b.create<linalg::YieldOp>(loc, result);
})
.getResult(0);
// Calculate H*W so that avg can be got from sum / (H*W)
Value H = getDimOp(rewriter, loc, input, 2);
Value W = getDimOp(rewriter, loc, input, 3);
auto castIndexToInt = [&](Value v) {
return rewriter.create<arith::IndexCastOp>(
loc, IntegerType::get(context, 64), v);
};
Value HtimesW = rewriter.create<arith::MulIOp>(loc, castIndexToInt(H),
castIndexToInt(W));
Value HtimesWf =
rewriter.create<arith::SIToFPOp>(loc, elementType, HtimesW);
Value c1Index = rewriter.create<arith::ConstantIndexOp>(loc, /*value=*/1);
Value outputTensor = rewriter.create<linalg::InitTensorOp>(
loc, ValueRange{N, C, c1Index, c1Index}, elementType);
SmallVector<AffineMap, 2> indexingMapsAvg{
ncIndexingMap, rewriter.getMultiDimIdentityMap(4)};
SmallVector<StringRef, 4> iteratorTypesAvg(4, "parallel");
Value avgPool2d =
rewriter
.create<linalg::GenericOp>(
loc, outputTensor.getType(), sumPool2d, outputTensor,
/*indexingMaps=*/indexingMapsAvg,
/*iteratorTypes=*/iteratorTypesAvg,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value avg = b.create<arith::DivFOp>(loc, args[0], HtimesWf);
b.create<linalg::YieldOp>(loc, avg);
})
.getResult(0);
Type newResultType = getTypeConverter()->convertType(op.getType());
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, avgPool2d);
return success();
}
};
} // namespace
namespace {
class ConvertAtenConv2dOp : public OpConversionPattern<AtenConv2dOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenConv2dOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
Location loc = op->getLoc();
MLIRContext *context = op->getContext();
AtenConv2dOp::Adaptor adaptor(operands);
Value input = adaptor.input(); /* in form of N*C*H*W */
Value weight = adaptor.weight(); /* in form of F*C*H*W */
Value groups = adaptor.groups();
Type elementType =
input.getType().cast<RankedTensorType>().getElementType();
if (!elementType.isa<mlir::FloatType>())
return op.emitError("unimplemented: non-floating point type");
Type intType = IntegerType::get(context, 64);
auto castIndexToInt = [&](Value v) {
return rewriter.create<arith::IndexCastOp>(loc, intType, v);
};
Value N = getDimOp(rewriter, loc, input, 0);
Value Hin = getDimOp(rewriter, loc, input, 2);
Value Win = getDimOp(rewriter, loc, input, 3);
Value F = getDimOp(rewriter, loc, weight, 0);
Value weightH = getDimOp(rewriter, loc, weight, 2);
Value weightW = getDimOp(rewriter, loc, weight, 3);
// Pattern match against the op's original operands, because otherwise we
// will get the lowered version of the operands which is harder to pattern
// match.
SmallVector<int64_t> paddingInts;
if (!matchPattern(op.padding(), m_TorchConstantIntList(paddingInts))) {
return rewriter.notifyMatchFailure(
op, "only support constant padding values");
}
SmallVector<int64_t, 2> strideInts;
if (!matchPattern(op.stride(), m_TorchConstantIntList(strideInts)))
return rewriter.notifyMatchFailure(op,
"only support constant int strides");
SmallVector<int64_t, 2> dilationInts;
if (!matchPattern(op.dilation(), m_TorchConstantIntList(dilationInts)))
return rewriter.notifyMatchFailure(op,
"only support constant int dilations");
if (!op.bias().getType().isa<Torch::NoneType>())
return rewriter.notifyMatchFailure(op, "only support None bias");
Value c1 =
rewriter.create<arith::ConstantOp>(loc, IntegerAttr::get(intType, 1));
Value groupEqual1 = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, groups, c1);
rewriter.create<AssertOp>(loc, groupEqual1,
rewriter.getStringAttr("expect groups to be 1"));
// Pad the input tensor according to padding.
SmallVector<int64_t, 4> paddingIncludingNC = {0, 0};
paddingIncludingNC.insert(paddingIncludingNC.end(), paddingInts.begin(),
paddingInts.end());
Value paddedInput =
getPaddedTensor(op, rewriter, input, paddingIncludingNC);
SmallVector<Value> paddingIntValues =
getAsConstantIntValues(rewriter, loc, paddingInts);
SmallVector<Value> dilationIntValues =
getAsConstantIntValues(rewriter, loc, dilationInts);
SmallVector<Value> strideIntValues =
getAsConstantIntValues(rewriter, loc, strideInts);
Value Hout = getOutputDimForConvOps(
rewriter, loc, Hin, paddingIntValues[0], dilationIntValues[0],
castIndexToInt(weightH), strideIntValues[0]);
Value Wout = getOutputDimForConvOps(
rewriter, loc, Win, paddingIntValues[1], dilationIntValues[1],
castIndexToInt(weightW), strideIntValues[1]);
Value c0float = rewriter.create<arith::ConstantOp>(
loc,
FloatAttr::get(
input.getType().cast<RankedTensorType>().getElementType(), 0.0));
Value initTensor = rewriter.create<linalg::InitTensorOp>(
loc, ValueRange{N, F, Hout, Wout}, elementType);
Value initTensor0 =
rewriter.create<linalg::FillOp>(loc, c0float, initTensor).getResult(0);
auto stridesAttr = rewriter.getI64VectorAttr(strideInts);
auto dilationAttr = rewriter.getI64VectorAttr(dilationInts);
Value conv2d =
rewriter
.create<linalg::Conv2DNchwFchwOp>(
loc, initTensor0.getType(), ValueRange{paddedInput, weight},
initTensor0, stridesAttr, dilationAttr)
.getResult(0);
Type newResultType = getTypeConverter()->convertType(op.getType());
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, conv2d);
return success();
}
};
} // namespace
// Normalization formula:
// ((input - mean) / sqrt(var + eps)) * weight + bias
static Value createLinalgPayloadCalculationForNormOps(
OpBuilder &b, Location loc, Type elemTy, Value input, Value mean, Value var,
Value eps, Value weight, Value bias) {
Value inputSubMean = b.create<arith::SubFOp>(loc, input, mean);
// The eps is always f64.
Value truncatedEps = b.create<arith::TruncFOp>(loc, elemTy, eps);
Value varPlusEps = b.create<arith::AddFOp>(loc, var, truncatedEps);
Value rSTD = b.create<math::RsqrtOp>(loc, varPlusEps);
Value temp = b.create<arith::MulFOp>(loc, inputSubMean, rSTD);
Value timesWeight = b.create<arith::MulFOp>(loc, temp, weight);
Value plusBias = b.create<arith::AddFOp>(loc, timesWeight, bias);
return plusBias;
}
static void createLinalgPayloadCalculationForGatherOps(
OpBuilder &b, Location loc, Value input, int64_t inputRank, Value index,
int64_t dim, int64_t outputRank) {
SmallVector<Value> indices;
for (int i = 0; i < inputRank; i++) {
if (i == dim) {
indices.push_back(castIntToIndex(b, loc, index));
} else {
// `outputRank` might be larger than `inputRank`. The `linalg::IndexOp`
// takes in the dimension of the output. Add `inputDimOffset` to
// related to the correct dimension of the output for dimension larger
// than the given `dim`.
int64_t inputDimOffset = i < dim ? 0 : outputRank - inputRank;
indices.push_back(b.create<linalg::IndexOp>(loc, i + inputDimOffset));
}
}
// Assert index < input.sizes[dim]
Value indexLTInputDim = b.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::slt, index,
castIndexToInt(b, loc, getDimOp(b, loc, input, dim)));
b.create<AssertOp>(loc, indexLTInputDim,
b.getStringAttr("index must be smaller than dim size"));
// Assert index >= 0
Value cst0 = b.create<arith::ConstantOp>(loc, b.getZeroAttr(index.getType()));
Value indexGEThanZero =
b.create<arith::CmpIOp>(loc, arith::CmpIPredicate::sge, index, cst0);
b.create<AssertOp>(loc, indexGEThanZero,
b.getStringAttr("index must be larger or equal to 0"));
Value extract = b.create<tensor::ExtractOp>(loc, input, indices);
b.create<linalg::YieldOp>(loc, extract);
}
namespace {
class ConvertAtenBatchNormOp : public OpConversionPattern<AtenBatchNormOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenBatchNormOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
AtenBatchNormOp::Adaptor adaptor(operands);
MLIRContext *context = op->getContext();
Location loc = op->getLoc();
Value input = adaptor.input();
Value weight = adaptor.weight();
Value bias = adaptor.bias();
Value runningMean = adaptor.running_mean();
Value runningVar = adaptor.running_var();
Value training = adaptor.training();
Value eps = adaptor.eps();
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
// TODO: Handle the None cases for the optional parameters:
// weight, bias.
if (failed(checkNotNone(rewriter, op, weight)) ||
failed(checkNotNone(rewriter, op, bias)) ||
failed(checkNotNone(rewriter, op, runningMean)) ||
failed(checkNotNone(rewriter, op, runningVar)))
return failure();
auto inputType = input.getType().cast<RankedTensorType>();
auto weightType = weight.getType().cast<RankedTensorType>();
auto biasType = bias.getType().cast<RankedTensorType>();
auto runningMeanType = runningMean.getType().cast<RankedTensorType>();
auto runningVarType = runningVar.getType().cast<RankedTensorType>();
auto inputRank = inputType.getRank();
if (inputRank <= 2)
return rewriter.notifyMatchFailure(
op, "input should have rank larger than 2");
if (weightType.getRank() != 1 || biasType.getRank() != 1 ||
runningMeanType.getRank() != 1 || runningVarType.getRank() != 1) {
return rewriter.notifyMatchFailure(
op, "expect weight, bias, running_mean and running_var to be rank 1");
}
// TODO: Add support for training.
auto constFalse = rewriter.create<arith::ConstantOp>(
loc, IntegerAttr::get(IntegerType::get(context, 1), 0));
auto trainingFalse = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, training, constFalse);
rewriter.create<AssertOp>(
loc, trainingFalse,
rewriter.getStringAttr("training is not supported for now"));
// num_features – C from an expected input of size (N,C,D,H,W ...)
Value numFeatures = rewriter.create<tensor::DimOp>(loc, input, 1);
auto contractingDim0EqualsNumFeatures = [&](Value v) {
auto dim0 = rewriter.create<tensor::DimOp>(loc, v, 0);
auto dim0Equal = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, numFeatures, dim0);
rewriter.create<AssertOp>(
loc, dim0Equal,
rewriter.getStringAttr(
"expect the size of dim 0 equal to the number of features"));
};
contractingDim0EqualsNumFeatures(weight);
contractingDim0EqualsNumFeatures(bias);
contractingDim0EqualsNumFeatures(runningMean);
contractingDim0EqualsNumFeatures(runningVar);
auto indexingMap = AffineMap::get(
/*dimCount=*/inputRank,
/*symbolCount=*/0, rewriter.getAffineDimExpr(1), context);
SmallVector<AffineMap> indexingMaps = {
rewriter.getMultiDimIdentityMap(inputRank), // input
indexingMap, // weight
indexingMap, // bias
indexingMap, // runningMean
indexingMap, // runningVar
rewriter.getMultiDimIdentityMap(inputRank), // output
};
SmallVector<StringRef> iteratorTypes(inputRank, "parallel");
Value batchNorm =
rewriter
.create<linalg::GenericOp>(
loc, input.getType(),
ValueRange{input, weight, bias, runningMean, runningVar}, input,
/*indexingMaps=*/indexingMaps,
/*iteratorTypes=*/iteratorTypes,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value input = args[0], weight = args[1], bias = args[2],
mean = args[3], var = args[4];
Value result = createLinalgPayloadCalculationForNormOps(
b, loc, var.getType(), input, mean, var, eps, weight,
bias);
b.create<linalg::YieldOp>(loc, result);
})
.getResult(0);
Type newResultType = getTypeConverter()->convertType(op.getType());
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, batchNorm);
return success();
}
};
} // namespace
// For layernorm, the mean and standard-deviation are calculated separately over
// the last certain number dimensions which have to be of the shape specified by
// normalized_shape.
//
// The shapes of different parts are as the following:
// +-------------------+--------------------+
// | meanAndVarShape | normalizedShape |
// +-------------------+---------------------
// <------------+ inputShape +-------------->
// There are the following steps:
// Step 1. Check if all the arguments meet the requirements.
// Step 2. Common parts to be used for getting mean and var.
// This includes elements count, affineMap and iteratorTypes.
// Step 3. Get mean.
// Step 4. Get var.
// Step 5. Get layernorm.
namespace {
class ConvertAtenLayerNormOp : public OpConversionPattern<AtenLayerNormOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenLayerNormOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
AtenLayerNormOp::Adaptor adaptor(operands);
MLIRContext *context = op->getContext();
Location loc = op->getLoc();
Value input = adaptor.input();
Value weight = adaptor.weight();
Value bias = adaptor.bias();
Value eps = adaptor.eps();
Value normalizedShape = op.normalized_shape();
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
// TODO: Handle the None cases for the optional parameters:
// weight, bias.
if (failed(checkNotNone(rewriter, op, weight)) ||
failed(checkNotNone(rewriter, op, bias)))
return failure();
auto inputType = input.getType().cast<RankedTensorType>();
auto weightType = weight.getType().cast<RankedTensorType>();
auto biasType = bias.getType().cast<RankedTensorType>();
int64_t inputRank = inputType.getRank();
Type elemTy = inputType.getElementType();
// Step 1. Check if all the arguments meet the requirements.
SmallVector<Value> normalizedShapeSizesTorchInt;
if (!getListConstructElements(normalizedShape,
normalizedShapeSizesTorchInt)) {
return rewriter.notifyMatchFailure(op,
"Unimplemented normalized_shape not"
"constructed from ListConstruct");
}
SmallVector<Value> normalizedShapeSizesInt = getTypeConvertedValues(
rewriter, loc, getTypeConverter(), normalizedShapeSizesTorchInt);
int64_t normalizedShapeRank = normalizedShapeSizesInt.size();
if (weightType.getRank() != normalizedShapeRank ||
biasType.getRank() != normalizedShapeRank ||
inputRank < normalizedShapeRank || normalizedShapeRank < 1)
return rewriter.notifyMatchFailure(op, "Input or weight or bias shape or"
"normalized shape not compatible");
// Check all the dimensions match the normalized_shape
int64_t meanAndVarShapeRank = inputRank - normalizedShapeSizesInt.size();
for (auto en : enumerate((normalizedShapeSizesInt))) {
auto index = en.index();
auto inputDim =
getDimOp(rewriter, loc, input, index + meanAndVarShapeRank);
auto weightDim = getDimOp(rewriter, loc, weight, index);
auto biasDim = getDimOp(rewriter, loc, bias, index);
auto expectedSize = en.value();
checkDimEqualHelper(rewriter, loc, inputDim, expectedSize);
checkDimEqualHelper(rewriter, loc, weightDim, expectedSize);
checkDimEqualHelper(rewriter, loc, biasDim, expectedSize);
}
// Get iterator types for input shape.
SmallVector<StringRef> normalizedShapeIteratorTypes(
normalizedShapeRank, getReductionIteratorTypeName());
SmallVector<StringRef> meanAndVarIterationTypes(
meanAndVarShapeRank, getParallelIteratorTypeName());
SmallVector<StringRef> inputShapeIteratorTypes = meanAndVarIterationTypes;
inputShapeIteratorTypes.append(normalizedShapeIteratorTypes);
// Step 2. Common parts to be used for getting mean and var.
// Get sizes and affineMaps needed for mean and var.
AffineMap inputShapeAffineMap = rewriter.getMultiDimIdentityMap(inputRank);
SmallVector<AffineExpr> meanAndVarShapeExprs;
for (int i = 0; i < meanAndVarShapeRank; i++)
meanAndVarShapeExprs.push_back(mlir::getAffineDimExpr(i, context));
auto meanAndVarShapeAffineMap = AffineMap::get(
/*dimCount=*/inputRank,
/*symbolCount=*/0, meanAndVarShapeExprs, context);
SmallVector<Value> meanAndVarShapeSizes =
getTensorSizesUntilDim(rewriter, loc, input, meanAndVarShapeRank - 1);
// Get number of elements to be used for calculating mean and var.
Value elemCnts = normalizedShapeSizesInt[0];
for (int i = 1; i < normalizedShapeRank; i++) {
elemCnts = rewriter.create<arith::MulIOp>(loc, elemCnts,
normalizedShapeSizesInt[i]);
}
Value elemCntsFloat =
rewriter.create<arith::SIToFPOp>(loc, elemTy, elemCnts);
// Helper to calculate mean and var.
auto genMeanOrVarCalculation = [&](Value sumOrSquareSum) {
SmallVector<AffineMap> indexingMaps(
2, rewriter.getMultiDimIdentityMap(meanAndVarShapeRank));
Value initShapeTensor = rewriter.create<linalg::InitTensorOp>(
loc, meanAndVarShapeSizes, elemTy);
return rewriter
.create<linalg::GenericOp>(
loc, initShapeTensor.getType(), sumOrSquareSum, initShapeTensor,
/*indexingMaps=*/indexingMaps,
/*iteratorTypes=*/meanAndVarIterationTypes,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value sumOrSqureSum = args[0];
Value result =
b.create<arith::DivFOp>(loc, sumOrSqureSum, elemCntsFloat);
b.create<linalg::YieldOp>(loc, result);
})
.getResult(0);
};
// Step 3. Get mean.
// Get sum to be used for calculating mean.
SmallVector<AffineMap, 2> sumIndexingMaps = {
inputShapeAffineMap, // input
meanAndVarShapeAffineMap, // output
};
auto initSumTensor =
createZeroInitTensor(rewriter, loc, meanAndVarShapeSizes, elemTy);
Value sum = rewriter
.create<linalg::GenericOp>(
loc, initSumTensor.getType(), input, initSumTensor,
/*indexingMaps=*/sumIndexingMaps,
/*iteratorTypes=*/inputShapeIteratorTypes,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value input = args[0], sum = args[1];
Value result =
rewriter.create<arith::AddFOp>(loc, sum, input);
b.create<linalg::YieldOp>(loc, result);
})
.getResult(0);
Value mean = genMeanOrVarCalculation(sum);
// Step 4. Get var.
// Calculate squareSum for the layer.
SmallVector<AffineMap> squareSumIndexingMaps{
inputShapeAffineMap,
meanAndVarShapeAffineMap,
meanAndVarShapeAffineMap,
};
auto initSquareSumTensor =
createZeroInitTensor(rewriter, loc, meanAndVarShapeSizes, elemTy);
Value squareSum =
rewriter
.create<linalg::GenericOp>(
loc, initSquareSumTensor.getType(), ValueRange{input, mean},
initSquareSumTensor,
/*indexingMaps=*/squareSumIndexingMaps,
/*iteratorTypes=*/inputShapeIteratorTypes,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value input = args[0], mean = args[1], squareSum = args[2];
Value sub = rewriter.create<arith::SubFOp>(loc, input, mean);
Value square = rewriter.create<arith::MulFOp>(loc, sub, sub);
Value result =
rewriter.create<arith::AddFOp>(loc, squareSum, square);
b.create<linalg::YieldOp>(loc, result);
})
.getResult(0);
Value var = genMeanOrVarCalculation(squareSum);
// Step 5. Get layernorm.
// Get affineMap for normalized shape.
SmallVector<AffineExpr> normalizedShapeExprs;
for (int i = meanAndVarShapeRank; i < inputRank; i++)
normalizedShapeExprs.push_back(mlir::getAffineDimExpr(i, context));
auto normalizedShapeAffineMap = AffineMap::get(
/*dimCount=*/inputRank,
/*symbolCount=*/0, normalizedShapeExprs, context);
auto inputSizes = getTensorSizes(rewriter, loc, input);
Value initLayerNormTensor =
rewriter.create<linalg::InitTensorOp>(loc, inputSizes, elemTy);
SmallVector<AffineMap> indexingMaps(1, inputShapeAffineMap);
indexingMaps.resize(3, meanAndVarShapeAffineMap);
indexingMaps.resize(5, normalizedShapeAffineMap);
indexingMaps.push_back(inputShapeAffineMap);
SmallVector<StringRef> layerNormIterationTypes(
inputRank, getParallelIteratorTypeName());
Value layerNorm =
rewriter
.create<linalg::GenericOp>(
loc, initLayerNormTensor.getType(),
ValueRange{input, mean, var, weight, bias}, initLayerNormTensor,
/*indexingMaps=*/indexingMaps,
/*iteratorTypes=*/layerNormIterationTypes,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value input = args[0], mean = args[1], var = args[2],
weight = args[3], bias = args[4];
Value result = createLinalgPayloadCalculationForNormOps(
b, loc, elemTy, input, mean, var, eps, weight, bias);
b.create<linalg::YieldOp>(loc, result);
})
.getResult(0);
Type newResultType = getTypeConverter()->convertType(op.getType());
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, layerNorm);
return success();
}
};
} // namespace
namespace {
class ConvertAtenMmOp : public OpConversionPattern<AtenMmOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenMmOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
Location loc = op->getLoc();
Value lhs = operands[0];
Value rhs = operands[1];
// A user can write an errorneous program where `aten.mm` is in fact called
// with operands of invalid rank or dtype. We cannot convert to linalg in
// this case or we will get a verifier error, which corresponds to breaking
// of *internal* compiler invariants, and for a user manifests as a compiler
// crash in the worst case (such as we try to canonicalize/fold/print the
// invalid op before the verifier gets to see it -- also release builds of a
// mature compiler usually have the verifier turned off for compile time
// reasons).
//
// The compiler cannot crash even if the user wrote an erroneous program!
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
if (lhs.getType().cast<RankedTensorType>().getRank() != 2 ||
rhs.getType().cast<RankedTensorType>().getRank() != 2) {
return rewriter.notifyMatchFailure(
op, "expected both operands to aten.mm to be rank 2");
}
Value lhsDim0 = rewriter.create<tensor::DimOp>(loc, lhs, 0);
Value lhsDim1 = rewriter.create<tensor::DimOp>(loc, lhs, 1);
Value rhsDim0 = rewriter.create<tensor::DimOp>(loc, rhs, 0);
Value rhsDim1 = rewriter.create<tensor::DimOp>(loc, rhs, 1);
Value contractingDimEqual = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, lhsDim1, rhsDim0);
rewriter.create<AssertOp>(
loc, contractingDimEqual,
rewriter.getStringAttr(
"mismatching contracting dimension for torch.aten.mm"));
Type newResultType = getTypeConverter()->convertType(op.getType());
Type elementType = newResultType.cast<TensorType>().getElementType();
Value initTensor = rewriter.create<linalg::InitTensorOp>(
loc, ValueRange{lhsDim0, rhsDim1}, elementType);
Value c0 = rewriter.create<arith::ConstantOp>(
loc, FloatAttr::get(elementType, 0.0));
Value zeroFill =
rewriter.create<linalg::FillOp>(loc, c0, initTensor).getResult(0);
Value matmul = rewriter
.create<linalg::MatmulOp>(loc, zeroFill.getType(),
ValueRange{lhs, rhs}, zeroFill)
.getResult(0);
// When constructed with just dynamic sizes, InitTensorOp will have a result
// type which has all `?`'s for dimensions, which might not be the result
// type of `op`. The constraints on later linalg ops means that the result
// of the MatmulOp will have this type too. So cast it to the desired type
// so that in the end we have the original result type.
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, matmul);
return success();
}
};
} // namespace
namespace {
class ConvertAtenMatmulOp : public OpConversionPattern<AtenMatmulOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenMatmulOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
Location loc = op->getLoc();
Value lhs = operands[0];
Value rhs = operands[1];
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
unsigned lhsRank = lhs.getType().cast<RankedTensorType>().getRank();
unsigned rhsRank = rhs.getType().cast<RankedTensorType>().getRank();
Type newResultType = getTypeConverter()->convertType(op.getType());
Type elementType = newResultType.cast<TensorType>().getElementType();
// The different cases of torch_matmul op is mentioned here:
// https://pytorch.org/docs/stable/generated/torch.matmul.html
// First Case: Dot Product.
if (lhsRank == 1 && rhsRank == 1) {
Value lhsDim0 = getDimOp(rewriter, loc, lhs, 0);
Value rhsDim0 = getDimOp(rewriter, loc, rhs, 0);
checkDimEqualHelper(rewriter, loc, lhsDim0, rhsDim0);
Value zeroTensor = createZeroInitTensor(rewriter, loc, {}, elementType);
Value dotProd =
rewriter
.create<linalg::DotOp>(loc, zeroTensor.getType(),
ValueRange{lhs, rhs}, zeroTensor)
.getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, dotProd);
return success();
}
// Second Case: Vec-Mat Multiplication.
if (lhsRank == 1 && rhsRank == 2) {
Value lhsDim0 = getDimOp(rewriter, loc, lhs, 0);
Value rhsDim0 = getDimOp(rewriter, loc, rhs, 0);
Value rhsDim1 = getDimOp(rewriter, loc, rhs, 1);
checkDimEqualHelper(rewriter, loc, lhsDim0, rhsDim0);
Value zeroTensor =
createZeroInitTensor(rewriter, loc, ValueRange{rhsDim1}, elementType);
Value matmul =
rewriter
.create<linalg::VecmatOp>(loc, zeroTensor.getType(),
ValueRange{lhs, rhs}, zeroTensor)
.getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, matmul);
return success();
}
// Third Case: Matrix-Vec Multiplication.
if (lhsRank == 2 && rhsRank == 1) {
Value lhsDim0 = getDimOp(rewriter, loc, lhs, 0);
Value lhsDim1 = getDimOp(rewriter, loc, lhs, 1);
Value rhsDim0 = getDimOp(rewriter, loc, rhs, 0);
checkDimEqualHelper(rewriter, loc, lhsDim1, rhsDim0);
Value zeroTensor =
createZeroInitTensor(rewriter, loc, ValueRange{lhsDim0}, elementType);
Value matmul =
rewriter
.create<linalg::MatvecOp>(loc, zeroTensor.getType(),
ValueRange{lhs, rhs}, zeroTensor)
.getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, matmul);
return success();
}
// Fourth Case: Batch-Matrix Multiplication.
// TODO: Broadcasting of batch dimension is remaining.
if (lhsRank >= 3 && rhsRank >= 3 && lhsRank == rhsRank) {
unsigned batchRank = lhsRank - 2;
SmallVector<Value, 4> resultShape;
SmallVector<AffineExpr> lhsExpr;
SmallVector<AffineExpr> rhsExpr;
SmallVector<AffineExpr> outExpr;
SmallVector<StringRef> iteratorTypes;
// Since broadcasting is a TODO, check whether the lhs and rhs batch
// dimension match.
for (unsigned i = 0; i < batchRank; i++) {
Value lhsBatch = getDimOp(rewriter, loc, lhs, i);
Value rhsBatch = getDimOp(rewriter, loc, rhs, i);
resultShape.push_back(lhsBatch);
lhsExpr.push_back(rewriter.getAffineDimExpr(i));
rhsExpr.push_back(rewriter.getAffineDimExpr(i));
outExpr.push_back(rewriter.getAffineDimExpr(i));
iteratorTypes.push_back(getParallelIteratorTypeName());
checkDimEqualHelper(rewriter, loc, lhsBatch, rhsBatch);
}
Value lhsDim0 = getDimOp(rewriter, loc, lhs, batchRank);
Value lhsDim1 = getDimOp(rewriter, loc, lhs, batchRank + 1);
Value rhsDim0 = getDimOp(rewriter, loc, rhs, batchRank);
Value rhsDim1 = getDimOp(rewriter, loc, rhs, batchRank + 1);
checkDimEqualHelper(rewriter, loc, lhsDim1, rhsDim0);
// Push the final matrix dimension.
resultShape.insert(resultShape.end(), {lhsDim0, rhsDim1});
lhsExpr.insert(lhsExpr.end(), {rewriter.getAffineDimExpr(batchRank),
rewriter.getAffineDimExpr(batchRank + 1)});
rhsExpr.insert(rhsExpr.end(), {rewriter.getAffineDimExpr(batchRank + 1),
rewriter.getAffineDimExpr(batchRank + 2)});
outExpr.insert(outExpr.end(), {rewriter.getAffineDimExpr(batchRank),
rewriter.getAffineDimExpr(batchRank + 2)});
Value initTensor0 =
createZeroInitTensor(rewriter, loc, resultShape, elementType);
auto indexingMaps =
AffineMap::inferFromExprList({lhsExpr, rhsExpr, outExpr});
iteratorTypes.insert(iteratorTypes.end(),
{"parallel", "reduction", "parallel"});
Value finalRes =
rewriter
.create<linalg::GenericOp>(
loc, newResultType, ValueRange{lhs, rhs}, initTensor0,
/*indexingMaps=*/indexingMaps,
/*iteratorTypes=*/iteratorTypes,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value l = args[0], r = args[1], res = args[2];
Value mul = b.create<arith::MulFOp>(loc, l, r);
Value add = b.create<arith::AddFOp>(loc, mul, res);
b.create<linalg::YieldOp>(loc, add);
})
.getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, finalRes);
return success();
}
return failure();
}
};
} // namespace
namespace {
class ConvertAtenBmmOp : public OpConversionPattern<AtenBmmOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenBmmOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
Location loc = op->getLoc();
Value lhs = operands[0];
Value rhs = operands[1];
RankedTensorType lhsType = lhs.getType().cast<RankedTensorType>();
RankedTensorType rhsType = rhs.getType().cast<RankedTensorType>();
if (lhsType.getRank() != 3 || rhsType.getRank() != 3) {
return rewriter.notifyMatchFailure(
op, "expected both operands to aten.bmm to be rank 3");
}
if (!lhsType.getElementType().isa<mlir::FloatType>() ||
lhsType.getElementType() != rhsType.getElementType())
return op.emitError(
"unimplemented: non floating point operands or operands of "
"different types");
Value lhsDim0 = getDimOp(rewriter, loc, lhs, 0);
Value lhsDim1 = getDimOp(rewriter, loc, lhs, 1);
Value lhsDim2 = getDimOp(rewriter, loc, lhs, 2);
Value rhsDim0 = getDimOp(rewriter, loc, rhs, 0);
Value rhsDim1 = getDimOp(rewriter, loc, rhs, 1);
Value rhsDim2 = getDimOp(rewriter, loc, rhs, 2);
// Check the batch numbers are equal.
checkDimEqualHelper(rewriter, loc, lhsDim0, rhsDim0);
// Check the matrixs shapes are valid for mulplication.
checkDimEqualHelper(rewriter, loc, lhsDim2, rhsDim1);
Type newResultType = getTypeConverter()->convertType(op.getType());
Type elementType = newResultType.cast<TensorType>().getElementType();
Value initTensor0 = createZeroInitTensor(
rewriter, loc, ValueRange{lhsDim0, lhsDim1, rhsDim2}, elementType);
Value bmm =
rewriter
.create<linalg::BatchMatmulOp>(loc, initTensor0.getType(),
ValueRange{lhs, rhs}, initTensor0)
.getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, bmm);
return success();
}
};
} // namespace
namespace {
// See comments at in convertMmOp and the heading for this section for general
// considerations. This function needs to be auto-generated.
class ConvertAtenLinearOp : public OpConversionPattern<AtenLinearOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenLinearOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
AtenLinearOp::Adaptor adaptor(operands);
MLIRContext *context = op->getContext();
Location loc = op->getLoc();
Value input = adaptor.input();
Value weight = adaptor.weight();
Value bias = adaptor.bias();
// TODO: Handle the case of bias being None (bias is optional).
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
auto inputType = input.getType().cast<RankedTensorType>();
auto weightType = weight.getType().cast<RankedTensorType>();
auto biasType = bias.getType().cast<RankedTensorType>();
// Only handle the case of rank 2 `input` for now.
// TODO: Insert the appropriate reshape to collapse any leading dimensions.
if (inputType.getRank() != 2 || weightType.getRank() != 2 ||
biasType.getRank() != 1) {
return rewriter.notifyMatchFailure(
op,
"expected both input and weight to be rank 2 and bias to be rank 1");
}
// TODO: Handle type promotion. What are ATen's promotion rules?
if (inputType.getElementType() != weightType.getElementType() ||
inputType.getElementType() != biasType.getElementType()) {
return rewriter.notifyMatchFailure(op, "unimplemented: type promotion");
}
// TODO: We can handle a static size 1 here at some complexity cost, but the
// dynamic case is not representable in linalg. We don't handle either for
// now. Biases are generally statically shaped for most models (since for
// inference they are constants, and for training they don't change shape
// typically), so this is not too constraining.
auto biasSize = bias.getType().cast<RankedTensorType>().getShape()[0];
if (biasSize == 1 || biasSize == ShapedType::kDynamicSize)
return rewriter.notifyMatchFailure(
op, "unimplemented: size-1 broadcasting for aten::LinearOp");
Value inputDim0 = getDimOp(rewriter, loc, input, 0);
Value inputDim1 = getDimOp(rewriter, loc, input, 1);
Value weightDim0 = getDimOp(rewriter, loc, weight, 0);
Value weightDim1 = getDimOp(rewriter, loc, weight, 1);
Value biasDim0 = getDimOp(rewriter, loc, bias, 0);
Value contractingDimEqual = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, inputDim1, weightDim1);
rewriter.create<AssertOp>(
loc, contractingDimEqual,
rewriter.getStringAttr(
"mismatching contracting dimension for aten.linear"));
// Here we take advantage of ruling out the size-1 case above.
// In the static-size-1 case, we will not emit this check at all.
Value biasSizeCorrect = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, weightDim0, biasDim0);
rewriter.create<AssertOp>(
loc, biasSizeCorrect,
rewriter.getStringAttr("mismatching bias size for aten.linear"));
Value initTensor = rewriter.create<linalg::InitTensorOp>(
loc, ValueRange{inputDim0, weightDim0}, inputType.getElementType());
SmallVector<AffineMap> broadcastIndexingMaps = {
AffineMap::get(
/*dimCount=*/2, /*symbolCount=*/0, rewriter.getAffineDimExpr(1)),
rewriter.getMultiDimIdentityMap(2)};
SmallVector<StringRef> iteratorTypes(2, "parallel");
Value broadcasted =
rewriter
.create<linalg::GenericOp>(
loc, initTensor.getType(), bias, initTensor,
/*indexingMaps=*/broadcastIndexingMaps,
/*iteratorTypes=*/iteratorTypes,
[](OpBuilder &b, Location loc, ValueRange args) {
b.create<linalg::YieldOp>(loc, args[0]);
})
.getResult(0);
// We need a matmul with dimension ordering (N, K) * (M, K), so transpose
// the weights to fit into linalg::MatmulOp which is (N, K) * (K, M).
// TODO: This whole aten.linear lowering should eventually be generated from
// a single linalg ODS generator statement. Both the bias and matmul part.
SmallVector<AffineMap> transposeIndexingMaps = {
AffineMap::get(
/*dimCount=*/2, /*symbolCount=*/0,
{rewriter.getAffineDimExpr(1), rewriter.getAffineDimExpr(0)},
context),
rewriter.getMultiDimIdentityMap(2)};
Value transposedWeightInitTensor = rewriter.create<linalg::InitTensorOp>(
loc, ValueRange{weightDim1, weightDim0}, weightType.getElementType());
Value transposedWeights =
rewriter
.create<linalg::GenericOp>(
loc, transposedWeightInitTensor.getType(), weight,
transposedWeightInitTensor,
/*indexingMaps=*/transposeIndexingMaps,
/*iteratorTypes=*/iteratorTypes,
[](OpBuilder &b, Location loc, ValueRange args) {
b.create<linalg::YieldOp>(loc, args[0]);
})
.getResult(0);
Value matmul = rewriter
.create<linalg::MatmulOp>(
loc, broadcasted.getType(),
ValueRange{input, transposedWeights}, broadcasted)
.getResult(0);
Type newResultType = getTypeConverter()->convertType(op.getType());
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, matmul);
return success();
}
};
} // namespace
// Convert a scalar value to the target type. The scalar value can be an element
// from a tensor or a scalar in the pytorch dialect. Both the scalar and dtype
// should be converted builtin types.
static Value convertScalarToDtype(OpBuilder &b, Location loc, Value scalar,
Type dtype) {
Type scalarType = scalar.getType();
if (scalarType == dtype)
return scalar;
// TODO: For the byte(ui8) or char(i8) case, we need the unconverted dtype to
// be able to know if we need signed or unsigned conversion.
auto isByteOrChar = [](Type type) {
if (auto integerTy = type.dyn_cast<mlir::IntegerType>()) {
return integerTy.getWidth() == 8;
}
return false;
};
if (isByteOrChar(scalarType) || isByteOrChar(dtype) ||
scalarType.isSignlessInteger(1) || dtype.isSignlessInteger(1)) {
// TODO: Handle bool type.
mlir::emitError(loc)
<< "unsupported byte, char or bool type for convertScalarToDtype "
<< scalarType << "(scalar type) -> " << dtype << "(dtype)";
return nullptr;
}
if (auto dtypeFloat = dtype.dyn_cast<mlir::FloatType>()) {
if (auto scalarFloat = scalarType.dyn_cast<mlir::FloatType>()) {
if (scalarFloat.getWidth() > dtypeFloat.getWidth())
return b.create<arith::TruncFOp>(loc, scalar, dtype);
// Only scalarFloat width < dtypeFloat width can reach here.
return b.create<arith::ExtFOp>(loc, scalar, dtype);
}
assert(scalarType.isa<mlir::IntegerType>());
// It's safe to use SIToFPOp because ui8/si8 are the only ones where
// unsigned handling is needed, and we checked for that case above.
return b.create<arith::SIToFPOp>(loc, scalar, dtype);
}
if (auto dtypeInteger = dtype.dyn_cast<mlir::IntegerType>()) {
if (auto scalarFloat = scalarType.dyn_cast<mlir::FloatType>())
return b.create<arith::FPToSIOp>(loc, scalar, dtype);
assert(scalarType.isa<mlir::IntegerType>());
auto scalarInteger = scalarType.cast<mlir::IntegerType>();
if (scalarInteger.getWidth() > dtypeInteger.getWidth())
return b.create<arith::TruncIOp>(loc, scalar, dtype);
// Only scalarInteger width < dtypeInteger width can reach here.
// It's safe to use ExtSIOp here because ui8/si8 are the only ones where
// unsigned handling is needed, and we checked for that case above.
return b.create<arith::ExtSIOp>(loc, scalar, dtype);
}
llvm_unreachable("convertScalarToDtype should handle all the types");
}
static Value createLinalgPayloadCalculationForElementwiseOp(
OpBuilder &b, Location loc, TypeConverter *converter,
ValueRange payloadArgs, Operation *op, ArrayRef<Value> operands) {
if (isa<AtenTanhOp>(op))
return b.create<math::TanhOp>(loc, payloadArgs[0]);
if (isa<AtenExpOp>(op))
return b.create<math::ExpOp>(loc, payloadArgs[0]);
if (isa<AtenFloorOp>(op))
return b.create<math::FloorOp>(loc, payloadArgs[0]);
if (isa<AtenLogOp>(op))
return b.create<math::LogOp>(loc, payloadArgs[0]);
if (isa<AtenSqrtOp>(op))
return b.create<math::SqrtOp>(loc, payloadArgs[0]);
if (isa<AtenLog2Op>(op))
return b.create<math::Log2Op>(loc, payloadArgs[0]);
if (isa<AtenSigmoidOp>(op)) {
Type elementType = payloadArgs[0].getType();
auto one = b.create<arith::ConstantOp>(loc, FloatAttr::get(elementType, 1));
auto negate = b.create<arith::NegFOp>(loc, payloadArgs[0]);
auto exp = b.create<math::ExpOp>(loc, negate);
auto added = b.create<arith::AddFOp>(loc, exp, one);
return b.create<arith::DivFOp>(loc, one, added);
}
if (auto relu = dyn_cast<AtenReluOp>(op)) {
if (!relu.getType()
.cast<ValueTensorType>()
.getDtype()
.isa<mlir::FloatType>()) {
relu.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
Type elementType = payloadArgs[0].getType();
Value constZero =
b.create<arith::ConstantOp>(loc, FloatAttr::get(elementType, 0.0));
Value pred = b.create<arith::CmpFOp>(loc, arith::CmpFPredicate::UGT,
payloadArgs[0], constZero);
return b.create<SelectOp>(loc, pred, payloadArgs[0], constZero);
}
if (auto gelu = dyn_cast<AtenGeluOp>(op)) {
if (!gelu.getType()
.cast<ValueTensorType>()
.getDtype()
.isa<mlir::FloatType>()) {
gelu.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
Value cdf = buildUnitNormalCdf(b, loc, payloadArgs[0]);
return b.create<arith::MulFOp>(loc, payloadArgs[0], cdf);
}
if (auto add = dyn_cast<AtenAddTensorOp>(op)) {
AtenAddTensorOp::Adaptor adaptor(operands);
Type dtype = converter->convertType(add.getType())
.cast<RankedTensorType>()
.getElementType();
Value lhs = convertScalarToDtype(b, loc, payloadArgs[0], dtype);
Value rhs = convertScalarToDtype(b, loc, payloadArgs[1], dtype);
Value alpha = convertScalarToDtype(b, loc, adaptor.alpha(), dtype);
if (dtype.isa<mlir::FloatType>()) {
Value scaled = b.create<arith::MulFOp>(loc, rhs, alpha);
return b.create<arith::AddFOp>(loc, lhs, scaled);
} else {
Value scaled = b.create<arith::MulIOp>(loc, rhs, alpha);
return b.create<arith::AddIOp>(loc, lhs, scaled);
}
}
if (auto sub = dyn_cast<AtenSubTensorOp>(op)) {
AtenSubTensorOp::Adaptor adaptor(operands);
Type dtype = converter->convertType(sub.getType())
.cast<RankedTensorType>()
.getElementType();
Value lhs = convertScalarToDtype(b, loc, payloadArgs[0], dtype);
Value rhs = convertScalarToDtype(b, loc, payloadArgs[1], dtype);
Value alpha = convertScalarToDtype(b, loc, adaptor.alpha(), dtype);
if (dtype.isa<mlir::FloatType>()) {
Value scaled = b.create<arith::MulFOp>(loc, rhs, alpha);
return b.create<arith::SubFOp>(loc, lhs, scaled);
} else {
Value scaled = b.create<arith::MulIOp>(loc, rhs, alpha);
return b.create<arith::SubIOp>(loc, lhs, scaled);
}
}
if (auto mul = dyn_cast<AtenMulTensorOp>(op)) {
if (!mul.getType()
.cast<ValueTensorType>()
.getDtype()
.isa<mlir::FloatType>()) {
mul.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
return b.create<arith::MulFOp>(loc, payloadArgs[0], payloadArgs[1]);
}
if (auto div = dyn_cast<AtenDivTensorOp>(op)) {
if (!div.getType()
.cast<ValueTensorType>()
.getDtype()
.isa<mlir::FloatType>()) {
div.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
return b.create<arith::DivFOp>(loc, payloadArgs[0], payloadArgs[1]);
}
if (auto pow = dyn_cast<AtenPowTensorScalarOp>(op)) {
if (!pow.getType()
.cast<ValueTensorType>()
.getDtype()
.isa<mlir::FloatType>()) {
pow.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
Type dtype = pow.self().getType().cast<ValueTensorType>().getDtype();
Value expPromoted = convertScalarToDtype(b, loc, operands[1], dtype);
return b.create<math::PowFOp>(loc, payloadArgs[0], expPromoted);
}
if (auto lerp = dyn_cast<AtenLerpTensorOp>(op)) {
if (!lerp.getType()
.cast<ValueTensorType>()
.getDtype()
.isa<mlir::FloatType>()) {
lerp.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
AtenLerpTensorOp::Adaptor adaptor(payloadArgs);
auto start = adaptor.self();
auto end = adaptor.end();
auto weight = adaptor.weight();
auto delta = b.create<arith::SubFOp>(loc, end, start);
auto weightedDelta = b.create<arith::MulFOp>(loc, delta, weight);
return b.create<arith::AddFOp>(loc, start, weightedDelta);
}
if (auto minimum = dyn_cast<AtenMinimumOp>(op)) {
if (!minimum.getType()
.cast<ValueTensorType>()
.getDtype()
.isa<mlir::FloatType>()) {
minimum.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
Value pred = b.create<arith::CmpFOp>(loc, arith::CmpFPredicate::ULT,
payloadArgs[0], payloadArgs[1]);
return b.create<SelectOp>(loc, pred, payloadArgs[0], payloadArgs[1]);
}
if (auto maximum = dyn_cast<AtenMaximumOp>(op)) {
if (!maximum.getType()
.cast<ValueTensorType>()
.getDtype()
.isa<mlir::FloatType>()) {
maximum.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
Value pred = b.create<arith::CmpFOp>(loc, arith::CmpFPredicate::UGT,
payloadArgs[0], payloadArgs[1]);
return b.create<SelectOp>(loc, pred, payloadArgs[0], payloadArgs[1]);
}
if (auto clamp = dyn_cast<AtenClampOp>(op)) {
Type dtype = converter->convertType(clamp.getType())
.cast<RankedTensorType>()
.getElementType();
if (!dtype.isa<mlir::FloatType>()) {
clamp.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
AtenClampOp::Adaptor adaptor(operands);
auto min = adaptor.min();
auto max = adaptor.max();
if (min.getType().isa<Torch::OptionalType>() ||
max.getType().isa<Torch::OptionalType>()) {
clamp.emitError("unimplemented: runtime optional type");
return nullptr;
}
auto result = payloadArgs[0];
if (!min.getType().isa<Torch::NoneType>()) {
auto minPromoted = convertScalarToDtype(b, loc, min, dtype);
auto pred = b.create<arith::CmpFOp>(loc, arith::CmpFPredicate::ULT,
result, minPromoted);
result = b.create<SelectOp>(loc, pred, minPromoted, result);
}
if (!max.getType().isa<Torch::NoneType>()) {
auto maxPromoted = convertScalarToDtype(b, loc, max, dtype);
auto pred = b.create<arith::CmpFOp>(loc, arith::CmpFPredicate::UGT,
result, maxPromoted);
result = b.create<SelectOp>(loc, pred, maxPromoted, result);
}
return result;
}
if (auto rsub = dyn_cast<AtenRsubScalarOp>(op)) {
Type dtype = converter->convertType(rsub.getType())
.cast<RankedTensorType>()
.getElementType();
if (!dtype.isa<mlir::FloatType>()) {
rsub.emitError("unimplemented: non-floating point dtype");
return nullptr;
}
Value self = payloadArgs[0];
Value other = convertScalarToDtype(b, loc, operands[1], dtype);
Value alpha = convertScalarToDtype(b, loc, operands[2], dtype);
Value mult = b.create<arith::MulFOp>(loc, self, alpha);
return b.create<arith::SubFOp>(loc, other, mult);
}
if (auto atenToDtype = dyn_cast<AtenToDtypeOp>(op)) {
Value input = payloadArgs[0];
Type dtype = converter->convertType(atenToDtype.getType())
.cast<RankedTensorType>()
.getElementType();
Value result = convertScalarToDtype(b, loc, input, dtype);
return result;
}
op->emitError("unimplemented lowering in "
"createLinalgPayloadCalculationForElementwiseOp");
return nullptr;
}
static Value createLinalgNeutralElementForReduceOp(OpBuilder &b, Location loc,
Operation *op,
Type elementType) {
if (isa<AtenSumOp, AtenSumDimIntListOp>(op) &&
elementType.isa<mlir::FloatType>())
return b.create<arith::ConstantOp>(loc, b.getFloatAttr(elementType, 0.0));
op->emitError("unimplemented lowering in "
"createLinalgNeutralElementForReduceOp");
return nullptr;
}
static Value createLinalgPayloadCalculationForReduceOp(
OpBuilder &b, Location loc, ValueRange payloadArgs, Operation *op,
ArrayRef<Value> operands, Type elementType) {
if (isa<AtenSumOp, AtenSumDimIntListOp>(op) &&
elementType.isa<mlir::FloatType>())
return b.create<arith::AddFOp>(loc, payloadArgs);
op->emitError("unimplemented lowering in "
"createLinalgPayloadCalculationForReduceOp");
return nullptr;
}
namespace {
// Aten argmax lowering represents the ArgMax op as an linalg.indexed_generic
// op, producing two output buffers.
//
// The first output buffer contains the index of the found maximum value. It is
// initialized to 0 and is resulting integer type.
//
// The second output buffer contains the maximum value found. It is initialized
// to the minimum representable value of the input element type. After being
// populated by indexed_generic, this buffer is disgarded as only the index is
// requested.
//
// The indexed_generic op updates both the maximum value and index if the
// current value exceeds the running max.
class ConvertAtenArgmaxOp : public OpConversionPattern<AtenArgmaxOp> {
public:
using OpConversionPattern<AtenArgmaxOp>::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenArgmaxOp argmaxOp, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
Location loc = argmaxOp.getLoc();
AtenArgmaxOp::Adaptor adaptor(operands);
Value input = adaptor.self();
RankedTensorType resultType =
getTypeConverter()
->convertType(argmaxOp.getResult().getType())
.cast<RankedTensorType>();
RankedTensorType inputType = input.getType().cast<RankedTensorType>();
Type outElementType = resultType.getElementType();
if (!outElementType.isa<IntegerType>())
return rewriter.notifyMatchFailure(
argmaxOp,
"aten.arg_max to linalg.* requires integer-like result type");
bool keepDim = false;
if (!matchPattern(argmaxOp.keepdim(), m_TorchConstantBool(&keepDim)))
return failure();
int64_t dim;
if (!matchPattern(argmaxOp.dim(), m_TorchConstantInt(&dim))) {
if (!argmaxOp.dim().getType().isa<Torch::NoneType>())
return rewriter.notifyMatchFailure(
argmaxOp,
"aten.arg_max to linalg.* requires int or NoneType value for Dim");
// For pytorch, if the value of Dim is None, argmax
// returns the index of the max value of the flattened input tensor,
// so here we flatten the input tensor.
SmallVector<ReassociationIndices> reassociation(1);
for (auto i : llvm::seq<int64_t>(0, inputType.getRank()))
reassociation[0].push_back(i);
input = rewriter.create<linalg::TensorCollapseShapeOp>(
argmaxOp->getLoc(), input, reassociation);
// Becomes 0 for flattened tensor.
dim = 0;
// Recast to fix shape.
inputType = input.getType().cast<RankedTensorType>();
}
Type inElementType = inputType.getElementType();
if (!inElementType.isa<mlir::FloatType>()) {
return rewriter.notifyMatchFailure(
argmaxOp,
"aten.arg_max to linalg.* requires Float input element type");
}
// Constant op to account for the reduction along dim.
auto c1 = rewriter.create<arith::ConstantIndexOp>(loc, /*value=*/1);
SmallVector<Value> resultShape;
for (int64_t i = 0; i < inputType.getRank(); i++) {
if (dim != i) {
auto currentDimSize = rewriter.create<tensor::DimOp>(loc, input, i);
resultShape.push_back(currentDimSize);
} else if (keepDim)
resultShape.push_back(c1);
}
// First fill the output buffer for the index.
Value filledTensorIdx =
createZeroInitTensor(rewriter, loc, resultShape, outElementType);
// Second fill the output buffer for the running max.
Value initTensorMax =
rewriter.create<linalg::InitTensorOp>(loc, resultShape, inElementType)
.result();
FloatAttr fillValueMaxAttr = rewriter.getFloatAttr(
inElementType,
APFloat::getLargest(
inElementType.cast<mlir::FloatType>().getFloatSemantics(), true));
Value fillValueMax =
rewriter.create<arith::ConstantOp>(loc, fillValueMaxAttr);
Value filledTensorMax =
rewriter.create<linalg::FillOp>(loc, fillValueMax, initTensorMax)
.result();
// Create the affine expressions that will be used to
// iterate over the input and output tensors.
// Here we also set the type of iterator: parallel or reduction.
SmallVector<AffineExpr> exprs;
SmallVector<StringRef> iteratorTypes;
SmallVector<AffineExpr> resultExprs;
for (auto size : llvm::enumerate(inputType.getShape())) {
exprs.push_back(rewriter.getAffineDimExpr(size.index()));
if (unsigned(dim) == size.index()) {
iteratorTypes.push_back(getReductionIteratorTypeName());
// If `keepDim`, create affine map to the first element
// in the current dimension.
if (keepDim)
resultExprs.push_back(rewriter.getAffineConstantExpr(0));
} else {
iteratorTypes.push_back(getParallelIteratorTypeName());
resultExprs.push_back(rewriter.getAffineDimExpr(size.index()));
}
}
auto maps = AffineMap::inferFromExprList({exprs, resultExprs, resultExprs});
auto linalgOp = rewriter.create<linalg::GenericOp>(
loc,
ArrayRef<Type>({filledTensorIdx.getType(), filledTensorMax.getType()}),
input, ValueRange({filledTensorIdx, filledTensorMax}), maps,
iteratorTypes,
[&](OpBuilder &nestedBuilder, Location nestedLoc,
ValueRange blockArgs) {
Value newValue = blockArgs[0];
Value oldIndex = blockArgs[1];
Value oldValue = blockArgs[2];
Value newIndex = rewriter.create<arith::IndexCastOp>(
nestedLoc, oldIndex.getType(),
rewriter.create<linalg::IndexOp>(loc, dim));
Value predicate;
if (inElementType.isa<mlir::FloatType>())
predicate = rewriter.create<arith::CmpFOp>(
nestedLoc, arith::CmpFPredicate::OGT, newValue, oldValue);
auto resultMax = rewriter.create<mlir::SelectOp>(nestedLoc, predicate,
newValue, oldValue);
auto resultIndex = rewriter.create<mlir::SelectOp>(
nestedLoc, predicate, newIndex, oldIndex);
nestedBuilder.create<linalg::YieldOp>(
nestedLoc, ValueRange({resultIndex, resultMax}));
});
// This cast is required to fix the shape in the case of keepDim=True
rewriter.replaceOpWithNewOp<tensor::CastOp>(argmaxOp, resultType,
linalgOp.getResult(0));
return success();
}
};
} // namespace
namespace {
// Converts an elementwise op.
// This specifically includes:
// - converting elementwise ops of any tensor arity
// - converting elementwise ops with any number of scalar captures (such as a
// scalar alpha to torch.aten.Add)
// - broadcasting of static size-1 dimensions
//
// Currently, we adopt the behavior that "size 1" broadcasting is a runtime
// error if it happens dynamically.
//
// Looking forward a bit, eventually, it probably makes sense to have
// a "linalg.generic-like" op for modeling a fused subgraph of numpy-broadcasted
// operands. Modeling elementwise ops that way is potentially useful to allow a
// more centralized reasoning about multiversioning. However a cost model will
// be needed for "pre-fusing" elementwise ops that way, as it can potentially be
// a pessimization. A mild extension of this pattern should work for such a
// general op.
struct ConvertElementwiseOp : ConversionPattern {
ConvertElementwiseOp(TypeConverter &typeConverter, MLIRContext *context)
: ConversionPattern(typeConverter, MatchAnyOpTypeTag(), /*benefit=*/1,
context) {}
LogicalResult
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (!isa<AtenTanhOp, AtenReluOp, AtenGeluOp, AtenAddTensorOp,
AtenMulTensorOp, AtenDivTensorOp, AtenSubTensorOp,
AtenLerpTensorOp, AtenSigmoidOp, AtenExpOp, AtenMinimumOp,
AtenMaximumOp, AtenToDtypeOp, AtenClampOp, AtenRsubScalarOp,
AtenLogOp, AtenSqrtOp, AtenFloorOp, AtenPowTensorScalarOp, AtenLog2Op>(op))
return rewriter.notifyMatchFailure(op, "not a supported elementwise op");
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
Location loc = op->getLoc();
auto tensorOperands = llvm::to_vector<6>(llvm::make_filter_range(
operands, [](Value v) { return v.getType().isa<RankedTensorType>(); }));
auto resultType = getTypeConverter()
->convertType(op->getResult(0).getType())
.cast<RankedTensorType>();
auto resultRank = resultType.getRank();
auto c1 = rewriter.create<arith::ConstantIndexOp>(loc, /*value=*/1);
// The overall error handling strategy here is best viewed by thinking about
// what happens for a single result dimension. This loop not structured that
// way because it is hard to create the affine maps for each operand unless
// we structure the loop to iterate over tensor operands as the outer loop
// instead of inner loop. This pseudocode gives better intuition:
// ```
// for each result dimension:
// for each tensor operand:
// if it doesn't even have high enough rank relative to the result:
// continue
// if it is a static size-1 along this result dimension:
// continue
// if this is the first tensor operand that didn't continue above:
// take its dimension size as the size of the non-broadcasted
// traversal along this dimension (this may include a dynamic size-1,
// **non-broadcasted** traversal!)
// emit error check "if the size does not match the non-broadcasted
// traversal size along this dimension, error"
// ```
// Initialize the resultShape to all 1's, as a fallback in case
// all sizes along that result dimension are statically 1.
SmallVector<Value> resultShape(resultRank, c1);
SmallVector<AffineMap> indexingMaps;
for (Value tensorOperand : tensorOperands) {
SmallVector<AffineExpr> exprs;
auto type = tensorOperand.getType().cast<RankedTensorType>();
for (auto size : llvm::enumerate(type.getShape())) {
// If the size is statically known to be 1, we don't want any
// error guards to be spuriously emitted, since we are specifically
// allowing size-1 broadcasts in this case, as they correspond to a
// constant-0 indexing map.
if (size.value() == 1) {
exprs.push_back(rewriter.getAffineConstantExpr(0));
continue;
}
// The rank of this operand might be smaller than the overall rank of
// the broadcast. Add an offset to correlate it to the correct
// dimension of the result.
auto resultDim = size.index() + (resultRank - type.getRank());
// The generated linalg op will now be iterating along the full size
// of this dimension. Record that fact.
exprs.push_back(rewriter.getAffineDimExpr(resultDim));
// Now, we need to ensure that such iteration is not going to trigger
// undefined behavior, by doing appropriate checks against the current
// dimension size.
auto currentDimSize =
rewriter.create<tensor::DimOp>(loc, tensorOperand, size.index());
// If the result size of this dimension has so far only hit the
// statically-known-to-be-1 case above (i.e., we have not yet assigned a
// new Value to `resultShape[resultDim]`), then we have no other dynamic
// values to check against, and merely need to record the current
// dimension size.
if (resultShape[resultDim] == c1) {
resultShape[resultDim] = currentDimSize;
continue;
}
// We prohibit the size-1 dynamic broadcasting scenario, so just check
// for exact equality with the running result size.
// This is the check which protects against the undefined behavior of
// the generated linalg op in the case of iterating two operands with
// dimensions sizes that are expected to match.
auto equalToRunning = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, resultShape[resultDim],
currentDimSize);
rewriter.create<AssertOp>(loc, equalToRunning,
"mismatched size for broadcast");
}
indexingMaps.push_back(AffineMap::get(
/*dimCount=*/resultRank, /*symbolCount=*/0, exprs, getContext()));
}
SmallVector<StringRef> iteratorTypes(resultRank, "parallel");
// Add the indexing map for the outs init tensor.
indexingMaps.push_back(rewriter.getMultiDimIdentityMap(resultRank));
Value initTensor = rewriter.create<linalg::InitTensorOp>(
loc, resultShape, resultType.getElementType());
bool hadErrorCreatingPayload = false;
auto generic = rewriter.create<linalg::GenericOp>(
loc, /*resultTensorTypes=*/initTensor.getType(),
/*inputs=*/tensorOperands,
/*outputs=*/initTensor,
/*indexingMaps=*/indexingMaps,
/*iteratorTypes=*/iteratorTypes,
[&](OpBuilder &b, Location loc, ValueRange payloadArgs) {
Value result = createLinalgPayloadCalculationForElementwiseOp(
b, loc, getTypeConverter(), payloadArgs, op, operands);
if (!result) {
hadErrorCreatingPayload = true;
return;
}
b.create<linalg::YieldOp>(loc, result);
});
if (hadErrorCreatingPayload)
return failure();
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, resultType,
generic.getResult(0));
return success();
}
};
} // namespace
namespace {
struct ConvertReductionOp : ConversionPattern {
ConvertReductionOp(TypeConverter &typeConverter, MLIRContext *context)
: ConversionPattern(typeConverter, MatchAnyOpTypeTag(), /*benefit=*/1,
context) {}
// This function is in charge of all the rewriting that will take
// place in `matchAndRewrite`. In particular, it converts
// the reduce operation into an `linalg.generic` operation
// to reduce the input tensor along the dimensions specified in
// `dimeSet`.
LogicalResult
createReductionLinalgGeneric(Operation *op, ArrayRef<Value> operands,
const DenseSet<int64_t> &dimSet, bool keepDim,
ConversionPatternRewriter &rewriter) const {
Location loc = op->getLoc();
auto tensorOperand = operands[0];
auto inputType = tensorOperand.getType().cast<RankedTensorType>();
auto resultType = getTypeConverter()
->convertType(op->getResult(0).getType())
.cast<RankedTensorType>();
// Get the result shape by obtaining the size of each
// dimension in the input tensor that is not getting reduced.
// If `keepDim` is true, the rank of the output tensor
// is kept the same as the rank of the input tensor, and the
// reduced dimensions are set to have size 1.
auto c1 = rewriter.create<arith::ConstantIndexOp>(loc, /*value=*/1);
SmallVector<Value> resultShape;
for (int64_t i = 0; i < inputType.getRank(); i++) {
auto currentDimSize =
rewriter.create<tensor::DimOp>(loc, tensorOperand, i);
if (!dimSet.contains(i))
resultShape.push_back(currentDimSize);
else if (keepDim)
resultShape.push_back(c1);
}
// Create the affine expressions that will be used to
// iterate over the input and output tensors.
// Here we also set the type of iterator: parallel or reduction.
SmallVector<AffineExpr> exprs;
SmallVector<StringRef> iteratorTypes;
SmallVector<AffineExpr> resultExprs;
for (auto size : llvm::enumerate(inputType.getShape())) {
exprs.push_back(rewriter.getAffineDimExpr(size.index()));
if (dimSet.contains(size.index())) {
iteratorTypes.push_back(getReductionIteratorTypeName());
// If `keepDim`, create affine map to the first element
// in the current dimension.
if (keepDim)
resultExprs.push_back(rewriter.getAffineConstantExpr(0));
} else {
iteratorTypes.push_back(getParallelIteratorTypeName());
resultExprs.push_back(rewriter.getAffineDimExpr(size.index()));
}
}
auto indexingMaps = AffineMap::inferFromExprList({exprs, resultExprs});
Value initTensor = rewriter.create<linalg::InitTensorOp>(
loc, resultShape, resultType.getElementType());
Value initValue = createLinalgNeutralElementForReduceOp(
rewriter, loc, op, resultType.getElementType());
Value accumulator =
rewriter.create<linalg::FillOp>(loc, initValue, initTensor)
.getResult(0);
bool hadErrorCreatingPayload = false;
auto generic = rewriter.create<linalg::GenericOp>(
loc, /*resultTensorTypes=*/accumulator.getType(),
/*inputs=*/tensorOperand,
/*outputs=*/accumulator,
/*indexingMaps=*/indexingMaps,
/*iteratorTypes=*/iteratorTypes,
[&](OpBuilder &b, Location loc, ValueRange payloadArgs) {
Value result = createLinalgPayloadCalculationForReduceOp(
b, loc, payloadArgs, op, operands, resultType.getElementType());
if (!result) {
hadErrorCreatingPayload = true;
return;
}
b.create<linalg::YieldOp>(loc, result);
});
if (hadErrorCreatingPayload)
return failure();
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, resultType,
generic.getResult(0));
return success();
}
LogicalResult
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
// Every reduce operation must set a value for the `dimSet` and
// `keepDim` in accordance with their specification.
DenseSet<int64_t> dimSet;
bool keepDim = false;
if (isa<AtenSumOp>(op)) {
auto tensorOperand = operands[0];
auto inputType = tensorOperand.getType().cast<RankedTensorType>();
// `AtenSumOp` reduces along all the dimensiosn of the input tensor.
for (int64_t i = 0; i < inputType.getRank(); i++)
dimSet.insert(i);
} else if (auto sumDimIntListOp = dyn_cast<AtenSumDimIntListOp>(op)) {
auto tensorOperand = operands[0];
auto inputType = tensorOperand.getType().cast<RankedTensorType>();
if (!matchPattern(sumDimIntListOp.keepdim(),
m_TorchConstantBool(&keepDim)))
return failure();
SmallVector<int64_t> dimList;
if (!matchPattern(sumDimIntListOp.dim(), m_TorchConstantIntList(dimList)))
return failure();
for (auto dim : dimList) {
// Torch allows for negative values in dimSet to go in reverse
// order in the dimensions of the input tensor.
dim = dim >= 0 ? dim : dim + inputType.getRank();
// Drop invalid dimensions
if (dim < inputType.getRank())
dimSet.insert(dim);
}
} else {
return rewriter.notifyMatchFailure(op, "not a supported reduce op");
}
return createReductionLinalgGeneric(op, operands, dimSet, keepDim,
rewriter);
}
};
} // namespace
namespace {
class ConvertAtenMaxPool2dOp : public OpConversionPattern<AtenMaxPool2dOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenMaxPool2dOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
Location loc = op->getLoc();
AtenMaxPool2dOp::Adaptor adaptor(operands);
Value self = adaptor.self();
Value ceilMode = adaptor.ceil_mode();
Type elementType = self.getType().cast<RankedTensorType>().getElementType();
if (!elementType.isa<mlir::FloatType>())
return op.emitError("unimplemented: non-floating point type");
// Pattern match against the op's original operands, because otherwise we
// will get the lowered version of the operands which is harder to pattern
// match.
SmallVector<int64_t, 2> strideInts;
if (!matchPattern(op.stride(), m_TorchConstantIntList(strideInts)))
return rewriter.notifyMatchFailure(op,
"only support constant int strides");
SmallVector<int64_t, 2> dilationInts;
if (!matchPattern(op.dilation(), m_TorchConstantIntList(dilationInts)))
return rewriter.notifyMatchFailure(op,
"only support constant int dilations");
SmallVector<int64_t, 2> paddingInts;
if (!matchPattern(op.padding(), m_TorchConstantIntList(paddingInts)))
return rewriter.notifyMatchFailure(op,
"only support constant int paddings");
SmallVector<int64_t, 2> kernelSizeInts;
if (!matchPattern(op.kernel_size(), m_TorchConstantIntList(kernelSizeInts)))
return rewriter.notifyMatchFailure(op, "only support kernel size ints");
Value falseValue = rewriter.create<arith::ConstantOp>(
loc, IntegerAttr::get(rewriter.getIntegerType(1), 0));
Value ceilModeFalse = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, ceilMode, falseValue);
rewriter.create<AssertOp>(
loc, ceilModeFalse,
rewriter.getStringAttr("only ceil_mode false is supported"));
SmallVector<int64_t, 4> paddingIncludingNC = {0, 0};
paddingIncludingNC.insert(paddingIncludingNC.end(), paddingInts.begin(),
paddingInts.end());
Value paddedInput = getPaddedTensor(op, rewriter, self, paddingIncludingNC);
Value N = getDimOp(rewriter, loc, self, 0);
Value C = getDimOp(rewriter, loc, self, 1);
Value H = getDimOp(rewriter, loc, self, 2);
Value W = getDimOp(rewriter, loc, self, 3);
SmallVector<Value> paddingIntValues =
getAsConstantIntValues(rewriter, loc, paddingInts);
SmallVector<Value> dilationIntValues =
getAsConstantIntValues(rewriter, loc, dilationInts);
SmallVector<Value> kernelSizeIntValues =
getAsConstantIntValues(rewriter, loc, kernelSizeInts);
SmallVector<Value> strideIntValues =
getAsConstantIntValues(rewriter, loc, strideInts);
Value Hout = getOutputDimForConvOps(
rewriter, loc, H, paddingIntValues[0], dilationIntValues[0],
kernelSizeIntValues[0], strideIntValues[0]);
Value Wout = getOutputDimForConvOps(
rewriter, loc, W, paddingIntValues[1], dilationIntValues[1],
kernelSizeIntValues[1], strideIntValues[1]);
// Initialize output tensor with smallest floating point value
Value outTensor = rewriter.create<linalg::InitTensorOp>(
loc, ValueRange{N, C, Hout, Wout}, elementType);
auto initialAttr = rewriter.getFloatAttr(
elementType,
APFloat::getSmallest(
elementType.cast<mlir::FloatType>().getFloatSemantics(),
/*Negative*/ true));
Value initValue = rewriter.create<arith::ConstantOp>(loc, initialAttr);
Value outTensorInitialized =
rewriter.create<linalg::FillOp>(loc, initValue, outTensor).getResult(0);
auto stridesAttr = rewriter.getI64VectorAttr(strideInts);
auto dilationAttr = rewriter.getI64VectorAttr(dilationInts);
Value windowTensor = rewriter.create<linalg::InitTensorOp>(
loc, getAsConstantIndexValues(rewriter, loc, kernelSizeInts),
elementType);
Value maxPool2d = rewriter
.create<linalg::PoolingNchwMaxOp>(
loc, outTensorInitialized.getType(),
ValueRange{paddedInput, windowTensor},
outTensorInitialized, stridesAttr, dilationAttr)
.getResult(0);
Type newResultType = getTypeConverter()->convertType(op.getType());
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, maxPool2d);
return success();
}
};
} // namespace
namespace {
class ConvertAtenFlattenUsingIntsOp
: public OpConversionPattern<AtenFlattenUsingIntsOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenFlattenUsingIntsOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
int64_t startDim;
if (!matchPattern(op.start_dim(), m_TorchConstantInt(&startDim)))
return rewriter.notifyMatchFailure(op, "start_dim must be constant");
int64_t endDim;
if (!matchPattern(op.end_dim(), m_TorchConstantInt(&endDim)))
return rewriter.notifyMatchFailure(op, "end_dim must be constant");
auto type = operands[0].getType().cast<RankedTensorType>();
auto inputRank = type.getRank();
auto resultType =
getTypeConverter()->convertType(op.getType()).cast<RankedTensorType>();
if (startDim < 0)
startDim += inputRank;
if (endDim < 0)
endDim += inputRank;
if (inputRank == 0) {
SmallVector<ReassociationIndices> reassociation;
if (!(startDim >= -1 && startDim <= 0 && endDim >= -1 && endDim <= 0))
return rewriter.notifyMatchFailure(
op, "start_dim and end_dim must be in [-1, 0] when inputRank is 0");
rewriter.replaceOpWithNewOp<linalg::TensorExpandShapeOp>(
op, resultType, operands[0], reassociation);
return success();
}
if (startDim < 0 || startDim >= inputRank || endDim < 0 ||
endDim >= inputRank || startDim > endDim)
return rewriter.notifyMatchFailure(
op, "statically invalid flattening dim range");
SmallVector<ReassociationIndices> reassociation(resultType.getRank());
int j = 0;
for (auto i : llvm::seq<int64_t>(0, inputRank)) {
reassociation[j].push_back(i);
if (i < startDim || i >= endDim)
j++;
}
Value collapsedTensor = rewriter.create<linalg::TensorCollapseShapeOp>(
op->getLoc(), operands[0], reassociation);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, resultType,
collapsedTensor);
return success();
}
};
} // namespace
namespace {
/// The `ConvertAtenViewOp` conversion pattern converts `aten.View` op to
/// `linalg.TensorExpandShape` op only when one or multiple static dimensions
/// are expanded. All the other cases of `aten.View` op need to be handled.
/// TODO: Handle all the other cases of `aten.View` op.
class ConvertAtenViewOp : public OpConversionPattern<AtenViewOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenViewOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
Location loc = op.getLoc();
Value input = operands[0];
auto inputType = input.getType().cast<RankedTensorType>();
int64_t inputRank = inputType.getRank();
TypeConverter *typeConverter = getTypeConverter();
auto resultType =
typeConverter->convertType(op.getType()).cast<RankedTensorType>();
int64_t resultRank = resultType.getRank();
// When we only have expansion of dimensions in `aten.View`, the output
// tensor rank will be strictly greater than the input tensor rank.
// TODO: Handle the cases of `aten.View` op where,
// 1. One or multiple dimensions are collapsed.
// 2. Few dimensions are expanded and few other dimensions are collapsed.
if (inputRank >= resultRank) {
return rewriter.notifyMatchFailure(
op, "unimplemented: operand tensor rank should be strictly less than "
"the desired output rank");
}
// Extract the desired output size as a list of integers. This list should
// have been created using the operation `torch.prim.ListConstruct`.
SmallVector<Value> expectedSizeTorchInt;
if (!getListConstructElements(op.size(), expectedSizeTorchInt)) {
return rewriter.notifyMatchFailure(op,
"unimplemented: the desired size is "
"not constructed from ListConstruct");
}
SmallVector<Value> expectedSize = getTypeConvertedValues(
rewriter, loc, typeConverter, expectedSizeTorchInt);
if (resultRank != (int64_t)expectedSize.size()) {
return rewriter.notifyMatchFailure(
op, "desired size list length mismatches with the result type rank");
}
// Check if the `aten.View` can be legalized to `linalg.TensorExpandShape`.
// It only handles the case of static dimension expansion. If the dimension
// is dynamic, it must not be expanded/splitted.
// TODO: Handle the case of dynamic dimension expansion.
SmallVector<ReassociationIndices> reassociation(inputRank);
SmallVector<int64_t> resultShape;
int64_t j = 0;
for (auto i : llvm::seq<int64_t>(0, inputRank)) {
if (inputType.isDynamicDim(i)) {
Value dim = getDimOp(rewriter, loc, input, i);
if (j >= resultRank) {
return rewriter.notifyMatchFailure(
op, "desired size is not compatible with the input tensor size");
}
checkDimEqualHelper(rewriter, loc, dim, expectedSize[j]);
reassociation[i].push_back(j++);
resultShape.push_back(kUnknownSize);
} else {
int64_t expandedDim = inputType.getDimSize(i);
int64_t outputDim;
// A do-while loop is used here to handle the cases where the input
// tensor has a dimension of size 1.
do {
if (j >= resultRank ||
!matchPattern(expectedSizeTorchInt[j],
m_TorchConstantInt(&outputDim)) ||
expandedDim % outputDim != 0) {
return rewriter.notifyMatchFailure(
op, "total number of elements mismatch in the expansion");
}
reassociation[i].push_back(j++);
resultShape.push_back(outputDim);
expandedDim /= outputDim;
} while (expandedDim != 1);
}
}
// Make sure that the splitted dimensions have the same number of elements
// as the dimension got splitted from.
if (j != resultRank)
return rewriter.notifyMatchFailure(
op, "desired size is not compatible with the input tensor size");
Type expandType =
RankedTensorType::get(resultShape, resultType.getElementType());
Value expandOp = rewriter.create<linalg::TensorExpandShapeOp>(
loc, expandType, operands[0], reassociation);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, resultType, expandOp);
return success();
}
};
} // namespace
namespace {
class ConvertAtenUnsqueezeOp : public OpConversionPattern<AtenUnsqueezeOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenUnsqueezeOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
int64_t dim;
if (!matchPattern(op.dim(), m_TorchConstantInt(&dim)))
return rewriter.notifyMatchFailure(op, "dim must be constant");
auto inputRank = operands[0].getType().cast<RankedTensorType>().getRank();
if (dim < 0)
dim += inputRank + 1;
if (!(0 <= dim && dim <= inputRank))
return rewriter.notifyMatchFailure(op, "statically invalid");
SmallVector<ReassociationIndices> reassociationMap(inputRank);
// From the perspective of the reassociation map, the situation of
// unsqueezing before or after the last dimension is symmetrical.
// Normalize it to the "before" case.
// The 0 case is special here, since there is no last dimension to insert
// before -- we simply rely on the loop below iterating 0 times.
if (dim == inputRank && inputRank != 0)
dim = inputRank - 1;
bool alreadyCrossedExpandedDim = false;
for (int i = 0; i != inputRank; i++) {
if (alreadyCrossedExpandedDim) {
reassociationMap[i].push_back(i + 1);
} else {
reassociationMap[i].push_back(i);
if (i == dim) {
reassociationMap[i].push_back(i + 1);
alreadyCrossedExpandedDim = true;
}
}
}
auto resultType = getTypeConverter()
->convertType(op->getResult(0).getType())
.cast<RankedTensorType>();
rewriter.replaceOpWithNewOp<linalg::TensorExpandShapeOp>(
op, resultType, operands[0], reassociationMap);
return success();
}
};
} // namespace
namespace {
class ConvertAtenTransposeIntOp
: public OpConversionPattern<AtenTransposeIntOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenTransposeIntOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
AtenTransposeIntOp::Adaptor adaptor(operands);
int64_t dim0;
if (!matchPattern(op.dim0(), m_TorchConstantInt(&dim0)))
return rewriter.notifyMatchFailure(op, "dim0 must be constant");
int64_t dim1;
if (!matchPattern(op.dim1(), m_TorchConstantInt(&dim1)))
return rewriter.notifyMatchFailure(op, "dim1 must be constant");
auto inVector = adaptor.self();
auto inType = inVector.getType().cast<RankedTensorType>();
auto inputRank = inType.getRank();
auto outType = getTypeConverter()
->convertType(op->getResult(0).getType())
.cast<RankedTensorType>();
auto elementType = inType.getElementType();
dim0 = toPositiveDim(dim0, inputRank);
if (!isValidDim(dim0, inputRank))
return rewriter.notifyMatchFailure(op, "dim0 out of range");
dim1 = toPositiveDim(dim1, inputRank);
if (!isValidDim(dim1, inputRank))
return rewriter.notifyMatchFailure(op, "dim1 out of range");
auto loc = op.getLoc();
SmallVector<Value> outputDims;
for (auto i = 0; i < inputRank; i++)
outputDims.push_back(getDimOp(rewriter, loc, adaptor.self(), i));
std::swap(outputDims[dim0], outputDims[dim1]);
Value outVector =
rewriter.create<linalg::InitTensorOp>(loc, outputDims, elementType);
SmallVector<AffineExpr> idExprs;
SmallVector<AffineExpr> swapExprs;
for (auto i = 0; i < inputRank; i++)
idExprs.push_back(getAffineDimExpr(i, rewriter.getContext()));
for (auto i = 0; i < inputRank; i++) {
if (i == dim0)
swapExprs.push_back(idExprs[dim1]);
else if (i == dim1)
swapExprs.push_back(idExprs[dim0]);
else
swapExprs.push_back(idExprs[i]);
}
SmallVector<AffineMap> indexingMaps = {
AffineMap::get(inputRank, 0, idExprs, op.getContext()),
AffineMap::get(inputRank, 0, swapExprs, op.getContext())};
SmallVector<StringRef> iteratorTypes(inputRank, "parallel");
auto transpose = rewriter
.create<linalg::GenericOp>(
loc, outVector.getType(), inVector, outVector,
indexingMaps, iteratorTypes,
[](OpBuilder &b, Location loc, ValueRange args) {
b.create<linalg::YieldOp>(loc, args[0]);
})
.getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, outType, transpose);
return success();
}
};
} // namespace
namespace {
class ConvertAtenPermuteOp : public OpConversionPattern<AtenPermuteOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenPermuteOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
AtenPermuteOp::Adaptor adaptor(operands);
SmallVector<int64_t> dimensions;
if (!matchPattern(op.dims(), m_TorchConstantIntList(dimensions)))
return rewriter.notifyMatchFailure(op, "all dimensions must be constant");
Value inVector = adaptor.self();
auto inType = inVector.getType().cast<RankedTensorType>();
int64_t inputRank = inType.getRank();
auto outType = getTypeConverter()
->convertType(op->getResult(0).getType())
.cast<RankedTensorType>();
Type elementType = inType.getElementType();
// Check if the dimensions are a valid constants.
int64_t numDimensions = dimensions.size();
if (inputRank != numDimensions)
return rewriter.notifyMatchFailure(
op, "size of `dims` must be equal to the rank of the input");
for (unsigned i = 0; i < numDimensions; i++) {
if (dimensions[i] < 0)
dimensions[i] = toPositiveDim(dimensions[i], inputRank);
if (!isValidDim(dimensions[i], inputRank))
return rewriter.notifyMatchFailure(op, "dimension out of range");
}
Location loc = op.getLoc();
SmallVector<Value> outputDims;
for (unsigned i = 0; i < inputRank; i++)
outputDims.push_back(getDimOp(rewriter, loc, inVector, dimensions[i]));
Value outVector =
rewriter.create<linalg::InitTensorOp>(loc, outputDims, elementType);
SmallVector<AffineExpr> idExprs;
SmallVector<AffineExpr> swapExprs;
for (unsigned i = 0; i < inputRank; i++)
idExprs.push_back(getAffineDimExpr(i, rewriter.getContext()));
for (unsigned i = 0; i < inputRank; i++)
swapExprs.push_back(idExprs[dimensions[i]]);
SmallVector<AffineMap> indexingMaps =
AffineMap::inferFromExprList({idExprs, swapExprs});
SmallVector<StringRef> iteratorTypes(inputRank, "parallel");
auto transpose = rewriter
.create<linalg::GenericOp>(
loc, outVector.getType(), inVector, outVector,
indexingMaps, iteratorTypes,
[](OpBuilder &b, Location loc, ValueRange args) {
b.create<linalg::YieldOp>(loc, args[0]);
})
.getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, outType, transpose);
return success();
}
};
} // namespace
namespace {
class ConvertAtenCatOp : public OpConversionPattern<AtenCatOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenCatOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
Location loc = op.getLoc();
TypeConverter *typeConverter = getTypeConverter();
AtenCatOp::Adaptor adaptor(operands);
Value dimValue = op.dim();
int64_t dim;
if (!matchPattern(dimValue, m_TorchConstantInt(&dim)))
return op.emitError("unimplemented: dim is not constant");
// Collect all the tensors to be concatenated.
auto tensorList = op.tensors();
SmallVector<Value> tensorsTorchType;
if (!getListConstructElements(tensorList, tensorsTorchType))
return op.emitError(
"unimplemented: the tensor list is not from list construct");
auto tensors =
getTypeConvertedValues(rewriter, loc, typeConverter, tensorsTorchType);
RankedTensorType newResultType =
typeConverter->convertType(op.getType()).cast<RankedTensorType>();
int rank = newResultType.getRank();
SmallVector<Value> offsets, sizes, strides;
sizes.reserve(rank);
strides.resize(rank, rewriter.create<arith::ConstantIndexOp>(loc, 1));
offsets.resize(rank, rewriter.create<arith::ConstantIndexOp>(loc, 0));
for (int i = 0; i < rank; ++i)
sizes.push_back(rewriter.create<tensor::DimOp>(loc, tensors[0], i));
// Calculate the size of the `dim` result dimension by adding the dim size
// of each tensor together.
Value resultDimSize = sizes[dim];
Value dimIndex = rewriter.create<arith::IndexCastOp>(
loc, rewriter.getIndexType(), adaptor.dim());
for (auto tensor : makeArrayRef(tensors).drop_front()) {
auto size = rewriter.create<tensor::DimOp>(loc, tensor, dimIndex);
resultDimSize = rewriter.create<arith::AddIOp>(loc, resultDimSize, size);
}
sizes[dim] = resultDimSize;
Value result = rewriter.create<linalg::InitTensorOp>(
loc, sizes, newResultType.getElementType());
for (auto tensor : tensors) {
sizes[dim] = rewriter.create<tensor::DimOp>(loc, tensor, dimIndex);
result = rewriter.create<tensor::InsertSliceOp>(loc, tensor, result,
offsets, sizes, strides);
offsets[dim] =
rewriter.create<arith::AddIOp>(loc, offsets[dim], sizes[dim]);
}
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, result);
return success();
}
};
} // namespace
namespace {
class ConvertAtenGatherOp : public OpConversionPattern<AtenGatherOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenGatherOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
Location loc = op->getLoc();
AtenGatherOp::Adaptor adaptor(operands);
Value dimValue = op.dim();
int64_t dim;
if (!matchPattern(dimValue, m_TorchConstantInt(&dim)))
return op.emitError("unimplemented: dim is not constant");
Value indices = adaptor.index();
Value self = adaptor.self();
RankedTensorType newResultTy =
getTypeConverter()->convertType(op.getType()).cast<RankedTensorType>();
int64_t rank = newResultTy.getRank();
SmallVector<Value> sizes = getTensorSizes(rewriter, loc, indices);
Value result = createZeroInitTensor(rewriter, loc, sizes,
newResultTy.getElementType());
SmallVector<AffineMap, 2> affineMaps(2,
rewriter.getMultiDimIdentityMap(rank));
SmallVector<StringRef> iteratorTypes(rank, getParallelIteratorTypeName());
auto genericOp = rewriter.create<linalg::GenericOp>(
loc, newResultTy, indices, result, affineMaps, iteratorTypes,
[&](OpBuilder &b, Location loc, ValueRange args) {
auto index = args[0];
createLinalgPayloadCalculationForGatherOps(b, loc, self, rank, index,
dim, rank);
});
rewriter.replaceOp(op, genericOp.getResult(0));
return success();
}
};
} // namespace
namespace {
class ConvertAtenEmbeddingOp : public OpConversionPattern<AtenEmbeddingOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenEmbeddingOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
Location loc = op->getLoc();
AtenEmbeddingOp::Adaptor adaptor(operands);
Value weight = adaptor.weight();
Value indices = adaptor.indices();
RankedTensorType newResultType =
typeConverter->convertType(op.getType()).cast<RankedTensorType>();
auto weightTy = weight.getType().cast<RankedTensorType>();
if (weightTy.getRank() != 2)
return rewriter.notifyMatchFailure(op, "weight must be rank 2");
Value embeddingDim = getDimOp(rewriter, loc, weight, 1);
Type elemTy = weightTy.getElementType();
SmallVector<Value> sizes = getTensorSizes(rewriter, loc, indices);
sizes.push_back(embeddingDim);
int64_t resultRank = sizes.size();
auto indicesTy = weight.getType().cast<RankedTensorType>();
int64_t indicesRank = indicesTy.getRank();
SmallVector<AffineExpr> indicesExprs;
for (int i = 0; i < indicesRank; i++)
indicesExprs.push_back(rewriter.getAffineDimExpr(i));
auto indicesAffineMap = AffineMap::get(
/*dimCount=*/resultRank,
/*symbolCount=*/0, indicesExprs, op->getContext());
SmallVector<AffineMap, 2> indexingMaps = {
indicesAffineMap,
rewriter.getMultiDimIdentityMap(resultRank),
};
SmallVector<StringRef> iteratorTypes(sizes.size(),
getParallelIteratorTypeName());
Value initTensor =
rewriter.create<linalg::InitTensorOp>(loc, sizes, elemTy);
Value embeddingResult =
rewriter
.create<linalg::GenericOp>(
loc, initTensor.getType(), indices, initTensor,
/*indexingMaps=*/indexingMaps, /*iteratorTypes=*/iteratorTypes,
[&](OpBuilder &b, Location loc, ValueRange args) {
Value index = args[0];
createLinalgPayloadCalculationForGatherOps(
b, loc, weight, weightTy.getRank(), index, /*dim=*/0,
resultRank);
})
.getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType,
embeddingResult);
return success();
}
};
} // namespace
namespace {
class ConvertAtenSizeIntOp : public OpConversionPattern<AtenSizeIntOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenSizeIntOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
Location loc = op->getLoc();
AtenSizeIntOp::Adaptor adaptor(operands);
Value self = adaptor.self();
Value dim = adaptor.dim();
auto type = self.getType().cast<RankedTensorType>();
Value inputRank = rewriter.create<arith::ConstantOp>(
loc, rewriter.getI64IntegerAttr(type.getRank()));
Value dimPositive = toPositiveDimDynamic(rewriter, loc, dim, inputRank);
assertIsValidDim(rewriter, loc, dimPositive, inputRank);
Value size = rewriter.create<tensor::DimOp>(
loc, adaptor.self(), castIntToIndex(rewriter, loc, dimPositive));
rewriter.replaceOp(op, castIndexToInt(rewriter, loc, size));
return success();
}
};
} // namespace
// Casts a 0d integer tensor to elemental type.
namespace {
class ConvertAtenIntTensorOp : public OpConversionPattern<AtenIntTensorOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenIntTensorOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
AtenIntTensorOp::Adaptor adaptor(operands);
Value intTensor = adaptor.a();
auto tensorType = intTensor.getType().cast<RankedTensorType>();
if (tensorType.getRank() != 0)
return rewriter.notifyMatchFailure(
op, "invalid rank: the rank of the input tensor must be 0");
rewriter.replaceOpWithNewOp<tensor::ExtractOp>(op, intTensor);
return success();
}
};
} // namespace
namespace {
class ConvertAtenBroadcastToOp : public OpConversionPattern<AtenBroadcastToOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenBroadcastToOp op, llvm::ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
AtenBroadcastToOp::Adaptor adaptor(operands);
Value self = adaptor.self();
auto selfType = self.getType().cast<RankedTensorType>();
ArrayRef<int64_t> selfShape = selfType.getShape();
Type elementType = selfType.getElementType();
Location loc = op.getLoc();
MLIRContext *context = op->getContext();
SmallVector<Value> inShape, outShape;
if (!getListConstructElements(adaptor.size(), inShape)) {
return rewriter.notifyMatchFailure(
op, "unimplemented: the size list is not from list construct");
}
SmallVector<Value> inShapeConverted =
getTypeConvertedValues(rewriter, loc, getTypeConverter(), inShape);
if (inShape.size() < selfShape.size())
return rewriter.notifyMatchFailure(
op, "invalid shape: must not be smaller than rank of tensor");
size_t diff = inShape.size() - selfShape.size();
// Create affine map and shapes for tensor initialization.
SmallVector<AffineExpr> outExpr;
Value zero =
rewriter.create<arith::ConstantOp>(loc, rewriter.getI64IntegerAttr(0));
for (size_t i = 0; i < inShape.size(); i++) {
Value shapeValue = inShapeConverted[i];
size_t j = i - diff;
if (i < diff) {
Value isValid = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::sge, shapeValue, zero);
rewriter.create<AssertOp>(
loc, isValid,
rewriter.getStringAttr(
"negative values not allowed in new dimensions"));
outShape.push_back(castIntToIndex(rewriter, loc, shapeValue));
continue;
}
if (selfShape[j] == 1) {
// Broadcast singleton dimension
Value one =
rewriter.create<arith::ConstantOp>(loc, rewriter.getIndexAttr(1));
Value isNegative = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::slt, shapeValue, zero);
Value select = rewriter.create<SelectOp>(
loc, isNegative, one, castIntToIndex(rewriter, loc, shapeValue));
outShape.push_back(select);
outExpr.push_back(mlir::getAffineConstantExpr(0, context));
continue;
}
// Non-broadcast case
Value dim = getDimOp(rewriter, loc, self, j);
Value isNegative = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::slt, shapeValue, zero);
Value isEqual = rewriter.create<arith::CmpIOp>(
loc, arith::CmpIPredicate::eq, castIndexToInt(rewriter, loc, dim),
shapeValue);
Value isValid = rewriter.create<arith::OrIOp>(loc, isNegative, isEqual);
rewriter.create<AssertOp>(
loc, isValid,
rewriter.getStringAttr(
"only broadcasting singleton dimensions supported"));
outShape.push_back(dim);
outExpr.push_back(mlir::getAffineDimExpr(i, context));
}
Value outTensor =
rewriter.create<linalg::InitTensorOp>(loc, outShape, elementType);
SmallVector<AffineMap> indexingMaps = {
AffineMap::get(inShape.size(), 0, outExpr, context),
rewriter.getMultiDimIdentityMap(inShape.size())};
SmallVector<StringRef> iteratorTypes(inShape.size(), "parallel");
Value result = rewriter
.create<linalg::GenericOp>(
loc, outTensor.getType(), self, outTensor,
indexingMaps, iteratorTypes,
[](OpBuilder &b, Location loc, ValueRange args) {
b.create<linalg::YieldOp>(loc, args[0]);
})
.getResult(0);
Type newResultType = getTypeConverter()->convertType(op.getType());
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, result);
return success();
}
};
} // namespace
namespace {
class ConvertAtenContiguousOp : public OpConversionPattern<AtenContiguousOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenContiguousOp op, llvm::ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
AtenContiguousOp::Adaptor adaptor(operands);
rewriter.replaceOp(op, adaptor.self());
return success();
}
};
} // namespace
namespace {
class ConvertAtenOnesOp : public OpConversionPattern<AtenOnesOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(AtenOnesOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
AtenOnesOp::Adaptor adaptor(operands);
Location loc = op.getLoc();
// We ignore device, but add simple asserts for unimplemented kwargs
if (!adaptor.layout().getType().isa<Torch::NoneType>())
return rewriter.notifyMatchFailure(op,
"only default layout is supported");
bool pinMemory;
if (!adaptor.pin_memory().getType().isa<Torch::NoneType>() &&
!matchPattern(adaptor.pin_memory(), m_TorchConstantBool(&pinMemory)))
return rewriter.notifyMatchFailure(op, "memory pinning not supported");
SmallVector<Value> size, sizeIndex;
if (!getListConstructElements(adaptor.size(), size)) {
return rewriter.notifyMatchFailure(
op, "size must be created by ListConstruct");
}
size = getTypeConvertedValues(rewriter, loc, getTypeConverter(), size);
for (size_t i = 0; i < size.size(); i++)
sizeIndex.push_back(castIntToIndex(rewriter, loc, size[i]));
RankedTensorType newResultType =
getTypeConverter()->convertType(op.getType()).cast<RankedTensorType>();
Type outElementType = newResultType.getElementType();
Value one = rewriter.create<arith::ConstantOp>(
loc, outElementType,
(outElementType.isa<mlir::FloatType>()
? rewriter.getFloatAttr(outElementType, 1).cast<mlir::Attribute>()
: rewriter.getIntegerAttr(outElementType, 1)
.cast<mlir::Attribute>()));
Value outTensor = rewriter
.create<linalg::InitTensorOp>(
loc, sizeIndex, newResultType.getElementType())
.getResult();
Value fillOp =
rewriter.create<linalg::FillOp>(loc, one, outTensor).getResult(0);
rewriter.replaceOpWithNewOp<tensor::CastOp>(op, newResultType, fillOp);
return success();
}
};
} // namespace
namespace {
class ConvertPrimNumToTensorScalarOp
: public OpConversionPattern<PrimNumToTensorScalarOp> {
public:
using OpConversionPattern::OpConversionPattern;
LogicalResult
matchAndRewrite(PrimNumToTensorScalarOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
if (failed(verifyLinalgCompatibleTypes(op, rewriter)))
return failure();
PrimNumToTensorScalarOp::Adaptor adaptor(operands);
Location loc = op.getLoc();
Value a = adaptor.a();
Value outTensor =
rewriter.create<linalg::InitTensorOp>(loc, ValueRange{}, a.getType())
->getResult(0);
rewriter.replaceOpWithNewOp<linalg::FillOp>(op, a, outTensor);
return success();
}
};
} // namespace
// -----------------------------------------------------------------------------
// The pass
// -----------------------------------------------------------------------------
namespace {
class ConvertTorchToLinalg
: public ConvertTorchToLinalgBase<ConvertTorchToLinalg> {
public:
void getDependentDialects(DialectRegistry ®istry) const override {
registry.insert<linalg::LinalgDialect>();
registry.insert<math::MathDialect>();
registry.insert<StandardOpsDialect>();
registry.insert<tensor::TensorDialect>();
registry.insert<arith::ArithmeticDialect>();
TorchConversion::getBackendTypeConversionDependentDialects(registry);
}
void runOnOperation() override {
MLIRContext *context = &getContext();
ConversionTarget target(*context);
target.addLegalDialect<linalg::LinalgDialect, StandardOpsDialect,
math::MathDialect, tensor::TensorDialect,
arith::ArithmeticDialect>();
TypeConverter typeConverter;
typeConverter.addConversion([](Type type) { return type; });
TorchConversion::setupBackendTypeConversion(target, typeConverter);
RewritePatternSet patterns(context);
target.addIllegalOp<AtenMmOp>();
patterns.add<ConvertAtenMmOp>(typeConverter, context);
target.addIllegalOp<AtenMatmulOp>();
patterns.add<ConvertAtenMatmulOp>(typeConverter, context);
target.addIllegalOp<AtenBmmOp>();
patterns.add<ConvertAtenBmmOp>(typeConverter, context);
target.addIllegalOp<AtenLinearOp>();
patterns.add<ConvertAtenLinearOp>(typeConverter, context);
target.addIllegalOp<AtenBatchNormOp>();
patterns.add<ConvertAtenBatchNormOp>(typeConverter, context);
target.addIllegalOp<AtenTanhOp, AtenReluOp, AtenGeluOp, AtenAddTensorOp,
AtenMulTensorOp, AtenDivTensorOp, AtenSubTensorOp,
AtenLerpTensorOp, AtenSigmoidOp, AtenMinimumOp,
AtenMaximumOp, AtenToDtypeOp, AtenClampOp,
AtenRsubScalarOp, AtenLogOp, AtenSqrtOp, AtenFloorOp,
AtenPowTensorScalarOp, AtenLog2Op>();
patterns.add<ConvertElementwiseOp>(typeConverter, context);
target.addIllegalOp<AtenUnsqueezeOp>();
patterns.add<ConvertAtenUnsqueezeOp>(typeConverter, context);
target.addIllegalOp<AtenConv2dOp>();
patterns.add<ConvertAtenConv2dOp>(typeConverter, context);
target.addIllegalOp<AtenAdaptiveAvgPool2dOp>();
patterns.add<ConvertAtenAdaptiveAvgPool2dOp>(typeConverter, context);
target.addIllegalOp<AtenFlattenUsingIntsOp>();
patterns.add<ConvertAtenFlattenUsingIntsOp>(typeConverter, context);
target.addIllegalOp<AtenViewOp>();
patterns.add<ConvertAtenViewOp>(typeConverter, context);
target.addIllegalOp<AtenMaxPool2dOp>();
patterns.add<ConvertAtenMaxPool2dOp>(typeConverter, context);
target.addIllegalOp<AtenSumOp>();
patterns.add<ConvertReductionOp>(typeConverter, context);
target.addIllegalOp<AtenTransposeIntOp>();
patterns.add<ConvertAtenTransposeIntOp>(typeConverter, context);
target.addIllegalOp<AtenPermuteOp>();
patterns.add<ConvertAtenPermuteOp>(typeConverter, context);
target.addIllegalOp<AtenCatOp>();
patterns.add<ConvertAtenCatOp>(typeConverter, context);
target.addIllegalOp<AtenGatherOp>();
patterns.add<ConvertAtenGatherOp>(typeConverter, context);
target.addIllegalOp<AtenLayerNormOp>();
patterns.add<ConvertAtenLayerNormOp>(typeConverter, context);
target.addIllegalOp<AtenBroadcastToOp>();
patterns.add<ConvertAtenBroadcastToOp>(typeConverter, context);
target.addIllegalOp<AtenArgmaxOp>();
patterns.add<ConvertAtenArgmaxOp>(typeConverter, context);
target.addIllegalOp<AtenSizeIntOp>();
patterns.add<ConvertAtenSizeIntOp>(typeConverter, context);
target.addIllegalOp<AtenEmbeddingOp>();
patterns.add<ConvertAtenEmbeddingOp>(typeConverter, context);
target.addIllegalOp<AtenOnesOp>();
patterns.add<ConvertAtenOnesOp>(typeConverter, context);
target.addIllegalOp<AtenContiguousOp>();
patterns.add<ConvertAtenContiguousOp>(typeConverter, context);
target.addIllegalOp<AtenIntTensorOp>();
patterns.add<ConvertAtenIntTensorOp>(typeConverter, context);
target.addIllegalOp<PrimNumToTensorScalarOp>();
patterns.add<ConvertPrimNumToTensorScalarOp>(typeConverter, context);
if (failed(applyPartialConversion(getOperation(), target,
std::move(patterns))))
return signalPassFailure();
}
};
} // namespace
std::unique_ptr<OperationPass<FuncOp>>
mlir::torch::createConvertTorchToLinalgPass() {
return std::make_unique<ConvertTorchToLinalg>();
}
| 43.587356 | 88 | 0.65382 | [
"shape",
"model"
] |
8ade2d8d2fb984b453241ebc069d78e17589548b | 8,330 | cpp | C++ | client/client.cpp | Bert-Z/Raichu | a7b21c1d450da3acc36efd120453e882e3eff7a4 | [
"MIT"
] | 3 | 2020-07-09T17:38:59.000Z | 2020-09-17T12:48:42.000Z | client/client.cpp | Bert-Z/Raichu | a7b21c1d450da3acc36efd120453e882e3eff7a4 | [
"MIT"
] | null | null | null | client/client.cpp | Bert-Z/Raichu | a7b21c1d450da3acc36efd120453e882e3eff7a4 | [
"MIT"
] | null | null | null | /*
*
* Copyright 2015 gRPC 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 <iostream>
#include <memory>
#include <string>
#include <sstream>
#include <vector>
#include <grpcpp/grpcpp.h>
#include "../rpc-proto/rpc.grpc.pb.h"
#include "../lock/lock.h"
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
// KV client rpc
using rpc::KV;
using rpc::KVRequest;
using rpc::KVResponse;
class Client
{
public:
Client(const std::string &master_node,
std::shared_ptr<Channel> master_channel,
std::shared_ptr<Channel> node2_channel,
std::shared_ptr<Channel> node3_channel)
: master_stub_(KV::NewStub(master_channel)),
node2_stub_(KV::NewStub(node2_channel)),
node3_stub_(KV::NewStub(node3_channel))
{
lock.reset(new raichu::lock::ReadWriteLock(master_node, "/lock"));
}
std::string Where(const std::string &key, const std::string &value = "")
{
KVRequest request;
request.set_key(key);
request.set_value(value);
KVResponse response;
ClientContext context;
Status status = master_stub_->Where(&context, request, &response);
std::string msg = response.message();
if (status.ok())
{
std::cout << msg << std::endl;
return msg;
}
else
{
if (msg.size() != 0)
{
std::cout << msg << std::endl;
return "not exist";
}
std::cout << status.error_code() << ": " << status.error_message()
<< std::endl;
return "RPC failed";
}
}
std::string Read(const std::string &key)
{
lock->lockRead();
std::string msg = Where(key);
if (msg == "RPC failed" || msg == "not exist")
{
return "Read failed";
}
KVRequest request;
request.set_key(key);
KVResponse response;
ClientContext context;
Status status;
if (msg == "localhost:50052")
status = node2_stub_->Read(&context, request, &response);
else if (msg == "localhost:50053")
status = node3_stub_->Read(&context, request, &response);
else
return "Wrong Read msg";
lock->unLockRead();
if (status.ok())
return response.message();
else
{
std::cout << status.error_code() << ": " << status.error_message()
<< std::endl;
return "RPC failed";
}
}
std::string Put(const std::string &key, const std::string &value)
{
lock->lockWrite();
std::string msg = Where(key, value);
if (msg == "RPC failed" || msg == "not exist")
{
return "Read failed";
}
KVRequest request;
request.set_key(key);
request.set_value(value);
KVResponse response;
ClientContext context;
Status status;
if (msg == "localhost:50052")
status = node2_stub_->Put(&context, request, &response);
else if (msg == "localhost:50053")
status = node3_stub_->Put(&context, request, &response);
else
return "Wrong Put msg";
lock->unLockWrite();
if (status.ok())
return response.message();
else
{
std::cout << status.error_code() << ": " << status.error_message()
<< std::endl;
return "RPC failed";
}
}
std::string Delete(const std::string &key)
{
lock->lockWrite();
std::string msg = Where(key);
if (msg == "RPC failed" || msg == "not exist")
{
return "Read failed";
}
KVRequest request;
request.set_key(key);
KVResponse response;
ClientContext context;
Status status;
if (msg == "localhost:50052")
status = node2_stub_->Delete(&context, request, &response);
else if (msg == "localhost:50053")
status = node3_stub_->Delete(&context, request, &response);
else
return "Wrong Delete msg";
lock->unLockWrite();
if (status.ok())
return response.message();
else
{
std::cout << status.error_code() << ": " << status.error_message()
<< std::endl;
return "RPC failed";
}
}
private:
std::unique_ptr<KV::Stub> master_stub_;
std::unique_ptr<KV::Stub> node2_stub_;
std::unique_ptr<KV::Stub> node3_stub_;
std::unique_ptr<raichu::lock::ReadWriteLock> lock;
};
void clientRun(const std::string &master_node, const std::string &node2, const std::string &node3)
{
// kv client
Client client("localhost:2182", grpc::CreateChannel(master_node, grpc::InsecureChannelCredentials()),
grpc::CreateChannel(
node2, grpc::InsecureChannelCredentials()),
grpc::CreateChannel(
node3, grpc::InsecureChannelCredentials()));
// client user guild
std::cout << "This is a kv storage system." << std::endl
<< "Operations: " << std::endl
<< " Help option: Help" << std::endl
<< " Quit option: Quit" << std::endl
<< " Read option: Read <Key>" << std::endl
<< " Put option: Put <Key> <Value>" << std::endl
<< " Delete option: Delete <Key>" << std::endl;
// input
std::string line;
std::vector<std::string> vec;
std::cout << ">";
while (std::getline(std::cin, line))
{
std::istringstream input(line);
vec.clear();
std::string str;
int count = 0;
while (std::getline(input, str, ' '))
{
count++;
if (count > 3)
{
std::cout << "Wrong input!" << std::endl;
break;
}
vec.push_back(str);
}
if (vec.size() == 1)
{
if (vec[0] == "Help")
{
std::cout << "This is a kv storage system." << std::endl
<< "Operations: " << std::endl
<< " Help option: Help" << std::endl
<< " Quit option: Quit" << std::endl
<< " Read option: Read <Key>" << std::endl
<< " Put option: Put <Key>:<Value>" << std::endl
<< " Delete option: Delete <Key>" << std::endl;
}
else if (vec[0] == "Quit")
{
std::cout << "Thanks for using!" << std::endl;
break;
}
else
std::cout << "Wrong input!" << std::endl;
}
else if (vec.size() == 2)
{
if (vec[0] == "Read")
std::cout << "Client received: " << client.Read(vec[1]) << std::endl;
else if (vec[0] == "Delete")
std::cout << "Client received: " << client.Delete(vec[1]) << std::endl;
else
std::cout << "Wrong input!" << std::endl;
}
else if (vec.size() == 3)
{
if (vec[0] == "Put")
std::cout << "Client received: " << client.Put(vec[1], vec[2]) << std::endl;
else
std::cout << "Wrong input!" << std::endl;
}
std::cout << ">";
}
}
int main(int argc, char **argv)
{
// Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint specified by
// the argument "--target=" which is the only expected argument.
// We indicate that the channel isn't authenticated (use of
// InsecureChannelCredentials()).
std::string target_str;
std::string arg_str("--target");
if (argc > 1)
{
std::string arg_val = argv[1];
size_t start_pos = arg_val.find(arg_str);
if (start_pos != std::string::npos)
{
start_pos += arg_str.size();
if (arg_val[start_pos] == '=')
{
target_str = arg_val.substr(start_pos + 1);
}
else
{
std::cout << "The only correct argument syntax is --target=" << std::endl;
return 0;
}
}
else
{
std::cout << "The only acceptable argument is --target=" << std::endl;
return 0;
}
}
else
{
target_str = "localhost:50051";
}
std::string node2 = "localhost:50052", node3 = "localhost:50053";
clientRun(target_str, node2, node3);
return 0;
}
| 26.112853 | 103 | 0.571549 | [
"vector"
] |
8adf1d67d1280f602a53b970f1ea29646d665f95 | 538 | cpp | C++ | atcoder/abc/abc147/b.cpp | zaurus-yusya/atcoder | 5fc345b3da50222fa1366d1ce52ae58799488cef | [
"MIT"
] | 3 | 2020-05-27T16:27:12.000Z | 2021-01-27T12:47:12.000Z | atcoder/abc/abc147/b.cpp | zaurus-yusya/Competitive-Programming | c72e13a11f76f463510bd4a476b86631d9d1b13a | [
"MIT"
] | null | null | null | atcoder/abc/abc147/b.cpp | zaurus-yusya/Competitive-Programming | c72e13a11f76f463510bd4a476b86631d9d1b13a | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;
// 0 false, 1 true
// stringの数字をint型にしてアスキーコードになったら -48する
int main() {
string s;
cin >> s;
int ans = 0;
rep(i,s.size() / 2){
if(s.at(i) != s.at(s.size()-i-1)){
ans++;
}
}
cout << ans << endl;
}
| 17.354839 | 42 | 0.550186 | [
"vector"
] |
8ae0b3104d456c133f5f72d8e3013f23980b2fd4 | 1,498 | cpp | C++ | source/backend/hiai/execution/NPUConvertTensor.cpp | WillTao-RD/MNN | 48575121859093bab8468d6992596962063b7aff | [
"Apache-2.0"
] | 2 | 2020-12-15T13:56:31.000Z | 2022-01-26T03:20:28.000Z | source/backend/hiai/execution/NPUConvertTensor.cpp | qaz734913414/MNN | a5d5769789054a76c6e4dce2ef97d1f45b0e7e2d | [
"Apache-2.0"
] | null | null | null | source/backend/hiai/execution/NPUConvertTensor.cpp | qaz734913414/MNN | a5d5769789054a76c6e4dce2ef97d1f45b0e7e2d | [
"Apache-2.0"
] | 1 | 2021-11-24T06:26:27.000Z | 2021-11-24T06:26:27.000Z | //
// NPUConvertTensor.cpp
// MNN
//
// Created by MNN on b'2020/10/15'.
// Copyright © 2018, Alibaba Group Holding Limited
//
#include "NPUConvertTensor.hpp"
#include "NPUBackend.hpp"
using namespace std;
namespace MNN {
NPUConvertTensor::NPUConvertTensor(MNN::Backend *b, const MNN::Op *op, const std::vector<Tensor *> &inputs, const std::vector<MNN::Tensor *> &outputs) : NPUCommonExecution(b, op) {
}
ErrorCode NPUConvertTensor::onResize(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) {
mNpuBackend->setNetworkInput(inputs, mOp);
auto opName = mOp->name()->str();
shared_ptr<ge::op::Reshape> convertTensor(new ge::op::Reshape(opName));
vector<int64_t> shapeDims = {outputs[0]->batch(), outputs[0]->channel(), outputs[0]->height(), outputs[0]->width()};
auto xOp = mNpuBackend->getInputOps(mOp);
int index = mOp->inputIndexes()->data()[0];
auto iter = mNpuBackend->mSclipMap.find(index);
if(iter != mNpuBackend->mSclipMap.end()){
(*convertTensor).SetInput(0, *xOp, mNpuBackend->mSclipMap[index]);
(*convertTensor).set_attr_shape(
ge::AttrValue::LIST_INT(shapeDims));
}else{
(*convertTensor).set_input_tensor(*xOp).set_attr_shape(
ge::AttrValue::LIST_INT(shapeDims));
}
mNpuBackend->setOutputOps(mOp, {convertTensor});
return NO_ERROR;
}
NPUCreatorRegister<TypedCreator<NPUConvertTensor>> __convert_tensor_op(OpType_ConvertTensor);
} // namespace MNN | 31.87234 | 180 | 0.682243 | [
"vector"
] |
8ae15849872cc7f1c9a40dd9616054a21ae52913 | 3,178 | cc | C++ | HLTrigger/JetMET/src/HLTRapGapFilter.cc | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 852 | 2015-01-11T21:03:51.000Z | 2022-03-25T21:14:00.000Z | HLTrigger/JetMET/src/HLTRapGapFilter.cc | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 30,371 | 2015-01-02T00:14:40.000Z | 2022-03-31T23:26:05.000Z | HLTrigger/JetMET/src/HLTRapGapFilter.cc | ckamtsikis/cmssw | ea19fe642bb7537cbf58451dcf73aa5fd1b66250 | [
"Apache-2.0"
] | 3,240 | 2015-01-02T05:53:18.000Z | 2022-03-31T17:24:21.000Z | /** \class HLTRapGapFilter
*
*
* \author Monica Vazquez Acosta (CERN)
*
*/
#include "HLTrigger/JetMET/interface/HLTRapGapFilter.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
//
// constructors and destructor
//
HLTRapGapFilter::HLTRapGapFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig) {
inputTag_ = iConfig.getParameter<edm::InputTag>("inputTag");
absEtaMin_ = iConfig.getParameter<double>("minEta");
absEtaMax_ = iConfig.getParameter<double>("maxEta");
caloThresh_ = iConfig.getParameter<double>("caloThresh");
m_theJetToken = consumes<reco::CaloJetCollection>(inputTag_);
}
HLTRapGapFilter::~HLTRapGapFilter() = default;
void HLTRapGapFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<edm::InputTag>("inputJetTag", edm::InputTag("iterativeCone5CaloJets"));
desc.add<double>("minEta", 3.0);
desc.add<double>("maxEta", 5.0);
desc.add<double>("caloThresh", 20.);
descriptions.add("hltRapGapFilter", desc);
}
// ------------ method called to produce the data ------------
bool HLTRapGapFilter::hltFilter(edm::Event& iEvent,
const edm::EventSetup& iSetup,
trigger::TriggerFilterObjectWithRefs& filterproduct) const {
using namespace reco;
using namespace trigger;
// The filter object
if (saveTags())
filterproduct.addCollectionTag(inputTag_);
edm::Handle<CaloJetCollection> recocalojets;
iEvent.getByToken(m_theJetToken, recocalojets);
// look at all candidates, check cuts and add to filter object
int n(0);
//std::cout << "Found " << recocalojets->size() << " jets in this event" << std::endl;
if (recocalojets->size() > 1) {
// events with two or more jets
double etjet = 0.;
double etajet = 0.;
double sumets = 0.;
int countjets = 0;
for (auto const& recocalojet : *recocalojets) {
etjet = recocalojet.energy();
etajet = recocalojet.eta();
if (std::abs(etajet) > absEtaMin_ && std::abs(etajet) < absEtaMax_) {
sumets += etjet;
//std::cout << "Adding jet with eta = " << etajet << ", and e = "
// << etjet << std::endl;
}
countjets++;
}
//std::cout << "Sum jet energy = " << sumets << std::endl;
if (sumets <= caloThresh_) {
//std::cout << "Passed filter!" << std::endl;
for (auto recocalojet = recocalojets->begin(); recocalojet != (recocalojets->end()); recocalojet++) {
CaloJetRef ref(CaloJetRef(recocalojets, distance(recocalojets->begin(), recocalojet)));
filterproduct.addObject(TriggerJet, ref);
n++;
}
}
} // events with two or more jets
// filter decision
bool accept(n > 0);
return accept;
}
| 31.465347 | 107 | 0.670862 | [
"object"
] |
8ae5eb7285dd63dd03478b0dc7f38c4b64059ee8 | 2,523 | cc | C++ | test/bug954/bug954.cc | stkaplan/legion | ad82a1c1f39ed20a16df29aa331428d42c0ecfb6 | [
"Apache-2.0"
] | null | null | null | test/bug954/bug954.cc | stkaplan/legion | ad82a1c1f39ed20a16df29aa331428d42c0ecfb6 | [
"Apache-2.0"
] | null | null | null | test/bug954/bug954.cc | stkaplan/legion | ad82a1c1f39ed20a16df29aa331428d42c0ecfb6 | [
"Apache-2.0"
] | null | null | null | /* Copyright 2020 Stanford University
*
* 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 "legion.h"
using namespace Legion;
enum TaskIDs {
TID_TOP_LEVEL,
TID_TEST,
};
enum FieldIDs {
FID_DATA = 11,
};
enum LayoutConstraintIDs {
LCID_ON_REGMEM = 22,
};
void task_test(const Task *task,
const std::vector<PhysicalRegion> ®ions,
Context ctx, Runtime *runtime)
{
}
void task_top_level(const Task *task,
const std::vector<PhysicalRegion> ®ions,
Context ctx, Runtime *runtime)
{
Rect<1> bounds(0, 99);
IndexSpace is = runtime->create_index_space(ctx, bounds);
FieldSpace fs = runtime->create_field_space(ctx);
FieldAllocator fsa = runtime->create_field_allocator(ctx, fs);
fsa.allocate_field(sizeof(int), FID_DATA);
LogicalRegion lr = runtime->create_logical_region(ctx, is, fs);
runtime->fill_field(ctx, lr, lr, FID_DATA, 0);
{ TaskLauncher launcher(TID_TEST, TaskArgument());
launcher.add_region_requirement(
RegionRequirement(lr, LEGION_READ_ONLY, LEGION_EXCLUSIVE, lr)
.add_field(FID_DATA));
runtime->execute_task(ctx, launcher);
}
runtime->destroy_logical_region(ctx, lr);
}
int main(int argc, char **argv)
{
{ LayoutConstraintRegistrar registrar(FieldSpace::NO_SPACE);
registrar.add_constraint(MemoryConstraint(Memory::REGDMA_MEM));
Runtime::preregister_layout(registrar, LCID_ON_REGMEM);
}
{ TaskVariantRegistrar registrar(TID_TOP_LEVEL, "top_level");
registrar.add_constraint(ProcessorConstraint(Processor::LOC_PROC));
Runtime::preregister_task_variant<task_top_level>(registrar, "top_level");
Runtime::set_top_level_task_id(TID_TOP_LEVEL);
}
{ TaskVariantRegistrar registrar(TID_TEST, "test");
registrar.add_constraint(ProcessorConstraint(Processor::LOC_PROC));
registrar.add_layout_constraint_set(0, LCID_ON_REGMEM);
Runtime::preregister_task_variant<task_test>(registrar, "test");
}
return Runtime::start(argc, argv);
}
| 32.766234 | 78 | 0.729291 | [
"vector"
] |
8aedb7e75912bfff29feabd2ce9a37cffcffa555 | 2,378 | cpp | C++ | PcmMediaDemo/PcmShowLabelUI.cpp | karllen/-cef3-duilib | 27d7db32c1695fba8fde697f98bd044ec865967d | [
"BSD-2-Clause",
"MIT"
] | 258 | 2017-06-10T00:18:26.000Z | 2022-03-25T05:10:02.000Z | PcmMediaDemo/PcmShowLabelUI.cpp | LynnCpp/cef3-duilib-YDDemo | 27d7db32c1695fba8fde697f98bd044ec865967d | [
"BSD-2-Clause",
"MIT"
] | 3 | 2017-07-11T03:49:46.000Z | 2020-07-08T14:59:59.000Z | PcmMediaDemo/PcmShowLabelUI.cpp | LynnCpp/cef3-duilib-YDDemo | 27d7db32c1695fba8fde697f98bd044ec865967d | [
"BSD-2-Clause",
"MIT"
] | 133 | 2017-06-10T00:17:55.000Z | 2022-01-09T09:58:56.000Z | #include "StdAfx.h"
#include "PcmShowLabelUI.h"
#include<vector>
CPcmShowLableUI::CPcmShowLableUI()
{
}
CPcmShowLableUI::~CPcmShowLableUI()
{
}
LPCTSTR CPcmShowLableUI::GetClass() const
{
return PcmShowLableUIClassName;
}
LPVOID CPcmShowLableUI::GetInterface(LPCTSTR pstrName)
{
if (_tcscmp(pstrName, PcmShowLableUIInterface) == 0){
return static_cast<CPcmShowLableUI*>(this);
}
return CLabelUI::GetInterface(pstrName);
}
void CPcmShowLableUI::DoEvent(DuiLib::TEventUI& event)
{
CLabelUI::DoEvent(event);
}
void CPcmShowLableUI::PaintStatusImage(HDC hDC)
{
CLabelUI::PaintStatusImage(hDC);
std::vector<char> pcm_buffer;
FILE * file = NULL;
file = fopen("pcm\\20180601155322.pcm", "rb");
if (file != NULL) {
//
pcm_buffer.clear();
pcm_buffer.shrink_to_fit();
fseek(file, 0, SEEK_END);
unsigned int size_byte = ftell(file);
fseek(file, 0, SEEK_SET);
pcm_buffer.resize(size_byte);
fread(&pcm_buffer[0], size_byte, 1, file);
fclose(file);
size_byte /= 2;
int step = 1, len = size_byte;
if (size_byte > 20000) {
len = 20000;
step = (int)(size_byte / len);
}
short * pcm_16 = (short*)(&pcm_buffer[0]);
std::vector<float> pcm_float;
pcm_float.resize(20000);
for (int i = 0, n = 0; n < len; i += step, n++) {
pcm_float[n] = pcm_16[i];
}
float max = pcm_float[0], min = pcm_float[0];
for (int i = 1; i< pcm_float.size(); i++){
if (max < pcm_float[i]){
max = pcm_float[i];
}
if (min > pcm_float[i]){
min = pcm_float[i];
}
}
int w = m_rcItem.right - m_rcItem.left;
int h = m_rcItem.bottom - m_rcItem.top;
std::vector<PointF> points;
float diffVal = max - min;
for (int i = 0; i < pcm_float.size(); i++){
points.push_back(PointF(i * w / pcm_float.size(), h - (pcm_float[i] - min) / diffVal * h));
}
const DWORD backColor = 0xFFC9C9C9;
CRenderEngine::DrawColor(hDC, m_rcItem, backColor);
const DWORD backLineColor = 0xFF0000FF;
for (int i = 0; i < points.size() - 1; i++){
RECT rect;
rect.left = points[i].X;
rect.top = points[i].Y + m_rcItem.top;
rect.right = points[i + 1].X;
rect.bottom = points[i + 1].Y + m_rcItem.top;
CRenderEngine::DrawLine(hDC, rect, 1, backLineColor);
}
}
}
void CPcmShowLableUI::DoPaint(HDC hDC, const RECT& rcPaint)
{
int i = 0;
} | 23.313725 | 95 | 0.62868 | [
"vector"
] |
8af669c068ffe7da361bbd2bc72c0998feea3afb | 16,106 | cpp | C++ | gen/blink/bindings/core/v8/V8PerformanceResourceTiming.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | 8 | 2019-05-05T16:38:05.000Z | 2021-11-09T11:45:38.000Z | gen/blink/bindings/core/v8/V8PerformanceResourceTiming.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | null | null | null | gen/blink/bindings/core/v8/V8PerformanceResourceTiming.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | 4 | 2018-12-14T07:52:46.000Z | 2021-06-11T18:06:09.000Z | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
#include "config.h"
#include "V8PerformanceResourceTiming.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "core/dom/ContextFeatures.h"
#include "core/dom/Document.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/TraceEvent.h"
#include "wtf/GetPtr.h"
#include "wtf/RefPtr.h"
namespace blink {
// Suppress warning: global constructors, because struct WrapperTypeInfo is trivial
// and does not depend on another global objects.
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
#endif
const WrapperTypeInfo V8PerformanceResourceTiming::wrapperTypeInfo = { gin::kEmbedderBlink, V8PerformanceResourceTiming::domTemplate, V8PerformanceResourceTiming::refObject, V8PerformanceResourceTiming::derefObject, V8PerformanceResourceTiming::trace, 0, 0, V8PerformanceResourceTiming::preparePrototypeObject, V8PerformanceResourceTiming::installConditionallyEnabledProperties, "PerformanceResourceTiming", &V8PerformanceEntry::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::NotInheritFromEventTarget, WrapperTypeInfo::Independent, WrapperTypeInfo::GarbageCollectedObject };
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in PerformanceResourceTiming.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
// bindings/core/v8/ScriptWrappable.h.
const WrapperTypeInfo& PerformanceResourceTiming::s_wrapperTypeInfo = V8PerformanceResourceTiming::wrapperTypeInfo;
namespace PerformanceResourceTimingV8Internal {
static void initiatorTypeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValueString(info, impl->initiatorType(), info.GetIsolate());
}
static void initiatorTypeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::initiatorTypeAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void workerStartAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->workerStart());
}
static void workerStartAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::workerStartAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void redirectStartAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->redirectStart());
}
static void redirectStartAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::redirectStartAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void redirectEndAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->redirectEnd());
}
static void redirectEndAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::redirectEndAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void fetchStartAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->fetchStart());
}
static void fetchStartAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::fetchStartAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void domainLookupStartAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->domainLookupStart());
}
static void domainLookupStartAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::domainLookupStartAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void domainLookupEndAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->domainLookupEnd());
}
static void domainLookupEndAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::domainLookupEndAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void connectStartAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->connectStart());
}
static void connectStartAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::connectStartAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void connectEndAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->connectEnd());
}
static void connectEndAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::connectEndAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void secureConnectionStartAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->secureConnectionStart());
}
static void secureConnectionStartAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::secureConnectionStartAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void requestStartAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->requestStart());
}
static void requestStartAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::requestStartAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void responseStartAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->responseStart());
}
static void responseStartAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::responseStartAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void responseEndAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
PerformanceResourceTiming* impl = V8PerformanceResourceTiming::toImpl(holder);
v8SetReturnValue(info, impl->responseEnd());
}
static void responseEndAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
PerformanceResourceTimingV8Internal::responseEndAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
} // namespace PerformanceResourceTimingV8Internal
static const V8DOMConfiguration::AccessorConfiguration V8PerformanceResourceTimingAccessors[] = {
{"initiatorType", PerformanceResourceTimingV8Internal::initiatorTypeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"redirectStart", PerformanceResourceTimingV8Internal::redirectStartAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"redirectEnd", PerformanceResourceTimingV8Internal::redirectEndAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"fetchStart", PerformanceResourceTimingV8Internal::fetchStartAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"domainLookupStart", PerformanceResourceTimingV8Internal::domainLookupStartAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"domainLookupEnd", PerformanceResourceTimingV8Internal::domainLookupEndAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"connectStart", PerformanceResourceTimingV8Internal::connectStartAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"connectEnd", PerformanceResourceTimingV8Internal::connectEndAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"secureConnectionStart", PerformanceResourceTimingV8Internal::secureConnectionStartAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"requestStart", PerformanceResourceTimingV8Internal::requestStartAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"responseStart", PerformanceResourceTimingV8Internal::responseStartAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"responseEnd", PerformanceResourceTimingV8Internal::responseEndAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
};
static void installV8PerformanceResourceTimingTemplate(v8::Local<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
{
functionTemplate->ReadOnlyPrototype();
v8::Local<v8::Signature> defaultSignature;
defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "PerformanceResourceTiming", V8PerformanceEntry::domTemplate(isolate), V8PerformanceResourceTiming::internalFieldCount,
0, 0,
V8PerformanceResourceTimingAccessors, WTF_ARRAY_LENGTH(V8PerformanceResourceTimingAccessors),
0, 0);
v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
ALLOW_UNUSED_LOCAL(instanceTemplate);
v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
ALLOW_UNUSED_LOCAL(prototypeTemplate);
if (RuntimeEnabledFeatures::serviceWorkerPerformanceTimelineEnabled()) {
static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration =\
{"workerStart", PerformanceResourceTimingV8Internal::workerStartAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder};
V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototypeTemplate, functionTemplate, defaultSignature, accessorConfiguration);
}
// Custom toString template
functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
}
v8::Local<v8::FunctionTemplate> V8PerformanceResourceTiming::domTemplate(v8::Isolate* isolate)
{
return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8PerformanceResourceTimingTemplate);
}
bool V8PerformanceResourceTiming::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
}
v8::Local<v8::Object> V8PerformanceResourceTiming::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
}
PerformanceResourceTiming* V8PerformanceResourceTiming::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value)
{
return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : 0;
}
void V8PerformanceResourceTiming::refObject(ScriptWrappable* scriptWrappable)
{
}
void V8PerformanceResourceTiming::derefObject(ScriptWrappable* scriptWrappable)
{
}
} // namespace blink
| 55.347079 | 639 | 0.801689 | [
"object"
] |
8af759819e6fbd2178c27c28309851d42f92ad3c | 931 | cpp | C++ | 209-Minimum-Size-Subarray-Sum/Minimum-Size-Subarray-Sum.cpp | xta0/LeetCode-Solutions | ab0de97b35fb54c24bcef0398a9d75bdac9ee8b2 | [
"MIT"
] | 4 | 2018-08-07T11:45:32.000Z | 2019-05-19T08:52:19.000Z | 209-Minimum-Size-Subarray-Sum/Minimum-Size-Subarray-Sum.cpp | xta0/LeetCode-Solutions | ab0de97b35fb54c24bcef0398a9d75bdac9ee8b2 | [
"MIT"
] | null | null | null | 209-Minimum-Size-Subarray-Sum/Minimum-Size-Subarray-Sum.cpp | xta0/LeetCode-Solutions | ab0de97b35fb54c24bcef0398a9d75bdac9ee8b2 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;
class Solution {
public:
int minSubArrayLen(int s, vector<int>& nums) {
vector<int> prefix;
int sum = 0;
for(int i=0;i<nums.size();i++){
sum+=nums[i];
prefix.push_back(sum);
}
int len = 0;
unordered_map<int,int> um;
for(int i=0; i<nums.size();i++){
int prefixSum = prefix[i];
if(prefixSum >= s){
len = min(len, i+1);
}
int target = prefixSum-s;
if(um.count(target)){
int index = um[target];
len = max(len, i-index);
}else{
if(!um.count(prefixSum)){
um[prefixSum] = i;
}
}
}
return len;
}
};
int main(){
return 0;
} | 21.159091 | 50 | 0.437164 | [
"vector"
] |
8afe79c2a12af5f6d5f46ee60926d69761225445 | 1,070 | cpp | C++ | Algorithm/Dark Horse/STL-02.cpp | HastingZang721/ProjectCode | 1461f5b0b9f8684425f09bedc9299c1ed9086197 | [
"MIT"
] | null | null | null | Algorithm/Dark Horse/STL-02.cpp | HastingZang721/ProjectCode | 1461f5b0b9f8684425f09bedc9299c1ed9086197 | [
"MIT"
] | null | null | null | Algorithm/Dark Horse/STL-02.cpp | HastingZang721/ProjectCode | 1461f5b0b9f8684425f09bedc9299c1ed9086197 | [
"MIT"
] | null | null | null | #include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<iterator>
#include<algorithm>
#include<exception>
using namespace std;
//String 容器
/*
*
*【】/at 两种不同的访问方法
*
*/
//vector 容器:可变数组
//单口容器
/*push_back();
* pop_back();
* insert()//在指定位置插入元素,但建议在尾部操作
* vector动态增长的基本原理
*
*
*
*/
void Prinyvector(vector<int>&v)
{
for(vector<int >::iterator it =v.begin();it!=v.end();it++)
{
cout<<*it<<endl;
}
cout<<endl;
}
////初始化
//void test1(){
// vector<int >v1;
// int arr[]={10,20,30};
// vector<int>v2(arr,arr+sizeof(arr)/sizeof(int));
// vector<int >v3(v2.begin(),v2.end());
// vector<int >v4(v3);
//
// Prinyvector(v2);
//
//
//
//
//
//}
void test2(){
//vector<int >v1;
int arr[]={10,11,12,131,15};
vector<int >v2(arr,arr+sizeof(arr)/sizeof(int));
vector<int>v3(v2);
//cout<<v3.size()<<endl;
v3.erase(v3.begin());
v3.erase(v3.begin()+1,v3.end());
Prinyvector(v3);
v3.clear();
cout<<v3.size()<<endl;
}
//
int main(){
test2();
return 0;
}
| 13.04878 | 62 | 0.553271 | [
"vector"
] |
8affd032a726ee509c92e7dd61903d98fc56972f | 297 | cpp | C++ | result/ListClusterServersResult.cpp | chaytanyasinha/gwadoc | 403a226aa7e8dc32fa2d00a016c679f9bdddb990 | [
"CC-BY-4.0"
] | null | null | null | result/ListClusterServersResult.cpp | chaytanyasinha/gwadoc | 403a226aa7e8dc32fa2d00a016c679f9bdddb990 | [
"CC-BY-4.0"
] | null | null | null | result/ListClusterServersResult.cpp | chaytanyasinha/gwadoc | 403a226aa7e8dc32fa2d00a016c679f9bdddb990 | [
"CC-BY-4.0"
] | null | null | null | #include "ListClusterServersResult.h"
#include "ClusterServer.h"
namespace Nacos
{
std::vector<ClusterServer*> ListClusterServersResult::getServers() const
{
return Servers;
}
void ListClusterServersResult::setServers(const std::vector<ClusterServer*> &value)
{
Servers = value;
}
}
| 17.470588 | 84 | 0.750842 | [
"vector"
] |
c106a75776e30fff6ccacc66fec0371906638964 | 4,277 | hpp | C++ | SbgatCore/include/SbgatCore/SBGATFrameGraph.hpp | bbercovici/SBGAT | 93e935baff49eb742470d7d593931f0573f0c062 | [
"MIT"
] | 6 | 2017-11-29T02:47:00.000Z | 2021-09-26T05:25:44.000Z | SbgatCore/include/SbgatCore/SBGATFrameGraph.hpp | bbercovici/SBGAT | 93e935baff49eb742470d7d593931f0573f0c062 | [
"MIT"
] | 34 | 2017-02-09T15:38:35.000Z | 2019-04-25T20:53:37.000Z | SbgatCore/include/SbgatCore/SBGATFrameGraph.hpp | bbercovici/SBGAT | 93e935baff49eb742470d7d593931f0573f0c062 | [
"MIT"
] | 1 | 2019-03-12T12:20:25.000Z | 2019-03-12T12:20:25.000Z | /**
@file SBGATFrameGraph.hpp
@author Benjamin Bercovici
@author Jay McMahon
@date October 2018
@brief Defines the SBGATFrameGraph class
@details Defines the SBGATFrameGraph class, allowing easy conversions in between reference frames
@copyright MIT License, Benjamin Bercovici and Jay McMahon
*/
#ifndef FRAMEGRAPH_HEADER
#define FRAMEGRAPH_HEADER
#include "SBGATRefFrame.hpp"
#include <memory>
#include "Adjacency_List.hpp"
class SBGATFrameGraph {
public:
/**
Constructor. Creates a undirected reference frame graph
*/
SBGATFrameGraph();
/**
Creates a frame and adds it to the graph
@param name of grame to be added. A warning is issued if that frame name was already used (no frame is added then)
*/
void add_frame(std::string frame_name);
/**
Converts the coordinates of the provided vector from frame
$from to frame $to. For this to work, $from and $to must be
in the SBGATFrameGraph and a path must be connecting them
@param input vector to convert
@param from name of reference frame to convert from
@param to name of reference frame to convert to
@param conserve_norm defines whether the provided coordinates are that of a vector whose norm should be conserved or not
True if the expected conversion is of the form x_B = [BN]x_N where
- x_N are the provided coordinates in the departure frame N,
- x_N are the expected coordinates in the departure frame B
- N the departure frame,
- B the arrival frame
- [BN] the direction cosine matrix orienting the two frames.
If False, then
a translational part T is added as in x_B = [BN]x_N + T, where
- x_B are the coordinates of point x expressed in the B frame
- x_N are the coordinates of point x expressed in the N frame
- [BN] being the direction cosine matrix orienting the two frames.
- T the coordinates of the displacement vector from the origin of frame B to that of frame N, expressed
in the B frame
@return converted coordinates
*/
arma::vec::fixed<3> convert(const arma::vec::fixed<3> & input,
std::string from,
std::string to,
bool conserve_norm = false) ;
/**
Sets the mrp of the transform to the one provided as argument
@param parent_name Name of parent frame
@param child_name Name of chuld frame
@param mrp MRP set
@param check True if consistency check should
*/
void set_transform_mrp(std::string parent_name,
std::string child_name,
arma::vec::fixed<3> & mrp);
/**
Sets the origin of the transform to the one provided as argument
@param parent_name Name of parent frame
@param child_name Name of chuld frame
@param origin Origin of child frame expressed in parent frame
@param check True if consistency check should
*/
void set_transform_origin(std::string parent_name,
std::string child_name,
arma::vec::fixed<3> & origin);
/**
Return a pointer to the reference frame whose name is passed as argument
WARNINGS:
- an exception will be thrown if the frame is not present in the graph
- this method should only be used to read from the reference frame
and not to modify if
@param frame_name Name of reference frame
@param Pointer to reference frame
*/
SBGATRefFrame * get_frame(std::string frame_name);
/**
Creates a reference frame transform between a
parent frame $parent_name and and child frame $child_name.
If either of the input names are not present in the graph,
a warning is issued and nothing happens.
If the provided transform or its opposite was already present,
a warning is issued and nothing happens
The transform is stored internaly in a pair formed with the following members:
- first: parent frame
- second: child frame
@param child_name Name of the children frame
@param parent_name Name of the parent frame
*/
void add_transform(std::string parent_name, std::string child_name) ;
protected:
Adjacency_List<std::shared_ptr <SBGATRefFrame> , std::pair< std::string, std::string > > adjacency_list;
std::map< std::string , std::shared_ptr <SBGATRefFrame> > ref_names_to_ref_ptrs;
void convert_to_parent_of_provided_child_frame(arma::vec::fixed<3> & coords, SBGATRefFrame * ref_frame,
bool conserve_norm) const;
void convert_to_child_of_provided_parent_frame(arma::vec::fixed<3> & coords, SBGATRefFrame * ref_frame,
bool conserve_norm) const;
};
#endif | 31.448529 | 121 | 0.759645 | [
"vector",
"transform"
] |
c10a4072e71855e24d2dd8c45fc97f6659a129f3 | 1,498 | hpp | C++ | caffe/include/caffe/layers/subsample_pooling_layer.hpp | shaoxiaohu/Face-Alignment-with-Two-Stage-Re-initialization- | ccd26fee4dd0b6cd0d11de4d5b4d2d746e8cc66b | [
"MIT"
] | 92 | 2017-07-19T05:12:05.000Z | 2021-11-09T07:59:07.000Z | caffe/include/caffe/layers/subsample_pooling_layer.hpp | mornydew/Face_Alignment_Two_Stage_Re-initialization | ccd26fee4dd0b6cd0d11de4d5b4d2d746e8cc66b | [
"MIT"
] | 11 | 2017-10-18T05:11:20.000Z | 2020-04-03T21:28:20.000Z | caffe/include/caffe/layers/subsample_pooling_layer.hpp | mornydew/Face_Alignment_Two_Stage_Re-initialization | ccd26fee4dd0b6cd0d11de4d5b4d2d746e8cc66b | [
"MIT"
] | 31 | 2017-07-20T11:37:39.000Z | 2021-03-08T09:01:26.000Z | #ifndef CAFFE_SUBSAMPLE_POOLING_LAYER_HPP_
#define CAFFE_SUBSAMPLE_POOLING_LAYER_HPP_
#include <vector>
#include "caffe/blob.hpp"
#include "caffe/layer.hpp"
#include "caffe/proto/caffe.pb.h"
namespace caffe {
/**
* @brief Pools the input image by taking the max, average, etc. within regions.
*
* TODO(dox): thorough documentation for Forward, Backward, and proto params.
*/
/* SubsamplePoolingLayer - Region of Interest Pooling Layer
*/
template <typename Dtype>
class SubsamplePoolingLayer : public Layer<Dtype> {
public:
explicit SubsamplePoolingLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual inline const char* type() const { return "ROIPooling"; }
virtual inline int MinBottomBlobs() const { return 1; }
virtual inline int MaxBottomBlobs() const { return 1; }
virtual inline int MinTopBlobs() const { return 1; }
virtual inline int MaxTopBlobs() const { return 1; }
protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
int channels_;
int input_H_;
int input_W_;
int output_H_;
int output_W_;
};
} // namespace caffe
#endif // CAFFE_SUBSAMPLE_POOLING_LAYER_HPP_
| 28.807692 | 80 | 0.744326 | [
"vector"
] |
c10a9df9c86d878f3533dad8101280d82a6a836a | 16,303 | cpp | C++ | openfpga/src/annotation/device_rr_gsb.cpp | antmicro/OpenFPGA | b78803a6bb4c07aaa5946fd7f579a49d8a3022f6 | [
"MIT"
] | 246 | 2020-12-03T08:49:29.000Z | 2022-03-28T21:19:55.000Z | openfpga/src/annotation/device_rr_gsb.cpp | a-canela/OpenFPGA | 063c58b6cbe2e01aa5520ec43ec80ff064d7f228 | [
"MIT"
] | 261 | 2020-12-03T00:23:54.000Z | 2022-03-31T10:00:37.000Z | openfpga/src/annotation/device_rr_gsb.cpp | a-canela/OpenFPGA | 063c58b6cbe2e01aa5520ec43ec80ff064d7f228 | [
"MIT"
] | 66 | 2020-12-12T09:05:53.000Z | 2022-03-28T07:51:41.000Z | /************************************************************************
* Member functions for class DeviceRRGSB
***********************************************************************/
#include "vtr_log.h"
#include "vtr_assert.h"
#include "device_rr_gsb.h"
/* namespace openfpga begins */
namespace openfpga {
/************************************************************************
* Constructors
***********************************************************************/
/************************************************************************
* Public accessors
***********************************************************************/
/* get the max coordinate of the switch block array */
vtr::Point<size_t> DeviceRRGSB::get_gsb_range() const {
size_t max_y = 0;
/* Get the largest size of sub-arrays */
for (size_t x = 0; x < rr_gsb_.size(); ++x) {
max_y = std::max(max_y, rr_gsb_[x].size());
}
vtr::Point<size_t> coordinate(rr_gsb_.size(), max_y);
return coordinate;
}
/* Get a rr switch block in the array with a coordinate */
const RRGSB& DeviceRRGSB::get_gsb(const vtr::Point<size_t>& coordinate) const {
VTR_ASSERT(validate_coordinate(coordinate));
return rr_gsb_[coordinate.x()][coordinate.y()];
}
/* Get a rr switch block in the array with a coordinate */
const RRGSB& DeviceRRGSB::get_gsb(const size_t& x, const size_t& y) const {
vtr::Point<size_t> coordinate(x, y);
return get_gsb(coordinate);
}
/* get the number of unique mirrors of switch blocks */
size_t DeviceRRGSB::get_num_cb_unique_module(const t_rr_type& cb_type) const {
VTR_ASSERT (validate_cb_type(cb_type));
switch(cb_type) {
case CHANX:
return cbx_unique_module_.size();
case CHANY:
return cby_unique_module_.size();
default:
VTR_LOG_ERROR("Invalid type of connection block!\n");
exit(1);
}
}
/* Identify if a GSB actually exists at a location */
bool DeviceRRGSB::is_gsb_exist(const vtr::Point<size_t> coord) const {
/* Out of range, does not exist */
if (false == validate_coordinate(coord)) {
return false;
}
/* If the GSB is empty, it does not exist */
if (true == get_gsb(coord).is_cb_exist(CHANX)) {
return true;
}
if (true == get_gsb(coord).is_cb_exist(CHANY)) {
return true;
}
if (true == get_gsb(coord).is_sb_exist()) {
return true;
}
return false;
}
/* get the number of unique mirrors of switch blocks */
size_t DeviceRRGSB::get_num_sb_unique_module() const {
return sb_unique_module_.size();
}
/* get the number of unique mirrors of switch blocks */
size_t DeviceRRGSB::get_num_gsb_unique_module() const {
return gsb_unique_module_.size();
}
/* Get a rr switch block which a unique mirror */
const RRGSB& DeviceRRGSB::get_sb_unique_module(const size_t& index) const {
VTR_ASSERT (validate_sb_unique_module_index(index));
return rr_gsb_[sb_unique_module_[index].x()][sb_unique_module_[index].y()];
}
/* Get a rr switch block which a unique mirror */
const RRGSB& DeviceRRGSB::get_cb_unique_module(const t_rr_type& cb_type, const size_t& index) const {
VTR_ASSERT (validate_cb_unique_module_index(cb_type, index));
VTR_ASSERT (validate_cb_type(cb_type));
switch(cb_type) {
case CHANX:
return rr_gsb_[cbx_unique_module_[index].x()][cbx_unique_module_[index].y()];
case CHANY:
return rr_gsb_[cby_unique_module_[index].x()][cby_unique_module_[index].y()];
default:
VTR_LOG_ERROR("Invalid type of connection block!\n");
exit(1);
}
}
/* Give a coordinate of a rr switch block, and return its unique mirror */
const RRGSB& DeviceRRGSB::get_cb_unique_module(const t_rr_type& cb_type, const vtr::Point<size_t>& coordinate) const {
VTR_ASSERT(validate_cb_type(cb_type));
VTR_ASSERT(validate_coordinate(coordinate));
size_t cb_unique_module_id;
switch(cb_type) {
case CHANX:
cb_unique_module_id = cbx_unique_module_id_[coordinate.x()][coordinate.y()];
break;
case CHANY:
cb_unique_module_id = cby_unique_module_id_[coordinate.x()][coordinate.y()];
break;
default:
VTR_LOG_ERROR("Invalid type of connection block!\n");
exit(1);
}
return get_cb_unique_module(cb_type, cb_unique_module_id);
}
/* Give a coordinate of a rr switch block, and return its unique mirror */
const RRGSB& DeviceRRGSB::get_sb_unique_module(const vtr::Point<size_t>& coordinate) const {
VTR_ASSERT(validate_coordinate(coordinate));
size_t sb_unique_module_id = sb_unique_module_id_[coordinate.x()][coordinate.y()];
return get_sb_unique_module(sb_unique_module_id);
}
/************************************************************************
* Public mutators
***********************************************************************/
/* Pre-allocate the rr_switch_block array that the device requires */
void DeviceRRGSB::reserve(const vtr::Point<size_t>& coordinate) {
rr_gsb_.resize(coordinate.x());
gsb_unique_module_id_.resize(coordinate.x());
sb_unique_module_id_.resize(coordinate.x());
cbx_unique_module_id_.resize(coordinate.x());
cby_unique_module_id_.resize(coordinate.x());
for (size_t x = 0; x < coordinate.x(); ++x) {
rr_gsb_[x].resize(coordinate.y());
gsb_unique_module_id_[x].resize(coordinate.y());
sb_unique_module_id_[x].resize(coordinate.y());
cbx_unique_module_id_[x].resize(coordinate.y());
cby_unique_module_id_[x].resize(coordinate.y());
}
}
/* Resize rr_switch_block array is needed*/
void DeviceRRGSB::resize_upon_need(const vtr::Point<size_t>& coordinate) {
if (coordinate.x() + 1 > rr_gsb_.size()) {
rr_gsb_.resize(coordinate.x() + 1);
sb_unique_module_id_.resize(coordinate.x() + 1);
cbx_unique_module_id_.resize(coordinate.x() + 1);
cby_unique_module_id_.resize(coordinate.x() + 1);
}
if (coordinate.y() + 1 > rr_gsb_[coordinate.x()].size()) {
rr_gsb_[coordinate.x()].resize(coordinate.y() + 1);
sb_unique_module_id_[coordinate.x()].resize(coordinate.y() + 1);
cbx_unique_module_id_[coordinate.x()].resize(coordinate.y() + 1);
cby_unique_module_id_[coordinate.x()].resize(coordinate.y() + 1);
}
}
/* Add a switch block to the array, which will automatically identify and update the lists of unique mirrors and rotatable mirrors */
void DeviceRRGSB::add_rr_gsb(const vtr::Point<size_t>& coordinate,
const RRGSB& rr_gsb) {
/* Resize upon needs*/
resize_upon_need(coordinate);
/* Add the switch block into array */
rr_gsb_[coordinate.x()][coordinate.y()] = rr_gsb;
}
/* Get a rr switch block in the array with a coordinate */
RRGSB& DeviceRRGSB::get_mutable_gsb(const vtr::Point<size_t>& coordinate) {
VTR_ASSERT(validate_coordinate(coordinate));
return rr_gsb_[coordinate.x()][coordinate.y()];
}
/* Get a rr switch block in the array with a coordinate */
RRGSB& DeviceRRGSB::get_mutable_gsb(const size_t& x, const size_t& y) {
vtr::Point<size_t> coordinate(x, y);
return get_mutable_gsb(coordinate);
}
/* Add a switch block to the array, which will automatically identify and update the lists of unique mirrors and rotatable mirrors */
void DeviceRRGSB::build_cb_unique_module(const RRGraph& rr_graph, const t_rr_type& cb_type) {
/* Make sure a clean start */
clear_cb_unique_module(cb_type);
for (size_t ix = 0; ix < rr_gsb_.size(); ++ix) {
for (size_t iy = 0; iy < rr_gsb_[ix].size(); ++iy) {
bool is_unique_module = true;
vtr::Point<size_t> gsb_coordinate(ix, iy);
/* Bypass non-exist CB */
if ( false == rr_gsb_[ix][iy].is_cb_exist(cb_type) ) {
continue;
}
/* Traverse the unique_mirror list and check it is an mirror of another */
for (size_t id = 0; id < get_num_cb_unique_module(cb_type); ++id) {
const RRGSB& unique_module = get_cb_unique_module(cb_type, id);
if (true == rr_gsb_[ix][iy].is_cb_mirror(rr_graph, unique_module, cb_type)) {
/* This is a mirror, raise the flag and we finish */
is_unique_module = false;
/* Record the id of unique mirror */
set_cb_unique_module_id(cb_type, gsb_coordinate, id);
break;
}
}
/* Add to list if this is a unique mirror*/
if (true == is_unique_module) {
add_cb_unique_module(cb_type, gsb_coordinate);
/* Record the id of unique mirror */
set_cb_unique_module_id(cb_type, gsb_coordinate, get_num_cb_unique_module(cb_type) - 1);
}
}
}
}
/* Add a switch block to the array, which will automatically identify and update the lists of unique mirrors and rotatable mirrors */
void DeviceRRGSB::build_sb_unique_module(const RRGraph& rr_graph) {
/* Make sure a clean start */
clear_sb_unique_module();
/* Build the unique module */
for (size_t ix = 0; ix < rr_gsb_.size(); ++ix) {
for (size_t iy = 0; iy < rr_gsb_[ix].size(); ++iy) {
bool is_unique_module = true;
vtr::Point<size_t> sb_coordinate(ix, iy);
/* Traverse the unique_mirror list and check it is an mirror of another */
for (size_t id = 0; id < get_num_sb_unique_module(); ++id) {
/* Check if the two modules have the same submodules,
* if so, these two modules are the same, indicating the sb is not unique.
* else the sb is unique
*/
const RRGSB& unique_module = get_sb_unique_module(id);
if (true == rr_gsb_[ix][iy].is_sb_mirror(rr_graph, unique_module)) {
/* This is a mirror, raise the flag and we finish */
is_unique_module = false;
/* Record the id of unique mirror */
sb_unique_module_id_[ix][iy] = id;
break;
}
}
/* Add to list if this is a unique mirror*/
if (true == is_unique_module) {
sb_unique_module_.push_back(sb_coordinate);
/* Record the id of unique mirror */
sb_unique_module_id_[ix][iy] = sb_unique_module_.size() - 1;
}
}
}
}
/* Add a switch block to the array, which will automatically identify and update the lists of unique mirrors and rotatable mirrors */
/* Find repeatable GSB block in the array */
void DeviceRRGSB::build_gsb_unique_module() {
/* Make sure a clean start */
clear_gsb_unique_module();
for (size_t ix = 0; ix < rr_gsb_.size(); ++ix) {
for (size_t iy = 0; iy < rr_gsb_[ix].size(); ++iy) {
bool is_unique_module = true;
vtr::Point<size_t> gsb_coordinate(ix, iy);
/* Traverse the unique_mirror list and check it is an mirror of another */
for (size_t id = 0; id < get_num_gsb_unique_module(); ++id) {
/* We have alreay built sb and cb unique module list
* We just need to check if the unique module id of SBs, CBX and CBY are the same or not
*/
const vtr::Point<size_t>& gsb_unique_module_coordinate = gsb_unique_module_[id];
if ((sb_unique_module_id_[ix][iy] == sb_unique_module_id_[gsb_unique_module_coordinate.x()][gsb_unique_module_coordinate.y()])
&& (cbx_unique_module_id_[ix][iy] == cbx_unique_module_id_[gsb_unique_module_coordinate.x()][gsb_unique_module_coordinate.y()])
&& (cby_unique_module_id_[ix][iy] == cby_unique_module_id_[gsb_unique_module_coordinate.x()][gsb_unique_module_coordinate.y()])) {
/* This is a mirror, raise the flag and we finish */
is_unique_module = false;
/* Record the id of unique mirror */
gsb_unique_module_id_[ix][iy] = id;
break;
}
}
/* Add to list if this is a unique mirror*/
if (true == is_unique_module) {
add_gsb_unique_module(gsb_coordinate);
/* Record the id of unique mirror */
gsb_unique_module_id_[ix][iy] = get_num_gsb_unique_module() - 1;
}
}
}
}
void DeviceRRGSB::build_unique_module(const RRGraph& rr_graph) {
build_sb_unique_module(rr_graph);
build_cb_unique_module(rr_graph, CHANX);
build_cb_unique_module(rr_graph, CHANY);
build_gsb_unique_module();
}
void DeviceRRGSB::add_gsb_unique_module(const vtr::Point<size_t>& coordinate) {
gsb_unique_module_.push_back(coordinate);
}
void DeviceRRGSB::add_cb_unique_module(const t_rr_type& cb_type, const vtr::Point<size_t>& coordinate) {
VTR_ASSERT (validate_cb_type(cb_type));
switch(cb_type) {
case CHANX:
cbx_unique_module_.push_back(coordinate);
return;
case CHANY:
cby_unique_module_.push_back(coordinate);
return;
default:
VTR_LOG_ERROR("Invalid type of connection block!\n");
exit(1);
}
}
void DeviceRRGSB::set_cb_unique_module_id(const t_rr_type& cb_type, const vtr::Point<size_t>& coordinate, size_t id) {
VTR_ASSERT(validate_cb_type(cb_type));
size_t x = coordinate.x();
size_t y = coordinate.y();
switch(cb_type) {
case CHANX:
cbx_unique_module_id_[x][y] = id;
return;
case CHANY:
cby_unique_module_id_[x][y] = id;
return;
default:
VTR_LOG_ERROR("Invalid type of connection block!\n");
exit(1);
}
}
/************************************************************************
* Public clean-up functions:
***********************************************************************/
/* clean the content */
void DeviceRRGSB::clear() {
clear_gsb();
clear_gsb_unique_module();
clear_gsb_unique_module_id();
/* clean unique module lists */
clear_cb_unique_module(CHANX);
clear_cb_unique_module_id(CHANX);
clear_cb_unique_module(CHANY);
clear_cb_unique_module_id(CHANY);
clear_sb_unique_module();
clear_sb_unique_module_id();
}
void DeviceRRGSB::clear_gsb() {
/* clean gsb array */
for (size_t x = 0; x < rr_gsb_.size(); ++x) {
rr_gsb_[x].clear();
}
rr_gsb_.clear();
}
void DeviceRRGSB::clear_gsb_unique_module_id() {
/* clean rr_switch_block array */
for (size_t x = 0; x < rr_gsb_.size(); ++x) {
gsb_unique_module_id_[x].clear();
}
}
void DeviceRRGSB::clear_sb_unique_module_id() {
/* clean rr_switch_block array */
for (size_t x = 0; x < rr_gsb_.size(); ++x) {
sb_unique_module_id_[x].clear();
}
}
void DeviceRRGSB::clear_cb_unique_module_id(const t_rr_type& cb_type) {
VTR_ASSERT (validate_cb_type(cb_type));
switch(cb_type) {
case CHANX:
for (size_t x = 0; x < rr_gsb_.size(); ++x) {
cbx_unique_module_id_[x].clear();
}
return;
case CHANY:
for (size_t x = 0; x < rr_gsb_.size(); ++x) {
cby_unique_module_id_[x].clear();
}
return;
default:
VTR_LOG_ERROR("Invalid type of connection block!\n");
exit(1);
}
}
/* clean the content related to unique_mirrors */
void DeviceRRGSB::clear_gsb_unique_module() {
/* clean unique mirror */
gsb_unique_module_.clear();
}
/* clean the content related to unique_mirrors */
void DeviceRRGSB::clear_sb_unique_module() {
/* clean unique mirror */
sb_unique_module_.clear();
}
void DeviceRRGSB::clear_cb_unique_module(const t_rr_type& cb_type) {
VTR_ASSERT (validate_cb_type(cb_type));
switch(cb_type) {
case CHANX:
cbx_unique_module_.clear();
return;
case CHANY:
cby_unique_module_.clear();
return;
default:
VTR_LOG_ERROR("Invalid type of connection block!\n");
exit(1);
}
}
/************************************************************************
* Internal validators
***********************************************************************/
/* Validate if the (x,y) is the range of this device */
bool DeviceRRGSB::validate_coordinate(const vtr::Point<size_t>& coordinate) const {
if (coordinate.x() >= rr_gsb_.capacity()) {
return false;
}
return (coordinate.y() < rr_gsb_[coordinate.x()].capacity());
}
/* Validate if the index in the range of unique_mirror vector*/
bool DeviceRRGSB::validate_sb_unique_module_index(const size_t& index) const {
return (index < sb_unique_module_.size());
}
bool DeviceRRGSB::validate_cb_unique_module_index(const t_rr_type& cb_type, const size_t& index) const {
VTR_ASSERT(validate_cb_type(cb_type));
switch(cb_type) {
case CHANX:
return (index < cbx_unique_module_.size());
case CHANY:
return (index < cby_unique_module_.size());
default:
VTR_LOG_ERROR("Invalid type of connection block!\n");
exit(1);
}
return false;
}
bool DeviceRRGSB::validate_cb_type(const t_rr_type& cb_type) const {
return ((CHANX == cb_type) || (CHANY == cb_type));
}
} /* End namespace openfpga*/
| 33.339468 | 139 | 0.64988 | [
"vector"
] |
c10bb2478a997a2ccae6ba9324219f0ca7d8e45e | 1,376 | cpp | C++ | src/unit_tests/string_test.cpp | mwbrown/circa | 425b4a3042addab813447813cc45888a012b2c2e | [
"MIT"
] | 27 | 2015-01-24T20:17:13.000Z | 2021-01-09T17:54:27.000Z | src/unit_tests/string_test.cpp | mwbrown/circa | 425b4a3042addab813447813cc45888a012b2c2e | [
"MIT"
] | 1 | 2015-09-18T15:58:12.000Z | 2015-09-18T20:37:00.000Z | src/unit_tests/string_test.cpp | mwbrown/circa | 425b4a3042addab813447813cc45888a012b2c2e | [
"MIT"
] | 5 | 2015-07-18T13:10:27.000Z | 2022-02-05T16:53:17.000Z | // Copyright (c) Andrew Fischer. See LICENSE file for license terms.
#include "unit_test_common.h"
#include "string_type.h"
namespace string_test {
void test_sneaky_equals()
{
Value val1, val2;
set_string(&val1, "Hello");
set_string(&val2, "Hello");
// initial: strings are stored differently.
test_assert(circa_string(&val1) != circa_string(&val2));
test_assert(circa_equals(&val1, &val2));
// after equality check: strings are stored with same object.
test_assert(circa_string(&val1) == circa_string(&val2));
}
void test_prepend()
{
Value hello, there;
set_string(&hello, "hello");
set_string(&there, "there");
test_equals(&hello, "hello");
test_equals(&there, "there");
string_prepend(&there, " ");
test_equals(&there, " there");
string_prepend(&there, &hello);
string_prepend(&there, "hello there");
test_equals(&hello, "hello");
}
void test_equality_with_symbol()
{
Value val;
set_symbol(&val, s_Append);
test_assert(string_equals(&val, ":Append"));
test_assert(!string_equals(&val, "Append"));
test_assert(!string_equals(&val, "Appen"));
}
void register_tests()
{
REGISTER_TEST_CASE(string_test::test_sneaky_equals);
REGISTER_TEST_CASE(string_test::test_prepend);
REGISTER_TEST_CASE(string_test::test_equality_with_symbol);
}
} // namespace string_test
| 24.140351 | 68 | 0.690407 | [
"object"
] |
c10ee55e47e1f8945928371c1c46ce6a5ddefda8 | 22,447 | cpp | C++ | Post/source/ShapeWorksPost-V1/SWPost/shapeworkspost.cpp | amylenz/ShapeWorks | 78c2ee067a23e31f5b83d0121e60addb1b0bf462 | [
"MIT"
] | null | null | null | Post/source/ShapeWorksPost-V1/SWPost/shapeworkspost.cpp | amylenz/ShapeWorks | 78c2ee067a23e31f5b83d0121e60addb1b0bf462 | [
"MIT"
] | null | null | null | Post/source/ShapeWorksPost-V1/SWPost/shapeworkspost.cpp | amylenz/ShapeWorks | 78c2ee067a23e31f5b83d0121e60addb1b0bf462 | [
"MIT"
] | null | null | null | #include <iostream>
#include <queue>
#include <fstream>
#include <string>
#ifndef IGL_VIEWER_WITH_NANOGUI
int main()
{
std::cerr<<
"Error: recompile with LIBIGL_VIEWER_WITH_NANOGUI defined."<<std::endl;
return EXIT_FAILURE;
}
#else
#include "tinyxml.h"
#include <nanogui/formhelper.h>
#include <nanogui/screen.h>
#include <nanogui/layout.h>
#include <nanogui/slider.h>
#include <nanogui/widget.h>
#include <nanogui/textbox.h>
#include <nanogui/button.h>
#include <nanogui/toolbutton.h>
#include <nanogui/popupbutton.h>
#include <nanogui/combobox.h>
#include <nanogui/colorwheel.h>
#include <nanogui/popupbutton.h>
#include <igl/remove_unreferenced.h>
#include <igl/slice.h>
#include <igl/readOBJ.h>
// #include <igl/readSTL.h>
#include <igl/viewer/Viewer.h>
#include <itkeigen/Eigen/Sparse>
#include "itkvtkFunctions.h"
#include "computeFunctions.h"
using namespace igl;
using namespace std;
using namespace Eigen;
Eigen::MatrixXd TV;
Eigen::MatrixXi TT;
Eigen::MatrixXi TF;
Eigen::MatrixXd W;//(17352, 1024);
vector<Eigen::MatrixXd> Wvec;
Eigen::MatrixXd V;
Eigen::MatrixXd Vref;
Eigen::MatrixXd Vtemp;
Eigen::MatrixXi Fref;
Eigen::MatrixXd Vcontrol_static;
Eigen::MatrixXi Fcontrol_static;
Eigen::MatrixXd Vpca_mode;
Eigen::MatrixXi Fpca_mode;
Eigen::MatrixXd Vshape;
Eigen::MatrixXi Fshape;
Eigen::MatrixXd Vmean_space;
Eigen::MatrixXi Fmean_space;
bool pre_computed = false;
bool points_flag = true;
Eigen::RowVector3d mesh_diffuse_color(0.88f,0.64f,0.41f);
float sig = 0;
float step_size = 0.1;
int pca_mode_number = 0;
bool disp_shape = false;
// int N_total = 89;
int data_val = 0;
/*////////////////////////////////////////////////////////////////////////////////////////
MAIN ROUTINE
*/////////////////////////////////////////////////////////////////////////////////////////
int main(int argc, char * argv[])
{
/*////////////////////////////////////////////////////////////////////////////////////////
TINYXML READ PARAMETERS AND FILES
*/////////////////////////////////////////////////////////////////////////////////////////
TiXmlDocument doc(argv[1]);
bool loadOkay = doc.LoadFile();
TiXmlHandle docHandle( &doc );
TiXmlElement *elem;
std::istringstream inputsBuffer;
std::string tmpString;
// vector of point paths
std::vector< std::string > pointPaths;
std::string repPointpath ("") ; // representative point path
std::string repDTpath (""); // representative DT path
std::string repMeshpath ("");
int numParticles;
int meshDecimationFlag = 0;
float meshDecimationPercentage = 1.00;
if(loadOkay){
elem = docHandle.FirstChild("point_files").Element();
if (!elem){
std::cerr << "ERROR : No Point Files Provided" << std::endl;
throw 1;
}
else{
inputsBuffer.str(elem->GetText());
while (inputsBuffer >> tmpString){
pointPaths.push_back(tmpString);
}
inputsBuffer.clear();
inputsBuffer.str("");
}
elem = docHandle.FirstChild("rep_point").Element();
if (!elem){
std::cerr << "ERROR : No representative point provided" << std::endl;
throw 1;
}
else{
inputsBuffer.str(elem->GetText());
inputsBuffer >> repPointpath;
inputsBuffer.clear();
inputsBuffer.str("");
}
elem = docHandle.FirstChild("rep_DT").Element();
if (!elem){
// std::cerr << "ERROR : No representative DT provided" << std::endl;
// throw 1;
}
else{
inputsBuffer.str(elem->GetText());
inputsBuffer >> repDTpath;
inputsBuffer.clear();
inputsBuffer.str("");
}
elem = docHandle.FirstChild("rep_mesh").Element();
if (!elem){
// std::cerr << "ERROR : No representative DT provided" << std::endl;
// throw 1;
}
else{
inputsBuffer.str(elem->GetText());
inputsBuffer >> repMeshpath;
inputsBuffer.clear();
inputsBuffer.str("");
}
elem = docHandle.FirstChild("num_points").Element();
if (!elem){
std::cerr << "ERROR : Provide Number of particles!" << std::endl;
throw 1;
}
else{
numParticles = atoi(elem->GetText());
}
elem = docHandle.FirstChild("mesh_decimation_on").Element();
if (!elem){
// std::cerr << "ERROR : Provide Number of particles!" << std::endl;
// throw 1;
}
else{
meshDecimationFlag = atoi(elem->GetText());
}
elem = docHandle.FirstChild("mesh_decimation_percent").Element();
if (!elem){
// std::cerr << "ERROR : Provide Number of particles!" << std::endl;
// throw 1;
}
else{
meshDecimationPercentage = atof(elem->GetText());
}
}
if(repMeshpath.length() == 0 && repDTpath.length() == 0){
std::cerr << "Specify Either a representative distance transform" << std::endl;
std::cerr << " or a PLY mesh" <<std::endl;
throw 1;
}
int whichDataType = 0;
if(repMeshpath.length() != 0){whichDataType = 1;}
else{ whichDataType = 0;}
/*////////////////////////////////////////////////////////////////////////////////////////
DATA PROCESSING
*/////////////////////////////////////////////////////////////////////////////////////////
// 1) Compute the template mesh and the template points
std::cout << "[1] Compute the template mesh ..." << std::endl;
// add mesh decimation routine
if(!whichDataType){
itkMeshfromDT(repDTpath);
if(meshDecimationFlag){
meshDecimation("TemplateMesh.obj", meshDecimationPercentage);
igl::readOBJ("TemplateMeshDecimated.obj",Vref,Fref);
}
else{igl::readOBJ("TemplateMesh.obj",Vref,Fref);}
}
else{
convertVTKtoOBJ(repMeshpath);
if(meshDecimationFlag){
meshDecimation("TemplateMesh.obj", meshDecimationPercentage);
igl::readOBJ("TemplateMeshDecimated.obj",Vref,Fref);
}
else{igl::readOBJ("TemplateMesh.obj",Vref,Fref);}
}
Vref *= Eigen::AngleAxisd(-90*3.14/180,
Eigen::Vector3d(-1,0,-0)).toRotationMatrix();
// read the control
Vcontrol_static = pointReadFormat(repPointpath, numParticles);
Vcontrol_static *= Eigen::AngleAxisd(-90*3.14/180,
Eigen::Vector3d(-1,0,-0)).toRotationMatrix();
// 2) Compute the transformations matrix
bool forward = true;
// // Tetrahedralize the interior
// // igl::copyleft::tetgen::tetrahedralize(Vref,Fref,"pYa500", TV,TT,TF);
TV = Vref;
TF = Fref;
TT = TF;
Vmean_space = findMean(pointPaths, numParticles);
Vmean_space *= Eigen::AngleAxisd(-90*3.14/180,
Eigen::Vector3d(-1,0,-0)).toRotationMatrix();
// // read the eigenvalues file and store it in a vector
// // generate a random color matrix
Eigen::MatrixXd C(Vcontrol_static.rows(), Vcontrol_static.cols());
for(int i = 0; i<Vcontrol_static.rows(); i++){
float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
float g = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
float b = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
C(i,0) = r;
C(i,1) = g;
C(i,2) = b;
}
// pre-computation of the W matrix
std::cout << "[2] W matrix one time computation" << std::endl;
Wvec = W_precomputation(Vcontrol_static, TV, TT, TF);
W = Wvec[0];
Vcontrol_static = Wvec[1];
std::cout << "[3] Compute PCA for the data" << std::endl;
eigenOut newEigenOut = findPCAModes(pointPaths, numParticles);
Eigen::MatrixXd pcaModes = newEigenOut.pcaModes;
Eigen::VectorXd eigenvalues = newEigenOut.eigenvalues;
pca_mode_number = eigenvalues.size() - 1;
// for debug write a print eigenvalues function
// printeigenvalues(eigenvalues);
// printpcamode(pcaModes, 29, numParticles);
/*////////////////////////////////////////////////////////////////////////////////////////
STARTING VIZ
*/////////////////////////////////////////////////////////////////////////////////////////
std::cout << "[4] Starting visualization! " <<std::endl;
Eigen::VectorXi b;
Vtemp = W * (Vmean_space.rowwise() + RowVector3d(1,0,0));
igl::viewer::Viewer viewer;
viewer.data.set_mesh(TV, TF);
viewer.data.set_vertices(Vtemp);
viewer.data.set_colors(mesh_diffuse_color);
viewer.core.invert_normals = false;
V = Vmean_space;
viewer.data.set_points(V,C);
// std::cout << "This is the first error " << std::endl;
viewer.callback_key_pressed =
[&](igl::viewer::Viewer & viewer,unsigned int key,int mods)->bool
{
switch(key)
{
default:
return false;
}
};
viewer.core.is_animating = true;
// set viewer call back init with all the nanogui functionality
viewer.callback_init = [&](igl::viewer::Viewer& viewer)
{
nanogui::Window *window = new nanogui::Window(viewer.screen, "Control Panel");
window->setPosition(Vector2i(10, 10));
window->setLayout(new nanogui::GroupLayout());
/*////////////////////////////////////////////////////////////////////////////////////////
CHECKBOX FOR DISPLAYING POINTS
*/////////////////////////////////////////////////////////////////////////////////////////
nanogui::CheckBox *cb_displaypoints = new nanogui::CheckBox(window, "Display points",
[&](bool state) {
// assign the flag for displaying the points
points_flag = state;
if(!state){
// clear the points and reset the display
viewer.data.clear();
viewer.data.set_mesh(TV, TF);
viewer.data.set_vertices(Vtemp);
viewer.data.set_colors(mesh_diffuse_color);
// if(count_keyframes){viewer.data.set_vertices(Vtemp);}
}
else{
if(disp_shape){
viewer.data.set_points(Vshape, C);
}
else{
viewer.data.set_points(V, C);
}
}
});
cb_displaypoints->setChecked(true);
/*////////////////////////////////////////////////////////////////////////////////////////
CHECKBOXES FOR ANIMATION AND DISPLAY SHAPES FLAG
*/////////////////////////////////////////////////////////////////////////////////////////
// Add a checkbox for the animation control
nanogui::CheckBox *cb_animate = new nanogui::CheckBox(window, "Animate",
[&](bool state) { viewer.core.is_animating = state; }
);
cb_animate->setChecked(true);
// Checkbox for displaying the direct shapes
nanogui::CheckBox *cb_displayshapes = new nanogui::CheckBox(window, "Display shapes",
[&](bool state) {
if(viewer.core.is_animating){
cout << "Stop the Animation to activate individual shape display"<< endl;
}
disp_shape = state;
}
);
cb_displayshapes->setChecked(false);
/*////////////////////////////////////////////////////////////////////////////////////////
SIGMA VARIATION SLIDER
*/////////////////////////////////////////////////////////////////////////////////////////
// Setup a panel
nanogui::Widget *panel_sigmaslider = new nanogui::Widget(window);
panel_sigmaslider->setLayout(new nanogui::BoxLayout(nanogui::Orientation::Horizontal,
nanogui::Alignment::Middle, 0, 20));
// textbox and the slider
new nanogui::Label(panel_sigmaslider, "sigma :", "sans-bold");
nanogui::Slider *slider_sigma = new nanogui::Slider(panel_sigmaslider);
slider_sigma->setValue(0.5f);
slider_sigma->setFixedWidth(100);
nanogui::TextBox *textBox_sigma = new nanogui::TextBox(panel_sigmaslider);
textBox_sigma->setFixedSize(Vector2i(80, 25));
textBox_sigma->setValue("0");
slider_sigma->setCallback([&,textBox_sigma](float value) {
if(!viewer.core.is_animating){
double y = 10 * (4 * value - 2);
int rounded = (int)(y + 0.5);
sig = (float) rounded / 10.0;
Vpca_mode = Eigen::Map<Eigen::MatrixXd>(pcaModes.col(pca_mode_number).data(), numParticles, 3);
Vpca_mode *= Eigen::AngleAxisd(-90*3.14/180,
Eigen::Vector3d(-1,0,-0)).toRotationMatrix();
V = mode_variation(Vpca_mode, Vmean_space, eigenvalues(pca_mode_number), sig);
Vtemp = W * (V.rowwise() + RowVector3d(1,0,0));
// std::cout << "All get fixed " <<std::endl;
viewer.data.set_vertices(Vtemp);
// display the overlay control points if the flag is true
if(points_flag){
viewer.data.set_points(V, C);
}
viewer.data.compute_normals();
textBox_sigma->setValue(std::to_string((double) rounded / 10.0));
}
});
/*////////////////////////////////////////////////////////////////////////////////////////
ANIMATION FRAMES PER SECONDS TEXTBOX
*/////////////////////////////////////////////////////////////////////////////////////////
// For setting the animation fps
nanogui::Widget *panel2 = new nanogui::Widget(window);
panel2->setLayout(new nanogui::BoxLayout(nanogui::Orientation::Horizontal,
nanogui::Alignment::Middle, 0, 20));
// textbox for the FPS
{
new nanogui::Label(panel2, "Animation FPS :", "sans-bold");
auto intBox = new nanogui::IntBox<int>(panel2);
intBox->setEditable(true);
intBox->setFixedSize(Vector2i(60, 25));
intBox->setFontSize(16);
// intBox->setFormat("[1-30][0-30]*");
intBox->setValue(30);
intBox->setCallback([&,intBox](int value){
viewer.core.animation_max_fps = value;
intBox->setValue(value);
});
}
/*////////////////////////////////////////////////////////////////////////////////////////
CONTROL POINTS SIZE TEXTBOX
*/////////////////////////////////////////////////////////////////////////////////////////
// Setup a panel
nanogui::Widget *panel3 = new nanogui::Widget(window);
panel3->setLayout(new nanogui::BoxLayout(nanogui::Orientation::Horizontal,
nanogui::Alignment::Middle, 0, 20));
// textbox for the point size
{
new nanogui::Label(panel3, "Point Size :", "sans-bold");
auto intBox = new nanogui::IntBox<int>(panel3);
intBox->setEditable(true);
intBox->setFixedSize(Vector2i(60, 25));
intBox->setFontSize(16);
intBox->setValue(30);
// intBox->setFormat("[1-30][0-30]*");
intBox->setCallback([&,intBox](int value){
viewer.core.point_size = value;
intBox->setValue(value);
});
}
/*////////////////////////////////////////////////////////////////////////////////////////
MESH COLOR PICKER
*/////////////////////////////////////////////////////////////////////////////////////////
// Setup the panel
nanogui::Widget *panel4 = new nanogui::Widget(window);
panel4->setLayout(new nanogui::BoxLayout(nanogui::Orientation::Horizontal,
nanogui::Alignment::Middle, 0, 20));
// color picker for the mesh
{
new nanogui::Label(panel4, "Mesh Diffuse Color :", "sans-bold");
nanogui::PopupButton *popupBtn = new nanogui::PopupButton(panel4, "", 0);
popupBtn->setBackgroundColor(nanogui::Color(255, 228, 58, 255));
popupBtn->setFontSize(16);
popupBtn->setFixedSize(Vector2i(60, 25));
nanogui::Popup *popup = popupBtn->popup();
popup->setLayout(new nanogui::GroupLayout());
nanogui::ColorWheel *colorwheel = new nanogui::ColorWheel(popup);
colorwheel->setColor(popupBtn->backgroundColor());
nanogui::Button *colorBtn = new nanogui::Button(popup, "Pick");
colorBtn->setFixedSize(Vector2i(100, 25));
nanogui::Color c = colorwheel->color();
colorBtn->setBackgroundColor(c);
colorwheel->setCallback([&,colorBtn](const nanogui::Color &value) {
colorBtn->setBackgroundColor(value);
mesh_diffuse_color[0] = value[0];
mesh_diffuse_color[1] = value[1];
mesh_diffuse_color[2] = value[2];
viewer.data.set_colors(mesh_diffuse_color);
});
colorBtn->setChangeCallback([colorBtn, popupBtn](bool pushed) {
if (pushed) {
popupBtn->setBackgroundColor(colorBtn->backgroundColor());
popupBtn->setPushed(false);
}
});
}
/*////////////////////////////////////////////////////////////////////////////////////////
BACKGROUND COLOR PICKER
*/////////////////////////////////////////////////////////////////////////////////////////
// Setup the panel
nanogui::Widget *panel41 = new nanogui::Widget(window);
panel41->setLayout(new nanogui::BoxLayout(nanogui::Orientation::Horizontal,
nanogui::Alignment::Middle, 0, 20));
// color picker for the background
{
new nanogui::Label(panel41, "Background Color :", "sans-bold");
nanogui::PopupButton *popupBtn = new nanogui::PopupButton(panel41, "", 0);
popupBtn->setBackgroundColor(nanogui::Color(1.0f, 1.0f, 1.0f, 1.0f));
popupBtn->setFontSize(16);
popupBtn->setFixedSize(Vector2i(60, 25));
nanogui::Popup *popup = popupBtn->popup();
popup->setLayout(new nanogui::GroupLayout());
nanogui::ColorWheel *colorwheel = new nanogui::ColorWheel(popup);
colorwheel->setColor(popupBtn->backgroundColor());
nanogui::Button *colorBtn = new nanogui::Button(popup, "Pick");
colorBtn->setFixedSize(Vector2i(100, 25));
nanogui::Color c = colorwheel->color();
colorBtn->setBackgroundColor(c);
colorwheel->setCallback([&,colorBtn](const nanogui::Color &value) {
colorBtn->setBackgroundColor(value);
Eigen::Vector4f background_color;
background_color << value[0], value[1], value[2], 1.0f;
viewer.core.background_color = background_color;
});
colorBtn->setChangeCallback([colorBtn, popupBtn](bool pushed) {
if (pushed) {
popupBtn->setBackgroundColor(colorBtn->backgroundColor());
popupBtn->setPushed(false);
}
});
}
/*////////////////////////////////////////////////////////////////////////////////////////
PCA MODE OF VARIATION TEXTBOX
*/////////////////////////////////////////////////////////////////////////////////////////
// Setup the panel
nanogui::Widget *panel5 = new nanogui::Widget(window);
panel5->setLayout(new nanogui::BoxLayout(nanogui::Orientation::Horizontal,
nanogui::Alignment::Middle, 0, 20));
// Textbox for the PCA Mode
{
new nanogui::Label(panel5, "PCA Mode :", "sans-bold");
auto intBox = new nanogui::IntBox<int>(panel5);
intBox->setEditable(true);
intBox->setFixedSize(Vector2i(60, 25));
intBox->setFontSize(16);
intBox->setValue(0);
// intBox->setFormat("[1-30][0-30]*");
intBox->setCallback([&,intBox](int value){
pca_mode_number = eigenvalues.size() - value - 1;
if(value > pointPaths.size() - 1) pca_mode_number = pointPaths.size() - 1;
intBox->setValue(value);
});
}
/*////////////////////////////////////////////////////////////////////////////////////////
SHAPE DISPLAY SELECTOR TEXTBOX
*/////////////////////////////////////////////////////////////////////////////////////////
// Setup the panel
nanogui::Widget *panel6 = new nanogui::Widget(window);
panel6->setLayout(new nanogui::BoxLayout(nanogui::Orientation::Horizontal,
nanogui::Alignment::Middle, 0, 20));
// Textbox for the Shape Display
{
new nanogui::Label(panel6, "Display Shapes :", "sans-bold");
auto intBox = new nanogui::IntBox<int>(panel6);
intBox->setEditable(true);
intBox->setFixedSize(Vector2i(60, 25));
intBox->setFontSize(16);
intBox->setValue(0);
// intBox->setFormat("[1-30][0-30]*");
intBox->setCallback([&,intBox](int value){
if(disp_shape && value < pointPaths.size()){
viewer.data.clear();
Vshape = pointReadFormat(pointPaths[value], numParticles);
// find the point interpolation
Vshape *= Eigen::AngleAxisd(-90*3.14/180,
Eigen::Vector3d(-1,0,-0)).toRotationMatrix();
Vtemp = W * (Vshape.rowwise() + RowVector3d(1,0,0));
viewer.data.set_mesh(TV, TF);
viewer.data.set_vertices(Vtemp);
if(points_flag){
viewer.data.set_points(Vshape, C);
}
viewer.data.set_colors(mesh_diffuse_color);
viewer.data.compute_normals();
intBox->setValue(value);
}
});
}
// }
/*////////////////////////////////////////////////////////////////////////////////////////
MAIN ANIMATION ROUTINE
*/////////////////////////////////////////////////////////////////////////////////////////
// The Main Animation Routine
viewer.callback_pre_draw = [&, textBox_sigma, slider_sigma](igl::viewer::Viewer & viewer)->bool
{
glDisable(GL_CULL_FACE);
if(viewer.core.is_animating)
{
Vpca_mode = Eigen::Map<Eigen::MatrixXd>(pcaModes.col(pca_mode_number).data(), numParticles, 3);
Vpca_mode *= Eigen::AngleAxisd(-90*3.14/180,
Eigen::Vector3d(-1,0,-0)).toRotationMatrix();
// find the point interpolation
V = mode_variation(Vpca_mode, Vmean_space, eigenvalues(pca_mode_number), sig);
Vtemp = W * (V.rowwise() + RowVector3d(1,0,0));
viewer.data.set_vertices(Vtemp);
// display the overlay control points if the flag is true
if(points_flag){
viewer.data.set_points(V, C);
}
viewer.data.compute_normals();
viewer.data.set_colors(mesh_diffuse_color);
if(forward){sig = sig + step_size;}
else{sig = sig - step_size;}
if(sig >= 2){forward = false;}
if(sig <= -2){forward = true;}
textBox_sigma->setValue(std::to_string(sig));
slider_sigma->setValue((sig + 2)/4.0);
}
return false;
};
// Generate menu
viewer.screen->performLayout();
return false;
};
// final touches before launching the viewer
viewer.core.show_lines = false;
viewer.data.set_face_based(true);
viewer.core.rotation_type =
igl::viewer::ViewerCore::ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP;
viewer.launch();
}
#endif
| 34.217988 | 107 | 0.551789 | [
"mesh",
"shape",
"vector",
"transform"
] |
c11bef4e7d3d6864043d0d064e9a147629d9e71c | 982 | hpp | C++ | include/eve/module/real/math/function/regular/generic/atan.hpp | orao/eve | a8bdc6a9cab06d905e8749354cde63776ab76846 | [
"MIT"
] | null | null | null | include/eve/module/real/math/function/regular/generic/atan.hpp | orao/eve | a8bdc6a9cab06d905e8749354cde63776ab76846 | [
"MIT"
] | null | null | null | include/eve/module/real/math/function/regular/generic/atan.hpp | orao/eve | a8bdc6a9cab06d905e8749354cde63776ab76846 | [
"MIT"
] | null | null | null | //==================================================================================================
/**
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
**/
//==================================================================================================
#pragma once
#include <eve/detail/implementation.hpp>
#include <eve/function/abs.hpp>
#include <eve/function/bitofsign.hpp>
#include <eve/function/bit_xor.hpp>
#include <eve/function/rec.hpp>
#include <eve/module/real/math/detail/generic/atan_kernel.hpp>
#include <eve/concept/value.hpp>
#include <eve/detail/apply_over.hpp>
namespace eve::detail
{
template<floating_value T>
EVE_FORCEINLINE auto atan_(EVE_SUPPORTS(cpu_)
, T const &a) noexcept
{
if constexpr(has_native_abi_v<T>)
{
T x = eve::abs(a);
return bit_xor(atan_kernel(x, rec(x)), bitofsign(a));
}
else return apply_over(atan, a);
}
}
| 28.882353 | 100 | 0.544807 | [
"vector"
] |
c1249dbb2e7b16e769c83cacc3eb3cb8facc40af | 7,041 | cpp | C++ | Source/ActionsLib/TrainActions.cpp | sunkwei/CNTK | 08691e97707538b110ca71bce4ad06c46d840517 | [
"Intel"
] | null | null | null | Source/ActionsLib/TrainActions.cpp | sunkwei/CNTK | 08691e97707538b110ca71bce4ad06c46d840517 | [
"Intel"
] | null | null | null | Source/ActionsLib/TrainActions.cpp | sunkwei/CNTK | 08691e97707538b110ca71bce4ad06c46d840517 | [
"Intel"
] | 1 | 2019-10-24T00:35:07.000Z | 2019-10-24T00:35:07.000Z | //
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
// TrainActions.cpp -- CNTK training-related actions
//
#define _CRT_NONSTDC_NO_DEPRECATE // make VS accept POSIX functions without _
#include "stdafx.h"
#include "Basics.h"
#include "Actions.h"
#include "ComputationNetwork.h"
#include "ComputationNode.h"
#include "DataReader.h"
#include "DataWriter.h"
#include "SimpleNetworkBuilder.h"
#include "NDLNetworkBuilder.h"
#include "ModelEditLanguage.h"
#include "SGD.h"
#include "Config.h"
#include "SimpleEvaluator.h"
#include "SimpleOutputWriter.h"
#include "BestGpu.h"
#include "ScriptableObjects.h"
#include "BrainScriptEvaluator.h"
#include "BrainScriptParser.h"
#include <string>
#include <chrono>
#include <algorithm>
#include <vector>
#include <iostream>
#include <queue>
#include <set>
#include <memory>
#ifndef let
#define let const auto
#endif
using namespace std;
using namespace Microsoft::MSR;
using namespace Microsoft::MSR::CNTK;
// ===========================================================================
// DoTrain() - implements CNTK "train" command
// ===========================================================================
// function to create an object of a certain type, using both old CNTK config and BrainScript
template <class C>
shared_ptr<C> CreateObject(const ScriptableObjects::IConfigRecord& config, const wchar_t* id)
{
// TODO: CNTK config added "traceLevel = 0" to 'config'. In BS, we cannot do that (IConfigRecord is immutable). Solution: Just say "traceLevel = 0" in the BS macros for readers.
return config[id].AsPtr<C>(); // BS instantiates this object through this call
}
template <class C>
shared_ptr<C> CreateObject(const ConfigParameters& config, const wchar_t* id)
{
ConfigParameters readerConfig(config(id));
if (!readerConfig.ExistsCurrent("traceLevel")) // do not overwrite "traceLevel" if it's already present
{
readerConfig.Insert("traceLevel", config(L"traceLevel", "0")); // TODO: fix this by adding it to all config blocks. Easy to fix in BS as 'config with [ traceLevel = 0 ]'.
}
return make_shared<C>(readerConfig); // old CNTK config specifies a dictionary which then must be explicitly instantiated
}
template <class ConfigRecordType, typename ElemType>
void DoTrain(const ConfigRecordType& config)
{
bool makeMode = config(L"makeMode", true);
DEVICEID_TYPE deviceId = DeviceFromConfig(config);
// determine the network-creation function
// We have several ways to create that network.
function<ComputationNetworkPtr(DEVICEID_TYPE)> createNetworkFn;
createNetworkFn = GetNetworkFactory<ConfigRecordType, ElemType>(config);
auto dataReader = CreateObject<DataReader>(config, L"reader");
shared_ptr<DataReader> cvDataReader;
if (config.Exists(L"cvReader"))
cvDataReader = CreateObject<DataReader>(config, L"cvReader");
shared_ptr<SGD<ElemType>> optimizer;
if (config.Exists(L"optimizer"))
{
optimizer = CreateObject<SGD<ElemType>>(config, L"optimizer");
}
else // legacy CNTK config syntax: needs a record called 'SGD'
{
const ConfigRecordType& configSGD(config(L"SGD"));
optimizer = make_shared<SGD<ElemType>>(configSGD);
}
optimizer->InitMPI(MPIWrapper::GetInstance());
optimizer->Train(createNetworkFn, deviceId, dataReader.get(), cvDataReader.get(), makeMode);
}
namespace Microsoft { namespace MSR { namespace ScriptableObjects {
using namespace Microsoft::MSR::CNTK;
// -----------------------------------------------------------------------
// register ComputationNode with the ScriptableObject system
// -----------------------------------------------------------------------
class TrainAction
{
};
template <>
shared_ptr<Object> MakeRuntimeObject<TrainAction>(const IConfigRecordPtr configp)
{
const IConfigRecord& config = *configp;
wstring precision = config[L"precision"]; // dispatch on ElemType
if (precision == L"float")
DoTrain<IConfigRecord, float>(config);
else if (precision == L"double")
DoTrain<IConfigRecord, double>(config);
else
RuntimeError("invalid value '%ls' for 'precision', must be 'float' or 'double'", precision.c_str());
return make_shared<Object>(); // return a dummy object
}
// register ComputationNode with the ScriptableObject system
ScriptableObjects::ConfigurableRuntimeTypeRegister::Add<TrainAction> registerTrainAction(L"TrainAction");
}}}
template void DoTrain<ScriptableObjects::IConfigRecord, float>(const ScriptableObjects::IConfigRecord& config);
template void DoTrain<ScriptableObjects::IConfigRecord, double>(const ScriptableObjects::IConfigRecord& config);
template void DoTrain<ConfigParameters, float>(const ConfigParameters& config);
template void DoTrain<ConfigParameters, double>(const ConfigParameters& config);
// ===========================================================================
// DoAdapt() - implements CNTK "adapt" command
// ===========================================================================
template <typename ElemType>
void DoAdapt(const ConfigParameters& config)
{
DEVICEID_TYPE deviceId = DeviceFromConfig(config);
ConfigParameters configSGD(config(L"SGD"));
bool makeMode = config(L"makeMode", "true");
ConfigParameters readerConfig(config(L"reader"));
readerConfig.Insert("traceLevel", config(L"traceLevel", "0"));
auto dataReader = make_shared<DataReader>(readerConfig);
shared_ptr<DataReader> cvDataReader;
ConfigParameters cvReaderConfig(config(L"cvReader", L""));
if (cvReaderConfig.size() != 0)
{
cvReaderConfig.Insert("traceLevel", config(L"traceLevel", "0"));
cvDataReader = make_shared<DataReader>(cvReaderConfig);
}
wstring origModelFileName = config(L"origModelFileName", L"");
wstring refNodeName = config(L"refNodeName", L"");
SGD<ElemType> sgd(configSGD);
sgd.InitMPI(MPIWrapper::GetInstance());
sgd.Adapt(origModelFileName, refNodeName, dataReader.get(), cvDataReader.get(), deviceId, makeMode);
}
template void DoAdapt<float>(const ConfigParameters& config);
template void DoAdapt<double>(const ConfigParameters& config);
// ===========================================================================
// DoEdit() - implements CNTK "edit" command
// ===========================================================================
template <typename ElemType>
void DoEdit(const ConfigParameters& config)
{
wstring editPath = config(L"editPath");
wstring ndlMacros = config(L"ndlMacros", "");
NDLScript<ElemType> ndlScript;
if (!ndlMacros.empty())
{
ndlScript.LoadConfigFile(ndlMacros);
}
MELScript<ElemType> melScript;
melScript.LoadConfigFileAndResolveVariables(editPath, config);
}
template void DoEdit<double>(const ConfigParameters& config);
template void DoEdit<float>(const ConfigParameters& config);
| 36.107692 | 181 | 0.670075 | [
"object",
"vector"
] |
c12abbcda673a7ee8a1a3b6ab7d58f0d09ab6ccd | 16,969 | cpp | C++ | pipeline/pipeline.cpp | anyong298/camera-pipeline | 529829bfbd70088b9aad7d297718765942505ae6 | [
"MIT"
] | 1 | 2022-02-07T07:07:18.000Z | 2022-02-07T07:07:18.000Z | pipeline/pipeline.cpp | anyong298/camera-pipeline | 529829bfbd70088b9aad7d297718765942505ae6 | [
"MIT"
] | null | null | null | pipeline/pipeline.cpp | anyong298/camera-pipeline | 529829bfbd70088b9aad7d297718765942505ae6 | [
"MIT"
] | 2 | 2020-09-04T07:03:18.000Z | 2020-09-20T15:35:18.000Z | /*
* University of Rochester
* Authors: Prikshet Sharma, Oliver Ziqi Zhang
*
* */
#include<stdio.h>
#include "Halide.h"
#define OBR_HEIGHT 10
using namespace Halide;
//using namespace Halide::Tools;
using namespace ConciseCasts;
Buffer<uint8_t> obr(Buffer<uint8_t> input)
{
//Buffer<uint8_t> input = Tools::load_image(argv[1]);
Func obrOffset;
Var x, y, c;
Expr value = f32(input(x, y, c));
// input_16 is the OBR region cast to 16 bit for calculations so that it doesn't overflow
Func input_16("input_16");
input_16(x, y, c) = u16(input(x, y, c));
Func black;
black(x, y, c) = 100;
RDom r(0, input.width(), 0, 10);
Expr average = sum(black(r.x, r.y, c))/(OBR_HEIGHT * u16(input.width()));
obrOffset(x, y, c) = u8(max((input_16(x, y, c)) - average, 0));
Buffer<uint8_t> output(input.height(), input.width(), input.channels());
obrOffset.realize(output);
return output;
}
Buffer<uint8_t> demosaic(Buffer<uint8_t> input0)
{
Var x("x"), y("y"), c("c");
Func castutoi("casting");
castutoi(x, y, c) = cast<int16_t>(input0(x, y, c));
Buffer<int16_t> input = castutoi.realize(input0.width(), input0.height(), input0.channels());
// demosaic.trace_stores();
//Fill Green to Blue tile
Func demosaicG("Green");
demosaicG(x, y, c) = input(x, y, c);
RDom bg(2, input.width() - 4, 2, input.height() - 4);
bg.where(bg.x % 2 == 1);
bg.where(bg.y % 2 == 1);
Expr b2g_n, b2g_s, b2g_w, b2g_e, omega_n, omega_e, omega_s, omega_w, result;
b2g_n = abs(input(bg.x, bg.y + 1, 1) - input(bg.x, bg.y - 1, 1)) + abs(input(bg.x, bg.y, 2) - input(bg.x, bg.y - 2, 2));
b2g_e = abs(input(bg.x - 1, bg.y, 1) - input(bg.x + 1, bg.y, 1)) + abs(input(bg.x, bg.y, 2) - input(bg.x + 2, bg.y, 2));
b2g_s = abs(input(bg.x, bg.y + 1, 1) - input(bg.x, bg.y - 1, 1)) + abs(input(bg.x, bg.y, 2) - input(bg.x, bg.y + 2, 2));
b2g_w = abs(input(bg.x - 1, bg.y, 1) - input(bg.x + 1, bg.y, 1)) + abs(input(bg.x, bg.y, 2) - input(bg.x - 2, bg.y, 2));
omega_n = 1/(b2g_n + 1.0f);
omega_e = 1/(b2g_e + 1.0f);
omega_s = 1/(b2g_s + 1.0f);
omega_w = 1/(b2g_w + 1.0f);
b2g_n = input(bg.x, bg.y - 1, 1) + (input(bg.x, bg.y, 2) - input(bg.x, bg.y - 2, 2)) / 2.0f;//G2 + (B5 - B1)/2
b2g_e = input(bg.x + 1, bg.y, 1) + (input(bg.x, bg.y, 2) - input(bg.x + 2, bg.y, 2)) / 2.0f;//G6 + (B5 - B7)/2
b2g_s = input(bg.x, bg.y + 1, 1) + (input(bg.x, bg.y, 2) - input(bg.x, bg.y + 2, 2)) / 2.0f;//G8 + (B5 - B9)/2
b2g_w = input(bg.x - 1, bg.y, 1) + (input(bg.x, bg.y, 2) - input(bg.x - 2, bg.y, 2)) / 2.0f;//G4 + (B5 - B3)/2
//put the value into green (x, y, 1)
result = (b2g_n * omega_n + b2g_w * omega_w + b2g_s * omega_s + b2g_e * omega_e)/(omega_w + omega_s + omega_e + omega_n);
demosaicG(bg.x, bg.y, 1) = i16(result);
//Fill Green to Red tile
RDom rg(2, input.width() - 4, 2, input.height() - 4);
rg.where(rg.x % 2 == 0);
rg.where(rg.y % 2 == 0);
Expr r2g_n, r2g_s, r2g_w, r2g_e;
r2g_n = abs(input(rg.x, rg.y + 1, 1) - input(rg.x, rg.y - 1, 1)) + abs(input(rg.x, rg.y, 0) - input(rg.x, rg.y - 2, 0));
r2g_e = abs(input(rg.x - 1, rg.y, 1) - input(rg.x + 1, rg.y, 1)) + abs(input(rg.x, rg.y, 0) - input(rg.x + 2, rg.y, 0));
r2g_s = abs(input(rg.x, rg.y + 1, 1) - input(rg.x, rg.y - 1, 1)) + abs(input(rg.x, rg.y, 0) - input(rg.x, rg.y + 2, 0));
r2g_w = abs(input(rg.x - 1, rg.y, 1) - input(rg.x + 1, rg.y, 1)) + abs(input(rg.x, rg.y, 0) - input(rg.x - 2, rg.y, 0));
omega_n = 1/(r2g_n + 1.0f);
omega_e = 1/(r2g_e + 1.0f);
omega_s = 1/(r2g_s + 1.0f);
omega_w = 1/(r2g_w + 1.0f);
r2g_n = input(rg.x, rg.y - 1, 1) + (input(rg.x, rg.y, 0) - input(rg.x, rg.y - 2, 0)) / 2.0f;//G2 + (B5 - B1)/2
r2g_e = input(rg.x + 1, rg.y, 1) + (input(rg.x, rg.y, 0) - input(rg.x + 2, rg.y, 0)) / 2.0f;//G6 + (B5 - B7)/2
r2g_s = input(rg.x, rg.y + 1, 1) + (input(rg.x, rg.y, 0) - input(rg.x, rg.y + 2, 0)) / 2.0f;//G8 + (B5 - B9)/2
r2g_w = input(rg.x - 1, rg.y, 1) + (input(rg.x, rg.y, 0) - input(rg.x - 2, rg.y, 0)) / 2.0f;//G4 + (B5 - B3)/2
//fill the green channel
result = (r2g_n * omega_n + r2g_w * omega_w + r2g_s * omega_s + r2g_e * omega_e)/(omega_w + omega_s + omega_e + omega_n);
demosaicG(rg.x, rg.y, 1) = i16(result);
Buffer<int16_t> buffer = demosaicG.realize(input0.width(), input0.height(), input0.channels());
//Up until now, all tiles have Green value
//Fill Blue to Red tile
Func demosaicRB("RB");
demosaicRB(x, y, c) = buffer(x, y, c);
RDom rb(1, input.width() - 2, 1, input.height() - 2);
rb.where(rb.x % 2 == 0);
rb.where(rb.y % 2 == 0);
Expr r2b_ne, r2b_se, r2b_sw, r2b_nw;
r2b_ne = abs(input(rb.x - 1, rb.y + 1, 2) - input(rb.x + 1, rb.y - 1, 2)) + abs(buffer(rb.x, rb.y, 1) - buffer(rb.x + 1, rb.y - 1, 1));//|B7 - B3| + |G5 - G3|
r2b_se = abs(input(rb.x - 1, rb.y - 1, 2) - input(rb.x + 1, rb.y + 1, 2)) + abs(buffer(rb.x, rb.y, 1) - buffer(rb.x + 1, rb.y + 1, 1));//|B1 - B9| + |G5 - G9|
r2b_sw = abs(input(rb.x - 1, rb.y + 1, 2) - input(rb.x + 1, rb.y - 1, 2)) + abs(buffer(rb.x, rb.y, 1) - buffer(rb.x - 1, rb.y + 1, 1));//|B3 - B7| + |G5 - G7|
r2b_nw = abs(input(rb.x - 1, rb.y - 1, 2) - input(rb.x + 1, rb.y + 1, 2)) + abs(buffer(rb.x, rb.y, 1) - buffer(rb.x - 1, rb.y - 1, 1));//|B9 - B1| + |G5 - G1|
omega_n = 1/(r2b_ne + 1.0f);
omega_e = 1/(r2b_se + 1.0f);
omega_s = 1/(r2b_sw + 1.0f);
omega_w = 1/(r2b_nw + 1.0f);
r2b_ne = input(rb.x + 1, rb.y - 1, 2) + (buffer(rb.x, rb.y, 1) - buffer(rb.x + 1, rb.y - 1, 1)) / 2.0f;//B3 + (G5 - G3)/2
r2b_se = input(rb.x + 1, rb.y + 1, 2) + (buffer(rb.x, rb.y, 1) - buffer(rb.x + 1, rb.y + 1, 1)) / 2.0f;//B9 + (G5 - G9)/2
r2b_sw = input(rb.x - 1, rb.y + 1, 2) + (buffer(rb.x, rb.y, 1) - buffer(rb.x - 1, rb.y + 1, 1)) / 2.0f;//B7 + (G5 - G7)/2
r2b_nw = input(rb.x - 1, rb.y - 1, 2) + (buffer(rb.x, rb.y, 1) - buffer(rb.x - 1, rb.y - 1, 1)) / 2.0f;//B1 + (G5 - G1)/2
//put the value into blue (x, y, 2)
result = (r2b_ne * omega_n + r2b_nw * omega_w + r2b_sw * omega_s + r2b_se * omega_e)/(omega_w + omega_s + omega_e + omega_n);
demosaicRB(rb.x, rb.y, 2) = i16(result);
//Fill Red to Blue tile
RDom br(1, input.width() - 2, 1, input.height() - 2);
br.where(br.x % 2 == 1);
br.where(br.y % 2 == 1);
Expr b2r_ne, b2r_se, b2r_sw, b2r_nw;
b2r_ne = abs(input(br.x - 1, br.y + 1, 0) - input(br.x + 1, br.y - 1, 0)) + abs(buffer(br.x, br.y, 1) - buffer(br.x + 1, br.y - 1, 1));//|R7 - R3| + |G5 - G3|
b2r_se = abs(input(br.x - 1, br.y - 1, 0) - input(br.x + 1, br.y + 1, 0)) + abs(buffer(br.x, br.y, 1) - buffer(br.x + 1, br.y + 1, 1));//|R1 - R9| + |G5 - G9|
b2r_sw = abs(input(br.x - 1, br.y + 1, 0) - input(br.x + 1, br.y - 1, 0)) + abs(buffer(br.x, br.y, 1) - buffer(br.x - 1, br.y + 1, 1));//|R3 - R7| + |G5 - G7|
b2r_nw = abs(input(br.x - 1, br.y - 1, 0) - input(br.x + 1, br.y + 1, 0)) + abs(buffer(br.x, br.y, 1) - buffer(br.x - 1, br.y - 1, 1));//|R9 - R1| + |G5 - G1|
omega_n = 1/(b2r_ne + 1.0f);
omega_e = 1/(b2r_se + 1.0f);
omega_s = 1/(b2r_sw + 1.0f);
omega_w = 1/(b2r_nw + 1.0f);
b2r_ne = input(br.x + 1, br.y - 1, 0) + (buffer(br.x, br.y, 1) - buffer(br.x + 1, br.y - 1, 1)) / 2.0f;//R3 + (G5 - G3)/2
b2r_se = input(br.x + 1, br.y + 1, 0) + (buffer(br.x, br.y, 1) - buffer(br.x + 1, br.y + 1, 1)) / 2.0f;//R9 + (G5 - G9)/2
b2r_sw = input(br.x - 1, br.y + 1, 0) + (buffer(br.x, br.y, 1) - buffer(br.x - 1, br.y + 1, 1)) / 2.0f;//R7 + (G5 - G7)/2
b2r_nw = input(br.x - 1, br.y - 1, 0) + (buffer(br.x, br.y, 1) - buffer(br.x - 1, br.y - 1, 1)) / 2.0f;//R1 + (G5 - G1)/2
//put the value into red channel (x, y, 0)
result = (b2r_ne * omega_n + b2r_nw * omega_w + b2r_sw * omega_s + b2r_se * omega_e)/(omega_w + omega_s + omega_e + omega_n);
demosaicRB(br.x, br.y, 0) = i16(result);
buffer = demosaicRB.realize(input0.width(), input0.height(), input0.channels());
//Fill Blue / Red to Green tile
Func demosaicRGB("RGB");
demosaicRGB(x, y, c) = u8(buffer(x, y, c));
RDom g(2, input.width() - 4, 2, input.height() - 4);
g.where((g.x % 2 == 1 && g.y % 2 == 0) || (g.x % 2 == 0 && g.y % 2 == 1));
Expr g_n, g_s, g_w, g_e;
//Blue
g_n = abs(input(g.x, g.y + 1, 1) - input(g.x, g.y - 1, 1)) + abs(buffer(g.x, g.y, 2) - buffer(g.x, g.y - 2, 2));//B_n = |B8 - B2| + |G5 - G1|
g_e = abs(input(g.x - 1, g.y, 1) - input(g.x + 1, g.y, 1)) + abs(buffer(g.x, g.y, 2) - buffer(g.x + 2, g.y, 2));//B_n = |B4 - B6| + |G5 - G7|
g_s = abs(input(g.x, g.y + 1, 1) - input(g.x, g.y - 1, 1)) + abs(buffer(g.x, g.y, 2) - buffer(g.x, g.y + 2, 2));//B_n = |B2 - B8| + |G5 - G9|
g_w = abs(input(g.x - 1, g.y, 1) - input(g.x + 1, g.y, 1)) + abs(buffer(g.x, g.y, 2) - buffer(g.x - 2, g.y, 2));//B_n = |B6 - B4| + |G5 - G3|
omega_n = 1/(g_n + 1.0f);
omega_e = 1/(g_e + 1.0f);
omega_s = 1/(g_s + 1.0f);
omega_w = 1/(g_w + 1.0f);
g_n = buffer(g.x, g.y - 1, 2) + (input(g.x, g.y, 1) - input(g.x, g.y - 2, 1)) / 2.0f;//B2 + (G5 - G1)/2
g_e = buffer(g.x + 1, g.y, 2) + (input(g.x, g.y, 1) - input(g.x + 2, g.y, 1)) / 2.0f;//B6 + (G5 - G7)/2
g_s = buffer(g.x, g.y + 1, 2) + (input(g.x, g.y, 1) - input(g.x, g.y + 2, 1)) / 2.0f;//B8 + (G5 - G9)/2
g_w = buffer(g.x - 1, g.y, 2) + (input(g.x, g.y, 1) - input(g.x - 2, g.y, 1)) / 2.0f;//B4 + (G5 - G3)/2
//put the value into green (x, y, 1)
result = (g_n * omega_n + g_w * omega_w + g_s * omega_s + g_e * omega_e)/(omega_w + omega_s + omega_e + omega_n);
demosaicRGB(g.x, g.y, 2) = u8(result);
//Red
g_n = abs(input(g.x, g.y + 1, 1) - input(g.x, g.y - 1, 1)) + abs(buffer(g.x, g.y, 2) - buffer(g.x, g.y - 2, 2));//B_n = |R8 - R2| + |G5 - G1|
g_e = abs(input(g.x - 1, g.y, 1) - input(g.x + 1, g.y, 1)) + abs(buffer(g.x, g.y, 2) - buffer(g.x + 2, g.y, 2));//B_n = |R4 - R6| + |G5 - G7|
g_s = abs(input(g.x, g.y + 1, 1) - input(g.x, g.y - 1, 1)) + abs(buffer(g.x, g.y, 2) - buffer(g.x, g.y + 2, 2));//B_n = |R2 - R8| + |G5 - G9|
g_w = abs(input(g.x - 1, g.y, 1) - input(g.x + 1, g.y, 1)) + abs(buffer(g.x, g.y, 2) - buffer(g.x - 2, g.y, 2));//B_n = |R6 - R4| + |G5 - G3|
omega_n = 1/(g_n + 1.0f);
omega_e = 1/(g_e + 1.0f);
omega_s = 1/(g_s + 1.0f);
omega_w = 1/(g_w + 1.0f);
g_n = buffer(g.x, g.y - 1, 0) + (input(g.x, g.y, 1) - input(g.x, g.y - 2, 1)) / 2.0f;//R2 + (G5 - G1)/2
g_e = buffer(g.x + 1, g.y, 0) + (input(g.x, g.y, 1) - input(g.x + 2, g.y, 1)) / 2.0f;//R6 + (G5 - G7)/2
g_s = buffer(g.x, g.y + 1, 0) + (input(g.x, g.y, 1) - input(g.x, g.y + 2, 1)) / 2.0f;//R8 + (G5 - G9)/2
g_w = buffer(g.x - 1, g.y, 0) + (input(g.x, g.y, 1) - input(g.x - 2, g.y, 1)) / 2.0f;//R4 + (G5 - G3)/2
//put the value into green (x, y, 1)
result = (g_n * omega_n + g_w * omega_w + g_s * omega_s + g_e * omega_e)/(omega_w + omega_s + omega_e + omega_n);
demosaicRGB(g.x, g.y, 0) = u8(result);
Buffer<uint8_t> output =
demosaicRGB.realize(input.width(), input.height(), input.channels());
return output;
}
Buffer<uint8_t> spatial_denoise(Buffer<uint8_t> input)
{
//Buffer<uint8_t> input = Tools::load_image(argv[1]);
printf("channels=%d\n", input.channels());
float sig_s_f = 2.0;
float sig_r_f = 2.0;
int L = sig_r_f * 3;
int W = sig_s_f * 3;
Var x, y, c, t;
// declare range and spatial filters
Func g_sig_s, g_sig_r;
RDom omega(-W, W, -W, W), l_r(-L, L, -L, L);;
g_sig_s(x, y) = f32(0);
g_sig_s(omega.x, omega.y) = f32(exp(-(omega.x * omega.x + omega.y * omega.y) / (2 * sig_s_f * sig_s_f)));
g_sig_r(t) = f32(exp(- t * t / (2 * sig_r_f * sig_r_f)));
Func imp_bi_filter, imp_bi_filter_num, imp_bi_filter_den, imp_bi_filter_num_clamped, imp_bi_filter_den_clamped;
Func box_filtered;
box_filtered(x, y, c) = u8((float)(1) / ((2 * L + 1) * (2 * L + 1)) * sum(input(x - l_r.x, y - l_r.y, c)));
// Compute box filtered image
Expr clamped_x = clamp(x, L, input.width() - 2 * L - 1);
Expr clamped_y = clamp(y, L, input.height() - 2 * L - 1);
imp_bi_filter_num(x, y, c) = f32(sum(g_sig_s(omega.x, omega.y) *
g_sig_r(box_filtered(x - omega.x, y - omega.y, c) - box_filtered(x, y, c)) *
input(x - omega.x, y - omega.y, c)));
imp_bi_filter_den(x, y, c) = f32(sum((g_sig_s(omega.x, omega.y))
* g_sig_r((box_filtered(x - omega.x, y - omega.y, c) - box_filtered(x, y, c)))));
imp_bi_filter_num_clamped(x, y, c) = imp_bi_filter_num(clamped_x, clamped_y, c);
imp_bi_filter_den_clamped(x, y, c) = imp_bi_filter_den(clamped_x, clamped_y, c);
imp_bi_filter(x, y, c) = u8(imp_bi_filter_num_clamped(x, y, c) / imp_bi_filter_den_clamped(x, y, c));
Buffer<uint8_t> shifted(input.width() - 2 * W, input.height() - 2 * W, input.channels());
shifted.set_min(W, W);
//imp_bi_filter.trace_stores();
imp_bi_filter.realize(shifted);
//Tools::save_image(shifted, "denoise.png");
return shifted;
}
float slope[3];
Buffer<uint8_t> white_balance(Buffer<uint8_t> input)
{
Func magnitude("magnitude");
Var i, j;
magnitude(i, j) = sqrt(input(i, j, 0) * input(i, j, 0) + input(i, j, 1) * input(i, j, 1) + input(i, j, 2) * input(i, j, 2));
Buffer<uint8_t> mag = magnitude.realize(input.width(), input.height());
float max = -1, tmp, max_r, max_g, max_b;
int w1 = 1, w2 = 1, w3 = 1;
// sscanf(argv[2], "%d", &w1);
// sscanf(argv[3], "%d", &w2);
// sscanf(argv[4], "%d", &w3);
// printf("%d\n", input(0, 0, 1));
for(int i = 1; i < input.width() - 1; i++){
for(int j = 1; j < input.height() - 1; j++){
tmp = mag(i, j) * w1 + (mag(i + 1, j) + mag(i, j + 1) + mag(i - 1, j) + mag(i, j - 1) ) / 4 * w2 + (mag(i - 1, j - 1) + mag(i + 1, j + 1) + mag(i + 1, j - 1) + mag(i - 1, j + 1)) / 4 * w3; //get teh magnitude of current RGB vector
if(max < tmp){// if current RGB is bigger(brighter), update max values
max = tmp;
max_r = input(i, j, 0);
max_g = input(i, j, 1);
max_b = input(i, j, 2);
printf("Current brightest pixel is R: %f, G: %f, B:%f\n", max_r, max_g, max_b);
}
}
}
printf("Current brightest pixel is R: %f, G: %f, B:%f\n", max_r, max_g, max_b);
slope[0] = 255 / max_r;
slope[1] = 255 / max_g;
slope[2] = 255 / max_b;
Func white_balance("white_balance");
Var x("x"), y("y"), c("c");
white_balance(x, y, c) = input(x, y, c);
white_balance(x, y, 0) = cast<uint8_t>(min(input(x, y, 0) * slope[0], 255.0f));
white_balance(x, y, 1) = cast<uint8_t>(min(input(x, y, 1) * slope[1], 255.0f));
white_balance(x, y, 2) = cast<uint8_t>(min(input(x, y, 2) * slope[2], 255.0f));
Buffer<uint8_t> output =
white_balance.realize(input.width(), input.height(), input.channels());
return output;
}
Buffer<uint8_t> gamma_correction(Buffer<uint8_t> input)
{
Func correct("correct");
Var x("x"), y("y"), c;
Expr value = cast<float>(input(x, y, c));
// value = 255 * (pow((value / 255.0f), (1/2.2f)));
value = (pow((value), (1/2.2f)));
correct(x, y, c) = (cast<uint8_t>(value));
Buffer<uint8_t> output = correct.realize(input.width(), input.height(), input.channels());
return output;
}
Buffer<uint8_t> demosaic_naive(Buffer<uint8_t> input)
{
Func demosaic("demosaic");
Var x("x"), y("y"), c("c");
// Expr value;
demosaic(x, y, c) = input(x, y, c);
//Red
RDom r(1, input.width() - 2, 1, input.height() - 2);
r.where(r.x % 2 == 0);
r.where(r.y % 2 == 0);
demosaic(r.x, r.y, 1) = (input(r.x, r.y + 1, 1) / 4 + input(r.x, r.y - 1, 1) / 4 + input(r.x + 1, r.y, 1) / 4 + input(r.x - 1, r.y, 1) / 4);
demosaic(r.x, r.y, 2) = (input(r.x + 1, r.y + 1, 2) / 4 + input(r.x + 1, r.y - 1, 2) / 4 + input(r.x - 1, r.y + 1, 2) / 4 + input(r.x - 1, r.y - 1, 2) / 4);
//Blue
RDom b(1, input.width() - 2, 1, input.height() - 2);
b.where(b.x % 2 == 1);
b.where(b.y % 2 == 1);
demosaic(b.x, b.y, 0) = (input(b.x + 1, b.y + 1, 0) / 4 + input(b.x - 1, b.y + 1, 0) / 4 + input(b.x + 1, b.y - 1, 0) / 4 + input(b.x - 1, b.y - 1, 0) / 4);
demosaic(b.x, b.y, 1) = (input(b.x + 1, b.y, 1) / 4 + input(b.x, b.y + 1, 1) / 4 + input(b.x - 1, b.y, 1) / 4 + input(b.x, b.y - 1, 1) / 4);
//Green
RDom g1(1, input.width() - 2, 1, input.height() - 2);
g1.where(g1.x % 2 == 0);
g1.where(g1.y % 2 == 1);
demosaic(g1.x, g1.y, 0) = (input(g1.x, g1.y + 1, 0) / 2 + input(g1.x, g1.y - 1, 0) / 2);
demosaic(g1.x, g1.y, 2) = (input(g1.x + 1, g1.y, 2) / 2 + input(g1.x - 1, g1.y, 2) / 2);
RDom g2(1, input.width() - 2, 1, input.height() - 2);
g2.where(g2.x % 2 == 1);
g2.where(g2.y % 2 == 0);
demosaic(g2.x, g2.y, 0) = (input(g2.x + 1, g2.y, 0) / 2 + input(g2.x - 1, g2.y, 0) / 2);
demosaic(g2.x, g2.y, 2) = (input(g2.x, g2.y + 1, 2) / 2 + input(g2.x, g2.y - 1, 2) / 2);
Buffer<uint8_t> output =
demosaic.realize(input.width(), input.height(), input.channels());
return output;
}
| 39.740047 | 234 | 0.527138 | [
"vector"
] |
c12e47af5ec88e81b86400fdbb3a612519dee841 | 73,339 | cpp | C++ | src/oc/code.cpp | shhong/nrn | 0d64e94330c6072529e31033d579b270f742454e | [
"BSD-3-Clause"
] | null | null | null | src/oc/code.cpp | shhong/nrn | 0d64e94330c6072529e31033d579b270f742454e | [
"BSD-3-Clause"
] | 1 | 2022-03-25T13:30:45.000Z | 2022-03-25T13:30:45.000Z | src/oc/code.cpp | shhong/nrn | 0d64e94330c6072529e31033d579b270f742454e | [
"BSD-3-Clause"
] | 1 | 2018-12-18T13:52:16.000Z | 2018-12-18T13:52:16.000Z | #include <../../nrnconf.h>
/* /local/src/master/nrn/src/oc/code.cpp,v 1.37 1999/07/03 14:20:21 hines Exp */
#if defined(__GO32__)
#include <go32.h>
#endif
#include <errno.h>
#include "hoc.h"
#include "code.h"
#include "hocstr.h"
#include "parse.hpp"
#include "ocfunc.h"
#include "ocmisc.h"
#include "hocparse.h"
#include "equation.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <nrnmpi.h>
#include "nrnfilewrap.h"
#if CABLE
#include "options.h"
#include "section.h"
int bbs_poll_;
extern void bbs_handle(void);
#define BBSPOLL if (--bbs_poll_ == 0) { bbs_handle(); }
int nrn_isecstack();
#else
#define BBSPOLL /**/
#endif
extern void debugzz(Inst*);
int hoc_return_type_code = 0; /* flag for allowing integers (1) and booleans (2) to be recognized as such */
# define STACKCHK if (stackp >= stacklast) \
execerror("Stack too deep.", "Increase with -NSTACK stacksize option");
int tstkchk_actual(int i, int j) {
int k, l;
char *s[2];
if (i != j) {
for (k = 0, l = i; k < 2; k++, l = j) {
switch (l) {
case NUMBER:
s[k] = "(double)";
break;
case STRING:
s[k] = "(char *)";
break;
case OBJECTVAR:
s[k] = "(Object **)";
break;
case USERINT:
s[k] = "(int)";
break;
case SYMBOL:
s[k] = "(Symbol)";
break;
case VAR:
s[k] = "(double *)";
break;
case OBJECTTMP: /* would use OBJECT if it existed */
s[k] = "(Object *)";
break;
case STKOBJ_UNREF:/* hoc_stkobj_unref allready called */
s[k] = "(Object * already unreffed on stack)";
break;
default:
s[k] = "(Unknown)";
break;
}
}
fprintf(stderr, "bad stack access: expecting %s; really %s\n", s[1], s[0]);
execerror("interpreter stack type error", (char *) 0);
}
return 0;
}
#define USEMACROS 1
/* warning! tstkchk(i,j) when i!=j will call execerror and error recovery
now uses stackp to recover OBJECTTMP resources. So it must be the case that
stackp - stack is an even number (since stack item, itemtype values
use a pair of stack locations). This invalidates the previous pop idiom
tstkchk((--stackp)->i, type), (--stackp)->val)) since if tstkchk calls
execerror without returning, stackp is no longer consistent since the
second decrement no longer takes place.
Furthermore, tstkchk(i,j) should be called prior to actually popping the
stack so that the execerror will properly unref the otherwise unexpected
possible OBJECTTMP.
*/
#if USEMACROS
/* warning! tstkchk is a macro that uses each arg twice. So error if
the arg in the call has side effects. Eg avoid args like --stackp
*/
#define tstkchk(i, j) (((i)!=(j))?tstkchk_actual(i,j):0)
#define pushxm(d) ((stackp++)->val = (d));((stackp++)->i = NUMBER)
#define pushsm(d) ((stackp++)->sym = (d));((stackp++)->i = SYMBOL)
#define nopopm() (stackp -= 2) /*provision at use made to deal with OBJECTTMP*/
#define xpopm() (tstkchk(stackp[-1].i, NUMBER), nopopm(), stackp->val)
#define spopm() (tstkchk(stackp[-1].i, SYMBOL), nopopm(), stackp->sym)
#else
#define pushxm(d) pushx(d)
#define pushsm(d) pushs(d)
#define xpopm() xpop()
#define spopm() spop()
#define nopopm() nopop()
#define tstkchk(i,j) tstkchk_actual(i,j)
#endif
#define EPS hoc_epsilon
#define NSTACK 1000 /* default size */
#define nstack hoc_nstack
// TODO - ugly but workable for now
namespace std {
#define stack stlstack
}
static Datum *stack; /* the stack */
static Datum *stackp; /* next free spot on stack */
static Datum *stacklast; /* last stack element */
#define NPROG 50000
Inst *prog; /* the machine */
Inst *progp; /* next free spot for code generation */
Inst *pc; /* program counter during execution */
Inst *progbase; /* start of current subprogram */
Inst *prog_parse_recover; /* start after parse error */
int hoc_returning; /* 1 if return stmt seen, 2 if break, 3 if continue */
/* 4 if stop */
typedef struct Frame { /* proc/func call stack frame */
Symbol *sp; /* symbol table entry */
Inst *retpc; /* where to resume after return */
Datum *argn; /* n-th argument on stack */
int nargs; /* number of arguments */
Inst *iter_stmt_begin; /* Iterator statement starts here */
Object *iter_stmt_ob; /* context of Iterator statement */
Object *ob; /* for stack frame debug message */
} Frame;
#define NFRAME 512 /* default size */
#define nframe hoc_nframe
static Frame *frame, *fp, *framelast; /* first, frame pointer, last */
/* temporary object references come from this pool. This allows the
stack to be aware if it is storing a temporary. We are trying to
solve problems of objrefs on the stack changing the object they point
to and also a failure of garbage collection since temporary objrefs have
not, in the past, been reffed or unreffed.
The first problem is easily solved without much efficiency loss
by having the stack store the object pointer instead of the objref pointer.
Garbage collection is implemented by reffing any object that is placed
on the stack via hoc_push_object (and thus borrows the use of the
type OBJECTTMP) It is then the responsibility of everything that
pops an object to determine whether the object should be unreffed.
This is also done on error recovery and when the stack frame is popped.
I hate the efficiency loss but it is not as bad as it could be
since most popping occurs when the stack frame is popped and in this
case it is faster to check for OBJECTTMP than if the returned Object**
is from the pool.
*/
#define DEBUG_GARBAGE 1
#define TOBJ_POOL_SIZE 50
static Object **hoc_temp_obj_pool_;
static int obj_pool_index_;
static int tobj_count; /* how many stack pushes of OBJECTTMP have been reffed*/
/*
Here is the old comment on the function when it was in hoc_oop.cpp.
At this time we are dealing uniformly with object variables and cannot
deal cleanly with objects. Eventually it may be possible to put an
object pointer on the stack but not now. Try to avoid using "functions
which return new objects" as arguments to other functions. If this is
done then it may happen that when the stack pointer is finally used it
may point to a different object than when it was put on the stack.
Things are safe when a temp_objvar is finally removed from the stack.
Memory leakage will occur if a temp_objvar is passed as an arg but never
assigned to a full fledged object variable. ie its reference count is 0
but unref will never be called on it.
The danger is illustrated with
proc p(obj.func_returning_object()) { // $o1 is on the stack
print $o1 // correct object
for i=0,100 {
o = obj.func_returning_different_object()
print i, $o1 //when i=50 $o1 will be different
}
}
In this case one should first assign $o1 to another object variable
and then use that object variable exclusively instead of $o1.
This also prevent leakage of the object pointed to by $o1.
If this ever becomes a problem then it is not too difficult to
implement objects on the stack with garbage collection.
*/
Object **hoc_temp_objptr(Object *obj) {
Object **tobj;
obj_pool_index_ = (obj_pool_index_ + 1) % TOBJ_POOL_SIZE;
tobj = hoc_temp_obj_pool_ + obj_pool_index_;
*tobj = obj;
return tobj;
}
/* should be called after finished with pointer from a popobj */
void hoc_tobj_unref(Object **p) {
if (p >= hoc_temp_obj_pool_ && p < hoc_temp_obj_pool_ + TOBJ_POOL_SIZE) {
--tobj_count;
hoc_obj_unref(*p);
}
}
/*
vec.cpp.x[0] used freed memory because the temporary vector was unreffed
after the x pointer was put on the stack but before it was evaluated.
The hoc_pop_defer replaces the nopop in in hoc_object_component handling
of a cplus steer method (which pushes a double pointer). The corresponding
hoc_unref_defer takes place in hoc_object_eval after evaluating
the pointer. This should take care of the most common (itself very rare)
problem. However it still would not in general
take care of the purposeless passing
of &vec.cpp.x[0] as an argument to a function since intervening pop_defer/unref_defer
pairs could take place.
*/
static Object *unref_defer_;
void hoc_unref_defer(void) {
if (unref_defer_) {
#if 0
printf("hoc_unref_defer %s %d\n", hoc_object_name(unref_defer_), unref_defer_->refcount);
#endif
hoc_obj_unref(unref_defer_);
unref_defer_ = (Object*)0;
}
}
void hoc_pop_defer(void) {
Object *obj;
if (unref_defer_) {
#if 0
printf("hoc_pop_defer unrefs %s %d\n", hoc_object_name(unref_defer_), unref_defer_->refcount);
#endif
hoc_unref_defer();
}
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
if (stackp[-1].i == OBJECTTMP) {
unref_defer_ = stackp[-2].obj;
if (unref_defer_) {
++unref_defer_->refcount;
}
#if 0
printf("hoc_pop_defer %s %d\n", hoc_object_name(unref_defer_), unref_defer_->refcount);
#endif
}
hoc_nopop();
}
/* should be called on each OBJECTTMP on the stack after adjusting the
stack pointer downward */
void hoc_stkobj_unref(Object *o, int stkindex) {
if (stack[stkindex + 1].i == OBJECTTMP) {
--tobj_count;
hoc_obj_unref(o);
stack[stkindex + 1].i = STKOBJ_UNREF;
}
}
/* check the args of the frame and unref any of type OBJECTTMP */
static void frameobj_clean(Frame *f) {
Datum *s;
int i, narg;
if (f->nargs == 0) {
return;
}
s = f->argn + 2;
for (i = f->nargs - 1; i >= 0; --i) {
s -= 2;
if (s[1].i == OBJECTTMP) {
hoc_stkobj_unref(s->obj, (int) (s - stack));
}
}
}
/* unref items on the stack frame associated with localobj in case of error */
static void frame_objauto_recover_on_err(Frame *ff) { /* only on error */
Frame *f;
for (f = fp; f > ff; --f) {
int i;
Symbol *sp = f->sp;
if (sp->u.u_proc == NULL) { /* skip if the procedure is not defined */
continue;
}
/* argn is the nargs argument on the stack. Stack items come in pairs
so stack increments are always multiples of 2.
Here, stkp is the last+1 localobj slot pair on the stack.
*/
Datum *stkp = f->argn + 2 + sp->u.u_proc->nauto * 2;
for (i = sp->u.u_proc->nobjauto; i > 0; --i) {
Object *ob = stkp[-2 * i].obj;
hoc_obj_unref(ob);
/* Note that these AUTOOBJECT stack locations have an itemtype that
are left over from the previous stack usage of that location.
Regardless of that itemtype (e.g. OBJECTTMP), these did NOT
increment tobj_count so we need to guarantee that the subsequent
stack_obtmp_recover_on_err does not inadvertently free it again
by setting the itemtype to a non OBJECTTMP value. I hope this is
the only place where stack space was used in which no item type
was specified.
We are doing this here which happens rarely to avoid having to
set them when the stack obj pointers are zeroed.
*/
stkp[-2 * i + 1].i = 0;
}
}
}
static void stack_obtmp_recover_on_err(int tcnt) {
if (tobj_count > tcnt) {
Datum *stkp;
/* stackp - 2 because stackp is next available stack slot and
stack item,itemtype takes up two slots.
*/
for (stkp = stackp - 2; stkp >= stack; stkp -= 2) {
if (stkp[1].i == OBJECTTMP) {
hoc_stkobj_unref(stkp->obj, (int) (stkp - stack));
if (tobj_count == tcnt) {
return;
}
} else if (stkp[1].i == STKOBJ_UNREF) {
printf("OBJECTTMP at stack index %ld already unreffed\n", stkp - stack);
}
}
}
}
void hoc_init_space(void) /* create space for stack and code */
{
if (nframe == 0) {
nframe = NFRAME;
}
if (nstack == 0) {
nstack = NSTACK;
}
stackp = stack = (Datum *) emalloc(sizeof(Datum) * nstack);
stacklast = stack + nstack;
progp = progbase = prog = (Inst *) emalloc(sizeof(Inst) * NPROG);
fp = frame = (Frame *) emalloc(sizeof(Frame) * nframe);
framelast = frame + nframe;
hoc_temp_obj_pool_ = (Object **) emalloc(sizeof(Object *) * TOBJ_POOL_SIZE);
}
#define MAXINITFCNS 10
static int maxinitfcns;
static Pfrv initfcns[MAXINITFCNS];
void hoc_prstack(void) {
int i;
Datum *s;
Printf("interpreter stack: %ld \n", (stackp - stack) / 2);
for (i = 0, s = stackp - 1; s > stack; --s, ++i) {
if (i > 10) {
Printf("...\n");
break;
}
Printf("%d stacktype=%d\n", i, s->i);
--s;
}
}
void hoc_on_init_register(Pfrv pf) {
/* modules that may have to be cleaned up after an execerror */
if (maxinitfcns < MAXINITFCNS) {
initfcns[maxinitfcns++] = pf;
} else {
fprintf(stderr, "increase definition for MAXINITFCNS\n");
nrn_exit(1);
}
}
void initcode(void) /* initialize for code generation */
{
int i;
errno = 0;
if (hoc_errno_count > 5) {
fprintf(stderr, "errno set %d times on last execution\n", hoc_errno_count);
}
hoc_errno_count = 0;
prog_parse_recover = progbase = prog;
progp = progbase;
hoc_unref_defer();
frame_objauto_recover_on_err(frame);
if (tobj_count) {
stack_obtmp_recover_on_err(0);
#if DEBUG_GARBAGE
if (tobj_count) {
printf("initcode failed with %d left\n", tobj_count);
}
#endif
tobj_count = 0;
}
stackp = stack;
fp = frame;
free_list(&p_symlist);
hoc_returning = 0;
do_equation = 0;
for (i = 0; i < maxinitfcns; ++i) {
(*initfcns[i])();
}
#if CABLE
nrn_initcode(); /* special requirements for NEURON */
#endif
}
static Frame *rframe;
static Datum *rstack;
static const char *parsestr;
extern "C" void oc_save_code(
Inst **a1,
Inst **a2,
Datum **a3,
Frame **a4,
int *a5,
int *a6,
Inst **a7,
Frame **a8,
Datum **a9,
Symlist **a10,
Inst **a11,
int *a12
) {
*a1 = progbase;
*a2 = progp;
*a3 = stackp;
*a4 = fp;
*a5 = hoc_returning;
*a6 = do_equation;
*a7 = pc;
*a8 = rframe;
*a9 = rstack;
*a10 = p_symlist;
*a11 = prog_parse_recover;
*a12 = tobj_count;
}
extern "C" void oc_restore_code(
Inst **a1,
Inst **a2,
Datum **a3,
Frame **a4,
int *a5,
int *a6,
Inst **a7,
Frame **a8,
Datum **a9,
Symlist **a10,
Inst **a11,
int *a12
) {
progbase = *a1;
progp = *a2;
frame_objauto_recover_on_err(*a4);
if (tobj_count > *a12) {
stack_obtmp_recover_on_err(*a12);
#if DEBUG_GARBAGE
if (tobj_count != *a12) {
printf("oc_restore_code tobj_count=%d should be %d\n", tobj_count, *a12);
}
#endif
}
stackp = *a3;
fp = *a4;
hoc_returning = *a5;
do_equation = *a6;
pc = *a7;
rframe = *a8;
rstack = *a9;
p_symlist = *a10;
prog_parse_recover = *a11;
}
int hoc_strgets_need(void) {
return strlen(parsestr);
}
char *hoc_strgets(char *cbuf, int nc) {/* getc for a string, used by parser */
strncpy(cbuf, parsestr, nc);
if (*parsestr == '\0') {
return (char *) 0;
} else {
return cbuf;
}
}
static void rinitcode(void) /* initialize for recursive code generation */
{
errno = 0;
hoc_errno_count = 0;
prog_parse_recover = progbase;
progp = progbase;
stackp = rstack;
fp = rframe;
free_list(&p_symlist);
if (hoc_returning != 4) { /* if stop not seen */
hoc_returning = 0;
}
do_equation = 0;
}
int hoc_ParseExec(int yystart) {
/* can recursively parse and execute what is in cbuf.
may parse single tokens. called from hoc_oc(str).
All these parse and execute routines should be combined into
a single method robust method. The pipeflag method has become
encrusted with too many irrelevant mechanisms. There is no longer
anything sacred about the cbuf. The only requiremnent is to tell
the get line function where to get its string.
*/
int yret;
Frame *sframe, *sfp;
Inst *sprogbase, *sprogp, *spc, *sprog_parse_recover;
Datum *sstackp, *sstack;
Symlist *sp_symlist;
if (yystart) {
sframe=rframe;sfp=fp;
sprogbase=progbase; sprogp=progp; spc=pc,
sprog_parse_recover=prog_parse_recover;
sstackp=stackp; sstack=rstack;
sp_symlist=p_symlist;
rframe = fp;
rstack = stackp;
progbase = progp;
p_symlist = (Symlist *)0;
}
if (yystart) {
rinitcode();
}
if (hoc_in_yyparse) {
hoc_execerror("Cannot reenter parser.",
"Maybe you were in the middle of a direct command.");
}
yret = yyparse();
switch (yret) {
case 1:
execute(progbase);
rinitcode();
break;
case 'e':
hoc_edit();
for (rinitcode(); hoc_yyparse(); rinitcode()) {
execute(progbase);
}
break;
case -3 :
hoc_execerror("incomplete statement parse not allowed\n", (char*)0);
default:
break;
}
if (yystart) {
rframe=sframe; fp=sfp;
progbase=sprogbase; progp=sprogp; pc=spc;
prog_parse_recover=sprog_parse_recover;
stackp=sstackp; rstack=sstack; p_symlist=sp_symlist;
}
return yret;
}
int hoc_xopen_run(Symbol *sp, const char *str) { /*recursively parse and execute for xopen*/
/* if sp != 0 then parse string and save code */
/* without executing. Note str must be a 'list'*/
int n=0;
Frame *sframe=rframe, *sfp=fp;
Inst *sprogbase=progbase, *sprogp=progp, *spc=pc,
*sprog_parse_recover=prog_parse_recover;
Datum *sstackp=stackp, *sstack=rstack;
Symlist *sp_symlist=p_symlist;
rframe = fp;
rstack = stackp;
progbase = progp;
p_symlist = (Symlist *)0;
if (sp == (Symbol *)0) {
for (rinitcode(); hoc_yyparse(); rinitcode())
execute(progbase);
}else{ int savpipeflag;
rinitcode();
savpipeflag = hoc_pipeflag;
hoc_pipeflag = 2;
parsestr=str;
if(!hoc_yyparse()) {
execerror("Nothing to parse", (char *)0);
}
n = (int)(progp-progbase);
hoc_pipeflag = savpipeflag;
hoc_define(sp);
rinitcode();
}
rframe=sframe; fp=sfp;
progbase=sprogbase; progp=sprogp; pc=spc;
prog_parse_recover=sprog_parse_recover;
stackp=sstackp; rstack=sstack; p_symlist=sp_symlist;
return n;
}
#define HOC_TEMP_CHARPTR_SIZE 128
static char *stmp[HOC_TEMP_CHARPTR_SIZE];
static int istmp = 0;
char **hoc_temp_charptr(void) {
istmp = (istmp + 1) % HOC_TEMP_CHARPTR_SIZE;
return stmp + istmp;
}
int hoc_is_temp_charptr(char **cpp) {
if (cpp >= stmp && cpp < stmp + HOC_TEMP_CHARPTR_SIZE) {
return 1;
}
return 0;
}
int hoc_stack_type(void) {
return stackp[-1].i;
}
void pushx(double d) { /* push double onto stack */
STACKCHK
(stackp++)->val = d;
(stackp++)->i = NUMBER;
}
void hoc_pushobj(Object **d) { /* push pointer to object pointer onto stack */
STACKCHK
if (d >= hoc_temp_obj_pool_ && d < (hoc_temp_obj_pool_ + TOBJ_POOL_SIZE)) {
hoc_push_object(*d);
return;
}
(stackp++)->pobj = d;
(stackp++)->i = OBJECTVAR;
}
void hoc_push_object(Object *d) { /* push pointer to object onto stack */
STACKCHK
(stackp++)->obj = d;
(stackp++)->i = OBJECTTMP; /* would use OBJECT if it existed */
hoc_obj_ref(d);
++tobj_count;
}
void hoc_pushstr(char **d) { /* push pointer to string pointer onto stack */
STACKCHK
(stackp++)->pstr = d;
(stackp++)->i = STRING;
}
void hoc_push_string(void) { /* code for pushing a symbols string */
Objectdata *odsav;
Object *obsav = 0;
Symlist *slsav;
Symbol *s;
s = (pc++)->sym;
if (!s) {
hoc_pushstr((char **) 0);
return;
}
if (s->type == CSTRING) {
hoc_pushstr(&(s->u.cstr));
} else {
if (s->cpublic == 2) {
s = s->u.sym;
odsav = hoc_objectdata_save();
obsav = hoc_thisobject;
slsav = hoc_symlist;
hoc_objectdata = hoc_top_level_data;
hoc_thisobject = 0;
hoc_symlist = hoc_top_level_symlist;
}
hoc_pushstr(OPSTR(s));
if (obsav) {
hoc_objectdata = hoc_objectdata_restore(odsav);
hoc_thisobject = obsav;
hoc_symlist = slsav;
}
}
}
void hoc_pushpx(double *d) { /* push double pointer onto stack */
STACKCHK
(stackp++)->pval = d;
(stackp++)->i = VAR;
}
void pushs(Symbol *d) { /* push symbol pointer onto stack */
STACKCHK
(stackp++)->sym = d;
(stackp++)->i = SYMBOL;
}
void pushi(int d) { /* push integer onto stack */
STACKCHK
(stackp++)->i = d;
(stackp++)->i = USERINT;
}
int hoc_stacktype(void) {
if (stackp <= stack) {
execerror("stack empty", (char *) 0);
}
return (stackp - 1)->i;
}
int hoc_argtype(int narg) { /* type of nth arg */
if (narg > fp->nargs)
execerror(fp->sp->name, "not enough arguments");
return (fp->argn[(narg - fp->nargs) * 2 + 1].i);
}
int hoc_is_double_arg(int narg) {
return (hoc_argtype(narg) == NUMBER);
}
int hoc_is_pdouble_arg(int narg) {
return (hoc_argtype(narg) == VAR);
}
int hoc_is_str_arg(int narg) {
return (hoc_argtype(narg) == STRING);
}
int hoc_is_object_arg(int narg) {
int type = hoc_argtype(narg);
return (type == OBJECTVAR || type == OBJECTTMP);
}
extern "C" int hoc_is_tempobj_arg(int narg) {
return (hoc_argtype(narg) == OBJECTTMP);
}
Datum *hoc_look_inside_stack(int i, int type) {/* stack pointer at depth i; i=0 is top */
tstkchk((stackp - 2 * i - 1)->i, type);
return stackp - 2 * (i + 1);
}
Object *hoc_obj_look_inside_stack(int i) { /* stack pointer at depth i; i=0 is top */
Datum *d = stackp - 2 * i - 2;
int type = d[1].i;
if (type == OBJECTTMP) {
return d[0].obj;
}
tstkchk(type, OBJECTVAR);
return *(d[0].pobj);
}
int hoc_obj_look_inside_stack_index(int i) {
return (int) ((stackp - 2 * i - 2) - stack);
}
int hoc_inside_stacktype(int i) { /* 0 is top */
return (stackp - 2 * i - 1)->i;
}
double xpop(void) { /* pop double and return top elem from stack */
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
tstkchk(stackp[-1].i, NUMBER);
stackp -= 2;
return stackp->val;
}
#if 0
void pstack(void) {
char* hoc_object_name();
Datum* d;
int i;
for (d=stackp; d > stack;) {
i = (--d)->i;
--d;
switch(i) {
case NUMBER:
printf("(double)\n");
break;
case STRING:
printf("(char *)\n");
break;
case OBJECTVAR:
printf("(Object **) %s\n", hoc_object_name(*(d->pobj)));
break;
case USERINT:
printf("(int)\n");
break;
case SYMBOL:
printf("(Symbol) %s\n", d->sym);
break;
case VAR:
printf("(double *)\n");
break;
case OBJECTTMP: /* would use OBJECT if it existed */
printf("(Object *) %s\n", hoc_object_name(d->obj));
break;
case STKOBJ_UNREF: /* hoc_stkobj_ref already called */
printf("(Object * already unreffed by hoc_stkobj_ref at stkindex %ld. Following name print may cause a crash if already freed.\n", d - stack);
printf(" %s\n", hoc_object_name(d->obj));
break;
default:
printf("(Unknown)\n");
break;
}
}
}
#endif
double *hoc_pxpop(void) {/* pop double pointer and return top elem from stack */
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
tstkchk(stackp[-1].i, VAR);
stackp -= 2;
return stackp->pval;
}
Symbol *spop(void) {/* pop symbol pointer and return top elem from stack */
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
tstkchk(stackp[-1].i, SYMBOL);
stackp -= 2;
return stackp->sym;
}
/*
When using objpop, after dealing with the pointer, one should call
hoc_tobj_unref(pobj) in order to prevent memory leakage since
the object may have been reffed when it was pushed on the stack
*/
Object **hoc_objpop(void) {/* pop pointer to object pointer and return top elem from stack */
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
stackp -= 2;
if (stackp[1].i == OBJECTTMP) {
return hoc_temp_objptr(stackp->obj);
}
tstkchk(stackp[1].i, OBJECTVAR); /* safe because cannot be OBJECTTMP */
return stackp->pobj;
}
Object *hoc_pop_object(void) {/* pop object and return top elem from stack */
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
tstkchk(stackp[-1].i, OBJECTTMP);
stackp -= 2;
return stackp->obj;
}
char **hoc_strpop(void) { /* pop pointer to string pointer and return top elem from stack */
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
tstkchk(stackp[-1].i, STRING);
stackp -= 2;
return stackp->pstr;
}
int ipop(void) {/* pop symbol pointer and return top elem from stack */
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
tstkchk(stackp[-1].i, USERINT);
stackp -= 2;
return stackp->i;
}
void nopop(void) {/* just pop the stack without returning anything */
if (stackp <= stack)
execerror("stack underflow", (char *) 0);
stackp -= 2;
if (stackp[1].i == OBJECTTMP) {
hoc_stkobj_unref(stackp->obj, (int) (stackp - stack));
}
}
void constpush(void) /* push constant onto stack */
{
pushxm(*((pc++)->sym)->u.pnum);
}
void pushzero(void) /* push zero onto stack */
{
pushxm(0.);
}
void varpush(void) /* push variable onto stack */
{
pushsm((pc++)->sym);
}
# define relative(pc) (pc + (pc)->i)
void forcode(void) {
double d;
Inst *savepc = pc; /* loop body */
int isec;
#if CABLE
isec = nrn_isecstack();
#endif
execute(savepc + 3); /* condition */
d = xpopm();
while (d) {
execute(relative(savepc)); /* body */
#if CABLE
if (hoc_returning) {nrn_secstack(isec);}
#endif
if (hoc_returning == 1 || hoc_returning == 4) /* return or stop */
break;
else if (hoc_returning == 2) /* break */
{
hoc_returning = 0;
break;
} else /* continue */
hoc_returning = 0;
if ((savepc + 2)->i) /* diff between while and for */
execute(relative(savepc + 2)); /* increment */
execute(savepc + 3);
d = xpopm();
}
if (!hoc_returning)
pc = relative(savepc + 1); /* next statement */
}
static void warn_assign_dynam_unit(const char* name) {
static int first = 1;
if (first) {
char mes[100];
first = 0;
sprintf(mes, "Assignment to %s physical constant %s",
_nrnunit_use_legacy_ ? "legacy" : "modern",
name);
hoc_warning(mes, NULL);
}
}
void shortfor(void) {
Inst *savepc = pc;
double begin, end, *pval = 0;
Symbol *sym;
int isec;
end = xpopm() + EPS;
begin = xpopm();
sym = spopm();
switch (sym->type) {
case UNDEF:
hoc_execerror(sym->name, "undefined variable");
case VAR:
if (!ISARRAY(sym)) {
if (sym->subtype == USERINT) {
execerror("integer iteration variable", sym->name);
} else if (sym->subtype == USERDOUBLE) {
pval = sym->u.pval;
}else if (sym->subtype == DYNAMICUNITS) {
pval = sym->u.pval + _nrnunit_use_legacy_;
warn_assign_dynam_unit(sym->name);
} else {
pval = OPVAL(sym);
}
break;
} else {
if (sym->subtype == USERINT)
execerror("integer iteration variable", sym->name);
else if (sym->subtype == USERDOUBLE)
pval = sym->u.pval + araypt(sym, SYMBOL);
else
pval = OPVAL(sym) + araypt(sym, OBJECTVAR);
}
break;
case AUTO:
pval = &(fp->argn[sym->u.u_auto * 2].val);
break;
default:
execerror("for loop non-variable", sym->name);
}
#if CABLE
isec = nrn_isecstack();
#endif
for (*pval = begin; *pval <= end; *pval += 1.) {
execute(relative(savepc));
#if CABLE
if (hoc_returning) {nrn_secstack(isec);}
#endif
if (hoc_returning == 1 || hoc_returning == 4) {
break;
} else if (hoc_returning == 2) {
hoc_returning = 0;
break;
} else {
hoc_returning = 0;
}
}
if (!hoc_returning)
pc = relative(savepc + 1);
}
void hoc_iterator(void) {
/* pc is ITERATOR symbol, argcount, stmtbegin, stmtend */
/* for testing execute stmt once */
Symbol *sym;
int argcount;
Inst *stmtbegin, *stmtend;
sym = (pc++)->sym;
argcount = (pc++)->i;
stmtbegin = relative(pc);
stmtend = relative(pc + 1);;
hoc_iterator_object(sym, argcount, stmtbegin, stmtend, hoc_thisobject);
}
void hoc_iterator_object(
Symbol *sym,
int argcount,
Inst *beginpc,
Inst *endpc,
Object *ob
) {
int i;
fp++;
if (fp >= framelast) {
fp--;
execerror(sym->name, "call nested too deeply, increase with -NFRAME framesize option");
}
fp->sp = sym;
fp->nargs = argcount;
fp->retpc = endpc;
fp->argn = stackp - 2;
stackp += sym->u.u_proc->nauto * 2;
/* clear the autoobject pointers */
for (i = sym->u.u_proc->nobjauto; i > 0; --i) {
stackp[-2*i].obj = (Object*)0;
}
fp->iter_stmt_begin = beginpc;
fp->iter_stmt_ob = ob;
fp->ob = ob;
STACKCHK
execute(sym->u.u_proc->defn.in);
nopop(); /* 0.0 from the procret() */
if (hoc_returning != 4) {
hoc_returning = 0;
}
}
void hoc_iterator_stmt(void) {
Inst *pcsav;
Object *ob;
Object *obsav;
Objectdata *obdsav;
Symlist *slsav;
int isec;
Frame *iter_f = fp; /* iterator frame */
Frame *ef = fp - 1; /* iterator statement frame */
fp++; /* execution frame */
fp->sp = iter_f->sp;
fp->ob = iter_f->ob;
if (ef != frame) {
/*SUPPRESS 26*/
fp->argn = ef->argn;
fp->nargs = ef->nargs;
} else { /* top. only for stack trace */
fp->argn = 0;
fp->nargs = 0;
}
ob = iter_f->iter_stmt_ob;
obsav = hoc_thisobject;
obdsav = hoc_objectdata_save();
slsav = hoc_symlist;
hoc_thisobject = ob;
if (ob) {
hoc_objectdata = ob->u.dataspace;
hoc_symlist = ob->ctemplate->symtable;
} else {
hoc_objectdata = hoc_top_level_data;
hoc_symlist = hoc_top_level_symlist;
}
pcsav = pc;
#if CABLE
isec = nrn_isecstack();
#endif
execute(iter_f->iter_stmt_begin);
pc = pcsav;
hoc_objectdata = hoc_objectdata_restore(obdsav);
hoc_thisobject = obsav;
hoc_symlist = slsav;
--fp;
#if CABLE
if (hoc_returning) {nrn_secstack(isec);}
#endif
switch (hoc_returning) {
case 1: /* return means not only return from iter but return from
the procedure containing the iter statement */
hoc_execerror("return from within an iterator statement not allowed.",
"Set a flag and use break.");
case 2: /* break means return from iter */
procret();
break;
case 3: /* continue means go on from iter as though nothing happened*/
hoc_returning = 0;
break;
}
}
static void for_segment2(Symbol *sym, int mode) {
/* symbol on stack; statement pointed to by pc
continuation pointed to by pc+1. template used is shortfor in code.cpp
of hoc system.
*/
#if CABLE
int i, imax;
Inst *savepc = pc;
double *pval=0, dx;
int isec;
#if METHOD3
extern int _method3;
#endif
switch (sym->type) {
case UNDEF:
hoc_execerror(sym->name, "undefined variable");
case VAR:
if (!ISARRAY(sym)) {
if (sym->subtype == USERINT) {
execerror("integer iteration variable", sym->name);
}else if (sym->subtype == USERDOUBLE){
pval = sym->u.pval;
}else if (sym->subtype == DYNAMICUNITS) {
pval = sym->u.pval + _nrnunit_use_legacy_;
warn_assign_dynam_unit(sym->name);
}else{
pval = OPVAL(sym);
}
break;
} else {
if (sym->subtype == USERINT)
execerror("integer iteration variable", sym->name);
else if (sym->subtype == USERDOUBLE)
pval = sym->u.pval + araypt(sym, SYMBOL);
else
pval = OPVAL(sym) + araypt(sym, OBJECTVAR);
}
break;
case AUTO:
pval = &(fp->argn[sym->u.u_auto*2].val);
break;
default:
execerror("for loop non-variable", sym->name);
}
imax = segment_limits(&dx);
#if METHOD3
if (_method3) {
for (i=0, *pval=0; i <= imax; i++) {
if (mode == 0 && (i == imax || i == 0)) { continue; }
if (i == imax) {
*pval = 1.;
} else {
*pval = i * dx;
}
execute(relative(savepc));
if (hoc_returning == 1 || hoc_returning == 4) {
break;
}else if (hoc_returning == 2) {
hoc_returning = 0;
break;
}else{
hoc_returning = 0;
}
}
}else
#endif
{
if (mode == 0) {
i = 1;
*pval = dx/2.;
}else{
i = 0;
*pval = 0.;
}
#if CABLE
isec = nrn_isecstack();
#endif
for (; i <= imax; i++) {
if (i == imax) {
if (mode == 0) { continue; }
*pval = 1.;
}
execute(relative(savepc));
#if CABLE
if (hoc_returning) {nrn_secstack(isec);}
#endif
if (hoc_returning == 1 || hoc_returning == 4) {
break;
}else if (hoc_returning == 2) {
hoc_returning = 0;
break;
}else{
hoc_returning = 0;
}
if (i == 0) {
*pval += dx/2.;
}
else if (i < imax) {
*pval += dx;
}
}
}
if (!hoc_returning)
pc =relative(savepc+1);
#else
execerror("for (var) {stmt} syntax only allowed in CABLE", (char *) 0);
#endif
}
void for_segment(void) {
for_segment2(spopm(), 1);
}
void for_segment1(void) {
Symbol *sym;
double d;
int mode;
d = xpopm();
sym = spopm();
mode = (fabs(d) < EPS) ? 0 : 1;
for_segment2(sym, mode);
}
void ifcode(void) {
double d;
Inst *savepc = pc; /* then part */
execute(savepc + 3); /* condition */
d = xpopm();
if (d)
execute(relative(savepc));
else if ((savepc + 1)->i) /* else part? */
execute(relative(savepc + 1));
if (!hoc_returning)
pc = relative(savepc + 2); /* next stmt */
}
void Break(void) /* break statement */
{
hoc_returning = 2;
}
void Continue(void) /* continue statement */
{
hoc_returning = 3;
}
void Stop(void) /* stop statement */
{
hoc_returning = 4;
}
void hoc_define(Symbol *sp) { /* put func/proc in symbol table */
Inst *inst, *newinst;
if (sp->u.u_proc->defn.in != STOP)
free((char *) sp->u.u_proc->defn.in);
free_list(&(sp->u.u_proc->list));
sp->u.u_proc->list = p_symlist;
p_symlist = (Symlist *) 0;
sp->u.u_proc->size = (unsigned) (progp - progbase);
sp->u.u_proc->defn.in = (Inst *) emalloc((unsigned) (progp - progbase) * sizeof(Inst));
newinst = sp->u.u_proc->defn.in;
for (inst = progbase; inst != progp;)
*newinst++ = *inst++;
progp = progbase; /* next code starts here */
}
void frame_debug(void) /* print the call sequence on an execerror */
{
Frame *f;
int i, j;
char id[10];
if (nrnmpi_numprocs_world > 1) {
sprintf(id, "%d ", nrnmpi_myid_world);
} else {
id[0] = '\0';
}
for (i = 5, f = fp; f != frame && --i; f = f - 1) { /* print only to depth of 5 */
for (j = i; j; j--) {
Fprintf(stderr, " ");
}
if (f->ob) {
Fprintf(stderr, "%s%s.%s(", id, hoc_object_name(f->ob), f->sp->name);
} else {
Fprintf(stderr, "%s%s(", id, f->sp->name);
}
for (j = 1; j <= f->nargs;) {
switch (f->argn[(j - f->nargs) * 2 + 1].i) {
case NUMBER:
Fprintf(stderr, "%g", f->argn[(j - f->nargs) * 2].val);
break;
case STRING: {
char *s = *f->argn[(j - f->nargs) * 2].pstr;
if (strlen(s) > 15) {
Fprintf(stderr, "\"%.10s...\"", s);
} else {
Fprintf(stderr, "\"%s\"", s);
}
}
break;
case OBJECTVAR:
Fprintf(stderr, "%s", hoc_object_name(*f->argn[(j - f->nargs) * 2].pobj));
break;
default:
Fprintf(stderr, "...");
break;
}
if (++j <= f->nargs) {
Fprintf(stderr, ", ");
}
}
Fprintf(stderr, ")\n");
}
if (i <= 0) {
Fprintf(stderr, "and others\n");
}
}
void push_frame(Symbol *sp, int narg) { /* helpful for explicit function calls */
if (++fp >= framelast) {
--fp;
execerror(sp->name, "call nested too deeply, increase with -NFRAME framesize option");
}
fp->sp = sp;
fp->nargs = narg;
fp->argn = stackp - 2; /* last argument */
fp->ob = hoc_thisobject;
}
void pop_frame(void) {
int i;
frameobj_clean(fp);
for (i = 0; i < fp->nargs; i++)
nopopm(); /* pop arguments */
--fp;
}
void call(void) /* call a function */
{
int i, isec;
Symbol *sp = pc[0].sym; /* symbol table entry */
/* for function */
if (++fp >= framelast) {
--fp;
execerror(sp->name, "call nested too deeply, increase with -NFRAME framesize option");
}
fp->sp = sp;
fp->nargs = pc[1].i;
fp->retpc = pc + 2;
fp->ob = hoc_thisobject;
/*SUPPRESS 26*/
fp->argn = stackp - 2; /* last argument */
BBSPOLL
#if CABLE
isec = nrn_isecstack();
#endif
if (sp->type == FUN_BLTIN || sp->type == OBJECTFUNC || sp->type == STRINGFUNC) {
stackp += sp->u.u_proc->nauto * 2; /* Offset stack for auto space */
STACKCHK
(*(sp->u.u_proc->defn.pf))();
if (hoc_errno_check()) {
hoc_warning("errno set during call of", sp->name);
}
} else if ((sp->type == FUNCTION || sp->type == PROCEDURE || sp->type == HOCOBJFUNCTION)
&& sp->u.u_proc->defn.in != STOP) {
stackp += sp->u.u_proc->nauto * 2; /* Offset stack for auto space */
STACKCHK
/* clear the autoobject pointers. */
for (i = sp->u.u_proc->nobjauto; i > 0; --i) {
stackp[-2*i].obj = (Object*)0;
}
if (sp->cpublic == 2) {
Objectdata *odsav = hoc_objectdata_save();
Object *obsav = hoc_thisobject;
Symlist *slsav = hoc_symlist;
hoc_objectdata = hoc_top_level_data;
hoc_thisobject = 0;
hoc_symlist = hoc_top_level_symlist;
execute(sp->u.u_proc->defn.in);
hoc_objectdata = hoc_objectdata_restore(odsav);
hoc_thisobject = obsav;
hoc_symlist = slsav;
} else {
execute(sp->u.u_proc->defn.in);
}
/* the autoobject pointers were unreffed at the ret() */
} else {
execerror(sp->name, "undefined function");
}
#if CABLE
if (hoc_returning) {nrn_secstack(isec);}
#endif
if (hoc_returning != 4) { /*if not stopping */
hoc_returning = 0;
}
}
void hoc_fake_call(Symbol *s) {
/*fake it so c code can call functions that ret() */
/* but these functions better not ask for any arguments */
/* don't forget a double is left on the stack and returning = 1 */
/* use the symbol for the function as the argument, only requirement
which is always true is that it has no local variables pushed on
the stack so nauto=0 and nobjauto=0 */
++fp;
fp->sp = s;
fp->nargs = 0;
fp->retpc = pc;
fp->ob = 0;
}
double hoc_call_func(Symbol *s, int narg) {
/* call the symbol as a function, The args better be pushed on the stack
first arg first. */
if (s->type == BLTIN) {
return (*(s->u.ptr))(xpop());
} else {
Inst *pcsav;
Inst fc[4];
fc[0].pf = hoc_call;
fc[1].sym = s;
fc[2].i = narg;
fc[3].in = STOP;
pcsav = hoc_pc;
hoc_execute(fc);
hoc_pc = pcsav;
return hoc_xpop();
}
}
void hoc_ret(void) { /* common return from func, proc, or iterator */
int i;
/* unref all the auto object pointers */
for (i = fp->sp->u.u_proc->nobjauto; i > 0; --i) {
hoc_obj_unref(stackp[-2 * i].obj);
}
stackp -= fp->sp->u.u_proc->nauto * 2; /* Pop off the autos */
frameobj_clean(fp);
for (i = 0; i < fp->nargs; i++)
nopopm(); /* pop arguments */
pc = (Inst *) fp->retpc;
--fp;
hoc_returning = 1;
}
void funcret(void) /* return from a function */
{
double d;
if (fp->sp->type != FUNCTION)
execerror(fp->sp->name, "(proc or iterator) returns value");
d = xpopm(); /* preserve function return value */
ret();
pushxm(d);
}
void procret(void) /* return from a procedure */
{
if (fp->sp->type == FUNCTION)
execerror(fp->sp->name,
"(func) returns no value");
if (fp->sp->type == HOCOBJFUNCTION)
execerror(fp->sp->name,
"(obfunc) returns no value");
ret();
pushxm(0.); /*will be popped immediately; necessary because caller
may have compiled it as a function*/
}
void hocobjret(void) /* return from a hoc level obfunc */
{
Object **d;
if (fp->sp->type != HOCOBJFUNCTION)
execerror(fp->sp->name, "objfunc returns objref");
d = hoc_objpop(); /* preserve function return value */
if (*d) { (*d)->refcount++; }
ret();
/*make a temp and ref it in case autoobj returned since ret would
have unreffed it*/
hoc_push_object(*d);
if (*d) { (*d)->refcount--; }
hoc_tobj_unref(d);
}
void hoc_Numarg(void) {
int narg;
Frame *f = fp - 1;
if (f == frame) {
narg = 0;
} else {
narg = f->nargs;
}
ret();
pushxm((double) narg);
}
void hoc_Argtype(void) {
int narg, iarg, type, itype = 0;
Frame *f = fp - 1;
if (f == frame) {
execerror("argtype can only be called in a func or proc", 0);
}
iarg = (int) chkarg(1, -1000., 100000.);
if (iarg > f->nargs || iarg < 1) {
itype = -1;
} else {
type = (f->argn[(iarg - f->nargs) * 2 + 1].i);
switch (type) {
case NUMBER:
itype = 0;
break;
case OBJECTVAR:
case OBJECTTMP:
itype = 1;
break;
case STRING:
itype = 2;
break;
case VAR:
itype = 3;
break;
}
}
ret();
pushxm((double) itype);
}
extern "C" int ifarg(int narg) { /* true if there is an nth argument */
if (narg > fp->nargs)
return 0;
return 1;
}
Object **hoc_objgetarg(int narg) {/* return pointer to nth argument */
Datum *d;
if (narg > fp->nargs)
execerror(fp->sp->name, "not enough arguments");
d = fp->argn + (narg - fp->nargs) * 2;
if (d[1].i == OBJECTTMP) {
return hoc_temp_objptr(d[0].obj);
}
tstkchk(d[1].i, OBJECTVAR);
return d[0].pobj;
}
char **hoc_pgargstr(int narg) { /* return pointer to nth argument */
char **cpp = NULL;
Symbol *sym;
int type;
if (narg > fp->nargs)
execerror(fp->sp->name, "not enough arguments");
type = fp->argn[(narg - fp->nargs) * 2 + 1].i;
if (type == STRING) {
cpp = fp->argn[(narg - fp->nargs) * 2].pstr;
} else if (type != SYMBOL) {
execerror("Expecting string argument", (char *) 0);
} else {
sym = fp->argn[(narg - fp->nargs) * 2].sym;
if (sym->type == CSTRING) {
cpp = &sym->u.cstr;
} else if (sym->type == STRING) {
cpp = OPSTR(sym);
} else {
execerror("Expecting string argument", (char *) 0);
}
}
return cpp;
}
double *hoc_pgetarg(int narg) { /* return pointer to nth argument */
if (narg > fp->nargs)
execerror(fp->sp->name, "not enough arguments");
tstkchk(fp->argn[(narg - fp->nargs) * 2 + 1].i, VAR);
return fp->argn[(narg - fp->nargs) * 2].pval;
}
extern "C" double *getarg(int narg) { /* return pointer to nth argument */
if (narg > fp->nargs)
execerror(fp->sp->name, "not enough arguments");
#if 1
tstkchk(fp->argn[(narg - fp->nargs) * 2 + 1].i, NUMBER);
#endif
return &fp->argn[(narg - fp->nargs) * 2].val;
}
int hoc_argindex(void) {
int j;
j = (int) xpopm();
if (j < 1) {
hoc_execerror("arg index i < 1", 0);
}
return j;
}
void arg(void) /* push argument onto stack */
{
int i;
i = (pc++)->i;
if (i == 0) {
i = hoc_argindex();
}
pushxm(*getarg(i));
}
void hoc_stringarg(void) /* push string arg onto stack */
{
int i;
i = (pc++)->i;
if (i == 0) {
i = hoc_argindex();
}
hoc_pushstr(hoc_pgargstr(i));
}
double hoc_opasgn(int op, double dest, double src) {
switch (op) {
case '+':
return dest + src;
case '*':
return dest * src;
case '-':
return dest - src;
case '/':
if (src == 0.) {
hoc_execerror("Divide by 0", (char *) 0);
}
return dest / src;
default:
return src;
}
}
void argassign(void) /* store top of stack in argument */
{
double d;
int i, op;
i = (pc++)->i;
if (i == 0) {
i = hoc_argindex();
}
op = (pc++)->i;
d = xpopm();
if (op) {
d = hoc_opasgn(op, *getarg(i), d);
}
pushxm(d); /* leave value on stack */
*getarg(i) = d;
}
void hoc_argrefasgn(void) {
double d, *pd;
int i, j, op;
i = (pc++)->i;
j = (pc++)->i;
if (i == 0) {
i = hoc_argindex();
}
op = (pc++)->i;
d = xpopm();
if (j) {
j = (int) (xpopm() + EPS);
}
pd = hoc_pgetarg(i);
if (op) {
d = hoc_opasgn(op, pd[j], d);
}
pushxm(d); /* leave value on stack */
pd[j] = d;
}
void hoc_argref(void) {
int i, j;
double *pd;
i = (pc++)->i;
j = (pc++)->i;
if (i == 0) {
i = hoc_argindex();
}
pd = hoc_pgetarg(i);
if (j) {
j = (int) (xpopm() + EPS);
}
pushxm(pd[j]);
}
void hoc_argrefarg(void) {
double *pd;
int i;
i = (pc++)->i;
if (i == 0) {
i = hoc_argindex();
}
pd = hoc_pgetarg(i);
hoc_pushpx(pd);
}
void bltin(void) /* evaluate built-in on top of stack */
{
double d;
d = xpopm();
d = (*((pc++)->sym->u.ptr))(d);
pushxm(d);
}
extern "C" Symbol *hoc_get_symbol(const char *var) {
Symlist *sl = (Symlist *) 0;
Symbol *prc, *sym;
Inst *last;
prc = hoc_parse_stmt(var, &sl);
hoc_run_stmt(prc);
last = (Inst *) prc->u.u_proc->defn.in + prc->u.u_proc->size - 1;
if (last[-2].pf == eval) {
sym = last[-3].sym;
} else if (last[-3].pf == rangepoint || last[-3].pf == rangevareval) {
sym = last[-2].sym;
} else if (last[-4].pf == hoc_object_eval) {
sym = last[-10].sym;
} else {
sym = (Symbol *) 0;
}
free_list(&sl);
return sym;
}
Symbol *hoc_get_last_pointer_symbol(void) {/* hard to imagine a kludgier function*/
Symbol *sym = (Symbol *) 0;
Inst *pcv;
int istop = 0;
for (pcv = pc; pcv; --pcv) {
if (pcv->pf == hoc_ob_pointer) {
if (pcv[-2].sym) {
sym = pcv[-2].sym; /* e.g. &ExpSyn[0].A */
} else {
sym = pcv[-6].sym; /* e.g. & Cell[0].soma.v(.5) */
}
break;
} else if (pcv->pf == hoc_evalpointer) {
sym = pcv[-1].sym;
break;
} else if (pcv->pf == rangevarevalpointer) {
sym = pcv[1].sym;
break;
} else if (pcv->in == STOP) {
/* hopefully only got here from python. Give up on second STOP*/
if (istop++ == 1) {
break;
}
}
}
return sym;
}
void hoc_autoobject(void) { /* AUTOOBJ symbol at pc+1. */
/* pointer to object pointer left on stack */
int i;
Symbol *obs;
Object **obp;
#if PDEBUG
printf("code for hoc_autoobject()\n");
#endif
obs = (pc++)->sym;
hoc_pushobj(&(fp->argn[obs->u.u_auto * 2].obj));
}
void eval(void) /* evaluate variable on stack */
{
Objectdata *odsav;
Object *obsav = 0;
Symlist *slsav;
double d = 0.0;
extern double cable_prop_eval(Symbol *);
Symbol *sym;
sym = spopm();
if (sym->cpublic == 2) {
sym = sym->u.sym;
odsav = hoc_objectdata_save();
obsav = hoc_thisobject;
slsav = hoc_symlist;
hoc_objectdata = hoc_top_level_data;
hoc_thisobject = 0;
hoc_symlist = hoc_top_level_symlist;
}
switch (sym->type) {
case UNDEF:
execerror("undefined variable", sym->name);
case VAR:
if (!ISARRAY(sym)) {
if (do_equation && sym->s_varn > 0
&& hoc_access[sym->s_varn] == 0) {
hoc_access[sym->s_varn] = var_access;
var_access = sym->s_varn;
}
switch (sym->subtype) {
case USERDOUBLE:
d = *(sym->u.pval);
break;
case USERINT:
d = (double) (*(sym->u.pvalint));
break;
case DYNAMICUNITS:
d = sym->u.pval[_nrnunit_use_legacy_];
break;
#if CABLE
case USERPROPERTY:
d = cable_prop_eval(sym);
break;
#endif
case USERFLOAT:
d = (double) (*(sym->u.pvalfloat));
break;
default:
d = *(OPVAL(sym));
break;
}
} else {
switch (sym->subtype) {
case USERDOUBLE:
d = (sym->u.pval)[araypt(sym, SYMBOL)];
break;
case USERINT:
d = (sym->u.pvalint)[araypt(sym, SYMBOL)];
break;
case USERFLOAT:
d = (sym->u.pvalfloat)[araypt(sym, SYMBOL)];
break;
#if NEMO
case NEMONODE:
hoc_eval_nemonode(sym, xpopm(), &d);
break;
case NEMOAREA:
hoc_eval_nemoarea(sym, xpopm(), &d);
break;
#endif /*NEMO*/
default:
d = (OPVAL(sym))[araypt(sym, OBJECTVAR)];
break;
}
}
break;
case AUTO:
d = fp->argn[sym->u.u_auto * 2].val;
break;
default:
execerror("attempt to evaluate a non-variable", sym->name);
}
if (obsav) {
hoc_objectdata = hoc_objectdata_restore(odsav);
hoc_thisobject = obsav;
hoc_symlist = slsav;
}
pushxm(d);
}
void hoc_evalpointer(void) /* leave pointer to variable on stack */
{
Objectdata *odsav;
Object *obsav = 0;
Symlist *slsav;
double *d = 0;
//*cable_prop_eval_pointer();
Symbol *sym;
sym = spopm();
if (sym->cpublic == 2) {
sym = sym->u.sym;
odsav = hoc_objectdata_save();
obsav = hoc_thisobject;
slsav = hoc_symlist;
hoc_objectdata = hoc_top_level_data;
hoc_thisobject = 0;
hoc_symlist = hoc_top_level_symlist;
}
switch (sym->type) {
case UNDEF:
execerror("undefined variable", sym->name);
case VAR:
if (!ISARRAY(sym)) {
switch (sym->subtype) {
case USERDOUBLE:
d = sym->u.pval;
break;
case USERINT:
case USERFLOAT:
execerror("can use pointer only to doubles", sym->name);
break;
case DYNAMICUNITS:
d = sym->u.pval + _nrnunit_use_legacy_;
break;
#if CABLE
case USERPROPERTY:
d = cable_prop_eval_pointer(sym);
break;
#endif
default:
d = OPVAL(sym);
break;
}
} else {
switch (sym->subtype) {
case USERDOUBLE:
d = sym->u.pval + araypt(sym, SYMBOL);
break;
case USERINT:
case USERFLOAT:
#if NEMO
case NEMONODE:
case NEMOAREA:
#endif /*NEMO*/
execerror("can use pointer only to doubles", sym->name);
break;
default:
d = OPVAL(sym) + araypt(sym, OBJECTVAR);
break;
}
}
break;
case AUTO:
#if 0
execerror("can't use pointer to local variable", sym->name);
#else
d = &(fp->argn[sym->u.u_auto * 2].val);
#endif
break;
default:
execerror("attempt to evaluate pointer to a non-variable", sym->name);
}
if (obsav) {
hoc_objectdata = hoc_objectdata_restore(odsav);
hoc_thisobject = obsav;
hoc_symlist = slsav;
}
hoc_pushpx(d);
}
void add(void) /* add top two elems on stack */
{
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 += d2;
pushxm(d1);
}
void hoc_sub(void) /* subtract top two elems on stack */
{
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 -= d2;
pushxm(d1);
}
void mul(void) /* multiply top two elems on stack */
{
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 *= d2;
pushxm(d1);
}
#if _CRAY
/*
try to do integer division, so that if x is an exact multiple of y
then we really get an integer as the result.
Algorithm: find n such that tx = x * 10^n and ty = y * 10^n are both
integral. If tx/ty leaves no remainder, then tx/ty is the correct
answer and is stored in iptr, intdiv returns true. Otherwise a
floating point division can be done, intdiv returns false.
*/
static int intdiv(double x, double y, int* iptr) {
long ix, iy, iz;
int done = 0;
while (!done)
{
if (fabs(x) > (1<<62) || fabs(y) > (1<<62))
return 0; /* out of range of integers */
if (x == (long) x && y == (long) y)
done = 1;
else
{
x *= (long double) 10;
y *= (long double) 10;
}
}
ix = (long) x;
iy = (long) y;
iz = ix/iy;
if (ix == iz*iy)
{ /* no remainder */
*iptr = (int) iz;
return 1;
}
return 0;
}
#endif
void hoc_div(void) /* divide top two elems on stack */
{
double d1, d2;
d2 = xpopm();
if (d2 == 0.0)
execerror("division by zero", (char *) 0);
d1 = xpopm();
#if _CRAY
{
int i;
if (intdiv(d1, d2, &i))
d1 = (int) i; /* result is an integer */
else
d1 = d1/d2; /* result is not an integer */
}
#else
d1 /= d2;
#endif
pushxm(d1);
}
void hoc_cyclic(void) /* the modulus function */
{
double d1, d2;
double r, q;
d2 = xpopm();
if (d2 <= 0.)
execerror("a%b, b<=0", (char *) 0);
d1 = xpopm();
r = d1;
if (r >= d2) {
q = floor(d1 / d2);
r = d1 - q * d2;
} else if (r <= -d2) {
q = floor(-d1 / d2);
r = d1 + q * d2;
}
if (r > d2) {
r = r - d2;
}
if (r < 0.) {
r = r + d2;
}
pushxm(r);
}
void negate(void) /* negate top element on stack */
{
double d;
d = xpopm();
pushxm(-d);
}
void gt(void) {
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 = (double) (d1 > d2 + EPS);
pushxm(d1);
}
void lt(void) {
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 = (double) (d1 < d2 - EPS);
pushxm(d1);
}
void ge(void) {
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 = (double) (d1 >= d2 - EPS);
pushxm(d1);
}
void le(void) {
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 = (double) (d1 <= d2 + EPS);
pushxm(d1);
}
void eq(void) {
int t1, t2;
double d1 = 0.0, d2;
t1 = (stackp - 1)->i;
t2 = (stackp - 3)->i;
switch (t2) {
case NUMBER:
tstkchk(t1, t2);
d2 = xpopm();
d1 = xpopm();
d1 = (double) (d1 <= d2 + EPS && d1 >= d2 - EPS);
break;
case STRING:
d1 = (double) (strcmp(*hoc_strpop(), *hoc_strpop()) == 0);
break;
case OBJECTTMP:
case OBJECTVAR:
{ Object** o1, **o2;
o1 = hoc_objpop();
o2 = hoc_objpop();
d1 = (double) (*o1 == *o2);
hoc_tobj_unref(o1);
hoc_tobj_unref(o2);
}
break;
default:
hoc_execerror("don't know how to compare these types", (char *) 0);
}
pushxm(d1);
}
void ne(void) {
int t1, t2;
double d1 = 0.0, d2;
t1 = (stackp - 1)->i;
t2 = (stackp - 3)->i;
switch (t1) {
case NUMBER:
tstkchk(t1, t2);
d2 = xpopm();
d1 = xpopm();
d1 = (double) (d1 < d2 - EPS || d1 > d2 + EPS);
break;
case STRING:
d1 = (double) (strcmp(*hoc_strpop(), *hoc_strpop()) != 0);
break;
case OBJECTTMP:
case OBJECTVAR:
{ Object** o1, **o2;
o1 = hoc_objpop();
o2 = hoc_objpop();
d1 = (double) (*o1 != *o2);
hoc_tobj_unref(o1);
hoc_tobj_unref(o2);
}
break;
default:
hoc_execerror("don't know how to compare these types", (char *) 0);
}
pushxm(d1);
}
void hoc_and(void) {
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 = (double) (d1 != 0.0 && d2 != 0.0);
pushxm(d1);
}
void hoc_or(void) {
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 = (double) (d1 != 0.0 || d2 != 0.0);
pushxm(d1);
}
void hoc_not(void) {
double d;
d = xpopm();
d = (double) (d == 0.0);
pushxm(d);
}
void power(void) /* arg1 raised to arg2 */
{
double d1, d2;
d2 = xpopm();
d1 = xpopm();
d1 = Pow(d1, d2);
pushxm(d1);
}
void assign(void) /* assign result of execute to top symbol */
{
Objectdata *odsav;
Object *obsav = 0;
Symlist *slsav;
int op;
Symbol *sym;
double d2;
op = (pc++)->i;
sym = spopm();
if (sym->cpublic == 2) {
sym = sym->u.sym;
odsav = hoc_objectdata_save();
obsav = hoc_thisobject;
slsav = hoc_symlist;
hoc_objectdata = hoc_top_level_data;
hoc_thisobject = 0;
hoc_symlist = hoc_top_level_symlist;
}
d2 = xpopm();
switch (sym->type) {
case UNDEF:
hoc_execerror(sym->name, "undefined variable");
case VAR:
if (!ISARRAY(sym)) {
switch (sym->subtype) {
case USERDOUBLE:
if (op) {
d2 = hoc_opasgn(op, *(sym->u.pval), d2);
}
*(sym->u.pval) = d2;
break;
case USERINT:
if (op) {
d2 = hoc_opasgn(op, (double) (*(sym->u.pvalint)), d2);
}
*(sym->u.pvalint) = (int) (d2 + EPS);
break;
#if CABLE
case USERPROPERTY:
cable_prop_assign(sym, &d2, op);
break;
#endif
case USERFLOAT:
if (op) {
d2 = hoc_opasgn(op, (double) (*(sym->u.pvalfloat)), d2);
}
*(sym->u.pvalfloat) = (float) (d2);
break;
case DYNAMICUNITS:
if (op) {
d2 = hoc_opasgn(op, sym->u.pval[_nrnunit_use_legacy_], d2);
}
sym->u.pval[_nrnunit_use_legacy_] = (float)(d2);
warn_assign_dynam_unit(sym->name);
break;
default:
if (op) {
d2 = hoc_opasgn(op, *(OPVAL(sym)), d2);
}
*(OPVAL(sym)) = d2;
break;
}
} else {
int ind;
switch (sym->subtype) {
case USERDOUBLE:
ind = araypt(sym, SYMBOL);
if (op) {
d2 = hoc_opasgn(op, (sym->u.pval)[ind], d2);
}
(sym->u.pval)[ind] = d2;
break;
case USERINT:
ind = araypt(sym, SYMBOL);
if (op) {
d2 = hoc_opasgn(op, (double) ((sym->u.pvalint)[ind]), d2);
}
(sym->u.pvalint)[ind] = (int) (d2 + EPS);
break;
case USERFLOAT:
ind = araypt(sym, SYMBOL);
if (op) {
d2 = hoc_opasgn(op, (double) ((sym->u.pvalfloat)[ind]), d2);
}
(sym->u.pvalfloat)[ind] = (float) d2;
break;
#if NEMO
case NEMONODE:
hoc_asgn_nemonode(sym, xpopm(), &d2, op);
break;
case NEMOAREA:
hoc_asgn_nemoarea(sym, xpopm(), &d2, op);
break;
#endif /*NEMO*/
default:
ind = araypt(sym, OBJECTVAR);
if (op) {
d2 = hoc_opasgn(op, (OPVAL(sym))[ind], d2);
}
(OPVAL(sym))[ind] = d2;
break;
}
}
break;
case AUTO:
if (op) {
d2 = hoc_opasgn(op, fp->argn[sym->u.u_auto * 2].val, d2);
}
fp->argn[sym->u.u_auto * 2].val = d2;
break;
default:
execerror("assignment to non-variable", sym->name);
}
if (obsav) {
hoc_objectdata = hoc_objectdata_restore(odsav);
hoc_thisobject = obsav;
hoc_symlist = slsav;
}
pushxm(d2);
}
void hoc_assign_str(char **cpp, const char *buf) {
char *s = *cpp;
*cpp = (char *) emalloc((unsigned) (strlen(buf) + 1));
Strcpy(*cpp, buf);
if (s) {
hoc_free_string(s);
}
}
void assstr(void) { /* assign string on top to stack - 1 */
char **ps1, **ps2;
ps1 = hoc_strpop();
ps2 = hoc_strpop();
hoc_assign_str(ps2, *ps1);
}
char *hoc_araystr(Symbol *sym, int index, Objectdata *obd) { /* returns array string for multiple dimensions */
static char name[100];
char *cp = name + 100;
char buf[20];
int i, n, j, n1;
*--cp = '\0';
if (ISARRAY(sym)) {
Arrayinfo *a;
if (sym->subtype == 0) {
a = obd[sym->u.oboff + 1].arayinfo;
} else {
a = sym->arayinfo;
}
for (i = a->nsub - 1; i >= 0; --i) {
n = a->sub[i];
j = index % n;
index /= n;
Sprintf(buf, "%d", j);
n1 = strlen(buf);
assert(n1 + 2 < cp - name);
*--cp = ']';
for (j = n1 - 1; j >= 0; --j) {
*--cp = buf[j];
}
*--cp = '[';
}
}
return cp;
}
int hoc_array_index(Symbol *sp, Objectdata *od) { /* subs must be in reverse order on stack */
int i;
if (ISARRAY(sp)) {
if (sp->subtype == 0) {
Objectdata *sav = hoc_objectdata;
hoc_objectdata = od;
i = araypt(sp, OBJECTVAR);
hoc_objectdata = sav;
} else {
i = araypt(sp, 0);
}
} else {
i = 0;
}
return i;
}
int araypt(Symbol *sp, int type) { /* return subscript - subs in reverse order on stack */
int i, total, varn;
int d;
Arrayinfo *aray;
if (type == OBJECTVAR) {
aray = OPARINFO(sp);
} else {
aray = sp->arayinfo;
}
total = 0;
for (i = 0; i < aray->nsub; i++) {
tstkchk((stackp - 2 * (aray->nsub - i) + 1)->i, NUMBER);
d = (int) ((stackp - 2 * (aray->nsub - i))->val + EPS);
if (d < 0 || d >= aray->sub[i])
execerror("subscript out of range", sp->name);
total = total * (aray->sub[i]) + d;
}
for (i = 0; i < aray->nsub; i++)
nopopm();
if (do_equation && sp->s_varn != 0
&& (varn = (aray->a_varn)[total]) != 0 && hoc_access[varn] == 0) {
hoc_access[varn] = var_access;
var_access = varn;
}
return total;
}
/* obsolete */
#if CABLE && 0
int nrnpnt_araypt(Symbol* sp, int pi) {
int i, total;
int d;
Arrayinfo *aray = sp->arayinfo;
/* the difference is that the first index is for a neuron point
process vector, and the remaining incices are normal vector indices.
the return value is the parameter index and the first
index is returned in pi. return is 0 if not a vector or if element 0.
*/
total = 0;
for (i = 0; i < aray->nsub; i++)
{
tstkchk((stackp - 2*(aray->nsub - i) + 1)->i, NUMBER);
d = (int)((stackp - 2*(aray->nsub - i))->val + EPS);
if (d < 0 || d >= aray->sub[i])
execerror("subscript out of range", sp->name);
total = total * (aray->sub[i]) + d;
if (i == 0) {
*pi = total;
total = 0;
}
}
for (i = 0; i< aray->nsub; i++)
nopopm();
return total;
}
#endif
void print(void) /* pop top value from stack, print it */
{
#if defined(__GO32__)
extern int egagrph;
if (egagrph) {
char buf[50];
sprintf(buf, "\t");
grx_output_some_chars(buf, strlen(buf));
prexpr();
grx_output_some_chars("\n", 1);
}else
#endif
{
nrnpy_pr("\t");
prexpr();
nrnpy_pr("\n");
}
}
void prexpr(void) /* print numeric value */
{
static HocStr *s;
char *ss;
#if CABLE
extern char* secaccessname();
#endif
Object **pob;
if (!s) s = hocstr_create(256);
switch (hoc_stacktype()) {
case NUMBER:
Sprintf(s->buf, "%.8g ", xpopm());
break;
case STRING:
ss = *(hoc_strpop());
hocstr_resize(s, strlen(ss) + 1);
Sprintf(s->buf, "%s ", ss);
break;
case OBJECTTMP:
case OBJECTVAR:
pob = hoc_objpop();
Sprintf(s->buf, "%s ", hoc_object_name(*pob));
hoc_tobj_unref(pob);
break;
#if 0 && CABLE
case SECTION:
Sprintf(s->buf, "%s ", secaccessname());
break;
#endif
default:
hoc_execerror("Don't know how to print this type\n", 0);
}
plprint(s->buf);
}
void prstr(void) /* print string value */
{
static HocStr *s;
char **cpp;
if (!s) s = hocstr_create(256);
cpp = hoc_strpop();
hocstr_resize(s, strlen(*cpp) + 10);
Sprintf(s->buf, "%s", *cpp);
plprint(s->buf);
}
/*-----------------------------------------------------------------*/
void hoc_delete_symbol(void)
/* Added 15-JUN-90 by JCW. This routine deletes a
"defined-on-the-fly" variable from the symbol
list. */
/* modified greatly by Hines. Very unsafe in general. */
{
#if 1
/*---- local variables -----*/
Symbol *doomed,
*sp;
/*---- start function ------*/
/* copy address of the symbol that will be deleted */
doomed = (pc++)->sym;
#endif
/* hoc_execerror("delete_symbol doesn't work right now.", (char *)0);*/
#if 1
if (doomed->type == UNDEF)
fprintf(stderr, "%s: no such variable\n", doomed->name);
else if (doomed->defined_on_the_fly == 0)
fprintf(stderr, "%s: can't be deleted\n", doomed->name);
else {
extern void hoc_free_symspace(Symbol*);
hoc_free_symspace(doomed);
}
#endif
}
/*----------------------------------------------------------*/
void hoc_newline(void) /* print newline */
{
plprint("\n");
}
void varread(void) /* read into variable */
{
double d = 0.0;
extern NrnFILEWrap *fin;
Symbol *var = (pc++)->sym;
assert(var->cpublic != 2);
if (!((var->type == VAR || var->type == UNDEF) && !ISARRAY(var)
&& var->subtype == NOTUSER
)
) {
execerror(var->name, "is not a scalar variable");
}
Again:
switch (nrn_fw_fscanf(fin, "%lf", OPVAL(var))) {
case EOF:
if (moreinput())
goto Again;
d = *(OPVAL(var)) = 0.0;
break;
case 0:
execerror("non-number read into", var->name);
break;
default:
d = 1.0;
break;
}
var->type = VAR;
pushxm(d);
}
static Inst *codechk(void) {
if (progp >= prog + NPROG - 1)
execerror("procedure too big", (char *) 0);
if (zzdebug)
debugzz(progp);
return progp++;
}
Inst *Code(Pfrv f) { /* install one instruction or operand */
progp->pf = f;
return codechk();
}
Inst *codei(int f) {
progp->pf = NULL;/* zero high order bits to avoid debugzz problem */
progp->i = f;
return codechk();
}
Inst *hoc_codeptr(void *vp) {
progp->ptr = vp;
return codechk();
}
void codesym(Symbol *f) {
progp->sym = f;
IGNORE(codechk());
}
void codein(Inst *f) {
progp->in = f;
IGNORE(codechk());
}
void insertcode(Inst *begin, Inst *end, Pfrv f) {
Inst *i;
for (i = end - 1; i != begin; i--) {
*i = *(i - 1);
}
begin->pf = f;
if (zzdebug) {
Inst *p;
printf("insert code: what follows is the entire code so far\n");
for (p = prog; p < progp; ++p) {
debugzz(p);
}
printf("end of insert code debugging\n");
}
}
#if defined(DOS) || defined(__GO32__) || defined (WIN32) || (MAC && !defined(DARWIN))
static int ntimes;
#endif
void execute(Inst *p) /* run the machine */
{
Inst *pcsav;
BBSPOLL
for (pc = p; pc->in != STOP && !hoc_returning;) {
#if defined(DOS)
if (++ntimes > 10) {
ntimes = 0;
#if 0
kbhit(); /* DOS can't capture interrupt when number crunching*/
#endif
}
#endif
#if defined(__GO32__) || (defined(WIN32) && !defined(CYGWIN))
if (++ntimes > 10) {
ntimes = 0;
hoc_check_intupt(1);
}
#endif
#if MAC && !defined(DARWIN)
/* there is significant overhead here */
if (++ntimes > 100) {
ntimes = 0;
hoc_check_intupt(1);
}
#endif
if (intset)
execerror("interrupted", (char *) 0);
/* (*((pc++)->pf))(); DEC 5000 increments pc after the return!*/
pcsav = pc++;
(*((pcsav)->pf))();
}
}
| 27.243314 | 158 | 0.52076 | [
"object",
"vector"
] |
c12ebde78e7dda0e70293db8c9be846c8db6eb40 | 4,412 | cpp | C++ | xtd.forms/src/xtd/forms/application.cpp | lineCode/xtd.forms | 53b126a41513b4009870498b9f8e522dfc94c8de | [
"MIT"
] | 1 | 2022-02-04T08:15:31.000Z | 2022-02-04T08:15:31.000Z | xtd.forms/src/xtd/forms/application.cpp | lineCode/xtd.forms | 53b126a41513b4009870498b9f8e522dfc94c8de | [
"MIT"
] | null | null | null | xtd.forms/src/xtd/forms/application.cpp | lineCode/xtd.forms | 53b126a41513b4009870498b9f8e522dfc94c8de | [
"MIT"
] | null | null | null | #include <chrono>
#include <xtd/xtd.io.hpp>
#include <xtd/environment.hpp>
#include <xtd/forms/native/application.hpp>
#include <xtd/forms/window_messages.hpp>
#include "../../../include/xtd/forms/application.hpp"
using namespace std;
using namespace xtd;
using namespace xtd::forms;
bool application::message_loop_ = false;
bool application::allow_quit() {
return native::application::allow_quit();
}
string application::common_app_data_path() {
//string common_app_data_path = io::combine(environment::get_folder_path(environment::special_folder::common_application_data), company_name(), product_name(), product_version());
//if (!io:directory::exists(common_app_data_path))
// io::directory::create_directory(common_app_data_path);
//return commonApp_data_path;
return "";
}
/*
microsoft::win32::registry_key application::common_app_data_registry() {
return microsoft::win32::registry::local_machine().create_sub_key("Software").create_sub_key(company_name()).create_sub_key(product_name()).create_sub_key(product_version());
}
*/
string application::company_name() {
if (!strings::is_empty(application_informations::company_name())) return application_informations::company_name();
return io::path::get_file_name_without_extension(executable_path());
}
string application::executable_path() {
return environment::get_command_line_args()[0];
}
bool application::message_loop() {
return message_loop_;
}
vector<reference_wrapper<form>> application::open_forms() {
vector<reference_wrapper<form>> forms;
for (auto control : control::top_level_controls_)
forms.push_back(static_cast<form&>(control.get()));
return forms;
/*
vector<reference_wrapper<form>> forms;
for (intptr_t handle : native::application::open_forms()) {
control& control = control::from_handle(handle);
forms.push_back(static_cast<form&>(control));
}
return forms;
*/
}
string application::product_name() {
if (!strings::is_empty(application_informations::product_name())) return application_informations::product_name();
return io::path::get_file_name_without_extension(executable_path());
}
void application::do_events() {
native::application::do_events();
}
void application::enable_visual_styles() {
native::application::enable_visual_style();
}
void application::end() {
native::application::end_application();
}
void application::exit() {
bool cancel_exit = false;
for (auto f : application::open_forms()) {
form_closing_event_args e;
f.get().on_form_closing(e);
if (e.cancel()) {
cancel_exit = true;
break;
}
}
if (!cancel_exit) {
for (auto f : application::open_forms()) {
form_closed_event_args e;
f.get().on_form_closed(e);
}
native::application::exit();
}
}
void application::run() {
native::application::register_wnd_proc(delegate<intptr_t(intptr_t, int32_t, intptr_t, intptr_t, intptr_t)>(application::wnd_proc_));
message_loop_ = true;
native::application::run();
message_loop_ = false;
}
void application::run(const form& form) {
native::application::main_form(form.control::data_->handle_);
const_cast<forms::form&>(form).show();
run();
}
void application::start() {
native::application::start_application();
}
event<application, delegate<void(const event_args&)>> application::idle;
intptr_t application::wnd_proc_(intptr_t hwnd, int32_t msg, intptr_t wparam, intptr_t lparam, intptr_t handle) {
message message = forms::message::create(hwnd, msg, wparam, lparam, 0, handle);
wnd_proc(message);
return message.result();
}
void application::wnd_proc(message& message) {
switch (message.msg()) {
case WM_ACTIVATEAPP: wm_activate_app(message); break;
case WM_ENTERIDLE: wm_enter_idle(message); break;
default: break;
}
}
void application::wm_activate_app(message& message) {
for (reference_wrapper<form>& form : open_forms())
form.get().send_message(form.get().control::data_->handle_, message.msg(), message.wparam(), message.lparam());
}
void application::wm_enter_idle(message& message) {
static chrono::high_resolution_clock::time_point last_idle_time;
if (chrono::high_resolution_clock::now() - last_idle_time >= chrono::milliseconds(100)) {
last_idle_time = chrono::high_resolution_clock::now();
application::idle(event_args::empty);
}
if (!application::idle.is_empty()) native::application::do_idle();
}
| 30.427586 | 181 | 0.732774 | [
"vector"
] |
c12f8a5bdc92911d048131182b0ca4f6c9073843 | 3,189 | cpp | C++ | live/src/v20180801/model/PlayDataInfoByStream.cpp | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 43 | 2019-08-14T08:14:12.000Z | 2022-03-30T12:35:09.000Z | live/src/v20180801/model/PlayDataInfoByStream.cpp | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 12 | 2019-07-15T10:44:59.000Z | 2021-11-02T12:35:00.000Z | live/src/v20180801/model/PlayDataInfoByStream.cpp | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 28 | 2019-07-12T09:06:22.000Z | 2022-03-30T08:04:18.000Z | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/live/v20180801/model/PlayDataInfoByStream.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Live::V20180801::Model;
using namespace std;
PlayDataInfoByStream::PlayDataInfoByStream() :
m_streamNameHasBeenSet(false),
m_totalFluxHasBeenSet(false)
{
}
CoreInternalOutcome PlayDataInfoByStream::Deserialize(const rapidjson::Value &value)
{
string requestId = "";
if (value.HasMember("StreamName") && !value["StreamName"].IsNull())
{
if (!value["StreamName"].IsString())
{
return CoreInternalOutcome(Core::Error("response `PlayDataInfoByStream.StreamName` IsString=false incorrectly").SetRequestId(requestId));
}
m_streamName = string(value["StreamName"].GetString());
m_streamNameHasBeenSet = true;
}
if (value.HasMember("TotalFlux") && !value["TotalFlux"].IsNull())
{
if (!value["TotalFlux"].IsLosslessDouble())
{
return CoreInternalOutcome(Core::Error("response `PlayDataInfoByStream.TotalFlux` IsLosslessDouble=false incorrectly").SetRequestId(requestId));
}
m_totalFlux = value["TotalFlux"].GetDouble();
m_totalFluxHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
void PlayDataInfoByStream::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const
{
if (m_streamNameHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "StreamName";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(m_streamName.c_str(), allocator).Move(), allocator);
}
if (m_totalFluxHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "TotalFlux";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, m_totalFlux, allocator);
}
}
string PlayDataInfoByStream::GetStreamName() const
{
return m_streamName;
}
void PlayDataInfoByStream::SetStreamName(const string& _streamName)
{
m_streamName = _streamName;
m_streamNameHasBeenSet = true;
}
bool PlayDataInfoByStream::StreamNameHasBeenSet() const
{
return m_streamNameHasBeenSet;
}
double PlayDataInfoByStream::GetTotalFlux() const
{
return m_totalFlux;
}
void PlayDataInfoByStream::SetTotalFlux(const double& _totalFlux)
{
m_totalFlux = _totalFlux;
m_totalFluxHasBeenSet = true;
}
bool PlayDataInfoByStream::TotalFluxHasBeenSet() const
{
return m_totalFluxHasBeenSet;
}
| 28.473214 | 156 | 0.71339 | [
"model"
] |
c1337ed70c609cfb73ea114fa665031cead01b93 | 15,914 | cpp | C++ | src/g1000/cgi/g1000_VSI.cpp | paperoga-dev/mscsim | a5bd3b88745bf8d91e85fd001b0972662ff8e410 | [
"MIT"
] | null | null | null | src/g1000/cgi/g1000_VSI.cpp | paperoga-dev/mscsim | a5bd3b88745bf8d91e85fd001b0972662ff8e410 | [
"MIT"
] | null | null | null | src/g1000/cgi/g1000_VSI.cpp | paperoga-dev/mscsim | a5bd3b88745bf8d91e85fd001b0972662ff8e410 | [
"MIT"
] | null | null | null | /****************************************************************************//*
* Copyright (C) 2021 Marek M. Cel
*
* 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 <g1000/cgi/g1000_VSI.h>
#include <sstream>
#include <osg/Geode>
#include <osg/Geometry>
#include <g1000/g1000_Defines.h>
#include <g1000/cgi/g1000_Colors.h>
#include <g1000/cgi/g1000_Fonts.h>
#include <g1000/utils/g1000_Misc.h>
#include <g1000/utils/g1000_Units.h>
////////////////////////////////////////////////////////////////////////////////
using namespace g1000;
////////////////////////////////////////////////////////////////////////////////
const double VSI::_x_offset = -10.0;
const double VSI::_y_offset = 19.0;
const osg::Vec3 VSI::_colorBack = osg::Vec3( 0.38, 0.38, 0.38 );
const double VSI::_z_back = -80.0;
const double VSI::_z_box = -60.0;
const double VSI::_z_bug = -59.0;
const double VSI::_z_frame = -60.0;
const double VSI::_z_ptr = -58.0;
const double VSI::_z_scale = -70.0;
const double VSI::_vs2pt = 0.014;
////////////////////////////////////////////////////////////////////////////////
VSI::VSI( IFD *ifd ) :
Module( ifd )
{
_pat = new osg::PositionAttitudeTransform();
_root->addChild( _pat.get() );
_pat->setPosition( osg::Vec3( _x_offset, _y_offset, 0.0 ) );
_patPointer = new osg::PositionAttitudeTransform();
_pat->addChild( _patPointer.get() );
_patBug = new osg::PositionAttitudeTransform();
_pat->addChild( _patBug.get() );
createBack();
createBoxSelect();
createBug();
createFrame();
createPointer();
createScale();
}
////////////////////////////////////////////////////////////////////////////////
VSI::~VSI() {}
////////////////////////////////////////////////////////////////////////////////
void VSI::update()
{
double vs_fpm = Units::mps2fpm( _ifd->gdc()->getClimbRate() );
double select_fpm = Units::mps2fpm( _ifd->input().sel_climbRate );
char vs_str[16] = { "" };
int vs_int = 50 * floor( fabs( vs_fpm / 50.0 ) + 0.5 );
//if ( vs_fpm < -2000.0 ) vs_int = -vs_int;
if ( vs_int != 0 )
sprintf( vs_str, "%d", vs_int );
_textVS->setText( vs_str );
//if ( climbRate_fpm < -2000.0 ) climbRate_fpm = -2000.0;
//if ( climbRate_fpm > 2000.0 ) climbRate_fpm = 2000.0;
double dy_ptr = Misc::satur( -29.0, 29.0, _vs2pt * vs_fpm );
double dy_sel = Misc::satur( -29.0, 29.0, _vs2pt * select_fpm );
_patPointer->setPosition( osg::Vec3( 0.0, dy_ptr, 0.0 ) );
_patBug->setPosition( osg::Vec3( 0.0, dy_sel, 0.0 ) );
char sel_str[16] = { "" };
sprintf( sel_str, "%d", (int)select_fpm );
_textSelect->setText( sel_str );
}
////////////////////////////////////////////////////////////////////////////////
void VSI::createBack()
{
const double x = 67.0;
const double h = 31.0;
const double w = 9.0;
const double d = 4.5;
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
_pat->addChild( geode.get() );
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array();
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array();
c->push_back( osg::Vec4( _colorBack, 0.5 ) );
v->push_back( osg::Vec3( x , -h , _z_back ) );
v->push_back( osg::Vec3( x + w , -h , _z_back ) );
v->push_back( osg::Vec3( x + w , -d , _z_back ) );
v->push_back( osg::Vec3( x , 0.0 , _z_back ) );
v->push_back( osg::Vec3( x , 0.0 , _z_back ) );
v->push_back( osg::Vec3( x + w , d , _z_back ) );
v->push_back( osg::Vec3( x + w , h , _z_back ) );
v->push_back( osg::Vec3( x , h , _z_back ) );
geometry->setVertexArray( v.get() );
geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::QUADS, 0, v->size() ) );
geometry->setColorArray( c.get() );
geometry->setColorBinding( osg::Geometry::BIND_OVERALL );
geode->addDrawable( geometry.get() );
}
////////////////////////////////////////////////////////////////////////////////
void VSI::createBoxSelect()
{
const double x = 67.1;
const double y = 31.0;
const double h = 6.0;
const double w = 12.0;
const double delta_x_txt = 1.0;
const double delta_y_txt = 1.7;
osg::ref_ptr<osg::Geode> geode_b = new osg::Geode();
osg::ref_ptr<osg::Geode> geode_f = new osg::Geode();
osg::ref_ptr<osg::Geode> geode_t = new osg::Geode();
_pat->addChild( geode_b.get() );
_pat->addChild( geode_f.get() );
_pat->addChild( geode_t.get() );
osg::ref_ptr<osg::Geometry> geom_b = new osg::Geometry();
osg::ref_ptr<osg::Geometry> geom_f = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> vb = new osg::Vec3Array();
osg::ref_ptr<osg::Vec3Array> vf = new osg::Vec3Array();
osg::ref_ptr<osg::Vec4Array> cb = new osg::Vec4Array();
osg::ref_ptr<osg::Vec4Array> cf = new osg::Vec4Array();
cb->push_back( osg::Vec4( Colors::_black, 1.0 ) );
cf->push_back( osg::Vec4( Colors::_white, 1.0 ) );
vf->push_back( osg::Vec3( x , y , _z_box ) );
vf->push_back( osg::Vec3( x + w , y , _z_box ) );
vf->push_back( osg::Vec3( x + w , y + h , _z_box ) );
vf->push_back( osg::Vec3( x , y + h , _z_box ) );
vb->push_back( osg::Vec3( x , y , _z_box + 1.0 ) );
vb->push_back( osg::Vec3( x + w , y , _z_box + 1.0 ) );
vb->push_back( osg::Vec3( x + w , y + h , _z_box + 1.0 ) );
vb->push_back( osg::Vec3( x , y + h , _z_box + 1.0 ) );
geom_b->setVertexArray( vb.get() );
geom_f->setVertexArray( vf.get() );
geom_b->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::QUADS, 0, vb->size() ) );
geom_f->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINE_LOOP, 0, vf->size() ) );
geom_b->setColorArray( cb.get() );
geom_f->setColorArray( cf.get() );
geom_b->setColorBinding( osg::Geometry::BIND_OVERALL );
geom_f->setColorBinding( osg::Geometry::BIND_OVERALL );
geode_b->addDrawable( geom_b.get() );
geode_f->addDrawable( geom_f.get() );
_textSelect = new osgText::Text();
_textSelect->setFont( Fonts::get( "fonts/g1000.ttf" ) );
_textSelect->setColor( osg::Vec4( Colors::_cyan, 1.0 ) );
_textSelect->setCharacterSize( 4.0 );
_textSelect->setAxisAlignment( osgText::TextBase::XY_PLANE );
_textSelect->setPosition( osg::Vec3( x + w - delta_x_txt, y + delta_y_txt, _z_box + 2.0 ) );
_textSelect->setLayout( osgText::Text::LEFT_TO_RIGHT );
_textSelect->setAlignment( osgText::Text::RIGHT_BASE_LINE );
_textSelect->setText( "0000" );
geode_t->addDrawable( _textSelect );
}
////////////////////////////////////////////////////////////////////////////////
void VSI::createBug()
{
const double dx = 67.0;
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
_patBug->addChild( geode.get() );
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array();
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array();
v->push_back( osg::Vec3( dx , 0.0, _z_bug ) );
v->push_back( osg::Vec3( dx , 2.0, _z_bug ) );
v->push_back( osg::Vec3( dx + 2.0 , 1.0, _z_bug ) );
v->push_back( osg::Vec3( dx , 2.0, _z_bug ) );
v->push_back( osg::Vec3( dx + 2.0 , 1.0, _z_bug ) );
v->push_back( osg::Vec3( dx + 2.0 , 2.0, _z_bug ) );
v->push_back( osg::Vec3( dx , 0.0, _z_bug ) );
v->push_back( osg::Vec3( dx , -2.0, _z_bug ) );
v->push_back( osg::Vec3( dx + 2.0 , -1.0, _z_bug ) );
v->push_back( osg::Vec3( dx , -2.0, _z_bug ) );
v->push_back( osg::Vec3( dx + 2.0 , -1.0, _z_bug ) );
v->push_back( osg::Vec3( dx + 2.0 , -2.0, _z_bug ) );
c->push_back( osg::Vec4( Colors::_cyan, 1.0 ) );
geom->setVertexArray( v.get() );
geom->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::TRIANGLES, 0, v->size() ) );
geom->setColorArray( c.get() );
geom->setColorBinding( osg::Geometry::BIND_OVERALL );
geode->addDrawable( geom.get() );
}
////////////////////////////////////////////////////////////////////////////////
void VSI::createFrame()
{
const double x = 67.0;
const double h = 31.0;
const double w = 9.0;
const double d = 4.5;
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
_pat->addChild( geode.get() );
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array();
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array();
c->push_back( osg::Vec4( Colors::_white, 1.0 ) );
v->push_back( osg::Vec3( x , -h , _z_frame ) );
v->push_back( osg::Vec3( x + w , -h , _z_frame ) );
v->push_back( osg::Vec3( x + w , -d , _z_frame ) );
v->push_back( osg::Vec3( x , 0.0 , _z_frame ) );
v->push_back( osg::Vec3( x , 0.0 , _z_frame ) );
v->push_back( osg::Vec3( x + w , d , _z_frame ) );
v->push_back( osg::Vec3( x + w , h , _z_frame ) );
v->push_back( osg::Vec3( x , h , _z_frame ) );
geometry->setVertexArray( v.get() );
geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINE_LOOP, 0, v->size() ) );
geometry->setColorArray( c.get() );
geometry->setColorBinding( osg::Geometry::BIND_OVERALL );
geode->addDrawable( geometry.get() );
}
////////////////////////////////////////////////////////////////////////////////
void VSI::createPointer()
{
const double dx = 67.0;
const double zf = _z_ptr;
const double zb = _z_ptr + 1.0;;
osg::ref_ptr<osg::Geode> geode_f = new osg::Geode();
osg::ref_ptr<osg::Geode> geode_b = new osg::Geode();
_patPointer->addChild( geode_f.get() );
_patPointer->addChild( geode_b.get() );
osg::ref_ptr<osg::Geometry> geom_f = new osg::Geometry();
osg::ref_ptr<osg::Geometry> geom_b = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> vf = new osg::Vec3Array();
osg::ref_ptr<osg::Vec4Array> cf = new osg::Vec4Array();
osg::ref_ptr<osg::Vec3Array> vb = new osg::Vec3Array();
osg::ref_ptr<osg::Vec4Array> cb = new osg::Vec4Array();
vf->push_back( osg::Vec3( dx , 0.0, zf ) );
vf->push_back( osg::Vec3( dx + 4.0 , 2.0, zf ) );
vf->push_back( osg::Vec3( dx + 4.0 , -2.0, zf ) );
vf->push_back( osg::Vec3( dx + 4.0 , 2.0, zf ) );
vf->push_back( osg::Vec3( dx + 4.0 , -2.0, zf ) );
vf->push_back( osg::Vec3( dx + 13.0 , -2.0, zf ) );
vf->push_back( osg::Vec3( dx + 4.0 , 2.0, zf ) );
vf->push_back( osg::Vec3( dx + 13.0 , 2.0, zf ) );
vf->push_back( osg::Vec3( dx + 13.0 , -2.0, zf ) );;
cf->push_back( osg::Vec4( Colors::_black, 1.0 ) );
vb->push_back( osg::Vec3( dx , 0.0, zb ) );
vb->push_back( osg::Vec3( dx + 4.0 , 2.0, zb ) );
vb->push_back( osg::Vec3( dx + 4.0 , 2.0, zb ) );
vb->push_back( osg::Vec3( dx + 13.0 , 2.0, zb ) );
vb->push_back( osg::Vec3( dx + 4.0 , 2.0, zb ) );
vb->push_back( osg::Vec3( dx + 13.0 , 2.0, zb ) );
vb->push_back( osg::Vec3( dx , 0.0, zb ) );
vb->push_back( osg::Vec3( dx + 4.0 , -2.0, zb ) );
vb->push_back( osg::Vec3( dx + 4.0 , -2.0, zb ) );
vb->push_back( osg::Vec3( dx + 13.0 , -2.0, zb ) );
vb->push_back( osg::Vec3( dx + 4.0 , -2.0, zb ) );
vb->push_back( osg::Vec3( dx + 13.0 , -2.0, zb ) );
vb->push_back( osg::Vec3( dx + 13.0 , 2.0, zb ) );
vb->push_back( osg::Vec3( dx + 13.0 , -2.0, zb ) );
cb->push_back( osg::Vec4( Colors::_white, 1.0 ) );
geom_f->setVertexArray( vf.get() );
geom_f->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::TRIANGLES, 0, vf->size() ) );
geom_f->setColorArray( cf.get() );
geom_f->setColorBinding( osg::Geometry::BIND_OVERALL );
geom_b->setVertexArray( vb.get() );
geom_b->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINES, 0, vb->size() ) );
geom_b->setColorArray( cb.get() );
geom_b->setColorBinding( osg::Geometry::BIND_OVERALL );
geode_f->addDrawable( geom_f.get() );
geode_b->addDrawable( geom_b.get() );
osg::ref_ptr<osg::Geode> geode_t = new osg::Geode();
_patPointer->addChild( geode_t.get() );
_textVS = new osgText::Text();
_textVS->setFont( Fonts::get( "fonts/g1000.ttf" ) );
_textVS->setColor( osg::Vec4( Colors::_white, 1.0 ) );
_textVS->setCharacterSize( 4.0 );
_textVS->setAxisAlignment( osgText::TextBase::XY_PLANE );
_textVS->setPosition( osg::Vec3( 79.8, 0.0, _z_box + 4.0 ) );
_textVS->setLayout( osgText::Text::LEFT_TO_RIGHT );
_textVS->setAlignment( osgText::Text::RIGHT_CENTER );
_textVS->setText( "0000" );
geode_t->addDrawable( _textVS );
}
////////////////////////////////////////////////////////////////////////////////
void VSI::createScale()
{
const double x = 67.0;
const double w1 = 3.0;
const double w2 = 2.0;
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
_pat->addChild( geode.get() );
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry();
osg::ref_ptr<osg::Vec3Array> v = new osg::Vec3Array();
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array();
c->push_back( osg::Vec4( Colors::_white, 1.0 ) );
const double step = 500.0;
const double min = -2000.0;
const double max = 2000.0;
const int steps = ( max - min ) / step + 1;
for ( int i = 0; i < steps; i++ )
{
double vs = min + i * step;
if ( fabs( vs ) > 1.0e-9 )
{
double x1 = x + w2;
double y = _vs2pt * vs;
if ( i % 2 == 0 )
{
x1 = x + w1;
std::stringstream alt_str;
alt_str << floor( fabs( vs / 1000 ) );
osg::ref_ptr<osgText::Text> text = new osgText::Text();
text->setFont( Fonts::get( "fonts/g1000.ttf" ) );
text->setColor( osg::Vec4( Colors::_white, 1.0 ) );
text->setCharacterSize( 4.0 );
text->setAxisAlignment( osgText::TextBase::XY_PLANE );
text->setPosition( osg::Vec3( x1 + 1.0, y, _z_scale ) );
text->setLayout( osgText::Text::LEFT_TO_RIGHT );
text->setAlignment( osgText::Text::LEFT_CENTER );
text->setText( alt_str.str() );
geode->addDrawable( text );
}
v->push_back( osg::Vec3( x , y, _z_scale ) );
v->push_back( osg::Vec3( x1 , y, _z_scale ) );
}
}
geometry->setVertexArray( v.get() );
geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINES, 0, v->size() ) );
geometry->setColorArray( c.get() );
geometry->setColorBinding( osg::Geometry::BIND_OVERALL );
geode->addDrawable( geometry.get() );
}
| 35.130243 | 99 | 0.552595 | [
"geometry"
] |
c137811b6f59a0b7b3d7bf00e82bb2a2feb83a6d | 2,086 | cpp | C++ | main.cpp | Sharvilpr23/csc315Project1 | 508bfb52008fafc6374ae9722afd0a9cfd8e8713 | [
"MIT"
] | 2 | 2021-08-13T08:36:30.000Z | 2021-08-13T08:37:00.000Z | main.cpp | Sharvilpr23/csc315Project1 | 508bfb52008fafc6374ae9722afd0a9cfd8e8713 | [
"MIT"
] | null | null | null | main.cpp | Sharvilpr23/csc315Project1 | 508bfb52008fafc6374ae9722afd0a9cfd8e8713 | [
"MIT"
] | null | null | null | /*************************************************************************//**
* @file
*
* @mainpage Paint Program
*
* @section course_section Course Information
*
* @authors Sharvil Pai Raiker, Eli Fox
*
* @date Feb. 14 2020
*
* @par Course:
* CSC 315- Spring 2020
*
* @details This program creates a paint progam similar to ms Paint.
* It is capable of creating a number of shapes, either filled or unfilled
* as well as lines. colors can also be selected, to color the outline, or fill
* color for the shapes. The shapes and color can be selected from the palette
* menu on the left. the shapes can also be be seelcted with the right click
* button. pressing d will delete the top object, pressing c will clear the
* screen. Pressing "esc" or "q" will exit the program.
* Creates a window, tracks mouse and keyboard events
*
* @section compile_section Compiling and Usage
*
* @par Compiling Instructions:
* None
*
* @par Usage:
@verbatim
./main
@endverbatim
*
* @section todo_bugs_modification_section Todo, Bugs, and Modifications
* Found a weird bug when I make the window very small and
* then try to draw a filled rectangle
*
* @par
* None
*
* @par Modifications and Development Timeline:
<a href =
"https://gitlab.mcs.sdsmt.edu/7509329/csc315_spring2020_project1/commits/master">
Click here for commit log</a>
****************************************************************************/
#include "util.h"
/*************************************************************************//**
* @brief main function
*
* @param[in] argc - number of command line arguments
* @param[in] argv - array of C strings representing the command line
* arguments
*
* @return main does not return due to the glutMainLoop function not
* returning
****************************************************************************/
int main(int argc, char** argv)
{
// Call the glut functions to initialize everythin
initOpenGL(argc, argv);
//Runs the glut Main loop
glutMainLoop();
return 0;
}
| 28.575342 | 83 | 0.59396 | [
"object"
] |
c137c92666596d46fbd49e2e389337f90b9c920b | 5,241 | cc | C++ | viewer/window_manager.cc | IJDykeman/experiments-1 | 22badf166b2ea441e953939463f751020b8c251b | [
"MIT"
] | 1 | 2022-02-28T04:19:34.000Z | 2022-02-28T04:19:34.000Z | viewer/window_manager.cc | IJDykeman/experiments-1 | 22badf166b2ea441e953939463f751020b8c251b | [
"MIT"
] | null | null | null | viewer/window_manager.cc | IJDykeman/experiments-1 | 22badf166b2ea441e953939463f751020b8c251b | [
"MIT"
] | null | null | null | #include "viewer/window_manager.hh"
//%deps(OPENGL, GLFW, GLEW, pthread)
#include <atomic>
#include <chrono>
#include <iostream>
#include <map>
#include <mutex>
#include <sstream>
#include <string>
#include <thread>
namespace viewer {
void key_callback(
GLFWwindow *window, int key, int scancode, int action, int mods);
void cursor_position_callback(GLFWwindow *window, double xpos, double ypos);
void mouse_button_callback(GLFWwindow *window,
int button,
int action,
int mods);
void window_size_callback(GLFWwindow *window, int width, int height);
void scroll_callback(GLFWwindow *window, double xoffset, double yoffset);
void error_callback(int error, const char *description);
//
// Manage a global registry of the created windows
//
std::mutex global_state_mutex;
struct GlobalState {
std::map<GLFWwindow *, std::shared_ptr<SimpleWindow>> windows;
};
// Global state singleton
std::shared_ptr<GlobalState> global_state;
std::atomic<bool> ready(false);
void render_func() {
while (true) {
if (ready) {
const std::lock_guard<std::mutex> lk(global_state_mutex);
WindowManager::draw(16);
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(16));
}
}
}
std::thread render_thread(render_func);
std::shared_ptr<GlobalState> maybe_create_global_state() {
std::unique_lock<std::mutex> lk(global_state_mutex);
if (!global_state) {
glfwSetErrorCallback(error_callback);
if (!glfwInit()) {
exit(EXIT_FAILURE);
}
glewExperimental = GL_TRUE;
global_state = std::make_shared<GlobalState>();
ready = true;
render_thread.detach();
}
return global_state;
}
void WindowManager::register_window(
const GlSize &size,
const std::shared_ptr<SimpleWindow> simple_window,
const std::string &window_name,
const int win_ver_maj) {
maybe_create_global_state();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, win_ver_maj);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
// 8x MSAA
glfwWindowHint(GLFW_SAMPLES, 8);
GLFWwindow *window = glfwCreateWindow(
size.height, size.width, window_name.c_str(), nullptr, nullptr);
simple_window->set_title(window_name);
if (!window) {
glfwTerminate();
std::cerr << "\nFailed to create new window" << std::endl;
exit(EXIT_FAILURE);
}
glfwSetKeyCallback(window, key_callback);
glfwSetCursorPosCallback(window, cursor_position_callback);
glfwSetMouseButtonCallback(window, mouse_button_callback);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSetScrollCallback(window, scroll_callback);
global_state->windows[window] = simple_window;
}
//
// Render all of the managed windows
//
void WindowManager::render() {
for (auto it = global_state->windows.begin();
it != global_state->windows.end();
it++) {
auto &glfw_win = it->first;
auto &window = it->second;
glfwMakeContextCurrent(glfw_win);
glewInit();
if (!glfwWindowShouldClose(glfw_win)) {
window->render();
glfwSwapBuffers(glfw_win);
} else {
glfwDestroyWindow(glfw_win);
global_state->windows.erase(it);
continue;
}
}
glfwPollEvents();
}
bool WindowManager::any_windows() {
// Not thread-safe, figure out later
if (global_state) {
return !global_state->windows.empty();
}
return false;
}
void WindowManager::draw(const int ms) {
int ms_slept = 0;
while (any_windows() && (ms_slept < ms)) {
constexpr int SLEEP_MS = 2;
render();
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_MS));
ms_slept += SLEEP_MS;
}
}
void WindowManager::spin() {
while (any_windows()) {
render();
std::this_thread::sleep_for(std::chrono::milliseconds(16));
}
glfwTerminate();
}
void error_callback(int error, const char *description) {
fputs(description, stderr);
}
void close_window(GLFWwindow *window) {
global_state->windows.at(window)->close();
}
void key_callback(
GLFWwindow *window, int key, int scancode, int action, int mods) {
if ((key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) || (key == GLFW_KEY_Q)) {
close_window(window);
glfwSetWindowShouldClose(window, GL_TRUE);
}
global_state->windows.at(window)->key_pressed(key, scancode, action, mods);
}
void cursor_position_callback(GLFWwindow *window, double xpos, double ypos) {
global_state->windows.at(window)->mouse_moved(xpos, ypos);
}
void mouse_button_callback(GLFWwindow *window,
int button,
int action,
int mods) {
if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) {
}
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
}
if (action == GLFW_RELEASE) {
}
global_state->windows.at(window)->mouse_button(button, action, mods);
}
void scroll_callback(GLFWwindow *window, double xoffset, double yoffset) {
global_state->windows.at(window)->on_scroll(yoffset);
}
void window_size_callback(GLFWwindow *window, int width, int height) {
global_state->windows.at(window)->resize(GlSize(width, height));
}
} // namespace viewer
| 25.565854 | 80 | 0.688227 | [
"render"
] |
c139cd78b4c01720da86b7d2321c3a7927d938bd | 45,921 | cpp | C++ | Binder/frameworks/base/core/jni/android_util_Binder.cpp | YyuTtian/sample | 7cbe4f3009f16df78c346d2cb58ac3d646130fa7 | [
"Apache-2.0"
] | null | null | null | Binder/frameworks/base/core/jni/android_util_Binder.cpp | YyuTtian/sample | 7cbe4f3009f16df78c346d2cb58ac3d646130fa7 | [
"Apache-2.0"
] | null | null | null | Binder/frameworks/base/core/jni/android_util_Binder.cpp | YyuTtian/sample | 7cbe4f3009f16df78c346d2cb58ac3d646130fa7 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2006 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.
*/
#define LOG_TAG "JavaBinder"
//#define LOG_NDEBUG 0
#include "android_os_Parcel.h"
#include "android_util_Binder.h"
#include "JNIHelp.h"
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <utils/Atomic.h>
#include <binder/IInterface.h>
#include <binder/IPCThreadState.h>
#include <utils/Log.h>
#include <utils/SystemClock.h>
#include <utils/List.h>
#include <utils/KeyedVector.h>
#include <log/logger.h>
#include <binder/Parcel.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <utils/threads.h>
#include <utils/String8.h>
#include <ScopedUtfChars.h>
#include <ScopedLocalRef.h>
#include "core_jni_helpers.h"
//#undef ALOGV
//#define ALOGV(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG_DEATH 0
#if DEBUG_DEATH
#define LOGDEATH ALOGD
#else
#define LOGDEATH ALOGV
#endif
using namespace android;
// ----------------------------------------------------------------------------
static struct bindernative_offsets_t
{
// Class state.
jclass mClass;
jmethodID mExecTransact;
// Object state.
jfieldID mObject;
} gBinderOffsets;
// ----------------------------------------------------------------------------
static struct binderinternal_offsets_t
{
// Class state.
jclass mClass;
jmethodID mForceGc;
} gBinderInternalOffsets;
// ----------------------------------------------------------------------------
static struct error_offsets_t
{
jclass mClass;
} gErrorOffsets;
// ----------------------------------------------------------------------------
static struct binderproxy_offsets_t
{
// Class state.
jclass mClass;
jmethodID mConstructor;
jmethodID mSendDeathNotice;
// Object state.
jfieldID mObject;
jfieldID mSelf;
jfieldID mOrgue;
} gBinderProxyOffsets;
static struct class_offsets_t
{
jmethodID mGetName;
} gClassOffsets;
// ----------------------------------------------------------------------------
static struct log_offsets_t
{
// Class state.
jclass mClass;
jmethodID mLogE;
} gLogOffsets;
static struct parcel_file_descriptor_offsets_t
{
jclass mClass;
jmethodID mConstructor;
} gParcelFileDescriptorOffsets;
static struct strict_mode_callback_offsets_t
{
jclass mClass;
jmethodID mCallback;
} gStrictModeCallbackOffsets;
// ****************************************************************************
// ****************************************************************************
// ****************************************************************************
static volatile int32_t gNumRefsCreated = 0;
static volatile int32_t gNumProxyRefs = 0;
static volatile int32_t gNumLocalRefs = 0;
static volatile int32_t gNumDeathRefs = 0;
static void incRefsCreated(JNIEnv* env)
{
int old = android_atomic_inc(&gNumRefsCreated);
if (old == 200) {
android_atomic_and(0, &gNumRefsCreated);
env->CallStaticVoidMethod(gBinderInternalOffsets.mClass,
gBinderInternalOffsets.mForceGc);
} else {
ALOGV("Now have %d binder ops", old);
}
}
static JavaVM* jnienv_to_javavm(JNIEnv* env)
{
JavaVM* vm;
return env->GetJavaVM(&vm) >= 0 ? vm : NULL;
}
static JNIEnv* javavm_to_jnienv(JavaVM* vm)
{
JNIEnv* env;
return vm->GetEnv((void **)&env, JNI_VERSION_1_4) >= 0 ? env : NULL;
}
static void report_exception(JNIEnv* env, jthrowable excep, const char* msg)
{
env->ExceptionClear();
jstring tagstr = env->NewStringUTF(LOG_TAG);
jstring msgstr = NULL;
if (tagstr != NULL) {
msgstr = env->NewStringUTF(msg);
}
if ((tagstr == NULL) || (msgstr == NULL)) {
env->ExceptionClear(); /* assume exception (OOM?) was thrown */
ALOGE("Unable to call Log.e()\n");
ALOGE("%s", msg);
goto bail;
}
env->CallStaticIntMethod(
gLogOffsets.mClass, gLogOffsets.mLogE, tagstr, msgstr, excep);
if (env->ExceptionCheck()) {
/* attempting to log the failure has failed */
ALOGW("Failed trying to log exception, msg='%s'\n", msg);
env->ExceptionClear();
}
if (env->IsInstanceOf(excep, gErrorOffsets.mClass)) {
/*
* It's an Error: Reraise the exception, detach this thread, and
* wait for the fireworks. Die even more blatantly after a minute
* if the gentler attempt doesn't do the trick.
*
* The GetJavaVM function isn't on the "approved" list of JNI calls
* that can be made while an exception is pending, so we want to
* get the VM ptr, throw the exception, and then detach the thread.
*/
env->Throw(excep);
env->ExceptionDescribe();
ALOGE("Forcefully exiting");
exit(1);
}
bail:
/* discard local refs created for us by VM */
env->DeleteLocalRef(tagstr);
env->DeleteLocalRef(msgstr);
}
class JavaBBinderHolder;
class JavaBBinder : public BBinder
{
public:
JavaBBinder(JNIEnv* env, jobject object)
: mVM(jnienv_to_javavm(env)), mObject(env->NewGlobalRef(object))
{
ALOGV("Creating JavaBBinder %p\n", this);
android_atomic_inc(&gNumLocalRefs);
incRefsCreated(env);
}
bool checkSubclass(const void* subclassID) const
{
return subclassID == &gBinderOffsets;
}
jobject object() const
{
return mObject;
}
protected:
virtual ~JavaBBinder()
{
ALOGV("Destroying JavaBBinder %p\n", this);
android_atomic_dec(&gNumLocalRefs);
JNIEnv* env = javavm_to_jnienv(mVM);
env->DeleteGlobalRef(mObject);
}
virtual status_t onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0)
{
JNIEnv* env = javavm_to_jnienv(mVM);
ALOGV("onTransact() on %p calling object %p in env %p vm %p\n", this, mObject, env, mVM);
IPCThreadState* thread_state = IPCThreadState::self();
const int32_t strict_policy_before = thread_state->getStrictModePolicy();
//printf("Transact from %p to Java code sending: ", this);
//data.print();
//printf("\n");
jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact,
code, reinterpret_cast<jlong>(&data), reinterpret_cast<jlong>(reply), flags);
if (env->ExceptionCheck()) {
jthrowable excep = env->ExceptionOccurred();
report_exception(env, excep,
"*** Uncaught remote exception! "
"(Exceptions are not yet supported across processes.)");
res = JNI_FALSE;
/* clean up JNI local ref -- we don't return to Java code */
env->DeleteLocalRef(excep);
}
// Check if the strict mode state changed while processing the
// call. The Binder state will be restored by the underlying
// Binder system in IPCThreadState, however we need to take care
// of the parallel Java state as well.
if (thread_state->getStrictModePolicy() != strict_policy_before) {
set_dalvik_blockguard_policy(env, strict_policy_before);
}
if (env->ExceptionCheck()) {
jthrowable excep = env->ExceptionOccurred();
report_exception(env, excep,
"*** Uncaught exception in onBinderStrictModePolicyChange");
/* clean up JNI local ref -- we don't return to Java code */
env->DeleteLocalRef(excep);
}
// Need to always call through the native implementation of
// SYSPROPS_TRANSACTION.
if (code == SYSPROPS_TRANSACTION) {
BBinder::onTransact(code, data, reply, flags);
}
//aout << "onTransact to Java code; result=" << res << endl
// << "Transact from " << this << " to Java code returning "
// << reply << ": " << *reply << endl;
return res != JNI_FALSE ? NO_ERROR : UNKNOWN_TRANSACTION;
}
virtual status_t dump(int fd, const Vector<String16>& args)
{
return 0;
}
private:
JavaVM* const mVM;
jobject const mObject;
};
// ----------------------------------------------------------------------------
class JavaBBinderHolder : public RefBase
{
public:
sp<JavaBBinder> get(JNIEnv* env, jobject obj)
{
AutoMutex _l(mLock);
sp<JavaBBinder> b = mBinder.promote();
if (b == NULL) {
b = new JavaBBinder(env, obj);
mBinder = b;
ALOGV("Creating JavaBinder %p (refs %p) for Object %p, weakCount=%" PRId32 "\n",
b.get(), b->getWeakRefs(), obj, b->getWeakRefs()->getWeakCount());
}
return b;
}
sp<JavaBBinder> getExisting()
{
AutoMutex _l(mLock);
return mBinder.promote();
}
private:
Mutex mLock;
wp<JavaBBinder> mBinder;
};
// ----------------------------------------------------------------------------
// Per-IBinder death recipient bookkeeping. This is how we reconcile local jobject
// death recipient references passed in through JNI with the permanent corresponding
// JavaDeathRecipient objects.
class JavaDeathRecipient;
class DeathRecipientList : public RefBase {
List< sp<JavaDeathRecipient> > mList;
Mutex mLock;
public:
DeathRecipientList();
~DeathRecipientList();
void add(const sp<JavaDeathRecipient>& recipient);
void remove(const sp<JavaDeathRecipient>& recipient);
sp<JavaDeathRecipient> find(jobject recipient);
Mutex& lock(); // Use with care; specifically for mutual exclusion during binder death
};
// ----------------------------------------------------------------------------
class JavaDeathRecipient : public IBinder::DeathRecipient
{
public:
JavaDeathRecipient(JNIEnv* env, jobject object, const sp<DeathRecipientList>& list)
: mVM(jnienv_to_javavm(env)), mObject(env->NewGlobalRef(object)),
mObjectWeak(NULL), mList(list)
{
// These objects manage their own lifetimes so are responsible for final bookkeeping.
// The list holds a strong reference to this object.
LOGDEATH("Adding JDR %p to DRL %p", this, list.get());
list->add(this);
android_atomic_inc(&gNumDeathRefs);
incRefsCreated(env);
}
void binderDied(const wp<IBinder>& who)
{
LOGDEATH("Receiving binderDied() on JavaDeathRecipient %p\n", this);
if (mObject != NULL) {
JNIEnv* env = javavm_to_jnienv(mVM);
env->CallStaticVoidMethod(gBinderProxyOffsets.mClass,
gBinderProxyOffsets.mSendDeathNotice, mObject);
if (env->ExceptionCheck()) {
jthrowable excep = env->ExceptionOccurred();
report_exception(env, excep,
"*** Uncaught exception returned from death notification!");
}
// Serialize with our containing DeathRecipientList so that we can't
// delete the global ref on mObject while the list is being iterated.
sp<DeathRecipientList> list = mList.promote();
if (list != NULL) {
AutoMutex _l(list->lock());
// Demote from strong ref to weak after binderDied() has been delivered,
// to allow the DeathRecipient and BinderProxy to be GC'd if no longer needed.
mObjectWeak = env->NewWeakGlobalRef(mObject);
env->DeleteGlobalRef(mObject);
mObject = NULL;
}
}
}
void clearReference()
{
sp<DeathRecipientList> list = mList.promote();
if (list != NULL) {
LOGDEATH("Removing JDR %p from DRL %p", this, list.get());
list->remove(this);
} else {
LOGDEATH("clearReference() on JDR %p but DRL wp purged", this);
}
}
bool matches(jobject obj) {
bool result;
JNIEnv* env = javavm_to_jnienv(mVM);
if (mObject != NULL) {
result = env->IsSameObject(obj, mObject);
} else {
jobject me = env->NewLocalRef(mObjectWeak);
result = env->IsSameObject(obj, me);
env->DeleteLocalRef(me);
}
return result;
}
void warnIfStillLive() {
if (mObject != NULL) {
// Okay, something is wrong -- we have a hard reference to a live death
// recipient on the VM side, but the list is being torn down.
JNIEnv* env = javavm_to_jnienv(mVM);
ScopedLocalRef<jclass> objClassRef(env, env->GetObjectClass(mObject));
ScopedLocalRef<jstring> nameRef(env,
(jstring) env->CallObjectMethod(objClassRef.get(), gClassOffsets.mGetName));
ScopedUtfChars nameUtf(env, nameRef.get());
if (nameUtf.c_str() != NULL) {
ALOGW("BinderProxy is being destroyed but the application did not call "
"unlinkToDeath to unlink all of its death recipients beforehand. "
"Releasing leaked death recipient: %s", nameUtf.c_str());
} else {
ALOGW("BinderProxy being destroyed; unable to get DR object name");
env->ExceptionClear();
}
}
}
protected:
virtual ~JavaDeathRecipient()
{
//ALOGI("Removing death ref: recipient=%p\n", mObject);
android_atomic_dec(&gNumDeathRefs);
JNIEnv* env = javavm_to_jnienv(mVM);
if (mObject != NULL) {
env->DeleteGlobalRef(mObject);
} else {
env->DeleteWeakGlobalRef(mObjectWeak);
}
}
private:
JavaVM* const mVM;
jobject mObject;
jweak mObjectWeak; // will be a weak ref to the same VM-side DeathRecipient after binderDied()
wp<DeathRecipientList> mList;
};
// ----------------------------------------------------------------------------
DeathRecipientList::DeathRecipientList() {
LOGDEATH("New DRL @ %p", this);
}
DeathRecipientList::~DeathRecipientList() {
LOGDEATH("Destroy DRL @ %p", this);
AutoMutex _l(mLock);
// Should never happen -- the JavaDeathRecipient objects that have added themselves
// to the list are holding references on the list object. Only when they are torn
// down can the list header be destroyed.
if (mList.size() > 0) {
List< sp<JavaDeathRecipient> >::iterator iter;
for (iter = mList.begin(); iter != mList.end(); iter++) {
(*iter)->warnIfStillLive();
}
}
}
void DeathRecipientList::add(const sp<JavaDeathRecipient>& recipient) {
AutoMutex _l(mLock);
LOGDEATH("DRL @ %p : add JDR %p", this, recipient.get());
mList.push_back(recipient);
}
void DeathRecipientList::remove(const sp<JavaDeathRecipient>& recipient) {
AutoMutex _l(mLock);
List< sp<JavaDeathRecipient> >::iterator iter;
for (iter = mList.begin(); iter != mList.end(); iter++) {
if (*iter == recipient) {
LOGDEATH("DRL @ %p : remove JDR %p", this, recipient.get());
mList.erase(iter);
return;
}
}
}
sp<JavaDeathRecipient> DeathRecipientList::find(jobject recipient) {
AutoMutex _l(mLock);
List< sp<JavaDeathRecipient> >::iterator iter;
for (iter = mList.begin(); iter != mList.end(); iter++) {
if ((*iter)->matches(recipient)) {
return *iter;
}
}
return NULL;
}
Mutex& DeathRecipientList::lock() {
return mLock;
}
// ----------------------------------------------------------------------------
namespace android {
static void proxy_cleanup(const void* id, void* obj, void* cleanupCookie)
{
android_atomic_dec(&gNumProxyRefs);
JNIEnv* env = javavm_to_jnienv((JavaVM*)cleanupCookie);
env->DeleteGlobalRef((jobject)obj);
}
static Mutex mProxyLock;
jobject javaObjectForIBinder(JNIEnv* env, const sp<IBinder>& val)
{
if (val == NULL) return NULL;
if (val->checkSubclass(&gBinderOffsets)) {
// One of our own!
jobject object = static_cast<JavaBBinder*>(val.get())->object();
LOGDEATH("objectForBinder %p: it's our own %p!\n", val.get(), object);
return object;
}
// For the rest of the function we will hold this lock, to serialize
// looking/creation of Java proxies for native Binder proxies.
AutoMutex _l(mProxyLock);
// Someone else's... do we know about it?
jobject object = (jobject)val->findObject(&gBinderProxyOffsets);
if (object != NULL) {
jobject res = jniGetReferent(env, object);
if (res != NULL) {
ALOGV("objectForBinder %p: found existing %p!\n", val.get(), res);
return res;
}
LOGDEATH("Proxy object %p of IBinder %p no longer in working set!!!", object, val.get());
android_atomic_dec(&gNumProxyRefs);
val->detachObject(&gBinderProxyOffsets);
env->DeleteGlobalRef(object);
}
object = env->NewObject(gBinderProxyOffsets.mClass, gBinderProxyOffsets.mConstructor);
if (object != NULL) {
LOGDEATH("objectForBinder %p: created new proxy %p !\n", val.get(), object);
// The proxy holds a reference to the native object.
env->SetLongField(object, gBinderProxyOffsets.mObject, (jlong)val.get());
val->incStrong((void*)javaObjectForIBinder);
// The native object needs to hold a weak reference back to the
// proxy, so we can retrieve the same proxy if it is still active.
jobject refObject = env->NewGlobalRef(
env->GetObjectField(object, gBinderProxyOffsets.mSelf));
val->attachObject(&gBinderProxyOffsets, refObject,
jnienv_to_javavm(env), proxy_cleanup);
// Also remember the death recipients registered on this proxy
sp<DeathRecipientList> drl = new DeathRecipientList;
drl->incStrong((void*)javaObjectForIBinder);
env->SetLongField(object, gBinderProxyOffsets.mOrgue, reinterpret_cast<jlong>(drl.get()));
// Note that a new object reference has been created.
android_atomic_inc(&gNumProxyRefs);
incRefsCreated(env);
}
return object;
}
sp<IBinder> ibinderForJavaObject(JNIEnv* env, jobject obj)
{
if (obj == NULL) return NULL;
if (env->IsInstanceOf(obj, gBinderOffsets.mClass)) {
JavaBBinderHolder* jbh = (JavaBBinderHolder*)
env->GetLongField(obj, gBinderOffsets.mObject);
return jbh != NULL ? jbh->get(env, obj) : NULL;
}
if (env->IsInstanceOf(obj, gBinderProxyOffsets.mClass)) {
return (IBinder*)
env->GetLongField(obj, gBinderProxyOffsets.mObject);
}
ALOGW("ibinderForJavaObject: %p is not a Binder object", obj);
return NULL;
}
jobject newParcelFileDescriptor(JNIEnv* env, jobject fileDesc)
{
return env->NewObject(
gParcelFileDescriptorOffsets.mClass, gParcelFileDescriptorOffsets.mConstructor, fileDesc);
}
void set_dalvik_blockguard_policy(JNIEnv* env, jint strict_policy)
{
// Call back into android.os.StrictMode#onBinderStrictModePolicyChange
// to sync our state back to it. See the comments in StrictMode.java.
env->CallStaticVoidMethod(gStrictModeCallbackOffsets.mClass,
gStrictModeCallbackOffsets.mCallback,
strict_policy);
}
void signalExceptionForError(JNIEnv* env, jobject obj, status_t err,
bool canThrowRemoteException, int parcelSize)
{
switch (err) {
case UNKNOWN_ERROR:
jniThrowException(env, "java/lang/RuntimeException", "Unknown error");
break;
case NO_MEMORY:
jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
break;
case INVALID_OPERATION:
jniThrowException(env, "java/lang/UnsupportedOperationException", NULL);
break;
case BAD_VALUE:
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
break;
case BAD_INDEX:
jniThrowException(env, "java/lang/IndexOutOfBoundsException", NULL);
break;
case BAD_TYPE:
jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
break;
case NAME_NOT_FOUND:
jniThrowException(env, "java/util/NoSuchElementException", NULL);
break;
case PERMISSION_DENIED:
jniThrowException(env, "java/lang/SecurityException", NULL);
break;
case NOT_ENOUGH_DATA:
jniThrowException(env, "android/os/ParcelFormatException", "Not enough data");
break;
case NO_INIT:
jniThrowException(env, "java/lang/RuntimeException", "Not initialized");
break;
case ALREADY_EXISTS:
jniThrowException(env, "java/lang/RuntimeException", "Item already exists");
break;
case DEAD_OBJECT:
// DeadObjectException is a checked exception, only throw from certain methods.
jniThrowException(env, canThrowRemoteException
? "android/os/DeadObjectException"
: "java/lang/RuntimeException", NULL);
break;
case UNKNOWN_TRANSACTION:
jniThrowException(env, "java/lang/RuntimeException", "Unknown transaction code");
break;
case FAILED_TRANSACTION: {
ALOGE("!!! FAILED BINDER TRANSACTION !!! (parcel size = %d)", parcelSize);
const char* exceptionToThrow;
char msg[128];
// TransactionTooLargeException is a checked exception, only throw from certain methods.
// FIXME: Transaction too large is the most common reason for FAILED_TRANSACTION
// but it is not the only one. The Binder driver can return BR_FAILED_REPLY
// for other reasons also, such as if the transaction is malformed or
// refers to an FD that has been closed. We should change the driver
// to enable us to distinguish these cases in the future.
if (canThrowRemoteException && parcelSize > 200*1024) {
// bona fide large payload
exceptionToThrow = "android/os/TransactionTooLargeException";
snprintf(msg, sizeof(msg)-1, "data parcel size %d bytes", parcelSize);
} else {
// Heuristic: a payload smaller than this threshold "shouldn't" be too
// big, so it's probably some other, more subtle problem. In practice
// it seems to always mean that the remote process died while the binder
// transaction was already in flight.
exceptionToThrow = (canThrowRemoteException)
? "android/os/DeadObjectException"
: "java/lang/RuntimeException";
snprintf(msg, sizeof(msg)-1,
"Transaction failed on small parcel; remote process probably died");
}
jniThrowException(env, exceptionToThrow, msg);
} break;
case FDS_NOT_ALLOWED:
jniThrowException(env, "java/lang/RuntimeException",
"Not allowed to write file descriptors here");
break;
case -EBADF:
jniThrowException(env, "java/lang/RuntimeException",
"Bad file descriptor");
break;
case -ENFILE:
jniThrowException(env, "java/lang/RuntimeException",
"File table overflow");
break;
case -EMFILE:
jniThrowException(env, "java/lang/RuntimeException",
"Too many open files");
break;
case -EFBIG:
jniThrowException(env, "java/lang/RuntimeException",
"File too large");
break;
case -ENOSPC:
jniThrowException(env, "java/lang/RuntimeException",
"No space left on device");
break;
case -ESPIPE:
jniThrowException(env, "java/lang/RuntimeException",
"Illegal seek");
break;
case -EROFS:
jniThrowException(env, "java/lang/RuntimeException",
"Read-only file system");
break;
case -EMLINK:
jniThrowException(env, "java/lang/RuntimeException",
"Too many links");
break;
default:
ALOGE("Unknown binder error code. 0x%" PRIx32, err);
String8 msg;
msg.appendFormat("Unknown binder error code. 0x%" PRIx32, err);
// RemoteException is a checked exception, only throw from certain methods.
jniThrowException(env, canThrowRemoteException
? "android/os/RemoteException" : "java/lang/RuntimeException", msg.string());
break;
}
}
}
// ----------------------------------------------------------------------------
static jint android_os_Binder_getCallingPid(JNIEnv* env, jobject clazz)
{
return IPCThreadState::self()->getCallingPid();
}
static jint android_os_Binder_getCallingUid(JNIEnv* env, jobject clazz)
{
return IPCThreadState::self()->getCallingUid();
}
static jlong android_os_Binder_clearCallingIdentity(JNIEnv* env, jobject clazz)
{
return IPCThreadState::self()->clearCallingIdentity();
}
static void android_os_Binder_restoreCallingIdentity(JNIEnv* env, jobject clazz, jlong token)
{
// XXX temporary sanity check to debug crashes.
int uid = (int)(token>>32);
if (uid > 0 && uid < 999) {
// In Android currently there are no uids in this range.
char buf[128];
sprintf(buf, "Restoring bad calling ident: 0x%" PRIx64, token);
jniThrowException(env, "java/lang/IllegalStateException", buf);
return;
}
IPCThreadState::self()->restoreCallingIdentity(token);
}
static void android_os_Binder_setThreadStrictModePolicy(JNIEnv* env, jobject clazz, jint policyMask)
{
IPCThreadState::self()->setStrictModePolicy(policyMask);
}
static jint android_os_Binder_getThreadStrictModePolicy(JNIEnv* env, jobject clazz)
{
return IPCThreadState::self()->getStrictModePolicy();
}
static void android_os_Binder_flushPendingCommands(JNIEnv* env, jobject clazz)
{
IPCThreadState::self()->flushCommands();
}
static void android_os_Binder_init(JNIEnv* env, jobject obj)
{
JavaBBinderHolder* jbh = new JavaBBinderHolder();
if (jbh == NULL) {
jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
return;
}
ALOGV("Java Binder %p: acquiring first ref on holder %p", obj, jbh);
jbh->incStrong((void*)android_os_Binder_init);
env->SetLongField(obj, gBinderOffsets.mObject, (jlong)jbh);
}
static void android_os_Binder_destroy(JNIEnv* env, jobject obj)
{
JavaBBinderHolder* jbh = (JavaBBinderHolder*)
env->GetLongField(obj, gBinderOffsets.mObject);
if (jbh != NULL) {
env->SetLongField(obj, gBinderOffsets.mObject, 0);
ALOGV("Java Binder %p: removing ref on holder %p", obj, jbh);
jbh->decStrong((void*)android_os_Binder_init);
} else {
// Encountering an uninitialized binder is harmless. All it means is that
// the Binder was only partially initialized when its finalizer ran and called
// destroy(). The Binder could be partially initialized for several reasons.
// For example, a Binder subclass constructor might have thrown an exception before
// it could delegate to its superclass's constructor. Consequently init() would
// not have been called and the holder pointer would remain NULL.
ALOGV("Java Binder %p: ignoring uninitialized binder", obj);
}
}
static void android_os_Binder_blockUntilThreadAvailable(JNIEnv* env, jobject clazz)
{
return IPCThreadState::self()->blockUntilThreadAvailable();
}
// ----------------------------------------------------------------------------
static const JNINativeMethod gBinderMethods[] = {
/* name, signature, funcPtr */
{ "getCallingPid", "()I", (void*)android_os_Binder_getCallingPid },
{ "getCallingUid", "()I", (void*)android_os_Binder_getCallingUid },
{ "clearCallingIdentity", "()J", (void*)android_os_Binder_clearCallingIdentity },
{ "restoreCallingIdentity", "(J)V", (void*)android_os_Binder_restoreCallingIdentity },
{ "setThreadStrictModePolicy", "(I)V", (void*)android_os_Binder_setThreadStrictModePolicy },
{ "getThreadStrictModePolicy", "()I", (void*)android_os_Binder_getThreadStrictModePolicy },
{ "flushPendingCommands", "()V", (void*)android_os_Binder_flushPendingCommands },
{ "init", "()V", (void*)android_os_Binder_init },
{ "destroy", "()V", (void*)android_os_Binder_destroy },
{ "blockUntilThreadAvailable", "()V", (void*)android_os_Binder_blockUntilThreadAvailable }
};
const char* const kBinderPathName = "android/os/Binder";
static int int_register_android_os_Binder(JNIEnv* env)
{
jclass clazz = FindClassOrDie(env, kBinderPathName);
gBinderOffsets.mClass = MakeGlobalRefOrDie(env, clazz);
gBinderOffsets.mExecTransact = GetMethodIDOrDie(env, clazz, "execTransact", "(IJJI)Z");
gBinderOffsets.mObject = GetFieldIDOrDie(env, clazz, "mObject", "J");
return RegisterMethodsOrDie(
env, kBinderPathName,
gBinderMethods, NELEM(gBinderMethods));
}
// ****************************************************************************
// ****************************************************************************
// ****************************************************************************
namespace android {
jint android_os_Debug_getLocalObjectCount(JNIEnv* env, jobject clazz)
{
return gNumLocalRefs;
}
jint android_os_Debug_getProxyObjectCount(JNIEnv* env, jobject clazz)
{
return gNumProxyRefs;
}
jint android_os_Debug_getDeathObjectCount(JNIEnv* env, jobject clazz)
{
return gNumDeathRefs;
}
}
// ****************************************************************************
// ****************************************************************************
// ****************************************************************************
static jobject android_os_BinderInternal_getContextObject(JNIEnv* env, jobject clazz)
{
sp<IBinder> b = ProcessState::self()->getContextObject(NULL);
return javaObjectForIBinder(env, b);
}
static void android_os_BinderInternal_joinThreadPool(JNIEnv* env, jobject clazz)
{
sp<IBinder> b = ProcessState::self()->getContextObject(NULL);
android::IPCThreadState::self()->joinThreadPool();
}
static void android_os_BinderInternal_disableBackgroundScheduling(JNIEnv* env,
jobject clazz, jboolean disable)
{
IPCThreadState::disableBackgroundScheduling(disable ? true : false);
}
static void android_os_BinderInternal_handleGc(JNIEnv* env, jobject clazz)
{
ALOGV("Gc has executed, clearing binder ops");
android_atomic_and(0, &gNumRefsCreated);
}
// ----------------------------------------------------------------------------
static const JNINativeMethod gBinderInternalMethods[] = {
/* name, signature, funcPtr */
{ "getContextObject", "()Landroid/os/IBinder;", (void*)android_os_BinderInternal_getContextObject },
{ "joinThreadPool", "()V", (void*)android_os_BinderInternal_joinThreadPool },
{ "disableBackgroundScheduling", "(Z)V", (void*)android_os_BinderInternal_disableBackgroundScheduling },
{ "handleGc", "()V", (void*)android_os_BinderInternal_handleGc }
};
const char* const kBinderInternalPathName = "com/android/internal/os/BinderInternal";
static int int_register_android_os_BinderInternal(JNIEnv* env)
{
jclass clazz = FindClassOrDie(env, kBinderInternalPathName);
gBinderInternalOffsets.mClass = MakeGlobalRefOrDie(env, clazz);
gBinderInternalOffsets.mForceGc = GetStaticMethodIDOrDie(env, clazz, "forceBinderGc", "()V");
return RegisterMethodsOrDie(
env, kBinderInternalPathName,
gBinderInternalMethods, NELEM(gBinderInternalMethods));
}
// ****************************************************************************
// ****************************************************************************
// ****************************************************************************
static jboolean android_os_BinderProxy_pingBinder(JNIEnv* env, jobject obj)
{
IBinder* target = (IBinder*)
env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
return JNI_FALSE;
}
status_t err = target->pingBinder();
return err == NO_ERROR ? JNI_TRUE : JNI_FALSE;
}
static jstring android_os_BinderProxy_getInterfaceDescriptor(JNIEnv* env, jobject obj)
{
IBinder* target = (IBinder*) env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target != NULL) {
const String16& desc = target->getInterfaceDescriptor();
return env->NewString(reinterpret_cast<const jchar*>(desc.string()),
desc.size());
}
jniThrowException(env, "java/lang/RuntimeException",
"No binder found for object");
return NULL;
}
static jboolean android_os_BinderProxy_isBinderAlive(JNIEnv* env, jobject obj)
{
IBinder* target = (IBinder*)
env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
return JNI_FALSE;
}
bool alive = target->isBinderAlive();
return alive ? JNI_TRUE : JNI_FALSE;
}
static int getprocname(pid_t pid, char *buf, size_t len) {
char filename[32];
FILE *f;
snprintf(filename, sizeof(filename), "/proc/%d/cmdline", pid);
f = fopen(filename, "r");
if (!f) {
*buf = '\0';
return 1;
}
if (!fgets(buf, len, f)) {
*buf = '\0';
fclose(f);
return 2;
}
fclose(f);
return 0;
}
static bool push_eventlog_string(char** pos, const char* end, const char* str) {
jint len = strlen(str);
int space_needed = 1 + sizeof(len) + len;
if (end - *pos < space_needed) {
ALOGW("not enough space for string. remain=%" PRIdPTR "; needed=%d",
end - *pos, space_needed);
return false;
}
**pos = EVENT_TYPE_STRING;
(*pos)++;
memcpy(*pos, &len, sizeof(len));
*pos += sizeof(len);
memcpy(*pos, str, len);
*pos += len;
return true;
}
static bool push_eventlog_int(char** pos, const char* end, jint val) {
int space_needed = 1 + sizeof(val);
if (end - *pos < space_needed) {
ALOGW("not enough space for int. remain=%" PRIdPTR "; needed=%d",
end - *pos, space_needed);
return false;
}
**pos = EVENT_TYPE_INT;
(*pos)++;
memcpy(*pos, &val, sizeof(val));
*pos += sizeof(val);
return true;
}
// From frameworks/base/core/java/android/content/EventLogTags.logtags:
static const bool kEnableBinderSample = false;
#define LOGTAG_BINDER_OPERATION 52004
static void conditionally_log_binder_call(int64_t start_millis,
IBinder* target, jint code) {
int duration_ms = static_cast<int>(uptimeMillis() - start_millis);
int sample_percent;
if (duration_ms >= 500) {
sample_percent = 100;
} else {
sample_percent = 100 * duration_ms / 500;
if (sample_percent == 0) {
return;
}
if (sample_percent < (random() % 100 + 1)) {
return;
}
}
char process_name[40];
getprocname(getpid(), process_name, sizeof(process_name));
String8 desc(target->getInterfaceDescriptor());
char buf[LOGGER_ENTRY_MAX_PAYLOAD];
buf[0] = EVENT_TYPE_LIST;
buf[1] = 5;
char* pos = &buf[2];
char* end = &buf[LOGGER_ENTRY_MAX_PAYLOAD - 1]; // leave room for final \n
if (!push_eventlog_string(&pos, end, desc.string())) return;
if (!push_eventlog_int(&pos, end, code)) return;
if (!push_eventlog_int(&pos, end, duration_ms)) return;
if (!push_eventlog_string(&pos, end, process_name)) return;
if (!push_eventlog_int(&pos, end, sample_percent)) return;
*(pos++) = '\n'; // conventional with EVENT_TYPE_LIST apparently.
android_bWriteLog(LOGTAG_BINDER_OPERATION, buf, pos - buf);
}
// We only measure binder call durations to potentially log them if
// we're on the main thread.
static bool should_time_binder_calls() {
return (getpid() == gettid());
}
static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj,
jint code, jobject dataObj, jobject replyObj, jint flags) // throws RemoteException
{
if (dataObj == NULL) {
jniThrowNullPointerException(env, NULL);
return JNI_FALSE;
}
Parcel* data = parcelForJavaObject(env, dataObj);
if (data == NULL) {
return JNI_FALSE;
}
Parcel* reply = parcelForJavaObject(env, replyObj);
if (reply == NULL && replyObj != NULL) {
return JNI_FALSE;
}
IBinder* target = (IBinder*)
env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
jniThrowException(env, "java/lang/IllegalStateException", "Binder has been finalized!");
return JNI_FALSE;
}
ALOGV("Java code calling transact on %p in Java object %p with code %" PRId32 "\n",
target, obj, code);
bool time_binder_calls;
int64_t start_millis;
if (kEnableBinderSample) {
// Only log the binder call duration for things on the Java-level main thread.
// But if we don't
time_binder_calls = should_time_binder_calls();
if (time_binder_calls) {
start_millis = uptimeMillis();
}
}
//printf("Transact from Java code to %p sending: ", target); data->print();
status_t err = target->transact(code, *data, reply, flags);
//if (reply) printf("Transact from Java code to %p received: ", target); reply->print();
if (kEnableBinderSample) {
if (time_binder_calls) {
conditionally_log_binder_call(start_millis, target, code);
}
}
if (err == NO_ERROR) {
return JNI_TRUE;
} else if (err == UNKNOWN_TRANSACTION) {
return JNI_FALSE;
}
signalExceptionForError(env, obj, err, true /*canThrowRemoteException*/, data->dataSize());
return JNI_FALSE;
}
static void android_os_BinderProxy_linkToDeath(JNIEnv* env, jobject obj,
jobject recipient, jint flags) // throws RemoteException
{
if (recipient == NULL) {
jniThrowNullPointerException(env, NULL);
return;
}
IBinder* target = (IBinder*)
env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
ALOGW("Binder has been finalized when calling linkToDeath() with recip=%p)\n", recipient);
assert(false);
}
LOGDEATH("linkToDeath: binder=%p recipient=%p\n", target, recipient);
if (!target->localBinder()) {
DeathRecipientList* list = (DeathRecipientList*)
env->GetLongField(obj, gBinderProxyOffsets.mOrgue);
sp<JavaDeathRecipient> jdr = new JavaDeathRecipient(env, recipient, list);
status_t err = target->linkToDeath(jdr, NULL, flags);
if (err != NO_ERROR) {
// Failure adding the death recipient, so clear its reference
// now.
jdr->clearReference();
signalExceptionForError(env, obj, err, true /*canThrowRemoteException*/);
}
}
}
static jboolean android_os_BinderProxy_unlinkToDeath(JNIEnv* env, jobject obj,
jobject recipient, jint flags)
{
jboolean res = JNI_FALSE;
if (recipient == NULL) {
jniThrowNullPointerException(env, NULL);
return res;
}
IBinder* target = (IBinder*)
env->GetLongField(obj, gBinderProxyOffsets.mObject);
if (target == NULL) {
ALOGW("Binder has been finalized when calling linkToDeath() with recip=%p)\n", recipient);
return JNI_FALSE;
}
LOGDEATH("unlinkToDeath: binder=%p recipient=%p\n", target, recipient);
if (!target->localBinder()) {
status_t err = NAME_NOT_FOUND;
// If we find the matching recipient, proceed to unlink using that
DeathRecipientList* list = (DeathRecipientList*)
env->GetLongField(obj, gBinderProxyOffsets.mOrgue);
sp<JavaDeathRecipient> origJDR = list->find(recipient);
LOGDEATH(" unlink found list %p and JDR %p", list, origJDR.get());
if (origJDR != NULL) {
wp<IBinder::DeathRecipient> dr;
err = target->unlinkToDeath(origJDR, NULL, flags, &dr);
if (err == NO_ERROR && dr != NULL) {
sp<IBinder::DeathRecipient> sdr = dr.promote();
JavaDeathRecipient* jdr = static_cast<JavaDeathRecipient*>(sdr.get());
if (jdr != NULL) {
jdr->clearReference();
}
}
}
if (err == NO_ERROR || err == DEAD_OBJECT) {
res = JNI_TRUE;
} else {
jniThrowException(env, "java/util/NoSuchElementException",
"Death link does not exist");
}
}
return res;
}
static void android_os_BinderProxy_destroy(JNIEnv* env, jobject obj)
{
IBinder* b = (IBinder*)
env->GetLongField(obj, gBinderProxyOffsets.mObject);
DeathRecipientList* drl = (DeathRecipientList*)
env->GetLongField(obj, gBinderProxyOffsets.mOrgue);
LOGDEATH("Destroying BinderProxy %p: binder=%p drl=%p\n", obj, b, drl);
env->SetLongField(obj, gBinderProxyOffsets.mObject, 0);
env->SetLongField(obj, gBinderProxyOffsets.mOrgue, 0);
drl->decStrong((void*)javaObjectForIBinder);
b->decStrong((void*)javaObjectForIBinder);
IPCThreadState::self()->flushCommands();
}
// ----------------------------------------------------------------------------
static const JNINativeMethod gBinderProxyMethods[] = {
/* name, signature, funcPtr */
{"pingBinder", "()Z", (void*)android_os_BinderProxy_pingBinder},
{"isBinderAlive", "()Z", (void*)android_os_BinderProxy_isBinderAlive},
{"getInterfaceDescriptor", "()Ljava/lang/String;", (void*)android_os_BinderProxy_getInterfaceDescriptor},
{"transactNative", "(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z", (void*)android_os_BinderProxy_transact},
{"linkToDeath", "(Landroid/os/IBinder$DeathRecipient;I)V", (void*)android_os_BinderProxy_linkToDeath},
{"unlinkToDeath", "(Landroid/os/IBinder$DeathRecipient;I)Z", (void*)android_os_BinderProxy_unlinkToDeath},
{"destroy", "()V", (void*)android_os_BinderProxy_destroy},
};
const char* const kBinderProxyPathName = "android/os/BinderProxy";
static int int_register_android_os_BinderProxy(JNIEnv* env)
{
jclass clazz = FindClassOrDie(env, "java/lang/Error");
gErrorOffsets.mClass = MakeGlobalRefOrDie(env, clazz);
clazz = FindClassOrDie(env, kBinderProxyPathName);
gBinderProxyOffsets.mClass = MakeGlobalRefOrDie(env, clazz);
gBinderProxyOffsets.mConstructor = GetMethodIDOrDie(env, clazz, "<init>", "()V");
gBinderProxyOffsets.mSendDeathNotice = GetStaticMethodIDOrDie(env, clazz, "sendDeathNotice",
"(Landroid/os/IBinder$DeathRecipient;)V");
gBinderProxyOffsets.mObject = GetFieldIDOrDie(env, clazz, "mObject", "J");
gBinderProxyOffsets.mSelf = GetFieldIDOrDie(env, clazz, "mSelf",
"Ljava/lang/ref/WeakReference;");
gBinderProxyOffsets.mOrgue = GetFieldIDOrDie(env, clazz, "mOrgue", "J");
clazz = FindClassOrDie(env, "java/lang/Class");
gClassOffsets.mGetName = GetMethodIDOrDie(env, clazz, "getName", "()Ljava/lang/String;");
return RegisterMethodsOrDie(
env, kBinderProxyPathName,
gBinderProxyMethods, NELEM(gBinderProxyMethods));
}
// ****************************************************************************
// ****************************************************************************
// ****************************************************************************
int register_android_os_Binder(JNIEnv* env)
{
if (int_register_android_os_Binder(env) < 0)
return -1;
if (int_register_android_os_BinderInternal(env) < 0)
return -1;
if (int_register_android_os_BinderProxy(env) < 0)
return -1;
jclass clazz = FindClassOrDie(env, "android/util/Log");
gLogOffsets.mClass = MakeGlobalRefOrDie(env, clazz);
gLogOffsets.mLogE = GetStaticMethodIDOrDie(env, clazz, "e",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I");
clazz = FindClassOrDie(env, "android/os/ParcelFileDescriptor");
gParcelFileDescriptorOffsets.mClass = MakeGlobalRefOrDie(env, clazz);
gParcelFileDescriptorOffsets.mConstructor = GetMethodIDOrDie(env, clazz, "<init>",
"(Ljava/io/FileDescriptor;)V");
clazz = FindClassOrDie(env, "android/os/StrictMode");
gStrictModeCallbackOffsets.mClass = MakeGlobalRefOrDie(env, clazz);
gStrictModeCallbackOffsets.mCallback = GetStaticMethodIDOrDie(env, clazz,
"onBinderStrictModePolicyChange", "(I)V");
return 0;
}
| 35.107798 | 116 | 0.610048 | [
"object",
"vector"
] |
c143f7b1d880f12dd42e396ffce329013e8941a7 | 2,534 | cpp | C++ | aws-cpp-sdk-macie2/source/model/ObjectCountByEncryptionType.cpp | perfectrecall/aws-sdk-cpp | fb8cbebf2fd62720b65aeff841ad2950e73d8ebd | [
"Apache-2.0"
] | 1 | 2022-02-12T08:09:30.000Z | 2022-02-12T08:09:30.000Z | aws-cpp-sdk-macie2/source/model/ObjectCountByEncryptionType.cpp | perfectrecall/aws-sdk-cpp | fb8cbebf2fd62720b65aeff841ad2950e73d8ebd | [
"Apache-2.0"
] | 1 | 2022-01-03T23:59:37.000Z | 2022-01-03T23:59:37.000Z | aws-cpp-sdk-macie2/source/model/ObjectCountByEncryptionType.cpp | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 1 | 2021-11-09T11:58:03.000Z | 2021-11-09T11:58:03.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/macie2/model/ObjectCountByEncryptionType.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace Macie2
{
namespace Model
{
ObjectCountByEncryptionType::ObjectCountByEncryptionType() :
m_customerManaged(0),
m_customerManagedHasBeenSet(false),
m_kmsManaged(0),
m_kmsManagedHasBeenSet(false),
m_s3Managed(0),
m_s3ManagedHasBeenSet(false),
m_unencrypted(0),
m_unencryptedHasBeenSet(false),
m_unknown(0),
m_unknownHasBeenSet(false)
{
}
ObjectCountByEncryptionType::ObjectCountByEncryptionType(JsonView jsonValue) :
m_customerManaged(0),
m_customerManagedHasBeenSet(false),
m_kmsManaged(0),
m_kmsManagedHasBeenSet(false),
m_s3Managed(0),
m_s3ManagedHasBeenSet(false),
m_unencrypted(0),
m_unencryptedHasBeenSet(false),
m_unknown(0),
m_unknownHasBeenSet(false)
{
*this = jsonValue;
}
ObjectCountByEncryptionType& ObjectCountByEncryptionType::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("customerManaged"))
{
m_customerManaged = jsonValue.GetInt64("customerManaged");
m_customerManagedHasBeenSet = true;
}
if(jsonValue.ValueExists("kmsManaged"))
{
m_kmsManaged = jsonValue.GetInt64("kmsManaged");
m_kmsManagedHasBeenSet = true;
}
if(jsonValue.ValueExists("s3Managed"))
{
m_s3Managed = jsonValue.GetInt64("s3Managed");
m_s3ManagedHasBeenSet = true;
}
if(jsonValue.ValueExists("unencrypted"))
{
m_unencrypted = jsonValue.GetInt64("unencrypted");
m_unencryptedHasBeenSet = true;
}
if(jsonValue.ValueExists("unknown"))
{
m_unknown = jsonValue.GetInt64("unknown");
m_unknownHasBeenSet = true;
}
return *this;
}
JsonValue ObjectCountByEncryptionType::Jsonize() const
{
JsonValue payload;
if(m_customerManagedHasBeenSet)
{
payload.WithInt64("customerManaged", m_customerManaged);
}
if(m_kmsManagedHasBeenSet)
{
payload.WithInt64("kmsManaged", m_kmsManaged);
}
if(m_s3ManagedHasBeenSet)
{
payload.WithInt64("s3Managed", m_s3Managed);
}
if(m_unencryptedHasBeenSet)
{
payload.WithInt64("unencrypted", m_unencrypted);
}
if(m_unknownHasBeenSet)
{
payload.WithInt64("unknown", m_unknown);
}
return payload;
}
} // namespace Model
} // namespace Macie2
} // namespace Aws
| 19.492308 | 88 | 0.723757 | [
"model"
] |
c1458f4e559e8fbfba353b628146b8bce44131f1 | 1,317 | cpp | C++ | grooking_patterns_cpp/7_tree_bfs/7_4.cpp | Amarnathpg123/grokking_coding_patterns | c615482ef2819d90cba832944943a6b5713d11f3 | [
"MIT"
] | 1 | 2021-09-19T16:41:58.000Z | 2021-09-19T16:41:58.000Z | grooking_patterns_cpp/7_tree_bfs/7_4.cpp | Amarnathpg123/grokking_coding_patterns | c615482ef2819d90cba832944943a6b5713d11f3 | [
"MIT"
] | null | null | null | grooking_patterns_cpp/7_tree_bfs/7_4.cpp | Amarnathpg123/grokking_coding_patterns | c615482ef2819d90cba832944943a6b5713d11f3 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
class Node {
public:
long key;
Node* left;
Node* right;
Node(long key_): key(key_), left(nullptr), right(nullptr) {}
};
void averages_of_levels(Node *root, vector<long> &averages){
if(not root) return;
queue<Node*> Q;
Q.push(root);
while(Q.size()){
size_t sz = Q.size();
long long level_sum = 0;
for(size_t i = Q.size(); i > 0; --i){
Node *current = Q.front(); Q.pop();
level_sum += current->key;
if(current->left != nullptr) Q.push(current->left);
if(current->right != nullptr) Q.push(current->right);
}
averages.push_back(level_sum/sz);
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
Node *root = new Node(12);
root->left = new Node(7);
root->right = new Node(1);
root->left->left = new Node(9);
root->left->right = new Node(98);
root->right->left = new Node(11);
root->right->right = new Node(5);
root->left->left->left = new Node(10);
root->right->right->right = new Node(8);
vector<long> averages;
printf("Averages of levels are: ");
averages_of_levels(root, averages);
for(auto &i: averages) printf("%ld ", i);
cout << endl;
return 0;
} | 24.849057 | 65 | 0.56492 | [
"vector"
] |
c146ecb6a30e943e970691c71e519ebcac59e4b5 | 1,176 | cpp | C++ | src/Engine/CDialog.cpp | j-sokol/ncursesPac | 8a41eece04f36f852a32022b2bfd3a038b3ad5d2 | [
"MIT"
] | 24 | 2017-04-22T03:28:52.000Z | 2021-11-08T12:30:58.000Z | src/Engine/CDialog.cpp | j-sokol/pac | 8a41eece04f36f852a32022b2bfd3a038b3ad5d2 | [
"MIT"
] | 2 | 2020-05-22T05:59:15.000Z | 2021-06-05T14:23:56.000Z | src/Engine/CDialog.cpp | j-sokol/ncursesPac | 8a41eece04f36f852a32022b2bfd3a038b3ad5d2 | [
"MIT"
] | 7 | 2017-04-18T23:07:43.000Z | 2021-11-07T16:44:00.000Z | #include <Engine/CDialog.h>
#include <Engine/CLayout.h>
#include <Engine/CMenu.h>
#include <Engine/CTime.h>
#include <Engine/CNCurses.h>
#include <Engine/CInputManager.h>
#include <algorithm>
void CDialog::show ( const std::vector<std::string> & message,
const std::string & label )
{
int window_height, window_width, msg_width;
msg_width = 0;
window_height = (message) . size () + 4;
for ( unsigned int i = 0; i < (message) . size (); ++i )
msg_width = ((msg_width > (int) (message) [ i ] . size ()) ? msg_width : (int) (message) [ i ] . size ());
window_width = std::max ( 33, msg_width + 4 );
int cur_h, cur_w;
getmaxyx ( stdscr, cur_h, cur_w );
int window_x = cur_w / 2 - (window_width - 2) / 2;
int window_y = cur_h / 2 - window_height / 2;
CWindow dialog ( window_x, window_y, window_width, window_height, true, label );
refresh ();
dialog . set_lower_text ( "Press any key to continue");
dialog . clear ();
for ( unsigned int i = 0; i < (message) . size (); ++i )
dialog . print_str ( (message) [i], 2, i + 2);
dialog . refresh ();
refresh ();
CTime::delay_ms ( 5000 );
CNCurses::get_input (-1);
} | 23.52 | 109 | 0.619048 | [
"vector"
] |
c1516d5e4e1ed595ddf96a3638dfec35e8f7ff22 | 2,727 | cpp | C++ | lib-opencc-android/src/main/jni/OpenCC/src/UTF8UtilTest.cpp | huxiaomao/android-opencc | a251591316323151a97d977c39c85e0571c60971 | [
"MIT"
] | 5,895 | 2015-01-01T12:28:18.000Z | 2022-03-31T07:50:46.000Z | lib-opencc-android/src/main/jni/OpenCC/src/UTF8UtilTest.cpp | huxiaomao/android-opencc | a251591316323151a97d977c39c85e0571c60971 | [
"MIT"
] | 479 | 2015-01-01T12:24:31.000Z | 2022-03-25T06:15:40.000Z | lib-opencc-android/src/main/jni/OpenCC/src/UTF8UtilTest.cpp | huxiaomao/android-opencc | a251591316323151a97d977c39c85e0571c60971 | [
"MIT"
] | 888 | 2015-01-01T11:17:44.000Z | 2022-03-31T06:44:44.000Z | /*
* Open Chinese Convert
*
* Copyright 2015 Carbo Kuo <byvoid@byvoid.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 "UTF8Util.hpp"
#include "TestUtils.hpp"
namespace opencc {
class UTF8UtilTest : public ::testing::Test {
protected:
UTF8UtilTest() : text("東菄鶇䍶𠍀倲𩜍𢘐"), length(strlen(text)){};
const char* text;
const size_t length;
};
TEST_F(UTF8UtilTest, NextCharLength) {
EXPECT_EQ(3, UTF8Util::NextCharLength(text));
EXPECT_EQ(3, UTF8Util::NextCharLength(text + 3));
EXPECT_EQ(3, UTF8Util::NextCharLength(text + 6));
EXPECT_EQ(3, UTF8Util::NextCharLength(text + 9));
EXPECT_EQ(4, UTF8Util::NextCharLength(text + 12));
EXPECT_EQ(3, UTF8Util::NextCharLength(text + 16));
EXPECT_EQ(4, UTF8Util::NextCharLength(text + 19));
EXPECT_EQ(4, UTF8Util::NextCharLength(text + 23));
EXPECT_THROW(EXPECT_EQ(3, UTF8Util::NextCharLength(text + 1)), InvalidUTF8);
EXPECT_THROW(EXPECT_EQ(3, UTF8Util::NextCharLength(text + 2)), InvalidUTF8);
}
TEST_F(UTF8UtilTest, PrevCharLength) {
EXPECT_EQ(4, UTF8Util::PrevCharLength(text + length));
EXPECT_EQ(4, UTF8Util::PrevCharLength(text + length - 4));
EXPECT_EQ(3, UTF8Util::PrevCharLength(text + length - 8));
EXPECT_THROW(EXPECT_EQ(3, UTF8Util::PrevCharLength(text + 1)), InvalidUTF8);
}
TEST_F(UTF8UtilTest, Length) {
EXPECT_EQ(0, UTF8Util::Length(""));
EXPECT_EQ(8, UTF8Util::Length(text));
}
TEST_F(UTF8UtilTest, NotShorterThan) {
EXPECT_TRUE(UTF8Util::NotShorterThan(text, 0));
EXPECT_TRUE(UTF8Util::NotShorterThan(text, length));
EXPECT_FALSE(UTF8Util::NotShorterThan(text, length + 1));
}
TEST_F(UTF8UtilTest, TruncateUTF8) {
EXPECT_EQ("", UTF8Util::TruncateUTF8(text, 0));
EXPECT_EQ("", UTF8Util::TruncateUTF8(text, 1));
EXPECT_EQ("東", UTF8Util::TruncateUTF8(text, 3));
EXPECT_EQ("東", UTF8Util::TruncateUTF8(text, 4));
EXPECT_EQ("東菄鶇䍶𠍀", UTF8Util::TruncateUTF8(text, 16));
EXPECT_EQ(text, UTF8Util::TruncateUTF8(text, length));
EXPECT_EQ(text, UTF8Util::TruncateUTF8(text, length + 1));
}
TEST_F(UTF8UtilTest, GetByteMap) {
std::vector<size_t> byteMap;
UTF8Util::GetByteMap(text, 6, &byteMap);
EXPECT_EQ(std::vector<size_t>({0, 3, 6, 9, 12, 16}), byteMap);
}
} // namespace opencc
| 34.518987 | 78 | 0.722039 | [
"vector"
] |
c15398eb7b41f322c15541e54766c1278de5cd88 | 15,540 | hpp | C++ | openstudiocore/src/analysisdriver/CloudAnalysisDriver_Impl.hpp | jasondegraw/OpenStudio | 2ab13f6e5e48940929041444e40ad9d36f80f552 | [
"blessing"
] | 1 | 2016-12-29T08:45:03.000Z | 2016-12-29T08:45:03.000Z | openstudiocore/src/analysisdriver/CloudAnalysisDriver_Impl.hpp | jasondegraw/OpenStudio | 2ab13f6e5e48940929041444e40ad9d36f80f552 | [
"blessing"
] | null | null | null | openstudiocore/src/analysisdriver/CloudAnalysisDriver_Impl.hpp | jasondegraw/OpenStudio | 2ab13f6e5e48940929041444e40ad9d36f80f552 | [
"blessing"
] | null | null | null | /**********************************************************************
* Copyright (c) 2008-2016, Alliance for Sustainable Energy.
* All rights reserved.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********************************************************************/
#ifndef ANALYSISDRIVER_CLOUDANALYSISDRIVER_IMPL_HPP
#define ANALYSISDRIVER_CLOUDANALYSISDRIVER_IMPL_HPP
#include "AnalysisDriverAPI.hpp"
#include "AnalysisDriverEnums.hpp"
#include "SimpleProject.hpp"
#include "../analysis/DataPoint.hpp"
#include "../utilities/cloud/CloudProvider.hpp"
#include "../utilities/cloud/OSServer.hpp"
#include <QObject>
#include <boost/smart_ptr.hpp>
#include <deque>
namespace openstudio {
class Tag;
namespace analysisdriver {
namespace detail {
/** CloudAnalysisDriver_Impl is the implementation class for CloudAnalysisDriver.*/
class ANALYSISDRIVER_API CloudAnalysisDriver_Impl : public QObject, public std::enable_shared_from_this<CloudAnalysisDriver_Impl> {
Q_OBJECT;
public:
/** @name Constructors and Destructors */
//@{
CloudAnalysisDriver_Impl(const CloudSession& session,
const SimpleProject& project);
virtual ~CloudAnalysisDriver_Impl() {}
//@}
/** @name Getters */
//@{
CloudSession session() const;
SimpleProject project() const;
AnalysisStatus status() const;
/** Returns the number of data points the CloudAnalysisDriver has been asked to process
* since the last time all the queues were cleared. */
unsigned numDataPointsInIteration() const;
/** Returns the number of data points in all of the processing queues. */
unsigned numIncompleteDataPoints() const;
/** Returns the number of data points in this iteration that are no longer being processed. */
unsigned numCompleteDataPoints() const;
/** Returns the number of complete data points that are marked as .failed(). */
unsigned numFailedDataPoints() const;
/** Returns the DataPoints whose json files failed to download. Note that these are counted
* as 'complete' by CloudAnalysisDriver, but not by Analysis. */
std::vector<analysis::DataPoint> failedJsonDownloads() const;
/** Returns the DataPoints whose details failed to download. Note that these are counted as
* 'complete' by CloudAnalysisDriver and by Analysis, but their .directory() is .empty(). */
std::vector<analysis::DataPoint> failedDetailedDownloads() const;
/** Returns true if dataPoint is associated with session(), that is, if its last run request
* was with session() (not local, and not another CloudSession). */
bool inSession(const analysis::DataPoint& dataPoint) const;
//@}
/** @name Blocking Class Members */
//@{
bool run(int msec=-1);
bool lastRunSuccess() const;
bool stop(int msec=-1);
bool lastStopSuccess() const;
bool downloadDetailedResults(analysis::DataPoint& dataPoint,int msec=-1);
bool lastDownloadDetailedResultsSuccess() const;
bool isRunning() const;
bool isStopping() const;
bool isDownloading() const;
std::vector<std::string> errors() const;
std::vector<std::string> warnings() const;
/** If no argument is specified, CloudAnalysisDriver will run until not isRunning() and
* not isDownloading(). If msec is specified, will wait for at most msec milliseconds.
* Returns true if not isRunning() and not isDownloading() upon exit; false otherwise. */
bool waitForFinished(int msec=-1);
//@}
/** @name Non-blocking class members */
//@{
/** Request the project() to run on the session(). Returns false if isRunning().
* Otherwise returns true and emits runRequestComplete(bool success) when either the
* analysis has stopped running on the server or the process has failed. The ultimate
* value of success will also be available from lastRunSuccess(). This method will try
* to pick up where a previous run left off. */
bool requestRun();
/** Request the project() to stop running on the session(). Returns false if not
* (isRunning() || isDownloading()). Otherwise returns true and emits
* stopRequestComplete(bool success) when the analysis has stopped running and the
* download queue is empty, or the process has failed. The ultimate value of
* success will also be available from lastStopSuccess(). */
bool requestStop(bool waitForAlreadyRunningDataPoints=false);
/** Request for dataPoint's detailed results to be downloaded. Returns false if
* !dataPoint.complete() or if the detailed results have already been downloaded or
* if the dataPoint does not belong to project().analysis(). Otherwise returns true
* and emits dowloadRequestsComplete(bool success) when the detailed downloads queue
* is empty or the process has failed. Look for the dataPointDetailsComplete signal
* to see when this particular dataPoint's results have been incorporated. */
bool requestDownloadDetailedResults(analysis::DataPoint& dataPoint);
//@}
/** @name Type Casting */
//@{
/** Get a public object that wraps this impl.*/
template<typename T>
T getPublicObject() const {
T result(std::dynamic_pointer_cast<typename T::ImplType>(
std::const_pointer_cast<CloudAnalysisDriver_Impl>(shared_from_this())));
return result;
}
//@}
signals:
/** @name Non-blocking Call Finished Signals */
//@{
void runRequestComplete(bool success);
void stopRequestComplete(bool success);
void detailedDownloadRequestsComplete(bool success);
//@}
/** @name AnalysisDriver/CurrentAnalysis Progress Signals */
//@{
void resultsChanged();
void iterationProgress(int numCompletedJobs,int numJobsInIteration);
// emitted when data point posted to server
void dataPointQueued(const openstudio::UUID& analysis, const openstudio::UUID& dataPoint);
// emitted when data point reported as running
void dataPointRunning(const openstudio::UUID& analysis, const openstudio::UUID& dataPoint);
// emitted when data point slim results downloaded and incorporated into project
void dataPointComplete(const openstudio::UUID& analysis, const openstudio::UUID& dataPoint);
// emitted when data point detailed results downloaded and incorporated into project
void dataPointDetailsComplete(const openstudio::UUID& analysis, const openstudio::UUID& dataPoint);
// emitted when last data point downloaded and incorporated into project
void analysisComplete(const openstudio::UUID& analysis);
void analysisStopped(const openstudio::UUID& analysis);
void analysisStatusChanged(analysisdriver::AnalysisStatus newStatus);
//@}
protected slots:
// RUNNING ================================================================
// 1. Is the server available?
void availableForRun(bool success);
// 2. If so, does the server know about out project?
void projectOnServer(bool success);
// 3. If not, create it
void projectCreated(bool success);
// 4. Does the server know about our analysis?
void analysisOnServer(bool success);
// 5a. If not, post it.
void analysisPosted(bool success);
// 5b. If so, are there any data points on the server?
void allDataPointUUIDsReturned(bool success);
// 6. If posted analysis (3a) or there are no data points (3b and result is empty),
// upload the analysis files.
void analysisUploaded(bool success);
// 7a. If there were data points (3b with non-empty result), figure out all the queues.
// Gets complete data points.
void readyToSortOutQueues(bool success);
// 7b. If the analysis was uploaded (4), populate the postQueue and start posting
// DataPoints.
// 8. Keep posting DataPoints until the postQueue is empty.
void dataPointsQueued(bool success);
// 9. Is the analysis already running on the server?
// (Could skip this step if uploaded analysis, but doesn't seem worth the extra
// state to do so.)
void analysisRunningOnServer(bool success);
// 10. If not, kick it off.
void analysisStarted(bool success);
// 11. Wait for the server to
// report that the analysis is running.
void waitingForAnalysisToStart(bool success);
void askAgainIfAnalysisRunning();
// 12. Wait for the server to report that
// at least one DataPoint is running.
void waitingForADataPointToStart(bool success);
void askAgainForRunningDataPoints();
// 13. Start the monitoring process (if already running or just kicked off).
// MONITORING =============================================================
// watch for complete data points
void completeDataPointUUIDsReturned(bool success);
void askIfAnalysisIsRunning();
// make sure analysis is still running
// (try to avoid spinning when nothing is happening)
void analysisRunningReturned(bool success);
void askForRunningDataPointUUIDs();
// see if data points are still running
// (mark DataPoints that are running, and also make sure something is happening.)
void runningDataPointUUIDsReturned(bool success);
void askForCompleteDataPointUUIDs();
// DOWNLOADING ============================================================
// slim results received
void jsonDownloadComplete(bool success);
void requestJsonRetry();
// pause between slim and detailed results
void readyForDownloadDataPointUUIDsReturned(bool success);
void askForReadyForDownloadDataPointUUIDs();
// detailed results received
void detailsDownloadComplete(bool success);
void requestDetailsRetry();
// STOPPING ===============================================================
// 0. If are to wait for already running DataPoints, switch the monitoring process to
// look for running data points, not for the analysis running.
// 1. Stop the analysis.
void analysisStopped(bool success);
// 2. Wait (almost-as) usual. If isStopping() and all processes have stopped, emit
// signal.
// MAINTENANCE ============================================================
// DataPoint or its results removed locally. Have server delete it too.
void dataPointOrItsResultsRemovedFromAnalysis(const openstudio::UUID& dataPointUUID);
// Process result of request put to server.
void dataPointDeletedFromServer(bool success);
void requestDeleteDataPointRetry();
// All data points or all results removed locally. Stop analysis and remove project.
void allDataPointsOrResultsRemovedFromAnalysis();
// Process result of request to delete project from server.
void projectDeletedFromServer(bool success);
void requestDeleteProjectRetry();
private:
REGISTER_LOGGER("openstudio.analysisdriver.CloudAnalysisDriver");
CloudSession m_session;
SimpleProject m_project;
bool m_lastRunSuccess;
bool m_lastStopSuccess;
bool m_lastDownloadDetailedResultsSuccess;
AnalysisStatus m_status;
std::vector<std::string> m_errors;
std::vector<std::string> m_warnings;
std::vector<analysis::DataPoint> m_iteration; // DataPoints in this iteration
bool m_processingQueuesInitialized; // if false, processing queues empty just because
// still spinning up process
// request run process
boost::optional<OSServer> m_requestRun;
std::deque<analysis::DataPoint> m_postQueue;
unsigned m_batchSize;
unsigned m_analysisNotRunningCount;
unsigned m_maxAnalysisNotRunningCount;
// the following are used in starting the run and in monitoring
unsigned m_dataPointsNotRunningCount;
unsigned m_maxDataPointsNotRunningCount;
// watch for complete data points
boost::optional<OSServer> m_monitorDataPoints;
std::vector<analysis::DataPoint> m_waitingQueue;
std::vector<analysis::DataPoint> m_runningQueue;
// download slim data points
boost::optional<OSServer> m_requestJson;
std::deque<analysis::DataPoint> m_jsonQueue;
unsigned m_numJsonTries;
std::vector<analysis::DataPoint> m_jsonFailures;
// check to see if details can be downloaded
boost::optional<OSServer> m_checkForResultsToDownload;
std::vector<analysis::DataPoint> m_preDetailsQueue;
bool m_onlyProcessingDownloadRequests; // to distinguish between main request being
// run or download of details
unsigned m_noNewReadyDataPointsCount;
// download detailed results
boost::optional<OSServer> m_requestDetails;
std::deque<analysis::DataPoint> m_detailsQueue;
unsigned m_numDetailsTries;
std::vector<analysis::DataPoint> m_detailsFailures;
// stop analysis
boost::optional<OSServer> m_requestStop;
bool m_waitForAlreadyRunningDataPoints;
// delete data point
boost::optional<OSServer> m_requestDeleteDataPoint;
std::deque<analysis::DataPoint> m_deleteDataPointsQueue;
unsigned m_numDeleteDataPointTries;
std::vector<analysis::DataPoint> m_deleteDataPointFailures;
// stop analysis and delete project
boost::optional<OSServer> m_requestDeleteProject;
bool m_needToDeleteProject;
unsigned m_numDeleteProjectTries;
void resetState();
void logError(const std::string& error);
void logWarning(const std::string& warning);
void appendErrorsAndWarnings(const OSServer& server);
void setStatus(AnalysisStatus status);
void registerRunRequestFailure();
bool postNextDataPointBatch(); // groups of 50
bool startMonitoring();
void registerMonitoringFailure();
bool startDownloadingJson();
bool requestNextJsonDownload();
void registerDownloadingJsonFailure();
bool startDownloadingDetails();
bool startDetailsReadyMonitoring();
bool startActualDownloads();
bool requestNextDetailsDownload();
void registerDownloadingDetailsFailure();
void registerStopRequestFailure();
bool requestNextDataPointDeletion();
void registerDataPointDeletionFailure();
bool requestProjectDeletion();
void registerProjectDeletionFailure();
void checkForRunCompleteOrStopped();
bool inIteration(const analysis::DataPoint& dataPoint) const;
bool inProcessingQueues(const analysis::DataPoint& dataPoint) const;
void removeFromIteration(const analysis::DataPoint& dataPoint);
std::string sessionTag() const;
void clearSessionTags(analysis::DataPoint& dataPoint) const;
};
} // detail
} // analysisdriver
} // openstudio
#endif // ANALYSISDRIVER_CLOUDANALYSISDRIVER_IMPL_HPP
| 36.308411 | 133 | 0.696075 | [
"object",
"vector"
] |
c156cebc1bb9a917dcc1d170ee41e774bd82f96c | 11,868 | cc | C++ | iree/base/signature_mangle.cc | mbrukman/iree | 6fbc32764c6fc38ad18f3ca9396778f79ded0c5e | [
"Apache-2.0"
] | 1 | 2020-08-16T17:38:49.000Z | 2020-08-16T17:38:49.000Z | iree/base/signature_mangle.cc | mbrukman/iree | 6fbc32764c6fc38ad18f3ca9396778f79ded0c5e | [
"Apache-2.0"
] | null | null | null | iree/base/signature_mangle.cc | mbrukman/iree | 6fbc32764c6fc38ad18f3ca9396778f79ded0c5e | [
"Apache-2.0"
] | null | null | null | // Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://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 "iree/base/signature_mangle.h"
#include "absl/memory/memory.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
namespace iree {
// -----------------------------------------------------------------------------
// AbiConstants
// -----------------------------------------------------------------------------
const std::array<size_t, 12> AbiConstants::kScalarTypeSize = {
4, // kIeeeFloat32 = 0,
2, // kIeeeFloat16 = 1,
8, // kIeeeFloat64 = 2,
2, // kGoogleBfloat16 = 3,
1, // kSint8 = 4,
2, // kSint16 = 5,
4, // kSint32 = 6,
8, // kSint64 = 7,
1, // kUint8 = 8,
2, // kUint16 = 9,
4, // kUint32 = 10,
8, // kUint64 = 11,
};
const std::array<const char*, 12> AbiConstants::kScalarTypeNames = {
"float32", "float16", "float64", "bfloat16", "sint8", "sint16",
"sint32", "sint64", "uint8", "uint16", "uint32", "uint64",
};
// -----------------------------------------------------------------------------
// SignatureBuilder and SignatureParser
// -----------------------------------------------------------------------------
SignatureBuilder& SignatureBuilder::Integer(int value, char tag) {
assert(tag == '_' || (tag >= 'a' && tag <= 'z') &&
"integer signature tag must be '_' or 'a'..'z'");
encoded_.push_back(tag);
absl::StrAppend(&encoded_, value);
return *this;
}
SignatureBuilder& SignatureBuilder::Span(absl::string_view contents, char tag) {
assert((tag >= 'A' && tag <= 'Z') && "span signature tag must be 'A'..'Z'");
encoded_.push_back(tag);
// If the contents starts with a digit or the escape char (!), then escape it.
absl::StrAppend(&encoded_, contents.size() + 1);
encoded_.push_back('!');
encoded_.append(contents.begin(), contents.end());
return *this;
}
SignatureParser::Type SignatureParser::Next() {
next_type_ = Type::kError;
next_tag_ = 0;
next_ival_ = 0;
next_sval_ = absl::string_view();
if (cursor_ == encoded_.end()) {
next_type_ = Type::kEnd;
return next_type_;
}
next_tag_ = *cursor_;
absl::string_view::const_iterator ival_begin = cursor_ + 1;
absl::string_view::const_iterator ival_end = ival_begin;
while (ival_end != encoded_.end() &&
((*ival_end >= '0' && *ival_end <= '9') ||
(*ival_end == '-' && ival_end == ival_begin))) {
++ival_end;
}
// No numeric value.
if (ival_end == ival_begin) {
return next_type_;
}
// Parse ival.
if (!absl::SimpleAtoi(
absl::string_view(&(*ival_begin), ival_end - ival_begin),
&next_ival_)) {
// Should not be possible.
return next_type_;
}
// For integer components ('_', 'a'..'z'), that is all.
if (next_tag_ == '_' || (next_tag_ >= 'a' && next_tag_ <= 'z')) {
next_type_ = Type::kInteger;
cursor_ = ival_end;
return next_type_;
}
// For string components ('A'..'Z'), extract the string.
if (next_tag_ >= 'A' && next_tag_ <= 'Z') {
if (next_ival_ < 0) return next_type_; // Negative size error.
absl::string_view::const_iterator sval_begin = ival_end;
absl::string_view::const_iterator sval_end = sval_begin + next_ival_;
if (sval_end > encoded_.end()) return next_type_; // Underrun.
// Remove escape char if escaped.
if (next_ival_ == 0 || *sval_begin != '!') {
next_type_ = Type::kError;
return next_type_;
}
next_ival_ -= 1;
++sval_begin;
next_sval_ = absl::string_view(&(*sval_begin), sval_end - sval_begin);
cursor_ = sval_end;
next_type_ = Type::kSpan;
return next_type_;
}
// Otherwise, error.
return next_type_;
}
bool SignatureParser::SeekTag(char tag) {
while (next_tag_ != tag && next_type_ != Type::kEnd) {
Next();
}
return next_type_ != Type::kEnd;
}
// -----------------------------------------------------------------------------
// RawSignatureMangler
// -----------------------------------------------------------------------------
SignatureBuilder RawSignatureMangler::ToFunctionSignature(
const SignatureBuilder& inputs, const SignatureBuilder& results) {
SignatureBuilder func_builder;
inputs.AppendTo(func_builder, 'I');
results.AppendTo(func_builder, 'R');
return func_builder;
}
void RawSignatureMangler::AddUnrecognized() {
builder_.Span(absl::string_view(), 'U');
}
void RawSignatureMangler::AddAnyReference() {
// A more constrained ref object would have a non empty span.
builder_.Span(absl::string_view(), 'O');
}
void RawSignatureMangler::AddShapedNDBuffer(
AbiConstants::ScalarType element_type, absl::Span<const int> shape) {
SignatureBuilder item_builder;
// Fields:
// 't': scalar type code
// 'd': shape dimension
if (static_cast<unsigned>(element_type) != 0) {
item_builder.Integer(static_cast<unsigned>(element_type), 't');
}
for (int d : shape) {
item_builder.Integer(d, 'd');
}
item_builder.AppendTo(builder_, 'B');
}
// -----------------------------------------------------------------------------
// RawSignatureParser
// -----------------------------------------------------------------------------
void RawSignatureParser::Description::ToString(std::string& s) const {
switch (type) {
case Type::kBuffer: {
const char* scalar_type_name = "!BADTYPE!";
unsigned scalar_type_u = static_cast<unsigned>(buffer.scalar_type);
if (scalar_type_u >= 0 &&
scalar_type_u <= AbiConstants::kScalarTypeNames.size()) {
scalar_type_name = AbiConstants::kScalarTypeNames[static_cast<unsigned>(
scalar_type_u)];
}
absl::StrAppend(&s, "Buffer<", scalar_type_name, "[");
for (size_t i = 0; i < dims.size(); ++i) {
if (i > 0) s.push_back('x');
if (dims[i] >= 0) {
absl::StrAppend(&s, dims[i]);
} else {
s.push_back('?');
}
}
absl::StrAppend(&s, "]>");
break;
}
case Type::kRefObject:
absl::StrAppend(&s, "RefObject<?>");
break;
default:
absl::StrAppend(&s, "!UNKNOWN!");
}
}
absl::optional<std::string> RawSignatureParser::FunctionSignatureToString(
absl::string_view signature) {
std::string s;
bool print_sep = false;
auto visitor = [&print_sep, &s](const Description& d) {
if (print_sep) {
s.append(", ");
}
d.ToString(s);
print_sep = true;
};
s.push_back('(');
VisitInputs(signature, visitor);
s.append(") -> (");
print_sep = false;
VisitResults(signature, visitor);
s.push_back(')');
if (!GetError()) {
return s;
} else {
return absl::nullopt;
}
}
// -----------------------------------------------------------------------------
// SipSignatureMangler
// -----------------------------------------------------------------------------
SipSignatureMangler::SipSignatureMangler() = default;
bool SipSignatureMangler::SetRawSignatureIndex(int raw_signature_index,
absl::Span<const Key> path) {
if (raw_signature_index < 0) {
return false;
}
Value* level = &root_;
for (const auto& key : path) {
// Is the indexing mode compatible?
if (level->index_mode == IndexMode::kNone) {
// Not yet committed: just adopt this first access.
level->index_mode = key.index_mode();
} else if (level->index_mode != key.index_mode()) {
// Indexing mode mismatch.
return false;
}
auto found_it = level->children.find(key);
if (found_it == level->children.end()) {
// Create a new level.
auto child = absl::make_unique<Value>();
Value* unowned_child = child.get();
level->children.insert(std::make_pair(key, std::move(child)));
level = unowned_child;
continue;
}
// Found.
level = found_it->second.get();
}
// Should now be on the leaf/terminal.
if (level->index_mode != IndexMode::kNone ||
level->raw_signature_index != -1) {
// It is not a leaf or has already been setup as a leaf.
return false;
}
level->raw_signature_index = raw_signature_index;
return true;
}
bool SipSignatureMangler::ToStructureSignature(SignatureBuilder* sb,
const Value* level) const {
char sub_span_tag;
switch (level->index_mode) {
case IndexMode::kNone:
// Leaf with un-assigned raw index.
if (level->raw_signature_index < 0) {
// An un-assigned leaf is only allowed for the root.
assert(level == &root_ && "Un-assigned non-root leaf not allowed");
return level == &root_;
} else {
sb->Integer(level->raw_signature_index);
return true;
}
case IndexMode::kSequence:
sub_span_tag = 'S';
break;
case IndexMode::kDict:
sub_span_tag = 'D';
break;
default:
return false;
}
SignatureBuilder child_sb;
for (const auto& kv : level->children) {
const Key& key = kv.first;
if (key.is_integer_key()) {
child_sb.Integer(key.ikey(), 'k');
} else if (key.is_string_key()) {
child_sb.Span(key.skey(), 'K');
} else {
return false;
}
if (!ToStructureSignature(&child_sb, kv.second.get())) return false;
}
child_sb.AppendTo(*sb, sub_span_tag);
return true;
}
absl::optional<SignatureBuilder> SipSignatureMangler::ToFunctionSignature(
const SipSignatureMangler& inputs_struct,
const SipSignatureMangler& results_struct) {
auto inputs_sb = inputs_struct.ToStructureSignature();
auto results_sb = results_struct.ToStructureSignature();
if (!inputs_sb || !results_sb) return {};
SignatureBuilder func_sb;
inputs_sb->AppendTo(func_sb, 'I');
results_sb->AppendTo(func_sb, 'R');
return func_sb;
}
// -----------------------------------------------------------------------------
// SipSignatureParser
// -----------------------------------------------------------------------------
void SipSignatureParser::ToStringVisitor::IntegerKey(SipSignatureParser& p,
int k) {
absl::StrAppend(&s_, indent_, k);
}
void SipSignatureParser::ToStringVisitor::StringKey(SipSignatureParser& p,
absl::string_view k) {
absl::StrAppend(&s_, indent_, k);
}
void SipSignatureParser::ToStringVisitor::OpenStruct(SipSignatureParser& p,
StructType struct_type) {
absl::StrAppend(&indent_, " ");
switch (struct_type) {
case StructType::kDict:
close_char_.push_back('}');
absl::StrAppend(&s_, ":{");
break;
case StructType::kSequence:
close_char_.push_back(']');
absl::StrAppend(&s_, ":[");
break;
default:
close_char_.push_back('?');
absl::StrAppend(&s_, ":?");
}
absl::StrAppend(&s_, "\n");
}
void SipSignatureParser::ToStringVisitor::CloseStruct(SipSignatureParser& p) {
if (indent_.size() >= 2) {
indent_.resize(indent_.size() - 2);
}
absl::StrAppend(&s_, indent_);
s_.push_back(close_char_.back());
close_char_.pop_back();
absl::StrAppend(&s_, ",\n");
}
void SipSignatureParser::ToStringVisitor::MapToRawSignatureIndex(
SipSignatureParser& p, int index) {
absl::StrAppend(&s_, "=raw(", index, "),\n");
}
} // namespace iree
| 30.587629 | 80 | 0.575329 | [
"object",
"shape"
] |
c1614f7766f2ca49925379ed7634fd27c4be803c | 37,075 | cpp | C++ | learning/FlyCapture2/src/FlyCapture2GUI_GTKmm/CamSelection.cpp | ColdMatter/PhotonBEC | c6bcf9bdefd267c8adde0d299cf5920b010c5022 | [
"MIT"
] | null | null | null | learning/FlyCapture2/src/FlyCapture2GUI_GTKmm/CamSelection.cpp | ColdMatter/PhotonBEC | c6bcf9bdefd267c8adde0d299cf5920b010c5022 | [
"MIT"
] | null | null | null | learning/FlyCapture2/src/FlyCapture2GUI_GTKmm/CamSelection.cpp | ColdMatter/PhotonBEC | c6bcf9bdefd267c8adde0d299cf5920b010c5022 | [
"MIT"
] | null | null | null | //=============================================================================
// Copyright © 2008 Point Grey Research, Inc. All Rights Reserved.
//
// This software is the confidential and proprietary information of Point
// Grey Research, Inc. ("Confidential Information"). You shall not
// disclose such Confidential Information and shall use it only in
// accordance with the terms of the license agreement you entered into
// with PGR.
//
// PGR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
// SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE, OR NON-INFRINGEMENT. PGR SHALL NOT BE LIABLE FOR ANY DAMAGES
// SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
// THIS SOFTWARE OR ITS DERIVATIVES.
//=============================================================================
//=============================================================================
// $Id: CamSelection.cpp,v 1.77 2010/11/12 18:10:10 soowei Exp $
//=============================================================================
#include "Precompiled.h"
#include "FlyCapture2GUI.h"
#include "CamSelection.h"
#include "GladeFileUtil.h"
namespace FlyCapture2
{
const char* CamSelection::sk_camSelectionWindow = "CamSelectionWin";
const char* CamSelection::sk_buttonOk = "buttonOk";
const char* CamSelection::sk_buttonCancel = "buttonCancel";
const char* CamSelection::sk_buttonConfigure = "buttonConfigure";
const char* CamSelection::sk_buttonRefresh = "buttonRefresh";
const char* CamSelection::sk_buttonAutoForceIP = "buttonAutoForceIP";
const char* CamSelection::sk_treeViewCamList = "treeviewCamList";
const char* CamSelection::sk_labelNumCameras = "lblNumCameras";
const char* CamSelection::sk_labelSerial = "lblCamSlnSerialNum";
const char* CamSelection::sk_labelModel = "lblCamSlnModel";
const char* CamSelection::sk_labelVendor = "lblCamSlnVendor";
const char* CamSelection::sk_labelSensor = "lblCamSlnSensor";
const char* CamSelection::sk_labelResolution = "lblCamSlnResolution";
const char* CamSelection::sk_labelInterface = "lblCamSlnInterface";
const char* CamSelection::sk_labelBusSpeed = "lblCamSlnBusSpeed";
const char* CamSelection::sk_labelDCAMVer = "lblCamSlnDCAMVer";
const char* CamSelection::sk_labelFirmwareVer = "lblCamSlnFirmwareVersion";
const char* CamSelection::sk_labelFirmwareBuildTime = "lblCamSlnFirmwareBuildTime";
const char* CamSelection::sk_labelDriverName = "lblCamSlnDriverName";
const char* CamSelection::sk_labelGigEVersion = "lblCamSlnGigEVersion";
const char* CamSelection::sk_labelGigEUserDefinedName = "lblCamSlnGigEUserDefinedName";
const char* CamSelection::sk_labelGigEXmlUrl1 = "lblCamSlnGigEXmlUrl1";
const char* CamSelection::sk_labelGigEXmlUrl2 = "lblCamSlnGigEXmlUrl2";
const char* CamSelection::sk_labelGigEMacAddress = "lblCamSlnGigEMacAddress";
const char* CamSelection::sk_labelGigEIpAddress = "lblCamSlnGigEIpAddress";
const char* CamSelection::sk_labelGigESubnetMask = "lblCamSlnGigESubnetMask";
const char* CamSelection::sk_labelGigEDefaultGateway = "lblCamSlnGigEDefaultGateway";
const char* CamSelection::sk_checkGigEIpLLA = "checkCamSlnIpLLA";
const char* CamSelection::sk_checkGigEIpDHCP = "checkCamSlnIpDHCP";
const char* CamSelection::sk_checkGigEIpPersistentIp = "checkCamSlnIpPersistentIp";
const char* CamSelection::sk_expanderGigE = "expanderGigEInfo";
CamSelection::CamSelection() :
m_refXml(0),
m_pDialog(0),
m_pButtonOk(0),
m_pButtonCancel(0),
m_pButtonConfigure(0),
m_pTreeViewCamList(0),
m_pLabelNumCameras(0),
m_pLabelSerial(0),
m_pLabelModel(0),
m_pLabelVendor(0),
m_pLabelSensor(0),
m_pLabelResolution(0),
m_pLabelInterface(0),
m_pLabelBusSpeed(0),
m_pLabelDCAMVer(0),
m_pLabelFirmwareVer(0),
m_pLabelFirmwareBuildTime(0),
m_guidArray(0),
m_psize(0),
m_response(Gtk::RESPONSE_NONE)
{
m_pKit = Gtk::Main::instance();
if ( m_pKit == NULL )
{
m_pKit = new Gtk::Main( 0, NULL );
}
// Initialize the thread system
if( !Glib::thread_supported() )
{
Glib::thread_init();
}
m_pBusEventDispatcher = NULL;
// Create the list store
m_refListStoreCamList = Gtk::ListStore::create( m_camListColumns );
}
CamSelection::~CamSelection()
{
if ( m_pBusEventDispatcher != NULL )
{
delete m_pBusEventDispatcher;
m_pBusEventDispatcher = NULL;
}
if ( m_pDialog != NULL )
{
delete m_pDialog;
m_pDialog = NULL;
}
}
bool CamSelection::Initialize()
{
Glib::ustring gladePath = GladeFileUtil::GetGladeFilePath();
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
m_refXml = Gnome::Glade::Xml::create(gladePath);
}
catch(const Gnome::Glade::XmlError& ex)
{
char szSecondary[512];
sprintf(
szSecondary,
"Error: %s. Make sure that the file is present.",
ex.what().c_str() );
Gtk::MessageDialog dialog( "Error loading Glade file", false, Gtk::MESSAGE_ERROR );
dialog.set_secondary_text( szSecondary );
dialog.run();
return false;
}
#else
std::auto_ptr<Gnome::Glade::XmlError> error;
m_refXml = Gnome::Glade::Xml::create(gladePath, "", "", error);
if(error.get())
{
char szSecondary[512];
sprintf(
szSecondary,
"Error: %s. Make sure that the file is present.",
ex.what().c_str() );
Gtk::MessageDialog dialog( "Error loading Glade file", false, Gtk::MESSAGE_ERROR );
dialog.set_secondary_text( szSecondary );
dialog.run();
return false;
}
#endif
m_refXml->get_widget( sk_camSelectionWindow, m_pDialog );
if ( m_pDialog == NULL )
{
return false;
}
// Get the widgets
GetWidgets();
// Disable the IP configuration checkboxes since they are read only
m_pCheckGigEIpLLA->set_sensitive( false );
m_pCheckGigEIpDHCP->set_sensitive( false );
m_pCheckGigEIpPersistentIp->set_sensitive( false );
// Attach the signals
AttachSignals();
// Set the tree view model
m_pTreeViewCamList->set_model( m_refListStoreCamList );
// Create column headers
PrepareTreeView();
// Load the PGR icon
LoadPGRIcon();
// Append the current version to the title
FC2Version version;
Utilities::GetLibraryVersion( &version );
if ( m_title.empty())
{
char titleStr[128];
sprintf(
titleStr,
"FlyCapture2 Camera Selection %u.%u.%u.%u",
version.major,
version.minor,
version.type,
version.build );
m_pDialog->set_title( titleStr);
}
else
{
m_pDialog->set_title( m_title);
}
return true;
}
void CamSelection::ShowModal( bool* okSelected, PGRGuid* guidArray, unsigned int* size )
{
// Populate the tree view
PopulateTreeView();
m_guidArray = guidArray;
m_psize = size;
Error error;
CallbackHandle callbackHandleBusReset;
// Register callback for bus resets
error = m_busMgr.RegisterCallback(&CamSelection::OnBusReset, BUS_RESET, this, &callbackHandleBusReset );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error registering callback\n", error );
}
// Create a dispatcher if there is none
if ( m_pBusEventDispatcher == NULL )
{
m_pBusEventDispatcher = new Glib::Dispatcher();
}
m_pBusEventDispatcher->connect( sigc::mem_fun(*this, &CamSelection::PopulateTreeView ) );
m_pBusEventDispatcher->connect( sigc::mem_fun(*this, &CamSelection::CloseAllDialogs ) );
m_pKit->run( *m_pDialog );
// Unregister callback for bus resets
error = m_busMgr.UnregisterCallback( callbackHandleBusReset );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error unregistering callback\n", error );
}
// When we get here, either Ok or Cancel was clicked
switch (m_response)
{
case Gtk::RESPONSE_OK:
*okSelected = true;
break;
case Gtk::RESPONSE_CANCEL:
case Gtk::RESPONSE_NONE:
*okSelected = false;
break;
default:
*okSelected = false;
break;
}
m_guidArray = 0; // letting go of weak pointer
}
void CamSelection::SetTitle( const char *pTitle)
{
m_title = pTitle;
}
void CamSelection::GetWidgets()
{
m_refXml->get_widget( sk_buttonOk, m_pButtonOk );
m_refXml->get_widget( sk_buttonCancel, m_pButtonCancel );
m_refXml->get_widget( sk_buttonConfigure, m_pButtonConfigure );
m_refXml->get_widget( sk_buttonRefresh, m_pButtonRefresh );
m_refXml->get_widget( sk_buttonAutoForceIP, m_pButtonAutoForceIP );
m_refXml->get_widget( sk_treeViewCamList, m_pTreeViewCamList );
m_refXml->get_widget( sk_labelNumCameras, m_pLabelNumCameras );
m_refXml->get_widget( sk_labelSerial, m_pLabelSerial );
m_refXml->get_widget( sk_labelModel, m_pLabelModel );
m_refXml->get_widget( sk_labelVendor, m_pLabelVendor );
m_refXml->get_widget( sk_labelSensor, m_pLabelSensor );
m_refXml->get_widget( sk_labelResolution, m_pLabelResolution );
m_refXml->get_widget( sk_labelInterface, m_pLabelInterface );
m_refXml->get_widget( sk_labelBusSpeed, m_pLabelBusSpeed );
m_refXml->get_widget( sk_labelDCAMVer, m_pLabelDCAMVer );
m_refXml->get_widget( sk_labelFirmwareVer, m_pLabelFirmwareVer );
m_refXml->get_widget( sk_labelFirmwareBuildTime, m_pLabelFirmwareBuildTime );
m_refXml->get_widget( sk_labelDriverName, m_pLabelDriverName );
m_refXml->get_widget( sk_labelGigEVersion, m_pLabelGigEVersion );
m_refXml->get_widget( sk_labelGigEUserDefinedName, m_pLabelGigEUserDefinedName );
m_refXml->get_widget( sk_labelGigEXmlUrl1, m_pLabelGigEXmlUrl1 );
m_refXml->get_widget( sk_labelGigEXmlUrl2, m_pLabelGigEXmlUrl2 );
m_refXml->get_widget( sk_labelGigEMacAddress, m_pLabelGigEMacAddress );
m_refXml->get_widget( sk_labelGigEIpAddress, m_pLabelGigEIpAddress );
m_refXml->get_widget( sk_labelGigESubnetMask, m_pLabelGigESubnetMask );
m_refXml->get_widget( sk_labelGigEDefaultGateway, m_pLabelGigEDefaultGateway );
m_refXml->get_widget( sk_checkGigEIpLLA, m_pCheckGigEIpLLA );
m_refXml->get_widget( sk_checkGigEIpDHCP, m_pCheckGigEIpDHCP );
m_refXml->get_widget( sk_checkGigEIpPersistentIp, m_pCheckGigEIpPersistentIp );
m_refXml->get_widget( sk_expanderGigE, m_pExpanderGigE );
}
void CamSelection::AttachSignals()
{
m_pButtonOk->signal_clicked().connect( sigc::mem_fun(*this, &CamSelection::OnOk) );
m_pButtonCancel->signal_clicked().connect( sigc::mem_fun(*this, &CamSelection::OnCancel) );
m_pButtonConfigure->signal_clicked().connect( sigc::mem_fun(*this, &CamSelection::OnConfigure) );
m_pButtonRefresh->signal_clicked().connect( sigc::mem_fun(*this, &CamSelection::OnRefresh) );
m_pButtonAutoForceIP->signal_clicked().connect( sigc::mem_fun(*this, &CamSelection::OnAutoForceIP) );
m_pTreeViewCamList->signal_row_activated().connect( sigc::mem_fun(*this, &CamSelection::OnTreeViewSelect) );
Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_pTreeViewCamList->get_selection();
refTreeSelection->signal_changed().connect( sigc::mem_fun(*this, &CamSelection::OnTreeViewSelectChanged) );
m_pExpanderGigE->property_expanded().signal_changed().connect( sigc::mem_fun(*this, &CamSelection::OnExpanderGigEClicked) );
}
void CamSelection::OnOk()
{
*m_psize = 0;
Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_pTreeViewCamList->get_selection();
refTreeSelection->selected_foreach_iter(
sigc::mem_fun(*this, &CamSelection::OnOkCallback));
m_response = Gtk::RESPONSE_OK;
m_pDialog->hide();
CloseAllDialogs();
}
void CamSelection::OnCancel()
{
*m_psize = 0;
m_response = Gtk::RESPONSE_CANCEL;
m_pDialog->hide();
CloseAllDialogs();
}
void CamSelection::OnConfigure()
{
Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_pTreeViewCamList->get_selection();
refTreeSelection->selected_foreach_iter(
sigc::mem_fun(*this, &CamSelection::OnConfigureCallback));
}
void CamSelection::OnRefresh()
{
Error error = m_busMgr.RescanBus();
if (error != PGRERROR_OK)
{
ShowErrorMessageDialog( "Error rescanning bus\n", error );
return;
}
PopulateTreeView();
}
#if defined(WIN32) || defined(WIN64)
bool CamSelection::SkipGigEEnumeration()
{
std::string regKeyName = "DisableGigEEnumeration";
bool skipEnumeration = false;
HKEY regKey = 0;
LONG retVal = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
TEXT("Software\\Point Grey Research, Inc.\\FlyCapture2\\"),
0,
KEY_ALL_ACCESS,
®Key );
if ( retVal == ERROR_SUCCESS )
{
DWORD regVal = 0;
DWORD regSize = sizeof(DWORD);
retVal = RegQueryValueEx(
regKey,
TEXT("DisableGigEEnumeration"),
0,
NULL,
(LPBYTE)®Val,
®Size );
if ( retVal == ERROR_SUCCESS )
{
if ( regVal != 0 )
{
skipEnumeration = true;
}
}
else
{
// Error querying registry key
retVal = RegCloseKey( regKey );
return true;
}
}
if(skipEnumeration)
{
Gtk::MessageDialog dialog("Enable GigE enumeration?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO);
dialog.set_secondary_text("GigE enumeration is currently disabled on the system. Do you wish to enable it?");
int retVal = dialog.run();
if (retVal == Gtk::RESPONSE_YES)
{
// Enable GigE Enumeration
DWORD regVal = 0;
DWORD regSize = sizeof(DWORD);
retVal = RegSetValueEx(
regKey,
TEXT("DisableGigEEnumeration"),
0,
REG_DWORD,
(BYTE*)®Val,
sizeof(DWORD));
if ( retVal == ERROR_SUCCESS )
{
Gtk::MessageDialog dialog2("GigE enumeration enabled", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK);
dialog2.set_secondary_text( "GigE cameras will now be visible!" );
dialog2.run();
skipEnumeration = false;
}
else
{
Gtk::MessageDialog dialog2("Error Enable GigE enumeration", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK);
dialog2.set_secondary_text( "GigE enumeration could not be enabled. Please login as administrator and try again." );
dialog2.run();
}
}
}
retVal = RegCloseKey( regKey );
return skipEnumeration;
}
#endif
void CamSelection::OnAutoForceIP()
{
#if defined(WIN32) || defined(WIN64)
if(SkipGigEEnumeration())
{
return;
}
#endif
Gtk::MessageDialog dialog( "Confirm Auto Force IP", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true );
dialog.set_secondary_text(
"This will set all GigE cameras discovered to an IP configuration "
"that will allow it to work with FlyCapture2. "
"Do you want to proceed?" );
const int retVal = dialog.run();
if (retVal != Gtk::RESPONSE_YES)
{
return;
}
const Error error = BusManager::ForceAllIPAddressesAutomatically();
if (error != PGRERROR_OK)
{
ShowErrorMessageDialog( "Error forcing IP addresses\n", error );
}
// Sleep for 5s before refreshing
Glib::usleep(5000 * 1000);
OnRefresh();
}
void CamSelection::OnTreeViewSelect(
const Gtk::TreeModel::Path& /*path*/,
Gtk::TreeViewColumn* /*column*/ )
{
// This function is called when a double click (or enter) is received
OnOk();
}
void CamSelection::OnTreeViewSelectChanged()
{
// This function is called when the selection changes in the tree view
Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_pTreeViewCamList->get_selection();
refTreeSelection->selected_foreach_iter(
sigc::mem_fun(*this, &CamSelection::TreeViewSelectChangedCallback));
}
void CamSelection::OnOkCallback( const Gtk::TreeModel::iterator& iter )
{
Gtk::TreeModel::Row row = *iter;
Glib::ustring serialNum = row[m_camListColumns.m_colSerialNum];
unsigned int serial = strtoul( serialNum.c_str(), NULL, 10 );
PGRGuid guid;
Error error = m_busMgr.GetCameraFromSerialNumber( serial, &guid );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera\n", error );
return;
}
m_guidArray[*m_psize] = guid;
(*m_psize)++;
}
void CamSelection::OnConfigureCallback( const Gtk::TreeModel::iterator& iter )
{
Gtk::TreeModel::Row row = *iter;
Glib::ustring serialNum = row[m_camListColumns.m_colSerialNum];
unsigned int serial = strtoul( serialNum.c_str(), NULL, 10 );
// Check if the camera control dialog already exists
std::map<unsigned int, SelectionStruct>::iterator iterSelection;
iterSelection = m_mapOnConfigureStruct.find(serial);
if ( iterSelection == m_mapOnConfigureStruct.end() )
{
// Camera currently does not have a camera control dialog connected to it
Error error;
PGRGuid guid;
error = m_busMgr.GetCameraFromSerialNumber( serial, &guid );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera\n", error );
return;
}
InterfaceType interfaceType;
error = m_busMgr.GetInterfaceTypeFromGuid( &guid, &interfaceType );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting interface type\n", error );
return;
}
CameraBase* pCamera = NULL;
if ( interfaceType == INTERFACE_GIGE )
{
pCamera = new GigECamera;
}
else
{
pCamera = new Camera;
}
error = pCamera->Connect( &guid );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error connecting to camera\n", error );
delete pCamera;
return;
}
CameraControlDlg* pCamCtl = new CameraControlDlg;
pCamCtl->Connect( pCamera );
pCamCtl->Show();
SelectionStruct selectStruct;
selectStruct.pCamera = pCamera;
selectStruct.pCamCtlDlg = pCamCtl;
m_mapOnConfigureStruct.insert(
std::pair<unsigned int, SelectionStruct>( serial, selectStruct) );
}
else
{
CameraControlDlg* pCamCtlDlg = iterSelection->second.pCamCtlDlg;
pCamCtlDlg->Show();
}
}
void CamSelection::TreeViewSelectChangedCallback( const Gtk::TreeModel::iterator& iter )
{
Gtk::TreeModel::Row row = *iter;
Glib::ustring serialNum = row[m_camListColumns.m_colSerialNum];
unsigned int serial = strtoul( serialNum.c_str(), NULL, 10 );
PGRGuid guid;
Error error = m_busMgr.GetCameraFromSerialNumber( serial, &guid );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera\n", error );
return;
}
SetCameraInformation( guid );
}
void CamSelection::PrepareTreeView()
{
m_pTreeViewCamList->set_headers_clickable( true );
m_pTreeViewCamList->append_column( "Serial #", m_camListColumns.m_colSerialNum );
m_pTreeViewCamList->append_column( "Model", m_camListColumns.m_colModel );
m_pTreeViewCamList->append_column( "Interface", m_camListColumns.m_colInterface );
m_pTreeViewCamList->append_column( "IP Address", m_camListColumns.m_colIpAddress );
Gtk::TreeView::Column* serialCol = m_pTreeViewCamList->get_column(0);
serialCol->set_sort_column(m_camListColumns.m_colSerialNum);
serialCol->set_expand( false );
Gtk::TreeView::Column* modelCol = m_pTreeViewCamList->get_column(1);
modelCol->set_sort_column(m_camListColumns.m_colModel);
modelCol->set_expand( true );
Gtk::TreeView::Column* interfaceCol = m_pTreeViewCamList->get_column(2);
interfaceCol->set_sort_column(m_camListColumns.m_colInterface);
interfaceCol->set_expand( false );
Gtk::TreeView::Column* ipAddressCol = m_pTreeViewCamList->get_column(3);
ipAddressCol->set_sort_column(m_camListColumns.m_colIpAddress);
ipAddressCol->set_expand( false );
}
void CamSelection::PopulateTreeView()
{
// Clear the camera list
m_refListStoreCamList->clear();
Error error;
unsigned int numCameras = 0;
error = m_busMgr.GetNumOfCameras( &numCameras );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting number of cameras\n", error );
return;
}
char numCamerasString[64];
sprintf( numCamerasString, "<b>(%u cameras detected)</b>", numCameras );
m_pLabelNumCameras->set_markup( numCamerasString );
if ( numCameras == 0 )
{
ClearCameraInformation();
return;
}
for ( unsigned int i = 0; i < numCameras; i++ )
{
PGRGuid guid;
error = m_busMgr.GetCameraFromIndex( i, &guid );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera\n", error );
continue;
}
InterfaceType currInterface;
error = m_busMgr.GetInterfaceTypeFromGuid( &guid, &currInterface );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera interface\n", error );
continue;
}
CameraBase* pCamera;
if ( currInterface == INTERFACE_GIGE )
{
pCamera = new GigECamera();
}
else
{
pCamera = new Camera();
}
error = pCamera->Connect( &guid );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error connecting to camera\n", error );
delete pCamera;
continue;
}
CameraInfo camInfo;
error = pCamera->GetCameraInfo( &camInfo );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera information\n", error );
delete pCamera;
continue;
}
// Append the camera to the list
Gtk::TreeModel::Row row = *(m_refListStoreCamList->append());
char serialString[16];
sprintf( serialString, "%u", camInfo.serialNumber );
const char* interfaceString;
interfaceString = GetInterfaceString( camInfo.interfaceType );
char ipAddressString[32] = {0};
if ( camInfo.ipAddress.octets[0] == 0 &&
camInfo.ipAddress.octets[1] == 0 &&
camInfo.ipAddress.octets[2] == 0 &&
camInfo.ipAddress.octets[3] == 0 )
{
sprintf( ipAddressString, "N/A" );
}
else
{
sprintf(
ipAddressString,
"%u.%u.%u.%u",
camInfo.ipAddress.octets[0],
camInfo.ipAddress.octets[1],
camInfo.ipAddress.octets[2],
camInfo.ipAddress.octets[3]);
}
row[m_camListColumns.m_colSerialNum] = serialString;
row[m_camListColumns.m_colModel] = camInfo.modelName;
row[m_camListColumns.m_colInterface] = interfaceString;
row[m_camListColumns.m_colIpAddress] = ipAddressString;
// Set the camera info to the first camera
if ( i == 0 )
{
SetCameraInformation( guid );
m_pTreeViewCamList->get_selection()->select( row );
}
delete pCamera;
}
m_pTreeViewCamList->get_selection()->set_mode( Gtk::SELECTION_MULTIPLE );
}
void CamSelection::SetCameraInformation( PGRGuid guid )
{
Error error;
InterfaceType interfaceType;
error = m_busMgr.GetInterfaceTypeFromGuid( &guid, &interfaceType );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera interface\n", error );
return;
}
CameraBase* pCamera;
if ( interfaceType == INTERFACE_GIGE )
{
pCamera = new GigECamera();
}
else
{
pCamera = new Camera();
}
error = pCamera->Connect( &guid );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error connecting to camera\n", error );
delete pCamera;
return;
}
CameraInfo camInfo;
error = pCamera->GetCameraInfo( &camInfo );
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera information\n", error );
delete pCamera;
return;
}
// Set the camera info labels
char serial[64];
sprintf( serial, "%u", camInfo.serialNumber );
if ( strstr( camInfo.modelName, "Compressor") == camInfo.modelName )
{
const unsigned int k_Ladybug2HeadReg = 0x1F80;
Error error;
unsigned int uiHeadNumber;
error = pCamera->ReadRegister( k_Ladybug2HeadReg, &uiHeadNumber );
if( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera information\n", error );
delete pCamera;
return;
}
sprintf ( serial, "%u(Head S/N.%u)", camInfo.serialNumber, uiHeadNumber );
}
else
{
sprintf( serial, "%u", camInfo.serialNumber );
}
const char* interfaceString;
interfaceString = GetInterfaceString( camInfo.interfaceType );
const char* busSpeedString;
busSpeedString = GetBusSpeedString( camInfo.maximumBusSpeed );
char dcamVer[16];
sprintf( dcamVer, "%1.2f", camInfo.iidcVer / 100.0f );
m_pLabelSerial->set_text( serial );
m_pLabelModel->set_text( camInfo.modelName );
m_pLabelVendor->set_text( camInfo.vendorName );
m_pLabelSensor->set_text( camInfo.sensorInfo );
m_pLabelResolution->set_text( camInfo.sensorResolution );
m_pLabelInterface->set_text( interfaceString );
m_pLabelBusSpeed->set_text( busSpeedString );
m_pLabelDCAMVer->set_text( dcamVer );
m_pLabelFirmwareVer->set_text( camInfo.firmwareVersion );
m_pLabelFirmwareBuildTime->set_text( camInfo.firmwareBuildTime );
m_pLabelDriverName->set_text( camInfo.driverName );
if ( camInfo.interfaceType == INTERFACE_GIGE )
{
m_pExpanderGigE->set_expanded(true);
char gigEVersion[16];
sprintf( gigEVersion, "%u.%u", camInfo.gigEMajorVersion, camInfo.gigEMinorVersion );
m_pLabelGigEVersion->set_text( gigEVersion );
m_pLabelGigEUserDefinedName->set_text( camInfo.userDefinedName );
m_pLabelGigEXmlUrl1->set_text( camInfo.xmlURL1 );
m_pLabelGigEXmlUrl2->set_text( camInfo.xmlURL2 );
char macAddress[64];
sprintf(
macAddress,
"%02X:%02X:%02X:%02X:%02X:%02X",
camInfo.macAddress.octets[0],
camInfo.macAddress.octets[1],
camInfo.macAddress.octets[2],
camInfo.macAddress.octets[3],
camInfo.macAddress.octets[4],
camInfo.macAddress.octets[5]);
m_pLabelGigEMacAddress->set_text( macAddress );
char ipAddress[32];
sprintf(
ipAddress,
"%u.%u.%u.%u",
camInfo.ipAddress.octets[0],
camInfo.ipAddress.octets[1],
camInfo.ipAddress.octets[2],
camInfo.ipAddress.octets[3]);
m_pLabelGigEIpAddress->set_text( ipAddress );
char subnetMask[32];
sprintf(
subnetMask,
"%u.%u.%u.%u",
camInfo.subnetMask.octets[0],
camInfo.subnetMask.octets[1],
camInfo.subnetMask.octets[2],
camInfo.subnetMask.octets[3]);
m_pLabelGigESubnetMask->set_text( subnetMask );
char defaultGateway[32];
sprintf(
defaultGateway,
"%u.%u.%u.%u",
camInfo.defaultGateway.octets[0],
camInfo.defaultGateway.octets[1],
camInfo.defaultGateway.octets[2],
camInfo.defaultGateway.octets[3]);
m_pLabelGigEDefaultGateway->set_text( defaultGateway );
GigECamera* pGigECamera = dynamic_cast<GigECamera*>(pCamera);
if ( pCamera != NULL )
{
unsigned int ipConfigurationVal = 0;
Error error = pGigECamera->ReadGVCPRegister( 0x0010, &ipConfigurationVal );
if ( error != PGRERROR_OK )
{
return;
}
m_pCheckGigEIpLLA->set_active( (ipConfigurationVal & 0x1) != 0 );
m_pCheckGigEIpDHCP->set_active( (ipConfigurationVal & 0x2) != 0 );
m_pCheckGigEIpPersistentIp->set_active( (ipConfigurationVal & 0x4) != 0 );
}
else
{
m_pCheckGigEIpLLA->set_active( false );
m_pCheckGigEIpDHCP->set_active( false );
m_pCheckGigEIpPersistentIp->set_active( false );
}
m_pCheckGigEIpLLA->set_sensitive( false );
m_pCheckGigEIpDHCP->set_sensitive( false );
m_pCheckGigEIpPersistentIp->set_sensitive( false );
}
else
{
m_pExpanderGigE->set_expanded(false);
m_pLabelGigEVersion->set_text( "N/A" );
m_pLabelGigEUserDefinedName->set_text( "N/A" );
m_pLabelGigEXmlUrl1->set_text( "N/A" );
m_pLabelGigEXmlUrl2->set_text( "N/A" );
m_pLabelGigEMacAddress->set_text( "N/A" );
m_pLabelGigEIpAddress->set_text( "N/A" );
m_pLabelGigESubnetMask->set_text( "N/A" );
m_pLabelGigEDefaultGateway->set_text( "N/A" );
m_pCheckGigEIpLLA->set_active( false );
m_pCheckGigEIpDHCP->set_active( false );
m_pCheckGigEIpPersistentIp->set_active( false );
m_pDialog->set_resizable(false);
}
error = pCamera->Disconnect();
if ( error != PGRERROR_OK )
{
ShowErrorMessageDialog( "Error getting camera information\n", error );
delete pCamera;
return;
}
delete pCamera;
}
void CamSelection::ClearCameraInformation()
{
const char* blank = "N/A";
m_pLabelSerial->set_text( blank );
m_pLabelModel->set_text( blank );
m_pLabelVendor->set_text( blank );
m_pLabelSensor->set_text( blank );
m_pLabelResolution->set_text( blank );
m_pLabelInterface->set_text( blank );
m_pLabelBusSpeed->set_text( blank );
m_pLabelDCAMVer->set_text( blank );
m_pLabelFirmwareVer->set_text( blank );
m_pLabelFirmwareBuildTime->set_text( blank );
m_pLabelDriverName->set_text( blank );
// Clear GigE related info Bug 16607
m_pExpanderGigE->set_expanded(false);
m_pLabelGigEVersion->set_text( "N/A" );
m_pLabelGigEUserDefinedName->set_text( "N/A" );
m_pLabelGigEXmlUrl1->set_text( "N/A" );
m_pLabelGigEXmlUrl2->set_text( "N/A" );
m_pLabelGigEMacAddress->set_text( "N/A" );
m_pLabelGigEIpAddress->set_text( "N/A" );
m_pLabelGigESubnetMask->set_text( "N/A" );
m_pLabelGigEDefaultGateway->set_text( "N/A" );
m_pCheckGigEIpLLA->set_active( false );
m_pCheckGigEIpDHCP->set_active( false );
m_pCheckGigEIpPersistentIp->set_active( false );
m_pDialog->set_resizable(false);
}
void CamSelection::OnBusReset( void* pParameter, unsigned int serialNumber )
{
static_cast<CamSelection*>(pParameter)->m_pBusEventDispatcher->emit();
}
void CamSelection::LoadPGRIcon()
{
m_iconPixBuf = Gdk::Pixbuf::create_from_inline( sizeof(PGRIcon), PGRIcon, false );
m_pDialog->set_default_icon( m_iconPixBuf );
}
const char* CamSelection::GetInterfaceString( InterfaceType type )
{
switch (type)
{
case INTERFACE_IEEE1394:
return "IEEE-1394";
case INTERFACE_USB2:
return "USB 2.0";
case INTERFACE_USB3:
return "USB 3.0";
case INTERFACE_GIGE:
return "GigE";
default:
return "Unknown interface";
}
}
const char* CamSelection::GetBusSpeedString( BusSpeed speed )
{
switch (speed)
{
case BUSSPEED_S100:
return "S100";
case BUSSPEED_S200:
return "S200";
case BUSSPEED_S400:
return "S400";
case BUSSPEED_S480:
return "S480";
case BUSSPEED_S800:
return "S800";
case BUSSPEED_S1600:
return "S1600";
case BUSSPEED_S3200:
return "S3200";
case BUSSPEED_S5000:
return "S5000";
default:
return "Unknown bus speed";
}
}
int CamSelection::ShowErrorMessageDialog(
Glib::ustring mainTxt,
Glib::ustring secondaryTxt )
{
Gtk::MessageDialog dialog( mainTxt, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK );
dialog.set_secondary_text( secondaryTxt );
return dialog.run();
}
int CamSelection::ShowErrorMessageDialog(
Glib::ustring mainTxt,
Error error )
{
Gtk::MessageDialog dialog( mainTxt, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK );
dialog.set_secondary_text( error.GetDescription() );
return dialog.run();
}
void CamSelection::CloseAllDialogs()
{
std::map<unsigned int, SelectionStruct>::iterator iterSelection;
for ( iterSelection = m_mapOnConfigureStruct.begin(); iterSelection != m_mapOnConfigureStruct.end(); iterSelection++ )
{
SelectionStruct tempStruct = iterSelection->second;
CameraBase* pCamera = tempStruct.pCamera;
CameraControlDlg* pCamCtlDlg = tempStruct.pCamCtlDlg;
pCamCtlDlg->Hide();
pCamCtlDlg->Disconnect();
delete pCamCtlDlg;
pCamera->Disconnect();
delete pCamera;
}
m_mapOnConfigureStruct.clear();
}
void CamSelection::OnExpanderGigEClicked()
{
//if ( m_pExpanderGigE->get_expanded() != true )
//{
/* m_pDialog->resize(1,1);
m_pDialog->queue_resize();*/
}
}
| 34.488372 | 132 | 0.591018 | [
"model"
] |
c164c0dce9af417a8ac07e1f4e0336a5a2248ccf | 7,559 | hh | C++ | src/boundary/BoundaryMOC.hh | RLReed/libdetran | 77637c788823e0a14aae7e40e476a291f6f3184b | [
"MIT"
] | null | null | null | src/boundary/BoundaryMOC.hh | RLReed/libdetran | 77637c788823e0a14aae7e40e476a291f6f3184b | [
"MIT"
] | null | null | null | src/boundary/BoundaryMOC.hh | RLReed/libdetran | 77637c788823e0a14aae7e40e476a291f6f3184b | [
"MIT"
] | null | null | null | //----------------------------------*-C++-*----------------------------------//
/**
* @file BoundaryMOC.hh
* @brief BoundaryMOC class definition
* @author Jeremy Roberts
* @date Jun 25, 2012
*/
//---------------------------------------------------------------------------//
#ifndef detran_BOUNDARYMOC_HH_
#define detran_BOUNDARYMOC_HH_
#include "boundary/BoundaryBase.hh"
#include "boundary/BoundaryConditionMOC.hh"
#include "geometry/MeshMOC.hh"
#include "angle/QuadratureMOC.hh"
namespace detran
{
/**
* @class BoundaryMOC
* @brief Boundary flux container for MOC problems.
*
* The method of characteristics solves the transport equation
* by sweeping along fixed tracks crossing the domain. Tracks
* begin and end at a global boundary. This class stores the
* angular flux for each track.
*/
template <class D>
class BoundaryMOC : public BoundaryBase<D>
{
public:
//-------------------------------------------------------------------------//
// TYPEDEFS
//-------------------------------------------------------------------------//
typedef BoundaryBase<D> Base;
typedef typename Base::SP_boundary SP_base;
typedef detran_utilities::SP<BoundaryMOC<D> > SP_boundary;
typedef typename Base::SP_input SP_input;
typedef detran_geometry::Mesh Mesh;
typedef detran_geometry::MeshMOC MeshMOC;
typedef detran_utilities::SP<MeshMOC> SP_mesh;
typedef detran_angle::QuadratureMOC QuadratureMOC;
typedef detran_utilities::SP<QuadratureMOC> SP_quadrature;
typedef BoundaryConditionMOC<D> BC_T;
typedef typename BC_T::SP_bc SP_bc;
typedef detran_utilities::size_t size_t;
typedef detran_utilities::vec_int vec_int;
typedef detran_utilities::vec2_int vec2_int;
typedef detran_utilities::vec3_int vec3_int;
typedef detran_utilities::vec2_dbl vec2_dbl;
typedef detran_utilities::vec3_dbl vec3_dbl;
typedef std::vector<vec3_dbl> bf_type;
typedef D D_T;
using Base::IN;
using Base::OUT;
//-------------------------------------------------------------------------//
// CONSTRUCTORS & DESTRUCTORS
//-------------------------------------------------------------------------//
/**
* @brief Constructor.
* @param input User input database.
* @param mesh Cartesian mesh.
* @param quadrature Angular quadrature.
*/
BoundaryMOC(SP_input input,
SP_mesh mesh,
SP_quadrature quadrature);
/// SP Constructor.
static SP_base
Create(SP_input input,
SP_mesh mesh,
SP_quadrature quadrature);
//-------------------------------------------------------------------------//
// ABSTRACT INTERFACE -- ALL BOUNDARY TYPES MUST IMPLEMENT THESE
//-------------------------------------------------------------------------//
/// Set the boundaries for a within-group solve.
void set(const size_t g);
/// Update the boundaries for each sweep.
void update(const size_t g);
/// brief Update the boundaries for a single angle.
void update(const size_t g, const size_t o, const size_t a);
/// Clear the boundary container for a group.
void clear(const size_t g);
/// Set the entire group boundary flux for reflecting sides.
void psi(const size_t g, double *v, const int inout, const int gs,
bool onlyref = true)
{
THROW("IMPLEMENT ME");
}
//-------------------------------------------------------------------------//
// BOUNDARY FLUX ACCESS
//-------------------------------------------------------------------------//
/**
* @brief Const access to a boundary flux using cardinal indices.
*
* This (and the mutable version) interface is for use
* in sweeping, where octants and angles are cycled.
*
* @param g Energy group.
* @param o Octant index.
* @param a Angle index (within octant).
* @param t Track index for angle.
* @return Constant reference to boundary flux.
*/
const double&
operator()(const size_t g, const size_t o, const size_t a,
const size_t inout, const size_t t) const;
/// Mutable access to boundary flux using cardinal indices.
double&
operator()(const size_t g, const size_t o, const size_t a,
const size_t inout, const size_t t);
/**
* @brief Assign the octant, angle, and track fed by an octant,
* angle, and track
*
* To make the boundary condition as independent as
* possible, BoundaryMOC knows what to do with the
* cardinal angle within an octant (i.e. with polar implicit)
*
* @param o1 Incident octant
* @param a1 Incident angle within octant
* @param t1 Incident track
* @param o2 Outgoing octant
* @param a2 Outgoing angle within octant
* @param t2 Outgoing track
*/
void feed_into(const size_t o1, const size_t a1, const size_t t1,
size_t &o2, size_t &a2, size_t &t2);
/**
* @brief Assign the octant, angle, and track feeding an octant,
* angle, and track
* @param o1 Outgoing octant
* @param a1 Outgoing angle within octant
* @param t1 Outgoing track
* @param o2 Incident octant
* @param a2 Incident angle within octant
* @param t2 Incident track
*/
void feed_from(const size_t o1, const size_t a1, const size_t t1,
size_t &o2, size_t &a2, size_t &t2);
/// Return vector of octant, azimuth, track triplets for a side.
const vec2_int& side_indices(const size_t side) const
{
return d_side_index[side];
}
private:
//-------------------------------------------------------------------------//
// DATA
//-------------------------------------------------------------------------//
// Expose base class members.
using Base::d_input;
using Base::d_mesh;
using Base::d_number_groups;
using Base::d_has_reflective;
using Base::d_is_reflective;
using Base::d_has_vacuum;
using Base::d_boundary_flux_size;
/// MOC Quadrature
SP_quadrature d_quadrature;
/// Boundary flux [energy, angle, inout, track]
bf_type d_boundary_flux;
/// Vector of boundary conditions.
std::vector<SP_bc> d_bc;
/// d_feed_into[o0][a0][t0][o1 a1 t1] says track a0, t0 feeds into track a1, t1
std::vector<vec3_int> d_feed_into;
/// d_feed_from[a0][t0][a1 t1] says track a0, t0 feeds from track a1, t1
std::vector<vec3_int> d_feed_from;
/// d_side_index[side][o a t]
vec3_int d_side_index;
//-------------------------------------------------------------------------//
// IMPLEMENTATION
//-------------------------------------------------------------------------//
/// Size the boundaries, etc.
void initialize();
/// Setup reflection indices.
void setup_indices();
/// Setup indices for an incident side.
void setup_side_indices();
};
} // end namespace detran
//---------------------------------------------------------------------------//
// INLINE FUNCTIONS
//---------------------------------------------------------------------------//
#include "BoundaryMOC.i.hh"
#endif // detran_BOUNDARYMOC_HH_
//---------------------------------------------------------------------------//
// end of file BoundaryMOC.hh
//---------------------------------------------------------------------------//
| 33.595556 | 81 | 0.528509 | [
"mesh",
"geometry",
"vector"
] |
c1676e254707a5ec5fee616d504380f51c5acb20 | 4,530 | cpp | C++ | src/prepare_and_process_graph.cpp | farkhor/MTCPU-VertexCentric | 97192d74760917eb3b37b299895c17d1af489fdc | [
"MIT"
] | 6 | 2016-05-10T02:52:38.000Z | 2018-02-06T03:56:14.000Z | src/prepare_and_process_graph.cpp | farkhor/MTCPU-VertexCentric | 97192d74760917eb3b37b299895c17d1af489fdc | [
"MIT"
] | null | null | null | src/prepare_and_process_graph.cpp | farkhor/MTCPU-VertexCentric | 97192d74760917eb3b37b299895c17d1af489fdc | [
"MIT"
] | null | null | null | #include <iostream>
#include <atomic>
#include <chrono>
#include <future>
#include "prepare_and_process_graph.hpp"
#include "utils/buffer.hpp"
#include "user_specified_codes/user_specified_pre_and_post_processing_functions.hpp"
#include "user_specified_codes/user_specified_functions.hpp"
void prepare_and_process_graph(
std::vector<initial_vertex>& initGraph,
const uint nEdges,
std::ofstream& outputFile,
std::vector<unsigned int>& indicesRange,
const int nThreads
) {
// Get the number of vertices.
const auto nVertices = initGraph.size();
/*********************************************************************************
* ALLOCATE BUFFERS AND PUT VERTICES INTO BUFFERS OF CSR REPRESENTATION.
********************************************************************************/
// Allocate buffers.
buffer< std::atomic< Vertex > > vertexValue( nVertices );
buffer<unsigned int> edgesIndices( nVertices + 1 );
edgesIndices.at(0) = 0;
buffer<unsigned int> vertexIndices( nEdges );
buffer<Edge> EdgeValue;
if( sizeof(Edge) > 1 ) EdgeValue.alloc( nEdges );
buffer<Vertex_static> VertexValueStatic;
if( sizeof(Vertex_static) > 1 ) VertexValueStatic.alloc( nVertices );
// Put vertices into buffers of CSR form.
for( unsigned int vIdx = 0; vIdx < nVertices; ++vIdx ) {
auto& vvv = initGraph.at(vIdx);
vertexValue[ vIdx ] = vvv.vertexValue;
if( sizeof(Vertex_static) > 1 ) VertexValueStatic[ vIdx ] = vvv.VertexValueStatic;
unsigned int nNbrs = vvv.nbrs.size();
auto edgeIdxOffset = edgesIndices[ vIdx ];
for( unsigned int nbrIdx = 0; nbrIdx < nNbrs; ++nbrIdx ) {
auto& nbr = vvv.nbrs.at( nbrIdx );
vertexIndices[ edgeIdxOffset + nbrIdx ] = nbr.srcIndex;
if( sizeof(Edge) > 1 ) EdgeValue[ edgeIdxOffset + nbrIdx ] = nbr.edgeValue;
}
edgesIndices[ vIdx + 1 ] = edgeIdxOffset + nNbrs;
}
// Free-up some occupied memory.
initGraph.resize( 0 );
/*************************************************************************************
* PROCESS THE PREPARED GRAPH.
*************************************************************************************/
// Define the function each thread will execute.
auto threadsProcessingFunction = [&]( const int threadID ) {
bool didSomeVerticesUpdate = false;
const auto threadStartVertexIndex = indicesRange.at( threadID );
const auto threadEndVertexIndex = indicesRange.at( threadID + 1 );
for( auto vIdx = threadStartVertexIndex; vIdx < threadEndVertexIndex; ++vIdx ) {
Vertex VertexInHand;
const Vertex preV = vertexValue[ vIdx ].load( std::memory_order_relaxed );
init_compute( VertexInHand, preV );
for( auto eIdx = edgesIndices[ vIdx ]; eIdx < edgesIndices[ vIdx + 1 ]; ++eIdx ) {
Vertex tmp;
auto srcVertexIndex = vertexIndices[ eIdx ];
compute_local(
vertexValue[ srcVertexIndex ].load( std::memory_order_relaxed ),
VertexValueStatic.get_ptr() + srcVertexIndex,
EdgeValue.get_ptr() + eIdx,
tmp
);
compute_reduce( VertexInHand, tmp );
}
if( update_condition( VertexInHand, preV ) ) {
vertexValue[ vIdx ].store( VertexInHand, std::memory_order_relaxed );
didSomeVerticesUpdate = true;
}
}
return didSomeVerticesUpdate;
};
// Set the timer and start.
using timer = std::chrono::high_resolution_clock;
unsigned int iterationCounter = 0;
bool anyUpdate;
const timer::time_point t1 = timer::now();
do{
std::vector< std::future< bool > > jobs( 0 );
for( auto threadIdx = 0; threadIdx < ( nThreads - 1 ); ++threadIdx )
jobs.emplace_back( std::async( std::launch::async, threadsProcessingFunction, threadIdx ) );
anyUpdate = threadsProcessingFunction( nThreads - 1 ); // Launcher thread's own work.
for( auto& job: jobs )
anyUpdate |= job.get();
++iterationCounter;
} while( anyUpdate == true );
const timer::time_point t2 = timer::now();
const auto processing_time = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();
std::cout << "Processing finished in " << static_cast<double>( processing_time ) / 1000.0 << " (ms).\n";
std::cout << "Performed " << iterationCounter << " iterations in total.\n";
/*************************************************************************************
* PERFORM USER-SPECIFIED OUTPUT FUNCTION.
*************************************************************************************/
// Print the output vertex values to the file.
for( unsigned int vvv = 0; vvv < nVertices; ++vvv )
print_vertex_output( vvv, vertexValue[ vvv ], outputFile );
}
| 39.051724 | 105 | 0.624724 | [
"vector"
] |
c169bed64191963a95ab403e3720f3c7f500907a | 1,896 | hpp | C++ | vc3.hpp | ttalvitie/dda-simulator | 59914b54aef2178fc04bd934621ffd534a74ac6b | [
"BSD-2-Clause"
] | 2 | 2020-12-21T13:22:53.000Z | 2021-09-11T10:31:56.000Z | vc3.hpp | ttalvitie/dda-simulator | 59914b54aef2178fc04bd934621ffd534a74ac6b | [
"BSD-2-Clause"
] | null | null | null | vc3.hpp | ttalvitie/dda-simulator | 59914b54aef2178fc04bd934621ffd534a74ac6b | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#include "bmm.hpp"
namespace dda_simulator {
/// Port numbered VC3 machine that finds a 3-approximation of a minimum
/// vertex cover of a simple graph. The algorithm ignores its input.
/// The algorithm is described in
/// Jukka Suomela: A Course on Deterministic Distributed Algorithms
/// http://users.ics.aalto.fi/suomela/dda/
/// The output vertex cover may be read using the isInVertexCover methods
/// of the states.
struct VC3Machine {
struct State {
/// State of the first part of the vertex.
BMMMachine::State state1;
/// State of the second part of the vertex.
BMMMachine::State state2;
bool isInVertexCover() const {
return state1.match != SIZE_MAX || state2.match != SIZE_MAX;
}
};
// The input is ignored.
typedef bool Input;
typedef std::pair<BMMMachine::Message, BMMMachine::Message> Message;
State init(std::size_t deg, bool input) const {
State ret;
ret.state1 = BMMMachine().init(deg, false);
ret.state2 = BMMMachine().init(deg, true);
return ret;
}
void send(const State& state, std::vector<Message>& msgs) const {
std::vector<BMMMachine::Message> msgs1;
std::vector<BMMMachine::Message> msgs2;
BMMMachine().send(state.state1, msgs2);
BMMMachine().send(state.state2, msgs1);
for(std::size_t i = 0; i < msgs1.size(); ++i) {
msgs.emplace_back(msgs1[i], msgs2[i]);
}
}
State receive(State state, const std::vector<Message>& msgs) const {
std::vector<BMMMachine::Message> msgs1;
std::vector<BMMMachine::Message> msgs2;
for(const Message& msg : msgs) {
msgs1.push_back(msg.first);
msgs2.push_back(msg.second);
}
state.state1 = BMMMachine().receive(state.state1, msgs1);
state.state2 = BMMMachine().receive(state.state2, msgs2);
return state;
}
bool stopped(const State& state) const {
return !state.state1.running && !state.state2.running;
}
};
}
| 25.28 | 73 | 0.689346 | [
"vector"
] |
c16af935993af66ad7d00c2fc089e0dc67c4fd5a | 2,762 | cc | C++ | tile/lang/gen_trivial.cc | redoclag/plaidml | 46d9e8b3f1e1093aab2a0dfa40b2e15e3cc7d314 | [
"Apache-2.0"
] | 4,535 | 2017-10-20T05:03:57.000Z | 2022-03-30T15:42:33.000Z | tile/lang/gen_trivial.cc | HOZHENWAI/plaidml | 46d9e8b3f1e1093aab2a0dfa40b2e15e3cc7d314 | [
"Apache-2.0"
] | 984 | 2017-10-20T17:16:09.000Z | 2022-03-30T05:43:18.000Z | tile/lang/gen_trivial.cc | HOZHENWAI/plaidml | 46d9e8b3f1e1093aab2a0dfa40b2e15e3cc7d314 | [
"Apache-2.0"
] | 492 | 2017-10-20T18:22:32.000Z | 2022-03-30T09:00:05.000Z | #include "tile/lang/gen_trivial.h"
#include <memory>
#include <string>
#include "base/util/logging.h"
#include "tile/lang/sembuilder.h"
namespace vertexai {
namespace tile {
namespace lang {
KernelInfo GenCopy(const TensorShape& shape, const std::string& oname, const std::string& iname,
const std::string& kname) {
using namespace sem::builder; // NOLINT
uint64_t size = shape.elem_size();
IVLOG(2, "Making a copy for " << iname.c_str() << " -> " << oname.c_str() << ", of size " << size);
sem::Function::params_t params;
sem::Type oparamtype{sem::Type::POINTER_MUT, shape.type};
sem::Type iparamtype{sem::Type::POINTER_CONST, shape.type};
iparamtype.region = sem::Type::GLOBAL;
oparamtype.region = sem::Type::GLOBAL;
params.push_back(std::make_pair(oparamtype, "out"));
params.push_back(std::make_pair(iparamtype, "in"));
sem::Type voidret{sem::Type::TVOID};
sem::StmtPtr body =
_Block({_("out")[_Index(sem::IndexExpr::GLOBAL, 0)] = _("in")[_Index(sem::IndexExpr::GLOBAL, 0)]});
auto func = std::make_shared<sem::Function>(kname, voidret, params, body);
KernelInfo ki;
ki.kname = kname;
ki.kfunc = func;
ki.outputs.push_back(oname);
ki.inputs.push_back(iname);
ki.gwork[0] = size;
ki.gwork[1] = 1;
ki.gwork[2] = 1;
ki.lwork[0] = ki.lwork[1] = ki.lwork[2] = 0;
ki.tot_bytes = size * ((bit_width(shape.type) + 7) / 8);
ki.tot_flops = size;
auto pb = ki.info.mutable_zero();
pb->set_copy(true);
ki.info.set_flops(ki.tot_flops);
ki.info.set_bytes(ki.tot_bytes);
ki.ktype = KernelType::kCopy;
return ki;
}
KernelInfo GenZero(const TensorShape& shape, const std::string& bname, const std::string& kname) {
using namespace sem::builder; // NOLINT
uint64_t size = shape.elem_size();
IVLOG(2, "Making a zero for " << bname.c_str() << ", of size " << size);
sem::Function::params_t params;
sem::Type paramtype{sem::Type::POINTER_MUT, shape.type};
paramtype.region = sem::Type::GLOBAL;
params.push_back(std::make_pair(paramtype, "out"));
sem::Type voidret{sem::Type::TVOID};
sem::StmtPtr body = _Block({_("out")[_Index(sem::IndexExpr::GLOBAL, 0)] = _Const(0)});
auto func = std::make_shared<sem::Function>(kname, voidret, params, body);
KernelInfo ki;
ki.kname = kname;
ki.kfunc = func;
ki.outputs.push_back(bname);
ki.gwork[0] = size;
ki.gwork[1] = 1;
ki.gwork[2] = 1;
ki.lwork[0] = ki.lwork[1] = ki.lwork[2] = 0;
ki.tot_bytes = size * ((bit_width(shape.type) + 7) / 8);
ki.tot_flops = size;
auto pb = ki.info.mutable_zero();
pb->set_copy(false);
ki.info.set_flops(ki.tot_flops);
ki.info.set_bytes(ki.tot_bytes);
ki.ktype = KernelType::kZero;
return ki;
}
} // namespace lang
} // namespace tile
} // namespace vertexai
| 33.682927 | 105 | 0.663287 | [
"shape"
] |
c16b512761a3517ddf5882d6e515c1bc6c8d78c2 | 8,320 | cpp | C++ | sources/gst-yoloplugin/yoloplugin_lib/yolov3.cpp | michaelchien1972/deepstream-plugins | 570e5201050b7ee1df39b8fed887d246abefa677 | [
"MIT"
] | 10 | 2018-07-24T17:47:50.000Z | 2021-05-14T23:02:14.000Z | sources/gst-yoloplugin/yoloplugin_lib/yolov3.cpp | whklwhkl/deepstream-plugins | 570e5201050b7ee1df39b8fed887d246abefa677 | [
"MIT"
] | null | null | null | sources/gst-yoloplugin/yoloplugin_lib/yolov3.cpp | whklwhkl/deepstream-plugins | 570e5201050b7ee1df39b8fed887d246abefa677 | [
"MIT"
] | 8 | 2018-11-25T20:29:55.000Z | 2021-02-22T11:02:35.000Z | /**
MIT License
Copyright (c) 2018 NVIDIA CORPORATION. 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.
*
*/
#include "yolov3.h"
#include "network_config.h"
YoloV3::YoloV3(uint batchSize) :
Yolo(batchSize),
m_Stride1(STRIDE_1),
m_Stride2(STRIDE_2),
m_Stride3(STRIDE_3),
m_GridSize1(GRID_SIZE_1),
m_GridSize2(GRID_SIZE_2),
m_GridSize3(GRID_SIZE_3),
m_OutputSize1(OUTPUT_SIZE_1),
m_OutputSize2(OUTPUT_SIZE_2),
m_OutputSize3(OUTPUT_SIZE_3),
m_OutputIndex1(-1),
m_OutputIndex2(-1),
m_OutputIndex3(-1),
m_OutputBlobName1(OUTPUT_BLOB_NAME_1),
m_OutputBlobName2(OUTPUT_BLOB_NAME_2),
m_OutputBlobName3(OUTPUT_BLOB_NAME_3),
m_Mask1(MASK_1),
m_Mask2(MASK_2),
m_Mask3(MASK_3)
{
m_OutputIndex1 = m_Engine->getBindingIndex(m_OutputBlobName1.c_str());
assert(m_OutputIndex1 != -1);
m_OutputIndex2 = m_Engine->getBindingIndex(m_OutputBlobName2.c_str());
assert(m_OutputIndex2 != -1);
m_OutputIndex3 = m_Engine->getBindingIndex(m_OutputBlobName3.c_str());
assert(m_OutputIndex3 != -1);
NV_CUDA_CHECK(
cudaMalloc(&m_Bindings.at(m_InputIndex), m_BatchSize * m_InputSize * sizeof(float)));
NV_CUDA_CHECK(
cudaMalloc(&m_Bindings.at(m_OutputIndex1), m_BatchSize * m_OutputSize1 * sizeof(float)));
NV_CUDA_CHECK(
cudaMalloc(&m_Bindings.at(m_OutputIndex2), m_BatchSize * m_OutputSize2 * sizeof(float)));
NV_CUDA_CHECK(
cudaMalloc(&m_Bindings.at(m_OutputIndex3), m_BatchSize * m_OutputSize3 * sizeof(float)));
m_TrtOutputBuffers.at(0) = new float[m_OutputSize1 * m_BatchSize];
m_TrtOutputBuffers.at(1) = new float[m_OutputSize2 * m_BatchSize];
m_TrtOutputBuffers.at(2) = new float[m_OutputSize3 * m_BatchSize];
};
void YoloV3::doInference(const unsigned char* input)
{
cudaStream_t stream;
NV_CUDA_CHECK(cudaStreamCreate(&stream));
NV_CUDA_CHECK(cudaMemcpyAsync(m_Bindings.at(m_InputIndex), input,
m_BatchSize * m_InputSize * sizeof(float), cudaMemcpyHostToDevice,
stream));
m_Context->enqueue(m_BatchSize, m_Bindings.data(), stream, nullptr);
NV_CUDA_CHECK(cudaMemcpyAsync(m_TrtOutputBuffers.at(0), m_Bindings.at(m_OutputIndex1),
m_BatchSize * m_OutputSize1 * sizeof(float),
cudaMemcpyDeviceToHost, stream));
NV_CUDA_CHECK(cudaMemcpyAsync(m_TrtOutputBuffers.at(1), m_Bindings.at(m_OutputIndex2),
m_BatchSize * m_OutputSize1 * sizeof(float),
cudaMemcpyDeviceToHost, stream));
NV_CUDA_CHECK(cudaMemcpyAsync(m_TrtOutputBuffers.at(2), m_Bindings.at(m_OutputIndex3),
m_BatchSize * m_OutputSize1 * sizeof(float),
cudaMemcpyDeviceToHost, stream));
cudaStreamSynchronize(stream);
cudaStreamDestroy(stream);
}
std::vector<BBoxInfo> YoloV3::decodeDetections(const int& imageIdx, const int& imageH,
const int& imageW)
{
std::vector<BBoxInfo> binfo;
std::vector<BBoxInfo> binfo1
= decodeTensor(imageH, imageW, &m_TrtOutputBuffers.at(0)[imageIdx * m_OutputSize1], m_Mask1,
m_GridSize1, m_Stride1);
std::vector<BBoxInfo> binfo2
= decodeTensor(imageH, imageW, &m_TrtOutputBuffers.at(1)[imageIdx * m_OutputSize2], m_Mask2,
m_GridSize2, m_Stride2);
std::vector<BBoxInfo> binfo3
= decodeTensor(imageH, imageW, &m_TrtOutputBuffers.at(2)[imageIdx * m_OutputSize3], m_Mask3,
m_GridSize3, m_Stride3);
binfo.insert(binfo.end(), binfo1.begin(), binfo1.end());
binfo.insert(binfo.end(), binfo2.begin(), binfo2.end());
binfo.insert(binfo.end(), binfo3.begin(), binfo3.end());
return binfo;
}
std::vector<BBoxInfo> YoloV3::decodeTensor(const int& imageH, const int& imageW,
const float* detections, const std::vector<int> mask,
const uint gridSize, const uint stride)
{
float scalingFactor
= std::min(static_cast<float>(m_InputW) / imageW, static_cast<float>(m_InputH) / imageH);
std::vector<BBoxInfo> binfo;
for (int y = 0; y < gridSize; ++y)
{
for (int x = 0; x < gridSize; ++x)
{
for (int b = 0; b < m_NumBBoxes; ++b)
{
const float pw = m_Anchors[mask[b] * 2];
const float ph = m_Anchors[mask[b] * 2 + 1];
const int numGridCells = gridSize * gridSize;
const int bbindex = y * gridSize + x;
const float bx
= x
+ sigmoid(
detections[bbindex + numGridCells * (b * (5 + m_NumOutputClasses) + 0)]);
const float by
= y
+ sigmoid(
detections[bbindex + numGridCells * (b * (5 + m_NumOutputClasses) + 1)]);
const float bw = pw
* exp(detections[bbindex + numGridCells * (b * (5 + m_NumOutputClasses) + 2)]);
const float bh = ph
* exp(detections[bbindex + numGridCells * (b * (5 + m_NumOutputClasses) + 3)]);
const float objectness = sigmoid(
detections[bbindex + numGridCells * (b * (5 + m_NumOutputClasses) + 4)]);
float maxProb = 0.0f;
int maxIndex = -1;
for (int i = 0; i < m_NumOutputClasses; ++i)
{
float prob = sigmoid(
detections[bbindex
+ numGridCells * (b * (5 + m_NumOutputClasses) + (5 + i))]);
if (prob > maxProb)
{
maxProb = prob;
maxIndex = i;
}
}
maxProb = objectness * maxProb;
if (maxProb > m_ProbThresh)
{
BBoxInfo bbi;
bbi.box = convertBBox(bx, by, bw, bh, stride);
// Undo Letterbox
float x_correction = (m_InputW - scalingFactor * imageW) / 2;
float y_correction = (m_InputH - scalingFactor * imageH) / 2;
bbi.box.x1 -= x_correction;
bbi.box.x2 -= x_correction;
bbi.box.y1 -= y_correction;
bbi.box.y2 -= y_correction;
// Restore to input resolution
bbi.box.x1 /= scalingFactor;
bbi.box.x2 /= scalingFactor;
bbi.box.y1 /= scalingFactor;
bbi.box.y2 /= scalingFactor;
bbi.label = maxIndex;
bbi.prob = maxProb;
binfo.push_back(bbi);
}
}
}
}
return binfo;
}
YoloV3::~YoloV3()
{
NV_CUDA_CHECK(cudaFree(m_Bindings.at(m_InputIndex)));
NV_CUDA_CHECK(cudaFree(m_Bindings.at(m_OutputIndex1)));
NV_CUDA_CHECK(cudaFree(m_Bindings.at(m_OutputIndex2)));
NV_CUDA_CHECK(cudaFree(m_Bindings.at(m_OutputIndex3)));
}
| 41.188119 | 100 | 0.59387 | [
"vector"
] |
c16e4be41972841658b472a012ba00847b5e61dd | 29,490 | cpp | C++ | C++/OS/Project5/parttwo.cpp | JRW2252/OldProjects | 58fb6788b7b08e45e1c29a62987f7af0dd2b8e13 | [
"Unlicense"
] | null | null | null | C++/OS/Project5/parttwo.cpp | JRW2252/OldProjects | 58fb6788b7b08e45e1c29a62987f7af0dd2b8e13 | [
"Unlicense"
] | null | null | null | C++/OS/Project5/parttwo.cpp | JRW2252/OldProjects | 58fb6788b7b08e45e1c29a62987f7af0dd2b8e13 | [
"Unlicense"
] | null | null | null | // CS3242 Operating Systems
// Spring 2015
// Project 5: Swapping and Paging, Part 2
// Alex Wardlaw, Ryan Williams, and Ryan Wraggs
// Date: 4/14/2015
// File: parttwo.cpp
#include <iostream>
#include <sstream> /* stringstream for num to int and int to num */
#include <stdio.h>
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time for srand */
#include <unistd.h> /* usleep */
#include <vector>
#include <iomanip> /* setw for charToString */
#define MAX_PROCESSES 52 // This will not ever change
#define PROCESS_COUNT 23 // useful when debugging to limit # of procs
#define MIN_DEATH_INTERVAL 20
#define MAX_DEATH_INTERVAL 300
#define MAX_FRAMES 280
#define MAX_PAGES 720
#define SHIFT_INTERVAL 10
#define PRINT_INTERVAL 50 // # of cpu quanta between memory map printouts
#define MAX_QUANTA 400 // # quanta to run before ending simulation.
#define SLEEP_LENGTH 25000 // Used with the usleep()to slow down sim between cycles (makes reading screen in real-time easier!)
using namespace std;
// Structs //
//this struct contains all of the info for a process's page info
struct Page
{
char procName;
int lifetime;
string pageName; //the page name as it appears in memory, ie, "A1"
int procPageNumber; //the page number, ie, 0-19
int location;
char validBit;
unsigned char reference; //unsigned char is 8 bits
};
struct Process
{
//segments (* * code(2), stack(3), heap(5), sub-p's (1-5) * *)
char name;
vector <Page> pages; // 0-1 == code, 2-4 = stack, 5-9 = heap, 10-19 = sub-p's
int lifetime;
};
// METHOD HEADERS //
void PrintMemory();
string NumberToString(int numIn);
int StringToNumber(string strIn);
int FIFO(string pageToAdd);
void LRU(vector <int []> vec);
int SecondChance(string pageToAdd);
void init_mem();
void touch(); // touch random process
bool kill(char p_name); // aka death: removes p from mem and backing
void print();
void createP(char p_name); // create process (* * code(2), stack(3), heap(5), sub-p's (1-5) * *)
bool removePage(int memPage); // remove page from mem
bool loadP(Process p); // load process into mem
bool AddProcessToBackingStore(Process p);
void PrintBackingStore();
void setRef(char p_name);
void PrintPageTable();
void IncrementRef();
void get_stats();
void print_stats();
string charToString(unsigned char c);
// GLOBALS //
int choice, quanta, locationLastAdded, used_frames, num_pages, num_processes, loaded, unloaded;
char p_names[] = {'@','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y', 'z'};
vector<string> memory;
vector<string> backingStore;
vector<Process> processVec;
vector<unsigned char> referenceBit;
int main(int argc, const char * argv[]) {
srand ((int)time(NULL)); //seed the random number generator.
string in;
do{
printf("\nChoose a page replacement algorithm\n1:\tFIFO\n2:\tLRU\n3:\tSecond Chance\n4:\tExit\n\nUser Input: ");
cin >> in;
choice = StringToNumber(in);
if(choice == 1)
cout << "You chose: " << choice << " for FIFO" << endl;
else if(choice == 2)
cout << "You chose: " << choice << " for LRU" << endl;
else if(choice == 3)
cout << "You chose: " << choice << " for Second Chance" << endl;
else if(choice == 4){
cout << "You chose: " << choice << endl;
cout << "\n * * *\tEXIT PROGRAM\t* * *" << endl;
exit(0);
}
else
cout << "\nInvalid choice. Try again.\n";
} while(choice != 1 && choice != 2 && choice != 3);
locationLastAdded = 0;
init_mem();
quanta = 0;
while (quanta <= MAX_QUANTA)
{
if (quanta % PRINT_INTERVAL == 0)
print();
//increments reference bit every 10 quanta if choice is LRU
if (choice == 2 && quanta % SHIFT_INTERVAL == 0)
IncrementRef();
//touch() touches, creates and kills processes
touch();
quanta++;
usleep(SLEEP_LENGTH);
}
}
void PrintMemory()
{
string sixSpaces = " ";
string ruler = "--------++--------||--------++--------||--------++--------||--------++--------||--------++--------||";
int rowWidth = 100;
int i = 0;
printf("Memory:\n");
while (i < MAX_FRAMES)
{
string numLine;
string memLine;
//creates the row with the numbers with the proper spacing.
for (int counter = 0; counter < rowWidth / 10; counter++)
{
if (i < MAX_FRAMES)
{
string str = NumberToString(i + 4);
if (str.length() == 1)
numLine += sixSpaces + " " + str;
else if (str.length() == 2)
numLine += sixSpaces+ " " + str;
else if (str.length() == 3)
numLine += sixSpaces + " " + str;
else if (str.length() == 4)
numLine += sixSpaces + str;
}
i += 5;
}
printf("%s\n", numLine.c_str());
printf("%s\n", ruler.c_str());
//creates the line showing whats in memory.
for (int counter = 0; counter < rowWidth/2; counter++)
{
//add the value if its not an empty string
if (memory[((i - rowWidth/2) + counter)] != "")
{
memLine += memory[((i - (rowWidth/2)) + counter)];
}
//else add two spaces if it is an empty string
else
memLine += " ";
//printf("memline: %s, memory: %s, index: %s\n", memLine.c_str(), memory[((i - rowWidth) + counter)].c_str(), NumberToString(((i - rowWidth) + counter)).c_str());
}
printf("%s\n", memLine.c_str());
}
printf("\n\n");
}
//converts number to string
string NumberToString (int numIn) {
stringstream ss;
string s;
ss << numIn;
ss >> s;
return s;
}
int StringToNumber(string strIn){
stringstream ss;
int choiceInt = -1;
ss << strIn;
ss >> choiceInt;
if (ss.fail())
return -1;
return choiceInt;
}
//returns location added
int FIFO(string pageToAdd){
//if it finds an empty spot, it adds it there
for (int i = 0; i < MAX_FRAMES; i++)
{
if (memory[i] == "")
{
removePage(i);
memory[i] = pageToAdd;
return i;
}
}
//this ensures the kernal '@' is never removed.
while (memory[locationLastAdded].find('@') != string::npos)
{
locationLastAdded++;
//necessary to ensure locationlastadded is always valid
if (locationLastAdded >= MAX_FRAMES)
locationLastAdded = 0;
}
//necessary to ensure locationlastadded is always valid
if (locationLastAdded >= MAX_FRAMES)
locationLastAdded = 0;
//removes the last added item then increments last added
removePage(locationLastAdded);
memory[locationLastAdded++] = pageToAdd;
return locationLastAdded - 1;
}
int LRU(string pageToAdd){
int oldestLoc = 0;
unsigned char oldest = 0;
oldest--;
//if it finds an empty spot, it adds it there
for (int i = 0; i < MAX_FRAMES; i++)
{
if (memory[i] == "")
{
removePage(i);
memory[i] = pageToAdd;
return i;
}
if (referenceBit[i] < oldest)
{
oldest = referenceBit[i];
oldestLoc = i;
}
}
removePage(oldestLoc);
memory[oldestLoc] = pageToAdd;
return oldestLoc;
}
int SecondChance(string pageToAdd){
//if it finds an empty spot, it adds it there
for (int i = 0; i < MAX_FRAMES; i++)
{
if (memory[i] == "")
{
removePage(i);
memory[i] = pageToAdd;
return i;
}
}
//this ensures the kernal '@' is never removed.
while (memory[locationLastAdded].find('@') != string::npos)
{
locationLastAdded++;
//necessary to ensure locationlastadded is always valid
if (locationLastAdded >= MAX_FRAMES)
locationLastAdded = 0;
}
while (true)
{
//necessary to ensure locationlastadded is always valid
if (locationLastAdded >= MAX_FRAMES)
locationLastAdded = 0;
//checks to see if reference bit is set, replaces if not
if (referenceBit[locationLastAdded] == 0)
{
//removes the last added item then increments last added
removePage(locationLastAdded);
memory[locationLastAdded++] = pageToAdd;
return locationLastAdded - 1;
}
//if reference bit is set, unset it, and increment locationLastAdded
else
referenceBit[locationLastAdded++] = 0;
}
}
void init_mem() {
int randomSelection = -1;
//create kernel first since i will not have a lifespan
Process p;
p.name = '@';
//kernel will always have 20 pages total
for (int i = 0; i < 20; i++)
{
Page pg;
pg.location = -1;
pg.validBit = 'i';
pg.reference = -1;
p.pages.push_back(pg);
}
//use i = 1 to prevent '@' from being used
for (int i = 1; i < PROCESS_COUNT; i++)
{
createP(p_names[i]);
}
vector <Process> tmp = processVec;
// filling backing store to max_pages 720
for(int i = 0; i < MAX_PAGES; i++){
backingStore.push_back("");
};
// filling memory to max_frames 280
for(int i = 0; i < MAX_FRAMES; i++){
memory.push_back("");
//set all reference bits to 0
referenceBit.push_back(0);
};
do{
randomSelection = rand()%tmp.size();
if(!AddProcessToBackingStore(tmp[randomSelection]))
break;
//added this to pull all processes into memory
loadP(tmp[randomSelection]);
tmp.erase(tmp.begin()+randomSelection);
} while (tmp.size() > 0);
//kernel must be loaded last to ensure it is in memory
AddProcessToBackingStore(p);
loadP(p);
}
void touch() { // touch random process
char toTouch;
int randP;
bool touched = false;
//to insure process to be touched is not kernal, '@'
do{
randP = rand()%PROCESS_COUNT;
toTouch = p_names[randP];
} while(toTouch == '@');
//these two are both covered in this one for loop
// 1. access code, stack, heap, segments
// 2. if P's lifetime expired remove from mem and backing ... (needs to be checked every unit of quanta though) ...
//number 2 will be covered because touch() is called every quanta.
for (int i = 0; i < processVec.size(); i++)
{
if (processVec[i].name == toTouch)
{
//this way we know the process exists.
touched = true;
loadP(processVec[i]);
setRef(processVec[i].name);
}
if (processVec[i].lifetime <= quanta)
{
kill(processVec[i].name);
}
}
if (!touched)
{
createP(toTouch);
AddProcessToBackingStore(processVec.back());
loadP(processVec.back());
}
}
bool kill(char p_name){ // aka death: removes p from mem and backing
int i;
bool found = false;
for(i = 0; i < memory.size(); i++){
// looking for p_name to remove from memory
if(memory[i].find(p_name) != string::npos){
memory[i] = "";
found = true;
}
}
for(i = 0; i < backingStore.size(); i++){
// looking for p_name to remove from backing store
if(backingStore[i].find(p_name) != string::npos){
backingStore[i] = "";
found = true;
}
}
if(found){
// remove p_name from processVec
for(i = 0; i < processVec.size(); i++){
if(processVec[i].name == p_name)
processVec.erase(processVec.begin()+i);
}
}
return found;
}
void print(){
// print mem, page table and backingStore
get_stats();
print_stats();
PrintMemory();
PrintPageTable();
PrintBackingStore();
}
void createP(char p_name){ // create process (* * code(2), stack(3), heap(5), sub-p's (1-5) * *)
int i, subs, lifeSpan;
subs = (rand()%4+1)*2;
lifeSpan = rand()%280+20;
Process p;
p.name = p_name;
// 1. create information segments for p
// segments
for(i = 0; i <= (9+subs); i++){
Page pg;
pg.location = -1;
pg.validBit = 'i';
pg.reference = -1;
p.pages.push_back(pg);
}
// 2. set lifetime for p randomly between 20 - 300 cycles or units of time
//need the + quanta part for when a process is created after quanta is greater than 300
p.lifetime = lifeSpan + quanta;
// 3. load p into backing store or mem (one or other not sure)
processVec.push_back(p);
}
//copies a page from memory into backing store. does not remove from memory
bool removePage(int memPage) {
//find an empty spot in backing store
for (int i = 0; i < MAX_PAGES; i++)
{
if (backingStore[i] == "")
{
backingStore[i] = memory[memPage];
return true;
}
}
return false;
}
bool loadP(Process p){ // load process into mem
// if process's segments are not in mem, simulate pg. fault and load them into mem
for (int i = 0; i < MAX_PAGES; i++)
{
if (backingStore[i].find(p.name) != string::npos)
{
switch (choice)
{
case 2:
referenceBit[LRU(backingStore[i])] = 255;
backingStore[i] = "";
break;
case 3:
referenceBit[SecondChance(backingStore[i])] = 255;
backingStore[i] = "";
break;
default:
referenceBit[FIFO(backingStore[i])] = 255;
backingStore[i] = "";
}
}
}
return true;
}
//adds a new process in backing store to be added into memory later
bool AddProcessToBackingStore(Process p) {
for (int i = 0; i < p.pages.size(); i++)
{
for (int j = 0; j < MAX_PAGES; j++)
{
if (backingStore[j] == "")
{
if (i < 2) {
backingStore[j] = p.name + NumberToString(0);
break;
} else if (i >= 2 && i < 5) {
backingStore[j] = p.name + NumberToString(1);
break;
} else if (i >=5 && i < 10) {
backingStore[j] = p.name + NumberToString(2);
break;
} else if (i >= 10 && i < 12) {
backingStore[j] = p.name + NumberToString(3);
break;
} else if (i >= 12 && i < 14){
backingStore[j] = p.name + NumberToString(4);
break;
} else if (i >= 14 && i < 16) {
backingStore[j] = p.name + NumberToString(5);
break;
} else if (i >= 16 && i < 18) {
backingStore[j] = p.name + NumberToString(6);
break;
} else if (i >= 18 && i < 20) {
backingStore[j] = p.name + NumberToString(7);
break;
} else if (i == 719) {
return false;
}
}
}
}
return true;
}
void PrintBackingStore() {
string sixSpaces = " ";
string ruler = "--------++--------||--------++--------||--------++--------||--------++--------||--------++--------||";
int rowWidth = 100;
int i = 0;
printf("Backing Store:\n");
while (i < MAX_PAGES)
{
string numLine;
string memLine;
//creates the row with the numbers with the proper spacing.
for (int counter = 0; counter < rowWidth / 10; counter++)
{
if (i < MAX_PAGES)
{
string str = NumberToString(i + 4);
if (str.length() == 1)
numLine += sixSpaces + " " + str;
else if (str.length() == 2)
numLine += sixSpaces+ " " + str;
else if (str.length() == 3)
numLine += sixSpaces + " " + str;
else if (str.length() == 4)
numLine += sixSpaces + str;
}
i += 5;
}
printf("%s\n", numLine.c_str());
printf("%s\n", ruler.c_str());
//creates the line showing whats in memory.
for (int counter = 0; counter < rowWidth/2; counter++)
{
//add the value if its not an empty string
if (backingStore[((i - rowWidth/2) + counter)] != "")
memLine += backingStore[((i - rowWidth/2) + counter)];
//else add two spaces if it is an empty string
else
memLine += " ";
}
printf("%s\n", memLine.c_str());
}
printf("\n\n");
}
//decrements reference bit of the particular process
void setRef(char p_name) {
for (int i = 0; i < MAX_FRAMES; i++)
{
if (memory[i].find(p_name) != string::npos)
referenceBit[i]--;
}
}
void PrintPageTable()
{
//first, create a vector of pages which has all the needed data:
vector<Page> allPageVec;
//use i = 1 to skip over '@'
for (int i = 1; i < PROCESS_COUNT; i++)
{
for (int j = 0; j < MAX_FRAMES; j++)
{
if (memory[j].find(p_names[i]) != string::npos)
{
Page p;
p.procName = p_names[i];
p.pageName = memory[j];
p.validBit = 'v';
p.location = j;
p.reference = referenceBit[j];
allPageVec.push_back(p);
}
}
for (int j = 0; j < MAX_PAGES; j++)
{
if (backingStore[j].find(p_names[i]) != string::npos)
{
Page p;
p.procName = p_names[i];
p.pageName = backingStore[j];
p.validBit = 'i';
p.location = 0;
p.reference = 0;
allPageVec.push_back(p);
}
}
}
int rowWidth = 11;
int letter = 1;
while (letter < PROCESS_COUNT)
{
for (int count = 0; count < rowWidth; count++)
{
printf("%*c ", 6, p_names[letter]);
letter++;
}
for (int rowCount = 0; rowCount < 20; rowCount++)
{
letter -= rowWidth;
printf("\n");
for (int count = 0; count < rowWidth; count++)
{
if (rowCount < 2)
{
string name = p_names[letter] + NumberToString(0);
bool found = false;
for (int j = 0; j < allPageVec.size(); j++)
{
if (allPageVec[j].pageName == name) {
string loc = NumberToString(allPageVec[j].location);
while(loc.length() < 3)
loc = "0" + loc;
string ref = charToString(allPageVec[j].reference);
printf("0%d %s %c%s|", rowCount, loc.c_str(), allPageVec[j].validBit, ref.c_str());
allPageVec.erase(allPageVec.begin() + j);
found = true;
break;
}
}
if (!found)
printf("0%d --- ---|", rowCount);
}
else if (rowCount > 1 && rowCount <= 4)
{
string name = p_names[letter] + NumberToString(1);
bool found = false;
for (int j = 0; j < allPageVec.size(); j++)
{
if (allPageVec[j].pageName == name) {
string loc = NumberToString(allPageVec[j].location);
while(loc.length() < 3)
loc = "0" + loc;
string ref = charToString(allPageVec[j].reference);
printf("0%d %s %c%s|", rowCount, loc.c_str(), allPageVec[j].validBit, ref.c_str());
allPageVec.erase(allPageVec.begin() + j);
found = true;
break;
}
}
if (!found)
printf("0%d --- ---|", rowCount); }
else if (rowCount > 4 && rowCount <= 9)
{
string name = p_names[letter] + NumberToString(2);
bool found = false;
for (int j = 0; j < allPageVec.size(); j++)
{
if (allPageVec[j].pageName == name) {
string loc = NumberToString(allPageVec[j].location);
while(loc.length() < 3)
loc = "0" + loc;
string ref = charToString(allPageVec[j].reference);
printf("0%d %s %c%s|", rowCount, loc.c_str(), allPageVec[j].validBit, ref.c_str());
allPageVec.erase(allPageVec.begin() + j);
found = true;
break;
}
}
if (!found)
printf("0%d --- ---|", rowCount);
}
else if (rowCount > 9 && rowCount <= 11)
{
string name = p_names[letter] + NumberToString(3);
bool found = false;
for (int j = 0; j < allPageVec.size(); j++)
{
if (allPageVec[j].pageName == name) {
string loc = NumberToString(allPageVec[j].location);
while(loc.length() < 3)
loc = "0" + loc;
string ref = charToString(allPageVec[j].reference);
printf("%d %s %c%s|", rowCount, loc.c_str(), allPageVec[j].validBit, ref.c_str());
allPageVec.erase(allPageVec.begin() + j);
found = true;
break;
}
}
if (!found)
printf("%d --- ---|", rowCount);
}
else if (rowCount > 11 && rowCount <=13)
{
string name = p_names[letter] + NumberToString(4);
bool found = false;
for (int j = 0; j < allPageVec.size(); j++)
{
if (allPageVec[j].pageName == name) {
string loc = NumberToString(allPageVec[j].location);
while(loc.length() < 3)
loc = "0" + loc;
string ref = charToString(allPageVec[j].reference);
printf("%d %s %c%s|", rowCount, loc.c_str(), allPageVec[j].validBit, ref.c_str());
allPageVec.erase(allPageVec.begin() + j);
found = true;
break;
}
}
if (!found)
printf("%d --- ---|", rowCount);
}
else if (rowCount > 13 && rowCount <= 15)
{
string name = p_names[letter] + NumberToString(5);
bool found = false;
for (int j = 0; j < allPageVec.size(); j++)
{
if (allPageVec[j].pageName == name) {
string loc = NumberToString(allPageVec[j].location);
while(loc.length() < 3)
loc = "0" + loc;
string ref = charToString(allPageVec[j].reference);
printf("%d %s %c%s|", rowCount, loc.c_str(), allPageVec[j].validBit, ref.c_str());
allPageVec.erase(allPageVec.begin() + j);
found = true;
break;
}
}
if (!found)
printf("%d --- ---|", rowCount);
}
else if (rowCount > 15 && rowCount <= 17)
{
string name = p_names[letter] + NumberToString(6);
bool found = false;
for (int j = 0; j < allPageVec.size(); j++)
{
if (allPageVec[j].pageName == name) {
string loc = NumberToString(allPageVec[j].location);
while(loc.length() < 3)
loc = "0" + loc;
string ref = charToString(allPageVec[j].reference);
printf("%d %s %c%s|", rowCount, loc.c_str(), allPageVec[j].validBit, ref.c_str());
allPageVec.erase(allPageVec.begin() + j);
found = true;
break;
}
}
if (!found)
printf("%d --- ---|", rowCount);
}
else if (rowCount > 17)
{
string name = p_names[letter] + NumberToString(7);
bool found = false;
for (int j = 0; j < allPageVec.size(); j++)
{
if (allPageVec[j].pageName == name) {
string loc = NumberToString(allPageVec[j].location);
while(loc.length() < 3)
loc = "0" + loc;
string ref = charToString(allPageVec[j].reference);
printf("%d %s %c%s|", rowCount, loc.c_str(), allPageVec[j].validBit, ref.c_str());
allPageVec.erase(allPageVec.begin() + j);
found = true;
break;
}
}
if (!found)
printf("%d --- ---|", rowCount);
}
letter++;
}
}
printf("\n\n");
}
}
string charToString(unsigned char c)
{
stringstream ss;
string s;
ss << setw(2) << setfill('0') << hex << (int) c;
ss >> s;
return s;
}
//actually decrements the reference value
void IncrementRef() {
for (int i = 0; i < MAX_FRAMES; i++)
{
referenceBit[i] = referenceBit[i] >> 1;
}
}
void get_stats() {
used_frames = 0; num_pages = 0; num_processes = 0; loaded = 0; unloaded = 0;
vector<Process>tmp = processVec;
for(int i = 0; i < backingStore.size(); i++) {
if(backingStore[i] != "")
++num_pages;
for(int j = 0; j < tmp.size(); j++){
if(tmp[j].name == backingStore[i][0]){
tmp.erase(tmp.begin()+j);
}
}
}
for(int i = 0; i < memory.size(); i++) {
if(memory[i] != "")
++used_frames;
}
loaded = (int)tmp.size();
unloaded = (int)processVec.size() - loaded;
}
void print_stats(){
// GLOBALS
// int choice, quanta, locationLastAdded, mem_used, mem_free, num_frames, num_pages;
get_stats();
printf("\n\t\tQUANTA ELAPSED:\t%d\n",quanta);
printf("\t\tFRAMES:%*df\tUSED FRAMES:%*df (%.1f%%)\tFREE FRAMES:%*df (%.1f%%)\n",9,MAX_FRAMES,5,used_frames, ((used_frames*1.0)/(MAX_FRAMES*1.0))*100.0,5,MAX_FRAMES-used_frames,(MAX_FRAMES*1.0)/((MAX_FRAMES-used_frames)*1.0));
printf("\t\tSWAP SPACE:%*dp\tTOTAL PAGES:%*dp (%.1f%%)\tLOADED PAGES:%*dp (%.1f%%)\n\t\tUNLOADED:%*dp\t(%.1f%%)\t\t\t\tFREE PAGES:%*dp (%.1f%%)\n", 5, MAX_PAGES, 5,loaded+unloaded, (((loaded+unloaded)*1.0)/(MAX_PAGES*1.0))*100.0, 4, loaded,((loaded*1.0)/(MAX_PAGES*1.0))*100.0, 7, unloaded,((unloaded*1.0)/(MAX_PAGES*1.0))*100.0 ,6, MAX_PAGES - num_pages,(((MAX_PAGES-num_pages)*1.0)/(MAX_PAGES*1.0))*100.0);
printf("\t\tPROCESSES:%*d\tLOADED:%*d\tUNLOADED:%*d\tDEAD:%*d\n\n",6,PROCESS_COUNT,5,loaded,5,unloaded,5,PROCESS_COUNT-(int)processVec.size());
}
| 34.092486 | 412 | 0.465107 | [
"vector"
] |
c17bb1508a67d15d92c3b88b4d8efa533f7bc8db | 2,648 | cc | C++ | src/modular/lib/pseudo_dir/pseudo_dir_server.cc | sunshinewithmoonlight/fuchsia-2003 | 02b23026dc7fecbad063210d5d45fa1b17feeb8b | [
"BSD-3-Clause"
] | null | null | null | src/modular/lib/pseudo_dir/pseudo_dir_server.cc | sunshinewithmoonlight/fuchsia-2003 | 02b23026dc7fecbad063210d5d45fa1b17feeb8b | [
"BSD-3-Clause"
] | null | null | null | src/modular/lib/pseudo_dir/pseudo_dir_server.cc | sunshinewithmoonlight/fuchsia-2003 | 02b23026dc7fecbad063210d5d45fa1b17feeb8b | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2019 The Fuchsia 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 "src/modular/lib/pseudo_dir/pseudo_dir_server.h"
#include <lib/async/cpp/task.h>
namespace modular {
PseudoDirServer::PseudoDirServer(std::unique_ptr<vfs::PseudoDir> pseudo_dir)
: pseudo_dir_(std::move(pseudo_dir)),
serving_thread_(
[this](fidl::InterfaceRequest<fuchsia::io::Directory> request) {
StartThread(std::move(request));
},
dir_.NewRequest()) {
// Block until the run loop in |serving_thread_| is ready before returning
// control to the caller.
std::unique_lock<std::mutex> lock(ready_mutex_);
thread_loop_ready_.wait(lock, [this] { return thread_loop_ != nullptr; });
}
PseudoDirServer::~PseudoDirServer() {
FXL_CHECK(thread_loop_);
// std::thread requires that we join() the thread before it is destroyed.
thread_loop_->Quit();
serving_thread_.join();
}
// Opens a read-only FD at |path|. Path must not begin with '/'.
fbl::unique_fd PseudoDirServer::OpenAt(std::string path) {
fuchsia::io::NodePtr node;
dir_->Open(fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_FLAG_DESCRIBE, // flags
0u, // mode
path, node.NewRequest());
return fsl::OpenChannelAsFileDescriptor(node.Unbind().TakeChannel());
}
void PseudoDirServer::Serve(zx::channel request) {
async::PostTask(thread_loop_->dispatcher(), [this, req = std::move(request)]() mutable {
pseudo_dir_->Serve(fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_RIGHT_WRITABLE,
std::move(req));
});
}
fuchsia::io::DirectoryPtr PseudoDirServer::Serve() {
fuchsia::io::DirectoryPtr directory;
Serve(directory.NewRequest().TakeChannel());
return directory;
}
// This method is the handler for a new thread. It lets the owning thread know
// that it has started and serves a directory requests. The thread is exited
// when this object is destroyed.
void PseudoDirServer::StartThread(fidl::InterfaceRequest<fuchsia::io::Directory> request) {
async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
{
std::lock_guard<std::mutex> lock(ready_mutex_);
// Setting this will let |thread_loop_ready_.wait()| proceed.
thread_loop_ = &loop;
pseudo_dir_->Serve(fuchsia::io::OPEN_RIGHT_READABLE, request.TakeChannel());
thread_loop_ready_.notify_one();
}
thread_loop_->Run();
// This thread exits when the owner thread calls thread_loop_->Quit().
}
} // namespace modular
| 35.306667 | 91 | 0.689577 | [
"object"
] |
c17f5c66f1468e242464990b9187ebb457217153 | 21,517 | cc | C++ | src/kudu/integration-tests/raft_config_change-itest.cc | YCjia/kudu | 36187ef62e9fb892ea286af8e9547790a3fd34ba | [
"Apache-2.0"
] | 11 | 2021-08-24T20:27:06.000Z | 2022-02-28T06:05:26.000Z | src/kudu/integration-tests/raft_config_change-itest.cc | YCjia/kudu | 36187ef62e9fb892ea286af8e9547790a3fd34ba | [
"Apache-2.0"
] | 29 | 2019-07-01T13:40:51.000Z | 2021-06-30T19:15:03.000Z | src/kudu/integration-tests/raft_config_change-itest.cc | YCjia/kudu | 36187ef62e9fb892ea286af8e9547790a3fd34ba | [
"Apache-2.0"
] | 16 | 2019-06-04T20:11:41.000Z | 2021-04-27T20:59:33.000Z | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include <cstdint>
#include <memory>
#include <ostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <boost/optional/optional.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include "kudu/common/common.pb.h"
#include "kudu/common/wire_protocol.pb.h"
#include "kudu/consensus/consensus.pb.h"
#include "kudu/consensus/metadata.pb.h"
#include "kudu/consensus/quorum_util.h"
#include "kudu/gutil/map-util.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/integration-tests/cluster_itest_util.h"
#include "kudu/integration-tests/external_mini_cluster-itest-base.h"
#include "kudu/integration-tests/mini_cluster_fs_inspector.h"
#include "kudu/integration-tests/test_workload.h"
#include "kudu/master/master.pb.h"
#include "kudu/mini-cluster/external_mini_cluster.h"
#include "kudu/util/monotime.h"
#include "kudu/util/pb_util.h"
#include "kudu/util/status.h"
#include "kudu/util/test_macros.h"
#include "kudu/util/test_util.h"
using kudu::consensus::ADD_PEER;
using kudu::consensus::COMMITTED_OPID;
using kudu::consensus::ConsensusStatePB;
using kudu::consensus::GetRaftConfigMember;
using kudu::consensus::MODIFY_PEER;
using kudu::consensus::RaftPeerAttrsPB;
using kudu::consensus::RaftPeerPB;
using kudu::consensus::REMOVE_PEER;
using kudu::itest::BulkChangeConfig;
using kudu::itest::GetTableLocations;
using kudu::itest::TServerDetails;
using kudu::master::VOTER_REPLICA;
using kudu::pb_util::SecureShortDebugString;
using std::string;
using std::unordered_set;
using std::vector;
using strings::Substitute;
namespace kudu {
class RaftConfigChangeITest : public ExternalMiniClusterITestBase {
};
// Regression test for KUDU-2147. In this test we cause an initial leader to
// heartbeat to a master with a new configuration change immediately after it
// has lost its leadership, reporting a new configuration with no leader. The
// master should update its record of which replica is the leader after a new
// leader is elected in that term.
//
// Steps followed in this test:
//
// 1. Inject latency into TS heartbeats to the master and reduce Raft leader
// heartbeat intervals to followers to be able to carefully control the
// sequence of events in this test.
// 2. Evict a follower from the config.
// 3. Immediately start an election on the remaining follower in the config.
// We know that this follower should win the election because in order to
// commit a removal from 3 voters, the removal op must be replicated to both
// of the two remaining voters in the config.
// 4. The master will get the config change heartbeat from the initial leader,
// which will indicate a new term and no current leader.
// 5. The master will then get a heartbeat from the new leader to report that
// it's now the leader of the config.
// 6. Once the master knows who the new leader is, the master will instruct the
// new leader to add a new replica to its config to bring it back up to 3
// voters. That new replica will be the follower that we evicted in step 2.
// 7. If that succeeds then the leader will replicate the eviction, the
// leader's own no-op, and the adding-back-in of the evicted replica to that
// evicted replica's log.
// 8. Once that process completes, all 3 replicas will have identical logs,
// which is what we wait for at the end of the test.
TEST_F(RaftConfigChangeITest, TestKudu2147) {
if (!AllowSlowTests()) {
// This test injects seconds of latency so can take a while to converge.
LOG(WARNING) << "Skipping test in fast-test mode.";
return;
}
const MonoDelta kTimeout = MonoDelta::FromSeconds(30);
// Slow down leader heartbeats so that in the explicit election below, the
// second leader does not immediately heartbeat to the initial leader. If
// that occurs, the initial leader will not report to the master that there
// is currently no leader.
NO_FATALS(StartCluster({"--raft_heartbeat_interval_ms=3000"}));
// Create a new table.
TestWorkload workload(cluster_.get());
workload.Setup();
workload.Start();
ASSERT_EVENTUALLY([&] {
ASSERT_GE(workload.batches_completed(), 10);
});
workload.StopAndJoin();
// The table should have replicas on three tservers.
ASSERT_OK(inspect_->WaitForReplicaCount(3));
master::GetTableLocationsResponsePB table_locations;
ASSERT_OK(GetTableLocations(cluster_->master_proxy(), TestWorkload::kDefaultTableName,
kTimeout, VOTER_REPLICA, &table_locations));
ASSERT_EQ(1, table_locations.tablet_locations_size()); // Only 1 tablet.
ASSERT_EQ(3, table_locations.tablet_locations().begin()->replicas_size()); // 3 replicas.
string tablet_id = table_locations.tablet_locations().begin()->tablet_id();
// Wait for all 3 replicas to converge before we start the test.
ASSERT_OK(WaitForServersToAgree(kTimeout, ts_map_, tablet_id, 1));
// Retry as needed to counter normal leader election activity.
ASSERT_EVENTUALLY([&] {
// Find initial leader.
TServerDetails* leader;
ASSERT_OK(FindTabletLeader(ts_map_, tablet_id, kTimeout, &leader));
ASSERT_OK(WaitForOpFromCurrentTerm(leader, tablet_id, COMMITTED_OPID, kTimeout));
vector<TServerDetails*> followers;
for (int i = 0; i < cluster_->num_tablet_servers(); i++) {
// Dynamically set the latency injection flag to induce TS -> master
// heartbeat delays. The leader delays its master heartbeats by 2 sec
// each time; followers delay their master heartbeats by even longer.
int ms_delay = cluster_->tablet_server(i)->uuid() == leader->uuid() ? 2000 : 5000;
ASSERT_OK(cluster_->SetFlag(cluster_->tablet_server(i),
"heartbeat_inject_latency_before_heartbeat_ms",
Substitute("$0", ms_delay)));
// Keep track of the followers.
if (cluster_->tablet_server(i)->uuid() != leader->uuid()) {
followers.push_back(ts_map_[cluster_->tablet_server(i)->uuid()]);
}
}
ASSERT_EQ(2, followers.size());
// Now that heartbeat injection is enabled, evict one follower and trigger
// an election on another follower immediately thereafter.
ASSERT_OK(itest::RemoveServer(leader, tablet_id, followers[0], kTimeout));
// Immediately start an election on the remaining follower. This will cause
// the initial leader's term to rev and it will have to step down. When it
// sends a tablet report to the master with the new configuration excluding
// the removed tablet it will report an unknown leader in the new term.
ASSERT_OK(itest::StartElection(followers[1], tablet_id, kTimeout));
});
// Wait until the master re-adds the evicted replica and it is back up and
// running. If the master hit KUDU-2147, this would fail because the master
// would be unable to add the removed server back, and that replica would be
// missing the config change op that removed it from the config.
ASSERT_OK(WaitForServersToAgree(kTimeout, ts_map_, tablet_id, 1));
}
// Test automatic promotion of a non-voter replica in a 3-4-3 re-replication
// (KUDU-1097) paradigm.
TEST_F(RaftConfigChangeITest, TestNonVoterPromotion) {
const MonoDelta kTimeout = MonoDelta::FromSeconds(30);
// Enable 3-4-3 re-replication.
NO_FATALS(StartCluster({"--raft_prepare_replacement_before_eviction=true"},
{"--raft_prepare_replacement_before_eviction=true",
"--catalog_manager_evict_excess_replicas=false"},
/*num_tablet_servers=*/ 4));
TestWorkload workload(cluster_.get());
workload.Setup();
// The table should initially have replicas on three tservers.
ASSERT_OK(inspect_->WaitForReplicaCount(3));
master::GetTableLocationsResponsePB table_locations;
ASSERT_OK(GetTableLocations(cluster_->master_proxy(), TestWorkload::kDefaultTableName,
kTimeout, VOTER_REPLICA, &table_locations));
ASSERT_EQ(1, table_locations.tablet_locations_size()); // Only 1 tablet.
ASSERT_EQ(3, table_locations.tablet_locations().begin()->replicas_size()); // 3 replicas.
string tablet_id = table_locations.tablet_locations().begin()->tablet_id();
// Find the TS that does not have a replica.
unordered_set<string> initial_replicas;
for (const auto& replica : table_locations.tablet_locations().begin()->replicas()) {
initial_replicas.insert(replica.ts_info().permanent_uuid());
}
TServerDetails* new_replica = nullptr;
for (const auto& entry : ts_map_) {
if (!ContainsKey(initial_replicas, entry.first)) {
new_replica = entry.second;
break;
}
}
ASSERT_NE(nullptr, new_replica);
TServerDetails* leader_replica = nullptr;
ASSERT_EVENTUALLY([&] {
ASSERT_OK(FindTabletLeader(ts_map_, tablet_id, kTimeout, &leader_replica));
ASSERT_NE(new_replica, leader_replica);
// Add the 4th replica as a NON_VOTER with promote=true.
RaftPeerAttrsPB attrs;
attrs.set_promote(true);
ASSERT_OK(AddServer(leader_replica, tablet_id, new_replica,
RaftPeerPB::NON_VOTER, kTimeout, attrs));
});
// Wait for there to be 4 voters in the config.
ASSERT_OK(WaitUntilCommittedConfigNumVotersIs(/*num_voters=*/ 4,
leader_replica,
tablet_id,
kTimeout));
NO_FATALS(cluster_->AssertNoCrashes());
}
// Functional test for the BulkChangeConfig RPC API.
TEST_F(RaftConfigChangeITest, TestBulkChangeConfig) {
const MonoDelta kTimeout = MonoDelta::FromSeconds(30);
const int kNumTabletServers = 4;
const int kNumInitialReplicas = 3;
NO_FATALS(StartCluster({"--enable_leader_failure_detection=false",
"--raft_prepare_replacement_before_eviction=true"},
{"--catalog_manager_wait_for_new_tablets_to_elect_leader=false",
"--raft_prepare_replacement_before_eviction=true"},
kNumTabletServers));
// Create a table.
TestWorkload workload(cluster_.get());
workload.Setup();
ASSERT_OK(inspect_->WaitForReplicaCount(kNumInitialReplicas));
master::GetTableLocationsResponsePB table_locations;
ASSERT_OK(GetTableLocations(cluster_->master_proxy(), TestWorkload::kDefaultTableName,
kTimeout, VOTER_REPLICA, &table_locations));
ASSERT_EQ(1, table_locations.tablet_locations_size()); // Only 1 tablet.
ASSERT_EQ(kNumInitialReplicas, table_locations.tablet_locations().begin()->replicas_size());
string tablet_id = table_locations.tablet_locations().begin()->tablet_id();
unordered_set<int> replica_indexes;
for (int i = 0; i < table_locations.tablet_locations().begin()->replicas_size(); i++) {
const auto& replica = table_locations.tablet_locations().begin()->replicas(i);
int idx = cluster_->tablet_server_index_by_uuid(replica.ts_info().permanent_uuid());
replica_indexes.emplace(idx);
ASSERT_OK(itest::WaitUntilTabletRunning(ts_map_[cluster_->tablet_server(idx)->uuid()],
tablet_id, kTimeout));
}
ASSERT_EQ(kNumInitialReplicas, replica_indexes.size());
const int kLeaderIndex = *replica_indexes.begin();
int new_replica_index = -1;
for (int i = 0; i < kNumTabletServers; i++) {
if (!ContainsKey(replica_indexes, i)) {
new_replica_index = i;
}
}
ASSERT_NE(-1, new_replica_index);
string leader_uuid = cluster_->tablet_server(kLeaderIndex)->uuid();
auto* leader_replica = ts_map_[leader_uuid];
ASSERT_OK(itest::StartElection(leader_replica, tablet_id, kTimeout));
workload.Start();
while (workload.rows_inserted() < 100) {
SleepFor(MonoDelta::FromMilliseconds(10));
}
workload.StopAndJoin();
// We don't want the master interfering with the rest of the test.
cluster_->master()->Shutdown();
struct BulkSpec {
consensus::ChangeConfigType change_type;
int tserver_index;
RaftPeerPB::MemberType member_type;
bool replace;
bool promote;
};
// Now comes the actual config change testing.
auto bulk_change = [&](const vector<BulkSpec>& changes,
boost::optional<int64_t> cas_config_index = boost::none) {
vector<consensus::BulkChangeConfigRequestPB::ConfigChangeItemPB> changes_pb;
for (const auto& chg : changes) {
const auto& ts_uuid = cluster_->tablet_server(chg.tserver_index)->uuid();
auto* replica = ts_map_[ts_uuid];
consensus::BulkChangeConfigRequestPB::ConfigChangeItemPB change_pb;
change_pb.set_type(chg.change_type);
RaftPeerPB* peer = change_pb.mutable_peer();
peer->set_permanent_uuid(ts_uuid);
peer->set_member_type(chg.member_type);
peer->mutable_attrs()->set_replace(chg.replace);
peer->mutable_attrs()->set_promote(chg.promote);
*peer->mutable_last_known_addr() = replica->registration.rpc_addresses(0);
changes_pb.emplace_back(std::move(change_pb));
}
LOG(INFO) << "submitting config change with changes:";
for (const auto& change_pb : changes_pb) {
LOG(INFO) << SecureShortDebugString(change_pb);
}
return BulkChangeConfig(leader_replica, tablet_id, changes_pb,
kTimeout, cas_config_index);
};
// 1) Add a voter. Change config to: V, V, V, V.
ASSERT_OK(bulk_change({ { ADD_PEER, new_replica_index, RaftPeerPB::VOTER,
/*replace=*/ false, /*promote=*/ false } }));
ConsensusStatePB cstate;
ASSERT_OK(WaitUntilNoPendingConfig(leader_replica, tablet_id, kTimeout, &cstate));
ASSERT_EQ(kNumTabletServers, cstate.committed_config().peers_size());
ASSERT_EQ(kNumTabletServers, CountVoters(cstate.committed_config()));
// 2) Simultaneous voter modification and attribute modification.
// Change config to: V, V, N, V+p.
// Note: setting a VOTER's attribute promote=true is meaningless.
int replica1_idx = (kLeaderIndex + 1) % kNumTabletServers;
int replica2_idx = (kLeaderIndex + 2) % kNumTabletServers;
ASSERT_OK(bulk_change({ { MODIFY_PEER, replica1_idx, RaftPeerPB::NON_VOTER,
/*replace=*/ false, /*promote=*/ false },
{ MODIFY_PEER, replica2_idx, RaftPeerPB::VOTER,
/*replace=*/ false, /*promote=*/ true } }));
ASSERT_OK(WaitUntilNoPendingConfig(leader_replica, tablet_id, kTimeout, &cstate));
ASSERT_EQ(kNumTabletServers, cstate.committed_config().peers_size());
ASSERT_EQ(kNumInitialReplicas, CountVoters(cstate.committed_config()));
RaftPeerPB* peer;
ASSERT_OK(GetRaftConfigMember(cstate.mutable_committed_config(),
cluster_->tablet_server(replica2_idx)->uuid(), &peer));
ASSERT_EQ(RaftPeerPB::VOTER, peer->member_type());
ASSERT_TRUE(peer->attrs().promote()) << SecureShortDebugString(*peer);
// 3) Single-attribute modification. Change config to: V, V, N+r, V+p.
// Note: at the time of writing, if the master is disabled this
// configuration will not trigger any actions such as promotion or
// eviction.
ASSERT_OK(bulk_change({ { MODIFY_PEER, replica1_idx, RaftPeerPB::NON_VOTER,
/*replace=*/ true, /*promote=*/ false } }));
ASSERT_OK(WaitUntilNoPendingConfig(leader_replica, tablet_id, kTimeout, &cstate));
ASSERT_EQ(kNumTabletServers, cstate.committed_config().peers_size())
<< SecureShortDebugString(cstate);
ASSERT_EQ(kNumInitialReplicas, CountVoters(cstate.committed_config()))
<< SecureShortDebugString(cstate);
ASSERT_OK(GetRaftConfigMember(cstate.mutable_committed_config(),
cluster_->tablet_server(replica1_idx)->uuid(), &peer));
ASSERT_EQ(RaftPeerPB::NON_VOTER, peer->member_type());
ASSERT_TRUE(peer->attrs().replace()) << SecureShortDebugString(*peer);
// 4) Deny changing config (illegally) from: { V, V, N, V } to: { V, V, V, N }
// because that would be both a promotion and a demotion in one step.
Status s = bulk_change({ { MODIFY_PEER, replica1_idx, RaftPeerPB::VOTER,
/*replace=*/ false, /*promote=*/ false },
{ MODIFY_PEER, replica2_idx, RaftPeerPB::NON_VOTER,
/*replace=*/ false, /*promote=*/ false } });
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
ASSERT_STR_CONTAINS(s.ToString(), "not safe to modify the VOTER status of "
"more than one peer at a time");
// 5) The caller must not be allowed to make the leader a NON_VOTER.
s = bulk_change({ { MODIFY_PEER, kLeaderIndex, RaftPeerPB::NON_VOTER,
/*replace=*/ false, /*promote=*/ false } });
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
ASSERT_STR_MATCHES(s.ToString(), "Cannot modify member type of peer .* because it is the leader");
// 6) The 'cas_config_index' flag must be respected, if set.
int64_t committed_config_opid_index = cstate.committed_config().opid_index();
s = bulk_change({ { MODIFY_PEER, replica1_idx, RaftPeerPB::NON_VOTER,
/*replace=*/ false, /*promote=*/ true } }, committed_config_opid_index + 1);
ASSERT_TRUE(s.IsIllegalState()) << s.ToString();
ASSERT_STR_MATCHES(s.ToString(), "specified cas_config_opid_index of .* but "
"the committed config has opid_index of .*");
// 7) Evict down to 2 voters. We will evict a voter and a non-voter at once.
ASSERT_OK(bulk_change({ { REMOVE_PEER, replica1_idx, RaftPeerPB::UNKNOWN_MEMBER_TYPE,
/*replace=*/ false, /*promote=*/ false },
{ REMOVE_PEER, replica2_idx, RaftPeerPB::UNKNOWN_MEMBER_TYPE,
/*replace=*/ false, /*promote=*/ false } }));
ASSERT_OK(WaitUntilNoPendingConfig(leader_replica, tablet_id, kTimeout, &cstate));
ASSERT_EQ(2, cstate.committed_config().peers_size());
ASSERT_EQ(2, CountVoters(cstate.committed_config()));
// 8) We should reject adding multiple voters at once.
s = bulk_change({ { ADD_PEER, replica1_idx, RaftPeerPB::VOTER,
/*replace=*/ false, /*promote=*/ false },
{ ADD_PEER, replica2_idx, RaftPeerPB::VOTER,
/*replace=*/ false, /*promote=*/ false } });
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
ASSERT_STR_MATCHES(s.ToString(), "not safe to modify the VOTER status of "
"more than one peer at a time");
// 9) Add them back one at a time so we get to full strength (4 voters) again.
auto to_restore = { replica1_idx, replica2_idx };
for (auto r : to_restore) {
ASSERT_OK(bulk_change({ { ADD_PEER, r, RaftPeerPB::VOTER,
/*replace=*/ false, /*promote=*/ false } }));
ASSERT_OK(WaitUntilNoPendingConfig(leader_replica, tablet_id, kTimeout, &cstate));
}
ASSERT_EQ(kNumTabletServers, cstate.committed_config().peers_size());
ASSERT_EQ(kNumTabletServers, CountVoters(cstate.committed_config()));
// 10) We should reject removing multiple voters at once.
s = bulk_change({ { REMOVE_PEER, replica1_idx, RaftPeerPB::UNKNOWN_MEMBER_TYPE,
/*replace=*/ false, /*promote=*/ false },
{ REMOVE_PEER, replica2_idx, RaftPeerPB::UNKNOWN_MEMBER_TYPE,
/*replace=*/ false, /*promote=*/ false } });
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
ASSERT_STR_MATCHES(s.ToString(), "not safe to modify the VOTER status of "
"more than one peer at a time");
// 11) Reject no-ops.
s = bulk_change({ { MODIFY_PEER, replica1_idx, RaftPeerPB::VOTER,
/*replace=*/ false, /*promote=*/ false } });
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
ASSERT_STR_MATCHES(s.ToString(), "must modify a field when calling MODIFY_PEER");
// 12) Reject empty bulk change config operations.
s = bulk_change({ });
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
ASSERT_STR_MATCHES(s.ToString(), "requested configuration change does not "
"actually modify the config");
// 13) Reject multiple changes to the same peer in a single request.
s = bulk_change({ { MODIFY_PEER, replica1_idx, RaftPeerPB::VOTER,
/*replace=*/ true, /*promote=*/ false },
{ MODIFY_PEER, replica1_idx, RaftPeerPB::VOTER,
/*replace=*/ false, /*promote=*/ true } });
ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
ASSERT_STR_MATCHES(s.ToString(), "only one change allowed per peer");
}
} // namespace kudu
| 47.922049 | 100 | 0.690198 | [
"vector"
] |
c18c8c8d4283bf8bfca57109c6b9674fd8676b26 | 10,354 | cpp | C++ | Source/Common/Output_Webvtt.cpp | ElderOrb/dvrescue | 163d24f6af1235ee1e022ec0bd80f9065da1f9b5 | [
"BSD-3-Clause"
] | 49 | 2019-10-22T09:34:46.000Z | 2022-03-06T14:47:36.000Z | Source/Common/Output_Webvtt.cpp | ElderOrb/dvrescue | 163d24f6af1235ee1e022ec0bd80f9065da1f9b5 | [
"BSD-3-Clause"
] | 296 | 2019-10-30T18:14:23.000Z | 2022-03-29T19:29:35.000Z | Source/Common/Output_Webvtt.cpp | ElderOrb/dvrescue | 163d24f6af1235ee1e022ec0bd80f9065da1f9b5 | [
"BSD-3-Clause"
] | 9 | 2019-10-22T09:34:50.000Z | 2021-07-26T14:20:20.000Z | /* Copyright (c) MIPoPS. All Rights Reserved.
*
* Use of this source code is governed by a BSD-3-Clause license that can
* be found in the LICENSE.txt file in the root of the source tree.
*/
//---------------------------------------------------------------------------
#include "Common/Output.h"
#include "Common/Output_Xml.h"
#include "Common/ProcessFile.h"
#include "ZenLib/Ztring.h"
#include <utility>
using namespace ZenLib;
//---------------------------------------------------------------------------
//***************************************************************************
// Info
//***************************************************************************
//---------------------------------------------------------------------------
static const char* const Writer_Name = "WebVTT";
//***************************************************************************
// Helpers
//***************************************************************************
static void Xml_Sta_Element(string& Text, int Sta, size_t n, size_t n_even = size_t(-1))
{
if (!n)
return;
Text += "STA t=";
Text += to_string(Sta);
Text += " n=";
Text += to_string(n);
if (n_even != size_t(-1))
{
Text += " n_even=";
Text += to_string(n_even);
}
Text += ", ";
}
static void Xml_Sta_Elements(string& Text, const size_t* const Stas, const size_t* const Stas_even = nullptr)
{
for (auto Sta = 0; Sta < Sta_Size; Sta++)
{
auto n = Stas[Sta];
auto n_even = Stas_even == nullptr ? size_t(-1) : Stas_even[Sta];
Xml_Sta_Element(Text, Sta, n, n_even);
}
}
static void Xml_Aud_Element(string& Text, size_t o, size_t n, size_t n_even = size_t(-1))
{
if (!n)
return;
Text += "AUD n=";
Text += to_string(n);
if (n_even != size_t(-1))
{
Text += " n_even=";
Text += to_string(n_even);
}
Text += ", ";
}
//***************************************************************************
// Output
//***************************************************************************
//---------------------------------------------------------------------------
return_value Output_Webvtt(ostream& Out, std::vector<file*>& PerFile, ostream* Err = nullptr)
{
string Text;
for (const auto& File : PerFile)
{
if (File->PerFrame.empty() || File->PerChange.empty())
continue; // Show the file only if there is some DV content
// File header and style
Text += "WEBVTT\n"
"Style:\n"
"::cue{\n"
" line - height: 5.33vh;\n"
" font - size: 4.1vh;\n"
" font - family: monospace;\n"
" font - style: normal;\n"
" font - weight: normal;\n"
" background - color: black;\n"
" color: white;\n"
"}\n"
"##\n"
"Kind: captions\n"
"Language : en - US\n";
// By Frame - For each line
auto FrameNumber_Max = File->PerFrame.size() - 1;
string TimeStamp_String;
seconds_to_timestamp(TimeStamp_String, 0, 3, true);
string TimeStamp2_String;
for (const auto& Frame : File->PerFrame)
{
decltype(FrameNumber_Max) FrameNumber = &Frame - &*File->PerFrame.begin();
//if (ShowFrame) // Actually always show frame
{
// Empty line
Text += '\n';
auto TimeStamp2 = Frame->PTS / 1000000000.0;
seconds_to_timestamp(TimeStamp2_String, TimeStamp2, 3, true);
Text += TimeStamp_String;
Text += " --> ";
Text += TimeStamp2_String;
TimeStamp_String = move(TimeStamp2_String);
Text += '\n';
// TimeCode
auto TimeCode_Seconds = (Frame->TimeCode >> 8) & 0x7FFFF; // Value
if (TimeCode_Seconds != 0x7FFFF)
{
auto TimeCode_DropFrame = Frame->TimeCode & 0x00000080 ? true : false;
auto TimeCode_Frames = Frame->TimeCode & 0x3F;
Text += "TC=";
timecode_to_string(Text, TimeCode_Seconds, TimeCode_DropFrame, TimeCode_Frames);
}
if ((Frame->TimeCode >> 31) & 0x1) // Repeat
{
Text += "(R)";
}
if ((Frame->TimeCode >> 30) & 0x1) // Non consecutive
{
Text += "(NC)";
}
// RecDate/RecTime
string RecDateTime_String;
auto RecDateTime_Years = (Frame->RecordedDateTime1 >> 17) & 0x7F;
if (RecDateTime_Years != 0x7F)
{
auto RecDateTime_Months = (Frame->RecordedDateTime2 >> 12) & 0x0F;
auto RecDateTime_Days = (Frame->RecordedDateTime2 >> 8) & 0x1F;
date_to_string(RecDateTime_String, RecDateTime_Years, RecDateTime_Months, RecDateTime_Days);
}
auto RecDateTime_Seconds = Frame->RecordedDateTime1 & 0x1FFFF;
if (RecDateTime_Seconds != 0x1FFFF)
{
if (!RecDateTime_String.empty())
RecDateTime_String += ' ';
auto RecDateTime_DropFrame = Frame->TimeCode & 0x00000080 ? true : false;
auto RecDateTime_Frames = Frame->RecordedDateTime2 & 0x7F;
timecode_to_string(RecDateTime_String, RecDateTime_Seconds, RecDateTime_DropFrame, RecDateTime_Frames);
}
if (!RecDateTime_String.empty())
{
if (TimeCode_Seconds != 0x7FFFF)
Text += ' ';
Text += "RDT=" + RecDateTime_String;
}
if ((Frame->RecordedDateTime1 >> 31) & 0x1) // Repeat
{
Text += "(R)";
}
if ((Frame->RecordedDateTime1 >> 30) & 0x1) // Non consecutive
{
Text += "(NC)";
}
if (Frame->RecordedDateTime1 & (1 << 29)) // Start
{
Text += "(Start)";
}
if (Frame->RecordedDateTime1 & (1 << 28)) // End
{
Text += "(End)";
}
// Arb
auto Arb = Frame->Arb;
if (Arb & (1 << 4)) // Value
{
if (TimeCode_Seconds != 0x7FFFF || !RecDateTime_String.empty())
Text += ' ';
auto Arb_Value = Arb & 0xF;
Text += string("ARB=") + uint4_to_hex4(Arb_Value);
}
if (Arb & (1 << 7)) // Repeat
{
Text += ("(R)");
}
if (Arb & (1 << 6)) // Non consecutive
{
Text += ("(NC)");
}
Text += '\n';
// Errors
if ((Frame->Video_STA_Errors && Frame->Video_STA_Errors_Count == DseqSta_Size) || (Frame->Audio_Data_Errors && Frame->Audio_Data_Errors_Count == Dseq_Size))
{
// Compute
computed_errors ComputedErrors;
ComputedErrors.Compute(*Frame);
// Display
auto Size_Before = Text.size();
Xml_Sta_Elements(Text, ComputedErrors.Video_Sta_TotalPerSta, ComputedErrors.Video_Sta_EvenTotalPerSta);
Xml_Aud_Element(Text, ComputedErrors.Audio_Data_Total, ComputedErrors.Audio_Data_EvenTotal);
auto Size_After = Text.size();
if (Size_After > Size_Before + 51)
{
Text.resize(Size_Before + 48);
Text.append(3, '.');
}
if (Size_After == Size_Before)
Text += ' '; // Actually no error
}
else
Text += ' ';
Text += '\n';
// Animation
auto FrameNumber_Anim_Current = FrameNumber;
if (FrameNumber_Anim_Current < 25)
{
Text.append(25 - FrameNumber_Anim_Current, ' ');
FrameNumber_Anim_Current = 0;
}
else
FrameNumber_Anim_Current -= 25;
for (; FrameNumber_Anim_Current < FrameNumber; FrameNumber_Anim_Current++)
{
auto& Frame_Anim = File->PerFrame[FrameNumber_Anim_Current];
if (Frame_Anim->Video_STA_Errors || Frame_Anim->Audio_Data_Errors)
Text += 'x';
else
Text += '-';
}
Text += '|';
FrameNumber_Anim_Current++;
auto FrameNumber_Anim_Max = FrameNumber_Anim_Current + 25;
decltype(FrameNumber_Max) PaddingCount;
if (FrameNumber_Anim_Max > FrameNumber_Max)
{
PaddingCount = FrameNumber_Anim_Max - FrameNumber_Max;
FrameNumber_Anim_Max = FrameNumber_Max;
}
else
PaddingCount = 0;
for (; FrameNumber_Anim_Current <= FrameNumber_Anim_Max; FrameNumber_Anim_Current++)
{
auto& Frame_Anim = File->PerFrame[FrameNumber_Anim_Current];
if (Frame_Anim->Video_STA_Errors || Frame_Anim->Audio_Data_Errors)
Text += 'x';
else
Text += '-';
}
if (PaddingCount)
Text.append(PaddingCount, ' ');
Text += '\n';
// Write content to output
if (auto ToReturn = WriteIfBig(Out, Text, Err, Writer_Name))
return ToReturn;
}
FrameNumber++;
}
}
// Write content to output
return Write(Out, Text, Err, Writer_Name);
}
| 37.379061 | 172 | 0.435001 | [
"vector"
] |
c19111e2081821fb0fc0b624b1d23971179db7b2 | 6,760 | hpp | C++ | lab_control_center/src/ObstacleSimulation.hpp | Durrrr95/cpm_lab | e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67 | [
"MIT"
] | 9 | 2020-06-24T11:22:15.000Z | 2022-01-13T14:14:13.000Z | lab_control_center/src/ObstacleSimulation.hpp | Durrrr95/cpm_lab | e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67 | [
"MIT"
] | 1 | 2021-05-10T13:48:04.000Z | 2021-05-10T13:48:04.000Z | lab_control_center/src/ObstacleSimulation.hpp | Durrrr95/cpm_lab | e2e6f4ace4ebc01e8ddd87e2f4acf13e6ffdcc67 | [
"MIT"
] | 2 | 2021-11-08T11:59:29.000Z | 2022-03-15T13:50:54.000Z | #pragma once
#include "commonroad_classes/CommonRoadScenario.hpp"
#include "commonroad_classes/ObstacleSimulationData.hpp"
#include <memory>
#include "cpm/Logging.hpp"
#include "cpm/CommandLineReader.hpp"
#include "cpm/init.hpp"
#include "cpm/ParticipantSingleton.hpp"
#include "cpm/SimpleTimer.hpp"
#include "CommonroadObstacle.hpp"
#include "VehicleCommandTrajectory.hpp"
#include "commonroad_classes/DynamicObstacle.hpp"
/**
* \class ObstacleSimulation
* \brief Nested class responsible for simulating a single obstacle
* Objects of this class have access to the writer / other members, e.g. the writer
* \ingroup lcc
*/
class ObstacleSimulation
{
private:
//Trajectory info
//! ID of the obstacle
uint8_t obstacle_id;
//! Trajectory data of the obstacle + obstacle type
ObstacleSimulationData trajectory; //Important: Position should always be set! Translate lanelet refs beforehand!
//! Current position in the trajectory vector (used for simulation)
size_t current_trajectory = 0;
//! As we cannot just send single points, but need to send a trajectory to vehicles: Send up to 10 trajectory points from future time steps
const size_t future_time_steps = 10;
/**
* \brief Interpolation function that delivers state values in between set trajectory points
* \param p1 First trajectory point to interpolate from
* \param p2 Second trajectory point to interpolate to
* \param current_time Current time, required for interpolation
* \param time_step_size Commonorad time step size, to translate from time given in p1, p2 to nanoseconds representation
* \param x_interp Return value for x coordinate, as result of the interpolation
* \param y_interp Return value for y coordinate, as result of the interpolation
* \param yaw_interp Return value for yaw, as result of the interpolation
* \return x,y,yaw values using references as input
*/
void interpolate_between(ObstacleSimulationSegment& p1, ObstacleSimulationSegment& p2, double current_time, double time_step_size, double &x_interp, double &y_interp, double &yaw_interp);
/**
* \brief Interpolation function that delivers trajectory values in between set trajectory points
* \param p1 First trajectory point to interpolate from
* \param p2 Second trajectory point to interpolate to
* \param current_time Current time, required for interpolation
* \param time_step_size Commonorad time step size, to translate from time given in p1, p2 to nanoseconds representation
* \param x_interp Return value for x coordinate, as result of the interpolation
* \param y_interp Return value for y coordinate, as result of the interpolation
* \param vx Return value for x-velocity, as result of the interpolation
* \param vy Return value for y-velocity, as result of the interpolation
* \return x,y,vx,vy values using references as input
*/
void interpolate_between(ObstacleSimulationSegment& p1, ObstacleSimulationSegment& p2, double current_time, double time_step_size, double &x_interp, double &y_interp, double &vx, double& vy);
/**
* \brief Create CommonroadObstacle object from the given information
* \param point Current point of the obstacle (gives shape, time, velocity...)
* \param x x position of the obstacle
* \param y y position of the obstacle
* \param yaw yaw of the obstacle
* \param t_now current time
*/
CommonroadObstacle construct_obstacle(ObstacleSimulationSegment& point, double x, double y, double yaw, uint64_t t_now);
/**
* \brief Create a VehicleCommandTrajectory object to be sent e.g. to a vehicle from a given obstacle trajectory
* \param trajectory_points Obstacle trajectory
* \param t_now Current time
*/
VehicleCommandTrajectory construct_trajectory(std::vector<TrajectoryPoint>& trajectory_points, uint64_t t_now);
/**
* \brief Get the position of the obstacle in a time step given by the segment, which might be inexact - in that case, return the position mean
* \param segment The position and further obstacle information in Commonroad representation
*/
std::pair<double, double> get_position(ObstacleSimulationSegment& segment);
public:
/**
* \brief constructor
* \param _trajectory The trajectory to follow: Important: Translate lanelet ref to position beforehand, so that it must not be done here anymore (a value is expected for every single trajectory point)
* \param _id The ID of the simulated obstacle
*/
ObstacleSimulation(ObstacleSimulationData _trajectory, int _id);
/**
* \brief Get the initial state of the obstacles periodically until the simulation is started
* \param t_now Current time, used for timestamp of msg
*/
CommonroadObstacle get_init_state(uint64_t t_now);
/**
* \brief Send the current obstacle state based on the current time, calculated relative to the start time of the simulation
* \param start_time Time when the simulation was started
* \param t_now Current time
* \param time_step_size Must be known to find out which current point is active
*/
CommonroadObstacle get_state(uint64_t start_time, uint64_t t_now, uint64_t time_step_size);
// /**
// * \brief Get the initial trajectory point of the vehicle
// * \param t_now Current time, used for timestamp of msg
// */
//Does not make sense, as with the current implementation the initial trajectory point would not get sent often enough
//TODO & @Max: We need a "Drive to point" for this, before the simulation starts
// VehicleCommandTrajectory get_init_trajectory(uint64_t t_now);
/**
* \brief This just returns the initial trajectory point multiple times (for a standing vehicle)
* \param t_now Current time, used for timestamp of msg
* \param timer_step_size Time step size of the calling timer, to create enough trajectory messages
*/
VehicleCommandTrajectory get_init_trajectory(uint64_t t_now, uint64_t timer_step_size);
/**
* \brief Get the current trajectory point of the vehicle, which is interpolated
* \param start_time Time when the simulation was started
* \param t_now Current time, used for timestamp of msg, in ns
* \param time_step_size Must be known to find out which current point is active, also in ns
*/
VehicleCommandTrajectory get_trajectory(uint64_t start_time, uint64_t t_now, uint64_t time_step_size);
/**
* \brief Get the ID of the obstacle
*/
uint8_t get_id();
/**
* \brief Reset internal counter variable which was implemented to make the lookup a bit faster
*/
void reset();
}; | 47.605634 | 205 | 0.735503 | [
"object",
"shape",
"vector"
] |
c1a328272c38463446483ce059c34453f49f651f | 2,173 | cc | C++ | gcc-gcc-7_3_0-release/libstdc++-v3/testsuite/20_util/function/1.cc | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 7 | 2020-05-02T17:34:05.000Z | 2021-10-17T10:15:18.000Z | gcc-gcc-7_3_0-release/libstdc++-v3/testsuite/20_util/function/1.cc | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | null | null | null | gcc-gcc-7_3_0-release/libstdc++-v3/testsuite/20_util/function/1.cc | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 2 | 2020-07-27T00:22:36.000Z | 2021-04-01T09:41:02.000Z | // { dg-do run { target c++11 } }
// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu>
//
// Copyright (C) 2005-2017 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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, 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 20.7.15 polymorphic function object wrapper
#include <functional>
#include <testsuite_hooks.h>
using namespace __gnu_test;
// Operations on empty function<> objects
void test01()
{
using std::function;
using std::bad_function_call;
// Default-construction
function<int(float)> f1;
VERIFY( ((bool)f1 == false) );
VERIFY( !f1 );
VERIFY( f1 == 0 );
VERIFY( 0 == f1 );
VERIFY( !(f1 != 0) );
VERIFY( !(0 != f1) );
// Copy-construction
function<int(float)> f2(f1);
VERIFY( !f2 );
// Construct with NULL pointer
function<int(float)> f3(0);
VERIFY( !f3 );
// Assignment
f1 = f2;
VERIFY( !f1);
// Assignment to NULL pointer
f1 = 0;
VERIFY( !f1 );
// Swap
swap(f1, f2);
VERIFY( !f1 );
VERIFY( !f2 );
// Invocation should throw bad_function_call
bool thrown = false;
try
{
f1(3.14159f);
VERIFY( false );
}
catch (bad_function_call)
{
thrown = true;
}
VERIFY( thrown );
// target_type returns typeid(void)
VERIFY( f1.target_type() == typeid(void) );
// target() always returns a NULL pointer
VERIFY( f1.target<int (*)(float)>() == 0);
// Check const version
const function<int(float)>& f1c = f1;
VERIFY( f1c.target<int (*)(float)>() == 0 );
VERIFY( !f1c );
}
int main()
{
test01();
return 0;
}
| 23.365591 | 74 | 0.649793 | [
"object"
] |
c1ba6954ecc5898b5b6919f5d42316d434d30dc3 | 4,544 | cpp | C++ | windows/colorbutton.cpp | chayward/libui | 34d1d0ac48f4695d3170a20e480567d68f587de0 | [
"MIT"
] | 11,062 | 2015-04-17T00:46:13.000Z | 2022-03-31T11:24:06.000Z | windows/colorbutton.cpp | chayward/libui | 34d1d0ac48f4695d3170a20e480567d68f587de0 | [
"MIT"
] | 505 | 2015-09-03T15:15:45.000Z | 2022-03-06T04:55:33.000Z | windows/colorbutton.cpp | chayward/libui | 34d1d0ac48f4695d3170a20e480567d68f587de0 | [
"MIT"
] | 798 | 2015-09-29T11:01:06.000Z | 2022-03-29T10:24:18.000Z | // 16 may 2016
#include "uipriv_windows.hpp"
struct uiColorButton {
uiWindowsControl c;
HWND hwnd;
double r;
double g;
double b;
double a;
void (*onChanged)(uiColorButton *, void *);
void *onChangedData;
};
static void uiColorButtonDestroy(uiControl *c)
{
uiColorButton *b = uiColorButton(c);
uiWindowsUnregisterWM_COMMANDHandler(b->hwnd);
uiWindowsUnregisterWM_NOTIFYHandler(b->hwnd);
uiWindowsEnsureDestroyWindow(b->hwnd);
uiFreeControl(uiControl(b));
}
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
{
uiColorButton *b = uiColorButton(c);
HWND parent;
struct colorDialogRGBA rgba;
if (code != BN_CLICKED)
return FALSE;
parent = parentToplevel(b->hwnd);
rgba.r = b->r;
rgba.g = b->g;
rgba.b = b->b;
rgba.a = b->a;
if (showColorDialog(parent, &rgba)) {
b->r = rgba.r;
b->g = rgba.g;
b->b = rgba.b;
b->a = rgba.a;
invalidateRect(b->hwnd, NULL, TRUE);
(*(b->onChanged))(b, b->onChangedData);
}
*lResult = 0;
return TRUE;
}
static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nmhdr, LRESULT *lResult)
{
uiColorButton *b = uiColorButton(c);
NMCUSTOMDRAW *nm = (NMCUSTOMDRAW *) nmhdr;
RECT client;
ID2D1DCRenderTarget *rt;
D2D1_RECT_F r;
D2D1_COLOR_F color;
D2D1_BRUSH_PROPERTIES bprop;
ID2D1SolidColorBrush *brush;
uiWindowsSizing sizing;
int x, y;
HRESULT hr;
if (nmhdr->code != NM_CUSTOMDRAW)
return FALSE;
// and allow the button to draw its background
if (nm->dwDrawStage != CDDS_PREPAINT)
return FALSE;
uiWindowsEnsureGetClientRect(b->hwnd, &client);
rt = makeHDCRenderTarget(nm->hdc, &client);
rt->BeginDraw();
uiWindowsGetSizing(b->hwnd, &sizing);
x = 3; // should be enough
y = 3;
uiWindowsSizingDlgUnitsToPixels(&sizing, &x, &y);
r.left = client.left + x;
r.top = client.top + y;
r.right = client.right - x;
r.bottom = client.bottom - y;
color.r = b->r;
color.g = b->g;
color.b = b->b;
color.a = b->a;
ZeroMemory(&bprop, sizeof (D2D1_BRUSH_PROPERTIES));
bprop.opacity = 1.0;
bprop.transform._11 = 1;
bprop.transform._22 = 1;
hr = rt->CreateSolidColorBrush(&color, &bprop, &brush);
if (hr != S_OK)
logHRESULT(L"error creating brush for color button", hr);
rt->FillRectangle(&r, brush);
brush->Release();
hr = rt->EndDraw(NULL, NULL);
if (hr != S_OK)
logHRESULT(L"error drawing color on color button", hr);
rt->Release();
// skip default processing (don't draw text)
*lResult = CDRF_SKIPDEFAULT;
return TRUE;
}
uiWindowsControlAllDefaultsExceptDestroy(uiColorButton)
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define buttonHeight 14
// TODO check widths
static void uiColorButtonMinimumSize(uiWindowsControl *c, int *width, int *height)
{
uiColorButton *b = uiColorButton(c);
SIZE size;
uiWindowsSizing sizing;
int y;
// try the comctl32 version 6 way
size.cx = 0; // explicitly ask for ideal size
size.cy = 0;
if (SendMessageW(b->hwnd, BCM_GETIDEALSIZE, 0, (LPARAM) (&size)) != FALSE) {
*width = size.cx;
*height = size.cy;
return;
}
// that didn't work; fall back to using Microsoft's metrics
// Microsoft says to use a fixed width for all buttons; this isn't good enough
// use the text width instead, with some edge padding
*width = uiWindowsWindowTextWidth(b->hwnd) + (2 * GetSystemMetrics(SM_CXEDGE));
y = buttonHeight;
uiWindowsGetSizing(b->hwnd, &sizing);
uiWindowsSizingDlgUnitsToPixels(&sizing, NULL, &y);
*height = y;
}
static void defaultOnChanged(uiColorButton *b, void *data)
{
// do nothing
}
void uiColorButtonColor(uiColorButton *b, double *r, double *g, double *bl, double *a)
{
*r = b->r;
*g = b->g;
*bl = b->b;
*a = b->a;
}
void uiColorButtonSetColor(uiColorButton *b, double r, double g, double bl, double a)
{
b->r = r;
b->g = g;
b->b = bl;
b->a = a;
invalidateRect(b->hwnd, NULL, TRUE);
}
void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data)
{
b->onChanged = f;
b->onChangedData = data;
}
uiColorButton *uiNewColorButton(void)
{
uiColorButton *b;
uiWindowsNewControl(uiColorButton, b);
// initial color is black
b->r = 0.0;
b->g = 0.0;
b->b = 0.0;
b->a = 1.0;
b->hwnd = uiWindowsEnsureCreateControlHWND(0,
L"button", L" ", // TODO; can't use "" TODO
BS_PUSHBUTTON | WS_TABSTOP,
hInstance, NULL,
TRUE);
uiWindowsRegisterWM_COMMANDHandler(b->hwnd, onWM_COMMAND, uiControl(b));
uiWindowsRegisterWM_NOTIFYHandler(b->hwnd, onWM_NOTIFY, uiControl(b));
uiColorButtonOnChanged(b, defaultOnChanged, NULL);
return b;
}
| 23.544041 | 94 | 0.695202 | [
"transform"
] |
c1bfdef44627f4767bdcbd2ef957daff0b7ec462 | 1,968 | cc | C++ | ppapi/examples/font/simple_font.cc | meego-tablet-ux/meego-app-browser | 0f4ef17bd4b399c9c990a2f6ca939099495c2b9c | [
"BSD-3-Clause"
] | 1 | 2015-10-12T09:14:22.000Z | 2015-10-12T09:14:22.000Z | ppapi/examples/font/simple_font.cc | meego-tablet-ux/meego-app-browser | 0f4ef17bd4b399c9c990a2f6ca939099495c2b9c | [
"BSD-3-Clause"
] | null | null | null | ppapi/examples/font/simple_font.cc | meego-tablet-ux/meego-app-browser | 0f4ef17bd4b399c9c990a2f6ca939099495c2b9c | [
"BSD-3-Clause"
] | 1 | 2020-11-04T07:22:28.000Z | 2020-11-04T07:22:28.000Z | // Copyright (c) 2011 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 "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/font_dev.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
static void DummyCompletionCallback(void* /*user_data*/, int32_t /*result*/) {
}
class MyInstance : public pp::Instance {
public:
MyInstance(PP_Instance instance)
: pp::Instance(instance) {
}
virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip) {
if (position.size() == last_size_)
return;
last_size_ = position.size();
pp::ImageData image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL, last_size_, true);
pp::Graphics2D device(this, last_size_, false);
BindGraphics(device);
pp::FontDescription_Dev desc;
desc.set_family(PP_FONTFAMILY_SANSSERIF);
desc.set_size(30);
pp::Font_Dev font(this, desc);
pp::Rect text_clip(position.size()); // Use entire bounds for clip.
font.DrawTextAt(&image,
pp::TextRun_Dev("\xD9\x85\xD8\xB1\xD8\xAD\xD8\xA8\xD8\xA7\xE2\x80\x8E",
true, true),
pp::Point(10, 40), 0xFF008000, clip, false);
font.DrawTextAt(&image, pp::TextRun_Dev("Hello"),
pp::Point(10, 80), 0xFF000080, text_clip, false);
device.PaintImageData(image, pp::Point(0, 0));
device.Flush(pp::CompletionCallback(&DummyCompletionCallback, NULL));
}
private:
pp::Size last_size_;
};
class MyModule : public pp::Module {
public:
virtual pp::Instance* CreateInstance(PP_Instance instance) {
return new MyInstance(instance);
}
};
namespace pp {
// Factory function for your specialization of the Module object.
Module* CreateModule() {
return new MyModule();
}
} // namespace pp
| 28.941176 | 80 | 0.692073 | [
"object"
] |
c1cddc158fd92ddf248aa680b6f921f9b35d5275 | 10,749 | cc | C++ | GeneratorInterface/RivetInterface/plugins/RivetHarvesting.cc | flodamas/cmssw | fff9de2a54e62debab81057f8d6f8c82c2fd3dd6 | [
"Apache-2.0"
] | null | null | null | GeneratorInterface/RivetInterface/plugins/RivetHarvesting.cc | flodamas/cmssw | fff9de2a54e62debab81057f8d6f8c82c2fd3dd6 | [
"Apache-2.0"
] | null | null | null | GeneratorInterface/RivetInterface/plugins/RivetHarvesting.cc | flodamas/cmssw | fff9de2a54e62debab81057f8d6f8c82c2fd3dd6 | [
"Apache-2.0"
] | null | null | null | #include "GeneratorInterface/RivetInterface/interface/RivetHarvesting.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
#include "DataFormats/Common/interface/Handle.h"
#include "Rivet/AnalysisHandler.hh"
#include "Rivet/Analysis.hh"
#include "Rivet/Tools/RivetYODA.hh"
#include "tinyxml.h"
#include <string>
#include <vector>
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace Rivet;
using namespace edm;
using namespace std;
RivetHarvesting::RivetHarvesting(const edm::ParameterSet& pset) :
_analysisHandler(),
_fileNames(pset.getParameter<std::vector<std::string> >("FilesToHarvest")),
_sumOfWeights(pset.getParameter<std::vector<double> >("VSumOfWeights")),
_crossSections(pset.getParameter<std::vector<double> >("VCrossSections")),
_outFileName(pset.getParameter<std::string>("OutputFile")),
_isFirstEvent(true),
_hepmcCollection(pset.getParameter<edm::InputTag>("HepMCCollection")),
_analysisNames(pset.getParameter<std::vector<std::string> >("AnalysisNames"))
{
if (_sumOfWeights.size() != _fileNames.size() ||
_sumOfWeights.size() != _crossSections.size() ||
_fileNames.size() != _crossSections.size()){
throw cms::Exception("RivetHarvesting") << "Mismatch in vector sizes: FilesToHarvest: " << _sumOfWeights.size() << ", VSumOfWeights: " << _sumOfWeights.size() << ", VCrossSections: " << _crossSections.size();
}
//get the analyses
_analysisHandler.addAnalyses(_analysisNames);
//go through the analyses and check those that need the cross section
const std::set< AnaHandle, CmpAnaHandle > & analyses = _analysisHandler.analyses();
std::set< AnaHandle, CmpAnaHandle >::const_iterator ibeg = analyses.begin();
std::set< AnaHandle, CmpAnaHandle >::const_iterator iend = analyses.end();
std::set< AnaHandle, CmpAnaHandle >::const_iterator iana;
double xsection = -1.;
xsection = pset.getParameter<double>("CrossSection");
for (iana = ibeg; iana != iend; ++iana){
if ((*iana)->needsCrossSection())
(*iana)->setCrossSection(xsection);
}
double totalSumOfWeights = _sumOfWeights[0];
_lumis.push_back(_sumOfWeights[0]/_crossSections[0]);
for (unsigned int i = 1; i < _sumOfWeights.size(); ++i){
_lumis.push_back(_sumOfWeights[i]/_crossSections[i]);
totalSumOfWeights += _sumOfWeights[i]*_lumis[0]/_lumis[i];
}
_analysisHandler.setSumOfWeights(totalSumOfWeights);
}
RivetHarvesting::~RivetHarvesting(){
}
void RivetHarvesting::beginJob(){
//set the environment, very ugly but rivet is monolithic when it comes to paths
char * cmsswbase = getenv("CMSSW_BASE");
char * cmsswrelease = getenv("CMSSW_RELEASE_BASE");
std::string rivetref, rivetinfo;
rivetref = "RIVET_REF_PATH=" + string(cmsswbase) + "/src/GeneratorInterface/RivetInterface/data:" + string(cmsswrelease) + "/src/GeneratorInterface/RivetInterface/data";
rivetinfo = "RIVET_INFO_PATH=" + string(cmsswbase) + "/src/GeneratorInterface/RivetInterface/data:" + string(cmsswrelease) + "/src/GeneratorInterface/RivetInterface/data";
char *rivetrefCstr = strdup(rivetref.c_str());
putenv(rivetrefCstr);
free(rivetrefCstr);
char *rivetinfoCstr = strdup(rivetinfo.c_str());
putenv(rivetinfoCstr);
free(rivetinfoCstr);
}
void RivetHarvesting::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup){
return;
}
void RivetHarvesting::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup){
if (!_isFirstEvent)
return;
//initialize the analysis handles, all histograms are booked
//we need at least one event to get the handler initialized
edm::Handle<HepMCProduct> evt;
iEvent.getByLabel(_hepmcCollection, evt);
// get HepMC GenEvent
const HepMC::GenEvent *myGenEvent = evt->GetEvent();
_analysisHandler.init(*myGenEvent);
//gain access to the histogram factory and change the histograms
/*
AIDA::ITree & tree = _analysisHandler.tree();
tree.ls(".", true);
//from Analysis.hh (cls 18Feb2014)
/// List of registered analysis data objects
//const vector<AnalysisObjectPtr>& analysisObjects() const {
//return _analysisobjects;
//}
for (std::vector<std::string>::const_iterator iAna = _analysisNames.begin(); iAna != _analysisNames.end(); ++iAna){
std::vector<std::string> listOfNames = tree.listObjectNames("./"+(*iAna), true);
std::vector<std::string>::const_iterator iNameBeg = listOfNames.begin();
std::vector<std::string>::const_iterator iNameEnd = listOfNames.end();
for (std::vector<std::string>::const_iterator iName = iNameBeg; iName != iNameEnd; ++iName ){
AIDA::IManagedObject * iObj = tree.find(*iName);
if (!iObj){
std::cout << *iName << " not found; SKIPPING!" << std::endl;
continue;
}
std::cout << *iName << " FOUND!" << std::endl;
vector<string>::const_iterator iFile;
vector<string>::const_iterator iFileBeg = _fileNames.begin();
vector<string>::const_iterator iFileEnd = _fileNames.end();
AIDA::IHistogram1D* histo = dynamic_cast<AIDA::IHistogram1D*>(iObj);
AIDA::IProfile1D* prof = dynamic_cast<AIDA::IProfile1D*>(iObj);
string tmpdir = "/tmpdir";
tree.mkdir(tmpdir);
unsigned int ifc = 0;
for (iFile = iFileBeg; iFile != iFileEnd; ++iFile) {
std::cout << "opening file " << *iFile << std::endl;
string name = *iName;
string tostrip = *iAna+'/';
name.replace(name.find(tostrip),tostrip.length(),"");
name.replace(name.find("/"),1,"");
cout << name << endl;
//vector<DPSXYPoint> original = getDPSXYValsErrs(*iFile, *iAna, name);
vector<Point2D> original = getPoint2DValsErrs(*iFile, *iAna, name);
if (histo){
const string tmppath = tmpdir + "/" + name;
cout << tmppath << endl;
IHistogram1D* tmphisto = _analysisHandler.histogramFactory().createCopy(tmppath, *histo);
tmphisto->reset();
for (unsigned int i = 0; i < original.size(); ++i){
tmphisto->fill(original[i].xval, original[i].yval);
}
tmphisto->scale(_lumis[ifc]);
histo->add(*tmphisto);
//iObj = new AIDA::IHistogram1D(*(_analysisHandler.histogramFactory().add(*iName, *histo, *tmphisto)));
tree.rm(tmppath);
//delete tmphisto;
} else if (prof) {
std::cout << *iName << "is a profile, doing nothing " << std::endl;
} else {
std::cout << *iName << " is neither a IHistogram1D neither a IProfile1D. Doing nothing with it." << std::endl;
}
++ifc;
}
cout << iObj << endl;
}
}
tree.ls(".", true);
*/
_isFirstEvent = false;
}
void RivetHarvesting::endRun(const edm::Run& iRun,const edm::EventSetup& iSetup){
return;
}
void RivetHarvesting::endJob(){
_analysisHandler.finalize();
_analysisHandler.writeData(_outFileName);
}
vector<YODA::Point2D> RivetHarvesting::getPoint2DValsErrs(std::string filename, std::string path, std::string name) {
// Open YODA XML file
TiXmlDocument doc(filename);
doc.LoadFile();
if (doc.Error()) {
string err = "Error in " + string(doc.Value());
err += ": " + string(doc.ErrorDesc());
cerr << err << endl;
throw cms::Exception("RivetHarvesting") << "Cannot open " << filename;
}
// Return value, to be populated
vector<Point2D> rtn;
try {
// Walk down tree to get to the <paper> element
const TiXmlNode* yodaN = doc.FirstChild("yoda");
if (!yodaN) throw cms::Exception("RivetHarvesting") << "Couldn't get <yoda> root element";
for (const TiXmlNode* dpsN = yodaN->FirstChild("dataPointSet"); dpsN; dpsN = dpsN->NextSibling()) {
const TiXmlElement* dpsE = dpsN->ToElement();
const string plotname = dpsE->Attribute("name");
const string plotpath = dpsE->Attribute("path");
if (plotpath != path && plotname != name)
continue;
/// Check path to make sure that this is a reference histogram.
//if (plotpath.find("/REF") != 0) {
// cerr << "Skipping non-reference histogram " << plotname << endl;
// continue;
//}
/// @todo Check that "path" matches filename
vector<Point2D> points;
for (const TiXmlNode* dpN = dpsN->FirstChild("dataPoint"); dpN; dpN = dpN->NextSibling()) {
const TiXmlNode* xMeasN = dpN->FirstChild("measurement");
const TiXmlNode* yMeasN = xMeasN->NextSibling();
if (xMeasN && yMeasN) {
const TiXmlElement* xMeasE = xMeasN->ToElement();
const TiXmlElement* yMeasE = yMeasN->ToElement();
const string xcentreStr = xMeasE->Attribute("value");
const string xerrplusStr = xMeasE->Attribute("errorPlus");
const string xerrminusStr = xMeasE->Attribute("errorMinus");
const string ycentreStr = yMeasE->Attribute("value");
const string yerrplusStr = yMeasE->Attribute("errorPlus");
const string yerrminusStr = yMeasE->Attribute("errorMinus");
//if (!centreStr) throw Error("Couldn't get a valid bin centre");
//if (!errplusStr) throw Error("Couldn't get a valid bin err+");
//if (!errminusStr) throw Error("Couldn't get a valid bin err-");
istringstream xssC(xcentreStr);
istringstream xssP(xerrplusStr);
istringstream xssM(xerrminusStr);
istringstream yssC(ycentreStr);
istringstream yssP(yerrplusStr);
istringstream yssM(yerrminusStr);
double xcentre, xerrplus, xerrminus, ycentre, yerrplus, yerrminus;
xssC >> xcentre; xssP >> xerrplus; xssM >> xerrminus;
yssC >> ycentre; yssP >> yerrplus; yssM >> yerrminus;
//cout << " " << centre << " + " << errplus << " - " << errminus << endl;
Point2D pt(xcentre, xerrminus, xerrplus, ycentre, yerrminus, yerrplus);
points.push_back(pt);
} else {
cerr << "Couldn't get <measurement> tag" << endl;
/// @todo Throw an exception here?
}
}
return points;
}
}
// Write out the error
/// @todo Rethrow as a general XML failure.
catch (std::exception& e) {
cerr << e.what() << endl;
throw;
}
throw cms::Exception("RivetHarvesting") << "could not find " << path << "/" << name << " in file " << filename;
return rtn;
}
DEFINE_FWK_MODULE(RivetHarvesting);
| 39.811111 | 214 | 0.649642 | [
"vector"
] |
c1cea6c36e4cae38537e34b4e688f4a109dae719 | 25,764 | hpp | C++ | 3rdParty/boost/1.71.0/boost/beast/core/static_string.hpp | rajeev02101987/arangodb | 817e6c04cb82777d266f3b444494140676da98e2 | [
"Apache-2.0"
] | 12,278 | 2015-01-29T17:11:33.000Z | 2022-03-31T21:12:00.000Z | 3rdParty/boost/1.71.0/boost/beast/core/static_string.hpp | rajeev02101987/arangodb | 817e6c04cb82777d266f3b444494140676da98e2 | [
"Apache-2.0"
] | 9,469 | 2015-01-30T05:33:07.000Z | 2022-03-31T16:17:21.000Z | 3rdParty/boost/1.71.0/boost/beast/core/static_string.hpp | rajeev02101987/arangodb | 817e6c04cb82777d266f3b444494140676da98e2 | [
"Apache-2.0"
] | 892 | 2015-01-29T16:26:19.000Z | 2022-03-20T07:44:30.000Z | //
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// 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)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_STATIC_STRING_HPP
#define BOOST_BEAST_STATIC_STRING_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/string.hpp>
#include <boost/beast/core/detail/static_string.hpp>
#include <algorithm>
#include <cstdint>
#include <initializer_list>
#include <iosfwd>
#include <stdexcept>
#include <string>
#include <type_traits>
namespace boost {
namespace beast {
/** A modifiable string with a fixed-size storage area.
These objects behave like `std::string` except that the storage
is not dynamically allocated but rather fixed in size.
These strings offer performance advantages when a protocol
imposes a natural small upper limit on the size of a value.
@note The stored string is always null-terminated.
@see to_static_string
*/
template<
std::size_t N,
class CharT = char,
class Traits = std::char_traits<CharT>>
class static_string
{
template<std::size_t, class, class>
friend class static_string;
void
term()
{
Traits::assign(s_[n_], 0);
}
std::size_t n_;
CharT s_[N+1];
public:
//
// Member types
//
using traits_type = Traits;
using value_type = typename Traits::char_type;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using pointer = value_type*;
using reference = value_type&;
using const_pointer = value_type const*;
using const_reference = value_type const&;
using iterator = value_type*;
using const_iterator = value_type const*;
using reverse_iterator =
std::reverse_iterator<iterator>;
using const_reverse_iterator =
std::reverse_iterator<const_iterator>;
/// The type of `string_view` returned by the interface
using string_view_type =
basic_string_view<CharT, Traits>;
//
// Constants
//
/// Maximum size of the string excluding the null terminator
static std::size_t constexpr max_size_n = N;
/// A special index
static constexpr size_type npos = size_type(-1);
//
// (constructor)
//
/// Default constructor (empty string).
static_string();
/** Construct with count copies of character `ch`.
The behavior is undefined if `count >= npos`
*/
static_string(size_type count, CharT ch);
/// Construct with a substring (pos, other.size()) of `other`.
template<std::size_t M>
static_string(static_string<M, CharT, Traits> const& other,
size_type pos);
/// Construct with a substring (pos, count) of `other`.
template<std::size_t M>
static_string(static_string<M, CharT, Traits> const& other,
size_type pos, size_type count);
/// Construct with the first `count` characters of `s`, including nulls.
static_string(CharT const* s, size_type count);
/// Construct from a null terminated string.
static_string(CharT const* s);
/// Construct from a range of characters
template<class InputIt>
static_string(InputIt first, InputIt last);
/// Copy constructor.
static_string(static_string const& other);
/// Copy constructor.
template<std::size_t M>
static_string(static_string<M, CharT, Traits> const& other);
/// Construct from an initializer list
static_string(std::initializer_list<CharT> init);
/// Construct from a `string_view`
explicit
static_string(string_view_type sv);
/** Construct from any object convertible to `string_view_type`.
The range (pos, n) is extracted from the value
obtained by converting `t` to `string_view_type`,
and used to construct the string.
*/
#if BOOST_BEAST_DOXYGEN
template<class T>
#else
template<class T, class = typename std::enable_if<
std::is_convertible<T, string_view_type>::value>::type>
#endif
static_string(T const& t, size_type pos, size_type n);
//
// (assignment)
//
/// Copy assignment.
static_string&
operator=(static_string const& str)
{
return assign(str);
}
/// Copy assignment.
template<std::size_t M>
static_string&
operator=(static_string<M, CharT, Traits> const& str)
{
return assign(str);
}
/// Assign from null-terminated string.
static_string&
operator=(CharT const* s);
/// Assign from single character.
static_string&
operator=(CharT ch)
{
return assign_char(ch,
std::integral_constant<bool, (N>0)>{});
}
/// Assign from initializer list.
static_string&
operator=(std::initializer_list<CharT> init)
{
return assign(init);
}
/// Assign from `string_view_type`.
static_string&
operator=(string_view_type sv)
{
return assign(sv);
}
/// Assign `count` copies of `ch`.
static_string&
assign(size_type count, CharT ch);
/// Assign from another `static_string`
static_string&
assign(static_string const& str);
// VFALCO NOTE this could come in two flavors,
// N>M and N<M, and skip the exception
// check when N>M
/// Assign from another `static_string`
template<std::size_t M>
static_string&
assign(static_string<M, CharT, Traits> const& str)
{
return assign(str.data(), str.size());
}
/// Assign `count` characterss starting at `npos` from `other`.
template<std::size_t M>
static_string&
assign(static_string<M, CharT, Traits> const& str,
size_type pos, size_type count = npos);
/// Assign the first `count` characters of `s`, including nulls.
static_string&
assign(CharT const* s, size_type count);
/// Assign a null terminated string.
static_string&
assign(CharT const* s)
{
return assign(s, Traits::length(s));
}
/// Assign from an iterator range of characters.
template<class InputIt>
static_string&
assign(InputIt first, InputIt last);
/// Assign from initializer list.
static_string&
assign(std::initializer_list<CharT> init)
{
return assign(init.begin(), init.end());
}
/// Assign from `string_view_type`.
static_string&
assign(string_view_type str)
{
return assign(str.data(), str.size());
}
/** Assign from any object convertible to `string_view_type`.
The range (pos, n) is extracted from the value
obtained by converting `t` to `string_view_type`,
and used to assign the string.
*/
template<class T>
#if BOOST_BEAST_DOXYGEN
static_string&
#else
typename std::enable_if<std::is_convertible<T,
string_view_type>::value, static_string&>::type
#endif
assign(T const& t,
size_type pos, size_type count = npos);
//
// Element access
//
/// Access specified character with bounds checking.
reference
at(size_type pos);
/// Access specified character with bounds checking.
const_reference
at(size_type pos) const;
/// Access specified character.
reference
operator[](size_type pos)
{
return s_[pos];
}
/// Access specified character.
const_reference
operator[](size_type pos) const
{
return s_[pos];
}
/// Accesses the first character.
CharT&
front()
{
return s_[0];
}
/// Accesses the first character.
CharT const&
front() const
{
return s_[0];
}
/// Accesses the last character.
CharT&
back()
{
return s_[n_-1];
}
/// Accesses the last character.
CharT const&
back() const
{
return s_[n_-1];
}
/// Returns a pointer to the first character of a string.
CharT*
data()
{
return &s_[0];
}
/// Returns a pointer to the first character of a string.
CharT const*
data() const
{
return &s_[0];
}
/// Returns a non-modifiable standard C character array version of the string.
CharT const*
c_str() const
{
return data();
}
/// Convert a static string to a `string_view_type`
operator string_view_type() const
{
return basic_string_view<
CharT, Traits>{data(), size()};
}
//
// Iterators
//
/// Returns an iterator to the beginning.
iterator
begin()
{
return &s_[0];
}
/// Returns an iterator to the beginning.
const_iterator
begin() const
{
return &s_[0];
}
/// Returns an iterator to the beginning.
const_iterator
cbegin() const
{
return &s_[0];
}
/// Returns an iterator to the end.
iterator
end()
{
return &s_[n_];
}
/// Returns an iterator to the end.
const_iterator
end() const
{
return &s_[n_];
}
/// Returns an iterator to the end.
const_iterator
cend() const
{
return &s_[n_];
}
/// Returns a reverse iterator to the beginning.
reverse_iterator
rbegin()
{
return reverse_iterator{end()};
}
/// Returns a reverse iterator to the beginning.
const_reverse_iterator
rbegin() const
{
return const_reverse_iterator{cend()};
}
/// Returns a reverse iterator to the beginning.
const_reverse_iterator
crbegin() const
{
return const_reverse_iterator{cend()};
}
/// Returns a reverse iterator to the end.
reverse_iterator
rend()
{
return reverse_iterator{begin()};
}
/// Returns a reverse iterator to the end.
const_reverse_iterator
rend() const
{
return const_reverse_iterator{cbegin()};
}
/// Returns a reverse iterator to the end.
const_reverse_iterator
crend() const
{
return const_reverse_iterator{cbegin()};
}
//
// Capacity
//
/// Returns `true` if the string is empty.
bool
empty() const
{
return n_ == 0;
}
/// Returns the number of characters, excluding the null terminator.
size_type
size() const
{
return n_;
}
/// Returns the number of characters, excluding the null terminator.
size_type
length() const
{
return size();
}
/// Returns the maximum number of characters that can be stored, excluding the null terminator.
size_type constexpr
max_size() const
{
return N;
}
/** Reserves storage.
This actually just throws an exception if `n > N`,
otherwise does nothing since the storage is fixed.
*/
void
reserve(std::size_t n);
/// Returns the number of characters that can be held in currently allocated storage.
size_type constexpr
capacity() const
{
return max_size();
}
/** Reduces memory usage by freeing unused memory.
This actually does nothing, since the storage is fixed.
*/
void
shrink_to_fit()
{
}
//
// Operations
//
/// Clears the contents.
void
clear();
static_string&
insert(size_type index, size_type count, CharT ch);
static_string&
insert(size_type index, CharT const* s)
{
return insert(index, s, Traits::length(s));
}
static_string&
insert(size_type index, CharT const* s, size_type count);
template<std::size_t M>
static_string&
insert(size_type index,
static_string<M, CharT, Traits> const& str)
{
return insert(index, str.data(), str.size());
}
template<std::size_t M>
static_string&
insert(size_type index,
static_string<M, CharT, Traits> const& str,
size_type index_str, size_type count = npos);
iterator
insert(const_iterator pos, CharT ch)
{
return insert(pos, 1, ch);
}
iterator
insert(const_iterator pos, size_type count, CharT ch);
template<class InputIt>
#if BOOST_BEAST_DOXYGEN
iterator
#else
typename std::enable_if<
detail::is_input_iterator<InputIt>::value,
iterator>::type
#endif
insert(const_iterator pos, InputIt first, InputIt last);
iterator
insert(const_iterator pos, std::initializer_list<CharT> init)
{
return insert(pos, init.begin(), init.end());
}
static_string&
insert(size_type index, string_view_type str)
{
return insert(index, str.data(), str.size());
}
template<class T>
#if BOOST_BEAST_DOXYGEN
static_string&
#else
typename std::enable_if<
std::is_convertible<T const&, string_view_type>::value &&
! std::is_convertible<T const&, CharT const*>::value,
static_string&>::type
#endif
insert(size_type index, T const& t,
size_type index_str, size_type count = npos);
static_string&
erase(size_type index = 0, size_type count = npos);
iterator
erase(const_iterator pos);
iterator
erase(const_iterator first, const_iterator last);
void
push_back(CharT ch);
void
pop_back()
{
Traits::assign(s_[--n_], 0);
}
static_string&
append(size_type count, CharT ch)
{
insert(end(), count, ch);
return *this;
}
template<std::size_t M>
static_string&
append(static_string<M, CharT, Traits> const& str)
{
insert(size(), str);
return *this;
}
template<std::size_t M>
static_string&
append(static_string<M, CharT, Traits> const& str,
size_type pos, size_type count = npos);
static_string&
append(CharT const* s, size_type count)
{
insert(size(), s, count);
return *this;
}
static_string&
append(CharT const* s)
{
insert(size(), s);
return *this;
}
template<class InputIt>
#if BOOST_BEAST_DOXYGEN
static_string&
#else
typename std::enable_if<
detail::is_input_iterator<InputIt>::value,
static_string&>::type
#endif
append(InputIt first, InputIt last)
{
insert(end(), first, last);
return *this;
}
static_string&
append(std::initializer_list<CharT> init)
{
insert(end(), init);
return *this;
}
static_string&
append(string_view_type sv)
{
insert(size(), sv);
return *this;
}
template<class T>
typename std::enable_if<
std::is_convertible<T const&, string_view_type>::value &&
! std::is_convertible<T const&, CharT const*>::value,
static_string&>::type
append(T const& t, size_type pos, size_type count = npos)
{
insert(size(), t, pos, count);
return *this;
}
template<std::size_t M>
static_string&
operator+=(static_string<M, CharT, Traits> const& str)
{
return append(str.data(), str.size());
}
static_string&
operator+=(CharT ch)
{
push_back(ch);
return *this;
}
static_string&
operator+=(CharT const* s)
{
return append(s);
}
static_string&
operator+=(std::initializer_list<CharT> init)
{
return append(init);
}
static_string&
operator+=(string_view_type const& str)
{
return append(str);
}
template<std::size_t M>
int
compare(static_string<M, CharT, Traits> const& str) const
{
return detail::lexicographical_compare<CharT, Traits>(
&s_[0], n_, &str.s_[0], str.n_);
}
template<std::size_t M>
int
compare(size_type pos1, size_type count1,
static_string<M, CharT, Traits> const& str) const
{
return detail::lexicographical_compare<CharT, Traits>(
substr(pos1, count1), str.data(), str.size());
}
template<std::size_t M>
int
compare(size_type pos1, size_type count1,
static_string<M, CharT, Traits> const& str,
size_type pos2, size_type count2 = npos) const
{
return detail::lexicographical_compare(
substr(pos1, count1), str.substr(pos2, count2));
}
int
compare(CharT const* s) const
{
return detail::lexicographical_compare<CharT, Traits>(
&s_[0], n_, s, Traits::length(s));
}
int
compare(size_type pos1, size_type count1,
CharT const* s) const
{
return detail::lexicographical_compare<CharT, Traits>(
substr(pos1, count1), s, Traits::length(s));
}
int
compare(size_type pos1, size_type count1,
CharT const*s, size_type count2) const
{
return detail::lexicographical_compare<CharT, Traits>(
substr(pos1, count1), s, count2);
}
int
compare(string_view_type str) const
{
return detail::lexicographical_compare<CharT, Traits>(
&s_[0], n_, str.data(), str.size());
}
int
compare(size_type pos1, size_type count1,
string_view_type str) const
{
return detail::lexicographical_compare<CharT, Traits>(
substr(pos1, count1), str);
}
template<class T>
#if BOOST_BEAST_DOXYGEN
int
#else
typename std::enable_if<
std::is_convertible<T const&, string_view_type>::value &&
! std::is_convertible<T const&, CharT const*>::value,
int>::type
#endif
compare(size_type pos1, size_type count1,
T const& t, size_type pos2,
size_type count2 = npos) const
{
return compare(pos1, count1,
string_view_type(t).substr(pos2, count2));
}
string_view_type
substr(size_type pos = 0, size_type count = npos) const;
/// Copy a substring (pos, pos+count) to character string pointed to by `dest`.
size_type
copy(CharT* dest, size_type count, size_type pos = 0) const;
/** Changes the number of characters stored.
If the resulting string is larger, the new
characters are uninitialized.
*/
void
resize(std::size_t n);
/** Changes the number of characters stored.
If the resulting string is larger, the new
characters are initialized to the value of `c`.
*/
void
resize(std::size_t n, CharT c);
/// Exchange the contents of this string with another.
void
swap(static_string& str);
/// Exchange the contents of this string with another.
template<std::size_t M>
void
swap(static_string<M, CharT, Traits>& str);
//
// Search
//
private:
static_string&
assign_char(CharT ch, std::true_type);
static_string&
assign_char(CharT ch, std::false_type);
};
//
// Disallowed operations
//
// These operations are explicitly deleted since
// there is no reasonable implementation possible.
template<std::size_t N, std::size_t M, class CharT, class Traits>
void
operator+(
static_string<N, CharT, Traits>const& lhs,
static_string<M, CharT, Traits>const& rhs) = delete;
template<std::size_t N, class CharT, class Traits>
void
operator+(CharT const* lhs,
static_string<N, CharT, Traits>const& rhs) = delete;
template<std::size_t N, class CharT, class Traits>
void
operator+(CharT lhs,
static_string<N, CharT, Traits> const& rhs) = delete;
template<std::size_t N, class CharT, class Traits>
void
operator+(static_string<N, CharT, Traits> const& lhs,
CharT const* rhs) = delete;
template<std::size_t N, class CharT, class Traits>
void
operator+(static_string<N, CharT, Traits> const& lhs,
CharT rhs) = delete;
//
// Non-member functions
//
template<std::size_t N, std::size_t M,
class CharT, class Traits>
bool
operator==(
static_string<N, CharT, Traits> const& lhs,
static_string<M, CharT, Traits> const& rhs)
{
return lhs.compare(rhs) == 0;
}
template<std::size_t N, std::size_t M,
class CharT, class Traits>
bool
operator!=(
static_string<N, CharT, Traits> const& lhs,
static_string<M, CharT, Traits> const& rhs)
{
return lhs.compare(rhs) != 0;
}
template<std::size_t N, std::size_t M,
class CharT, class Traits>
bool
operator<(
static_string<N, CharT, Traits> const& lhs,
static_string<M, CharT, Traits> const& rhs)
{
return lhs.compare(rhs) < 0;
}
template<std::size_t N, std::size_t M,
class CharT, class Traits>
bool
operator<=(
static_string<N, CharT, Traits> const& lhs,
static_string<M, CharT, Traits> const& rhs)
{
return lhs.compare(rhs) <= 0;
}
template<std::size_t N, std::size_t M,
class CharT, class Traits>
bool
operator>(
static_string<N, CharT, Traits> const& lhs,
static_string<M, CharT, Traits> const& rhs)
{
return lhs.compare(rhs) > 0;
}
template<std::size_t N, std::size_t M,
class CharT, class Traits>
bool
operator>=(
static_string<N, CharT, Traits> const& lhs,
static_string<M, CharT, Traits> const& rhs)
{
return lhs.compare(rhs) >= 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator==(
CharT const* lhs,
static_string<N, CharT, Traits> const& rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs, Traits::length(lhs),
rhs.data(), rhs.size()) == 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator==(
static_string<N, CharT, Traits> const& lhs,
CharT const* rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs.data(), lhs.size(),
rhs, Traits::length(rhs)) == 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator!=(
CharT const* lhs,
static_string<N, CharT, Traits> const& rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs, Traits::length(lhs),
rhs.data(), rhs.size()) != 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator!=(
static_string<N, CharT, Traits> const& lhs,
CharT const* rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs.data(), lhs.size(),
rhs, Traits::length(rhs)) != 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator<(
CharT const* lhs,
static_string<N, CharT, Traits> const& rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs, Traits::length(lhs),
rhs.data(), rhs.size()) < 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator<(
static_string<N, CharT, Traits> const& lhs,
CharT const* rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs.data(), lhs.size(),
rhs, Traits::length(rhs)) < 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator<=(
CharT const* lhs,
static_string<N, CharT, Traits> const& rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs, Traits::length(lhs),
rhs.data(), rhs.size()) <= 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator<=(
static_string<N, CharT, Traits> const& lhs,
CharT const* rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs.data(), lhs.size(),
rhs, Traits::length(rhs)) <= 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator>(
CharT const* lhs,
static_string<N, CharT, Traits> const& rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs, Traits::length(lhs),
rhs.data(), rhs.size()) > 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator>(
static_string<N, CharT, Traits> const& lhs,
CharT const* rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs.data(), lhs.size(),
rhs, Traits::length(rhs)) > 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator>=(
CharT const* lhs,
static_string<N, CharT, Traits> const& rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs, Traits::length(lhs),
rhs.data(), rhs.size()) >= 0;
}
template<std::size_t N, class CharT, class Traits>
bool
operator>=(
static_string<N, CharT, Traits> const& lhs,
CharT const* rhs)
{
return detail::lexicographical_compare<CharT, Traits>(
lhs.data(), lhs.size(),
rhs, Traits::length(rhs)) >= 0;
}
//
// swap
//
template<std::size_t N, class CharT, class Traits>
void
swap(
static_string<N, CharT, Traits>& lhs,
static_string<N, CharT, Traits>& rhs)
{
lhs.swap(rhs);
}
template<std::size_t N, std::size_t M,
class CharT, class Traits>
void
swap(
static_string<N, CharT, Traits>& lhs,
static_string<M, CharT, Traits>& rhs)
{
lhs.swap(rhs);
}
//
// Input/Output
//
template<std::size_t N, class CharT, class Traits>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os,
static_string<N, CharT, Traits> const& str)
{
return os << static_cast<
beast::basic_string_view<CharT, Traits>>(str);
}
//
// Numeric conversions
//
/** Returns a static string representing an integer as a decimal.
@param x The signed or unsigned integer to convert.
This must be an integral type.
@return A @ref static_string with an implementation defined
maximum size large enough to hold the longest possible decimal
representation of any integer of the given type.
*/
template<
class Integer
#ifndef BOOST_BEAST_DOXYGEN
,class = typename std::enable_if<
std::is_integral<Integer>::value>::type
#endif
>
static_string<detail::max_digits(sizeof(Integer))>
to_static_string(Integer x);
} // beast
} // boost
#include <boost/beast/core/impl/static_string.hpp>
#endif
| 23.106726 | 99 | 0.630686 | [
"object"
] |
c1cfdc4c2a8ab4b2101a6093579c25c3cd9dc193 | 12,128 | cpp | C++ | src/rendering/graphics/Text.cpp | skylerpfli/libpag | 41adf2754a428569d3513a85908bcc6c1bf3d906 | [
"BSL-1.0",
"CC0-1.0",
"MIT"
] | 1 | 2022-03-10T07:54:48.000Z | 2022-03-10T07:54:48.000Z | src/rendering/graphics/Text.cpp | skylerpfli/libpag | 41adf2754a428569d3513a85908bcc6c1bf3d906 | [
"BSL-1.0",
"CC0-1.0",
"MIT"
] | 5 | 2022-02-03T18:46:02.000Z | 2022-03-03T14:25:59.000Z | src/rendering/graphics/Text.cpp | skylerpfli/libpag | 41adf2754a428569d3513a85908bcc6c1bf3d906 | [
"BSL-1.0",
"CC0-1.0",
"MIT"
] | null | null | null | /////////////////////////////////////////////////////////////////////////////////////////////////
//
// Tencent is pleased to support the open source community by making libpag available.
//
// Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// unless required by applicable law or agreed to in writing, software distributed under the
// license is distributed on an "as is" basis, without warranties or conditions of any kind,
// either express or implied. see the license for the specific language governing permissions
// and limitations under the license.
//
/////////////////////////////////////////////////////////////////////////////////////////////////
#include "Text.h"
#include <unordered_map>
#include "base/utils/TGFXCast.h"
#include "core/PathEffect.h"
#include "gpu/Canvas.h"
#include "pag/file.h"
#include "rendering/caches/RenderCache.h"
namespace pag {
static std::unique_ptr<tgfx::Paint> CreateFillPaint(const MutableGlyph* glyph) {
if (glyph->getStyle() != TextStyle::Fill && glyph->getStyle() != TextStyle::StrokeAndFill) {
return nullptr;
}
auto fillPaint = new tgfx::Paint();
fillPaint->setStyle(tgfx::PaintStyle::Fill);
fillPaint->setColor(ToTGFX(glyph->getFillColor()));
fillPaint->setAlpha(glyph->getAlpha());
return std::unique_ptr<tgfx::Paint>(fillPaint);
}
static std::unique_ptr<tgfx::Paint> CreateStrokePaint(const MutableGlyph* glyph) {
if (glyph->getStyle() != TextStyle::Stroke && glyph->getStyle() != TextStyle::StrokeAndFill) {
return nullptr;
}
auto strokePaint = new tgfx::Paint();
strokePaint->setStyle(tgfx::PaintStyle::Stroke);
strokePaint->setColor(ToTGFX(glyph->getStrokeColor()));
strokePaint->setAlpha(glyph->getAlpha());
strokePaint->setStrokeWidth(glyph->getStrokeWidth());
return std::unique_ptr<tgfx::Paint>(strokePaint);
}
static std::unique_ptr<TextRun> MakeTextRun(const std::vector<MutableGlyph*>& glyphs) {
if (glyphs.empty()) {
return nullptr;
}
auto textRun = new TextRun();
auto firstGlyph = glyphs[0];
// Creates text paints.
textRun->paints[0] = CreateFillPaint(firstGlyph).release();
textRun->paints[1] = CreateStrokePaint(firstGlyph).release();
auto textStyle = firstGlyph->getStyle();
if ((textStyle == TextStyle::StrokeAndFill && !firstGlyph->getStrokeOverFill()) ||
textRun->paints[0] == nullptr) {
std::swap(textRun->paints[0], textRun->paints[1]);
}
// Creates text blob.
auto noTranslateMatrix = firstGlyph->getTotalMatrix();
noTranslateMatrix.setTranslateX(0);
noTranslateMatrix.setTranslateY(0);
textRun->matrix = noTranslateMatrix;
noTranslateMatrix.invert(&noTranslateMatrix);
std::vector<tgfx::GlyphID> glyphIDs = {};
std::vector<tgfx::Point> positions = {};
for (auto& glyph : glyphs) {
glyphIDs.push_back(glyph->getGlyphID());
auto m = glyph->getTotalMatrix();
m.postConcat(noTranslateMatrix);
positions.push_back({m.getTranslateX(), m.getTranslateY()});
}
textRun->textFont = firstGlyph->getFont();
textRun->glyphIDs = glyphIDs;
textRun->positions = positions;
return std::unique_ptr<TextRun>(textRun);
}
std::shared_ptr<Graphic> Text::MakeFrom(const std::vector<GlyphHandle>& glyphs,
std::shared_ptr<TextGlyphs> textGlyphs,
const tgfx::Rect* calculatedBounds) {
if (glyphs.empty()) {
return nullptr;
}
// 用 vector 存 key 的目的是让文字叠加顺序固定。
// 不固定的话叠加区域的像素会不一样,肉眼看不出来,但是测试用例的结果不稳定。
std::vector<tgfx::BytesKey> styleKeys = {};
std::unordered_map<tgfx::BytesKey, std::vector<MutableGlyph*>, tgfx::BytesHasher> styleMap = {};
for (auto& glyph : glyphs) {
if (!glyph->isVisible()) {
continue;
}
tgfx::BytesKey styleKey = {};
glyph->computeStyleKey(&styleKey);
auto size = styleMap.size();
styleMap[styleKey].push_back(glyph.get());
if (styleMap.size() != size) {
styleKeys.push_back(styleKey);
}
}
bool hasAlpha = false;
tgfx::Rect bounds = calculatedBounds ? *calculatedBounds : tgfx::Rect::MakeEmpty();
std::vector<TextRun*> textRuns;
float maxStrokeWidth = 0;
for (auto& key : styleKeys) {
auto& glyphList = styleMap[key];
tgfx::Rect textBounds = tgfx::Rect::MakeEmpty();
for (auto glyph : glyphList) {
auto glyphBounds = glyph->getBounds();
glyph->getMatrix().mapRect(&glyphBounds);
textBounds.join(glyphBounds);
}
if (textBounds.isEmpty()) {
continue;
}
if (calculatedBounds == nullptr) {
bounds.join(textBounds);
}
auto strokeWidth = glyphList[0]->getStrokeWidth();
if (strokeWidth > maxStrokeWidth) {
maxStrokeWidth = strokeWidth;
}
if (glyphList[0]->getAlpha() != 1.0f) {
hasAlpha = true;
}
auto textRun = MakeTextRun(glyphList).release();
textRuns.push_back(textRun);
}
bounds.outset(maxStrokeWidth, maxStrokeWidth);
if (textRuns.empty()) {
return nullptr;
}
return std::shared_ptr<Graphic>(
new Text(glyphs, std::move(textRuns), bounds, hasAlpha, std::move(textGlyphs)));
}
Text::Text(std::vector<GlyphHandle> glyphs, std::vector<TextRun*> textRuns,
const tgfx::Rect& bounds, bool hasAlpha, std::shared_ptr<TextGlyphs> textGlyphs)
: glyphs(std::move(glyphs)), textRuns(std::move(textRuns)), bounds(bounds), hasAlpha(hasAlpha),
textGlyphs(std::move(textGlyphs)) {
}
Text::~Text() {
for (auto& textRun : textRuns) {
delete textRun;
}
}
void Text::measureBounds(tgfx::Rect* rect) const {
*rect = bounds;
}
static void ApplyPaintToPath(const tgfx::Paint& paint, tgfx::Path* path) {
if (paint.getStyle() == tgfx::PaintStyle::Fill || path == nullptr) {
return;
}
auto strokePath = *path;
auto strokeEffect = tgfx::PathEffect::MakeStroke(*paint.getStroke());
if (strokeEffect) {
strokeEffect->applyTo(&strokePath);
}
*path = strokePath;
}
bool Text::hitTest(RenderCache*, float x, float y) {
for (auto& textRun : textRuns) {
auto local = tgfx::Point::Make(x, y);
tgfx::Matrix invertMatrix = {};
if (!textRun->matrix.invert(&invertMatrix)) {
continue;
}
invertMatrix.mapPoints(&local, 1);
tgfx::Path glyphPath = {};
int index = 0;
auto& textFont = textRun->textFont;
for (auto& glyphID : textRun->glyphIDs) {
textFont.getGlyphPath(glyphID, &glyphPath);
auto pos = textRun->positions[index++];
auto localX = local.x - pos.x;
auto localY = local.y - pos.y;
for (auto paint : textRun->paints) {
if (paint == nullptr) {
continue;
}
auto tempPath = glyphPath;
ApplyPaintToPath(*paint, &tempPath);
if (tempPath.contains(localX, localY)) {
return true;
}
}
}
}
return false;
}
bool Text::getPath(tgfx::Path* path) const {
if (hasAlpha || path == nullptr) {
return false;
}
tgfx::Path textPath = {};
for (auto& textRun : textRuns) {
tgfx::Path glyphPath = {};
int index = 0;
auto& textFont = textRun->textFont;
for (auto& glyphID : textRun->glyphIDs) {
tgfx::Path tempPath = {};
if (!textFont.getGlyphPath(glyphID, &tempPath)) {
return false;
}
auto pos = textRun->positions[index];
tempPath.transform(tgfx::Matrix::MakeTrans(pos.x, pos.y));
glyphPath.addPath(tempPath);
index++;
}
glyphPath.transform(textRun->matrix);
tgfx::Path tempPath = glyphPath;
auto firstPaint = textRun->paints[0];
auto secondPaint = textRun->paints[1];
ApplyPaintToPath(*firstPaint, &tempPath);
textPath.addPath(tempPath);
if (secondPaint != nullptr) {
tempPath = glyphPath;
ApplyPaintToPath(*secondPaint, &tempPath);
textPath.addPath(tempPath);
}
}
path->addPath(textPath);
return true;
}
void Text::prepare(RenderCache*) const {
}
static std::vector<TextStyle> GetGlyphStyles(const GlyphHandle& glyph) {
std::vector<TextStyle> styles = {};
if (glyph->getStyle() == TextStyle::Fill) {
styles.push_back(TextStyle::Fill);
} else if (glyph->getStyle() == TextStyle::Stroke) {
styles.push_back(TextStyle::Stroke);
} else {
if (glyph->getStrokeOverFill()) {
styles.push_back(TextStyle::Fill);
styles.push_back(TextStyle::Stroke);
} else {
styles.push_back(TextStyle::Stroke);
styles.push_back(TextStyle::Fill);
}
}
return styles;
}
void Text::draw(tgfx::Canvas* canvas, RenderCache* renderCache) const {
auto textAtlas = renderCache->getTextAtlas(textGlyphs.get());
if (textAtlas != nullptr) {
draw(canvas, textAtlas);
} else {
drawTextRuns(canvas, 0);
drawTextRuns(canvas, 1);
}
}
struct Parameters {
size_t textureIndex = 0;
std::vector<tgfx::Matrix> matrices;
std::vector<tgfx::Rect> rects;
std::vector<tgfx::Color> colors;
};
static void Draw(tgfx::Canvas* canvas, const TextAtlas* atlas, const Parameters& parameters) {
if (parameters.matrices.empty()) {
return;
}
auto atlasTexture = atlas->getAtlasTexture(parameters.textureIndex);
canvas->drawAtlas(atlasTexture.get(), ¶meters.matrices[0], ¶meters.rects[0],
parameters.colors.empty() ? nullptr : ¶meters.colors[0],
parameters.matrices.size());
}
void Text::draw(tgfx::Canvas* canvas, const TextAtlas* textAtlas) const {
Parameters parameters = {};
for (auto& glyph : glyphs) {
if (!glyph->isVisible()) {
continue;
}
auto styles = GetGlyphStyles(glyph);
AtlasLocator locator;
for (auto style : styles) {
tgfx::BytesKey bytesKey;
glyph->computeAtlasKey(&bytesKey, style);
if (!textAtlas->getLocator(bytesKey, &locator)) {
continue;
}
if (parameters.textureIndex != locator.textureIndex) {
Draw(canvas, textAtlas, parameters);
parameters = {};
parameters.textureIndex = locator.textureIndex;
}
float strokeWidth = 0;
Color color = glyph->getFillColor();
if (style == TextStyle::Stroke) {
strokeWidth = glyph->getStrokeWidth();
color = glyph->getStrokeColor();
}
tgfx::Matrix invertedMatrix = tgfx::Matrix::I();
glyph->getExtraMatrix().invert(&invertedMatrix);
auto glyphBounds = glyph->getBounds();
invertedMatrix.mapRect(&glyphBounds);
auto matrix = tgfx::Matrix::I();
matrix.postScale((glyphBounds.width() + strokeWidth * 2) / locator.location.width(),
(glyphBounds.height() + strokeWidth * 2) / locator.location.height());
matrix.postTranslate(glyphBounds.x() - strokeWidth, glyphBounds.y() - strokeWidth);
matrix.postConcat(glyph->getTotalMatrix());
matrix.preTranslate(-0.5f, -0.5f);
parameters.matrices.push_back(matrix);
auto rect = locator.location;
rect.outset(0.5f, 0.5f);
parameters.rects.push_back(rect);
if (glyph->getFont().getTypeface()->hasColor()) {
auto alpha = canvas->getAlpha();
canvas->setAlpha(alpha * glyph->getAlpha());
Draw(canvas, textAtlas, parameters);
parameters = {};
canvas->setAlpha(alpha);
} else {
auto color4f = ToTGFX(color);
color4f.alpha *= glyph->getAlpha();
parameters.colors.push_back(color4f);
}
}
}
Draw(canvas, textAtlas, parameters);
}
void Text::drawTextRuns(tgfx::Canvas* canvas, int paintIndex) const {
auto totalMatrix = canvas->getMatrix();
for (auto& textRun : textRuns) {
auto textPaint = textRun->paints[paintIndex];
if (!textPaint) {
continue;
}
canvas->setMatrix(totalMatrix);
canvas->concat(textRun->matrix);
auto ids = &textRun->glyphIDs[0];
auto positions = &textRun->positions[0];
canvas->drawGlyphs(ids, positions, textRun->glyphIDs.size(), textRun->textFont, *textPaint);
}
canvas->setMatrix(totalMatrix);
}
} // namespace pag
| 34.067416 | 99 | 0.645531 | [
"vector",
"transform"
] |
c1d0efa72208c1ac6ad68b5b219bc3b66def65e3 | 9,554 | cpp | C++ | compiler/main/runpasses.cpp | milisarge/chapel | 5a3bb108f1dde56f19ad0811726809566b9e6613 | [
"ECL-2.0",
"Apache-2.0"
] | 3 | 2020-02-24T13:34:10.000Z | 2020-04-17T07:41:55.000Z | compiler/main/runpasses.cpp | milisarge/chapel | 5a3bb108f1dde56f19ad0811726809566b9e6613 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | compiler/main/runpasses.cpp | milisarge/chapel | 5a3bb108f1dde56f19ad0811726809566b9e6613 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | /*
* Copyright 2004-2020 Hewlett Packard Enterprise Development LP
* Other additional copyright holders may be indicated within.
*
* The entirety of this work is 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 "runpasses.h"
#include "checks.h"
#include "driver.h"
#include "log.h"
#include "parser.h"
#include "passes.h"
#include "PhaseTracker.h"
#include <cstdio>
#include <sys/time.h>
int currentPassNo = 1;
struct PassInfo {
void (*passFunction) (); // The function which implements the pass.
void (*checkFunction)(); // per-pass check function
const char* name;
char logTag;
};
// These entries should be kept in the same order as the entries in passlist.h.
#define LOG_parse 'p'
#define LOG_checkParsed LOG_NEVER
#define LOG_docs LOG_NEVER
#define LOG_readExternC LOG_NO_SHORT
#define LOG_cleanup LOG_NO_SHORT
#define LOG_scopeResolve 's'
#define LOG_flattenClasses LOG_NO_SHORT
#define LOG_normalize 'n'
#define LOG_checkNormalized LOG_NEVER
#define LOG_buildDefaultFunctions LOG_NO_SHORT
#define LOG_createTaskFunctions LOG_NO_SHORT
#define LOG_expandExternArrayCalls LOG_NO_SHORT
#define LOG_resolve 'r'
#define LOG_resolveIntents LOG_NO_SHORT
#define LOG_checkResolved LOG_NEVER
#define LOG_replaceArrayAccessesWithRefTemps LOG_NO_SHORT
#define LOG_flattenFunctions LOG_NO_SHORT
#define LOG_cullOverReferences LOG_NO_SHORT
#define LOG_lowerErrorHandling LOG_NO_SHORT
#define LOG_callDestructors LOG_NO_SHORT
#define LOG_lowerIterators LOG_NO_SHORT
#define LOG_parallel LOG_NO_SHORT
#define LOG_prune LOG_NO_SHORT
#define LOG_bulkCopyRecords LOG_NO_SHORT
#define LOG_removeUnnecessaryAutoCopyCalls LOG_NO_SHORT
#define LOG_inlineFunctions LOG_NO_SHORT
#define LOG_scalarReplace LOG_NO_SHORT
#define LOG_refPropagation LOG_NO_SHORT
#define LOG_copyPropagation LOG_NO_SHORT
#define LOG_deadCodeElimination LOG_NO_SHORT
#define LOG_removeEmptyRecords LOG_NO_SHORT
#define LOG_localizeGlobals LOG_NO_SHORT
#define LOG_loopInvariantCodeMotion LOG_NO_SHORT
#define LOG_prune2 LOG_NO_SHORT
#define LOG_returnStarTuplesByRefArgs LOG_NO_SHORT
#define LOG_insertWideReferences LOG_NO_SHORT
#define LOG_optimizeOnClauses LOG_NO_SHORT
#define LOG_addInitCalls LOG_NO_SHORT
#define LOG_insertLineNumbers LOG_NO_SHORT
#define LOG_denormalize LOG_NO_SHORT
#define LOG_codegen 'c'
#define LOG_makeBinary LOG_NEVER
#define RUN(x) { x, check_ ## x, #x, LOG_ ## x }
//
// passlist: contains passes in the order that they are called
//
static PassInfo sPassList[] = {
// Chapel to AST
RUN(parse), // parse files and create AST
RUN(checkParsed), // checks semantics of parsed AST
RUN(docs), // if fDocs is set, this will generate docs.
// if the executable is named "chpldoc" then
// the application will stop after this phase
// Read in runtime and included C header file types/prototypes
RUN(readExternC),
// create wrapper functions to allow arrays to be passed to extern routines
RUN(expandExternArrayCalls),
// Scope resolution and normalization
RUN(cleanup), // post parsing transformations
RUN(scopeResolve), // resolve symbols by scope
RUN(flattenClasses), // denest nested classes
RUN(normalize), // normalization transformations
RUN(checkNormalized), // check semantics of normalized AST
RUN(buildDefaultFunctions), // build default functions
RUN(createTaskFunctions), // convert 'begin' et al. to functions
// Function resolution and shallow type inference
RUN(resolve), // resolves function calls and types
RUN(resolveIntents), // resolve argument intents
RUN(checkResolved), // checks semantics of resolved AST
RUN(replaceArrayAccessesWithRefTemps), // replace multiple array access calls with reference temps
// Post-resolution cleanup
RUN(flattenFunctions), // denest nested functions
RUN(cullOverReferences), // remove excess references
RUN(lowerErrorHandling), // lower error handling constructs
RUN(callDestructors),
RUN(lowerIterators), // lowers iterators into functions/classes
RUN(parallel), // parallel transforms
RUN(prune), // prune AST of dead functions and types
// Optimizations
RUN(bulkCopyRecords), // replace simple assignments with PRIM_ASSIGN.
RUN(removeUnnecessaryAutoCopyCalls),
RUN(inlineFunctions), // function inlining
RUN(scalarReplace), // scalar replace all tuples
RUN(refPropagation), // reference propagation
RUN(copyPropagation), // copy propagation
RUN(deadCodeElimination), // eliminate dead code
RUN(removeEmptyRecords), // remove empty records
RUN(localizeGlobals), // pull out global constants from loop runs
RUN(loopInvariantCodeMotion), // move loop invariant code above loop runs
RUN(prune2), // prune AST of dead functions and types again
RUN(returnStarTuplesByRefArgs),
RUN(insertWideReferences), // inserts wide references for on clauses
RUN(optimizeOnClauses), // Optimize on clauses
RUN(addInitCalls), // Add module init calls and guards.
// AST to C or LLVM
RUN(insertLineNumbers), // insert line numbers for error messages
RUN(denormalize), // denormalize -- remove local temps
RUN(codegen), // generate C code
RUN(makeBinary) // invoke underlying C compiler
};
static void runPass(PhaseTracker& tracker, size_t passIndex, bool isChpldoc);
void runPasses(PhaseTracker& tracker, bool isChpldoc) {
size_t passListSize = sizeof(sPassList) / sizeof(sPassList[0]);
setupLogfiles();
if (printPasses == true || printPassesFile != 0) {
tracker.ReportPass();
}
for (size_t i = 0; i < passListSize; i++) {
runPass(tracker, i, isChpldoc);
USR_STOP(); // quit if fatal errors were encountered in pass
currentPassNo++;
// Break early if this is a parse-only run
if (fParseOnly == true && strcmp(sPassList[i].name, "checkParsed") == 0) {
break;
}
// Breaks early if the user specified to stop after this pass
if (stopAfterPass[0] != '\0' && strcmp(sPassList[i].name, stopAfterPass) == 0) {
break;
}
// Break early if this is a chpl doc run
if (isChpldoc == true && strcmp(sPassList[i].name, "docs") == 0) {
break;
}
}
destroyAst();
teardownLogfiles();
}
static void runPass(PhaseTracker& tracker, size_t passIndex, bool isChpldoc) {
PassInfo* info = &sPassList[passIndex];
//
// The primary work for this pass
//
tracker.StartPhase(info->name, PhaseTracker::kPrimary);
if (fPrintStatistics[0] != '\0' && passIndex > 0)
printStatistics("clean");
(*(info->passFunction))();
//
// Statistics and logging
//
if (fPrintStatistics[0] != '\0')
printStatistics(info->name);
logWriteLog(info->name, currentPassNo, info->logTag);
considerExitingEndOfPass();
//
// An optional verify pass
//
tracker.StartPhase(info->name, PhaseTracker::kVerify);
(*(info->checkFunction))(); // Run per-pass check function.
//
// Clean up the global pointers to AST. If we're running chpldoc,
// there's no real reason to run this step (and at the time of this
// writing, it didn't work if we hadn't parsed all the 'use'd
// modules.
//
if (!isChpldoc) {
tracker.StartPhase(info->name, PhaseTracker::kCleanAst);
cleanAst();
}
if (printPasses == true || printPassesFile != 0) {
tracker.ReportPass();
}
}
//
// The logging machinery wants to know a "name" for every pass that it can
// match to command line arguments but does not, currently, want to know
// about the pass list itself.
//
// This function provides a vector of the pass list names
//
// This routine also verifies that each non-NUL flag is unique.
void initPassesForLogging() {
size_t passListSize = sizeof(sPassList) / sizeof(sPassList[0]);
for (size_t i = 0; i < passListSize; i++) {
PassInfo* pass = &sPassList[i];
logMakePassAvailable(pass->name, pass->logTag);
}
}
| 36.746154 | 100 | 0.646326 | [
"vector"
] |
c1d9fd322610deb06a8d9071c2b565c253cb4880 | 3,949 | cpp | C++ | Samples/Tests/General/FrictionPerTriangleTest.cpp | sherief/JoltPhysics | aa6910724d54e81a451bef6deb1544bd6b33541f | [
"MIT"
] | null | null | null | Samples/Tests/General/FrictionPerTriangleTest.cpp | sherief/JoltPhysics | aa6910724d54e81a451bef6deb1544bd6b33541f | [
"MIT"
] | null | null | null | Samples/Tests/General/FrictionPerTriangleTest.cpp | sherief/JoltPhysics | aa6910724d54e81a451bef6deb1544bd6b33541f | [
"MIT"
] | null | null | null | // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
// SPDX-License-Identifier: MIT
#include <TestFramework.h>
#include <Tests/General/FrictionPerTriangleTest.h>
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
#include <Jolt/Physics/Collision/Shape/MeshShape.h>
#include <Jolt/Geometry/Triangle.h>
#include <Jolt/Physics/Body/BodyCreationSettings.h>
#include <Layers.h>
JPH_IMPLEMENT_RTTI_VIRTUAL(FrictionPerTriangleTest)
{
JPH_ADD_BASE_CLASS(FrictionPerTriangleTest, Test)
}
void FrictionPerTriangleTest::Initialize()
{
const int num_sections = 5;
const float section_size = 50.0f;
// Create a strip of triangles
TriangleList triangles;
for (int z = 0; z <= num_sections; ++z)
{
float z1 = section_size * (z - 0.5f * num_sections);
float z2 = z1 + section_size;
Float3 v1 = Float3(-100.0f, 0, z1);
Float3 v2 = Float3(100.0f, 0, z1);
Float3 v3 = Float3(-100.0f, 0, z2);
Float3 v4 = Float3(100.0f, 0, z2);
triangles.push_back(Triangle(v1, v3, v4, z));
triangles.push_back(Triangle(v1, v4, v2, z));
}
// Create materials with increasing friction
PhysicsMaterialList materials;
for (uint i = 0; i <= num_sections; ++i)
{
float friction = float(i) / float(num_sections);
materials.push_back(new MyMaterial("Friction " + ConvertToString(friction), Color::sGetDistinctColor(i), friction, 0.0f));
}
// A ramp
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new MeshShapeSettings(triangles, materials), Vec3::sZero(), Quat::sRotation(Vec3::sAxisX(), 0.2f * JPH_PI), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
// A box with friction 1 that slides down the ramp
Ref<BoxShape> box_shape = new BoxShape(Vec3(2.0f, 2.0f, 2.0f), cDefaultConvexRadius, new MyMaterial("Box Friction 1", Color::sYellow, 1.0f, 0.0f));
mBodyInterface->CreateAndAddBody(BodyCreationSettings(box_shape, Vec3(0, 60.0f, -75.0f), Quat::sRotation(Vec3::sAxisX(), 0.2f * JPH_PI), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
}
void FrictionPerTriangleTest::sGetFrictionAndRestitution(const Body &inBody, const SubShapeID &inSubShapeID, float &outFriction, float &outRestitution)
{
// Get the material that corresponds to the sub shape ID
const PhysicsMaterial *material = inBody.GetShape()->GetMaterial(inSubShapeID);
if (material == PhysicsMaterial::sDefault)
{
// This is the default material, use the settings from the body (note all bodies in our test have a material so this should not happen)
outFriction = inBody.GetFriction();
outRestitution = inBody.GetRestitution();
}
else
{
// If it's not the default material we know its a material that we created so we can cast it and get the values
const MyMaterial *my_material = static_cast<const MyMaterial *>(material);
outFriction = my_material->mFriction;
outRestitution = my_material->mRestitution;
}
}
void FrictionPerTriangleTest::sOverrideContactSettings(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings)
{
// Get the custom friction and restitution for both bodies
float friction1, friction2, restitution1, restitution2;
sGetFrictionAndRestitution(inBody1, inManifold.mSubShapeID1, friction1, restitution1);
sGetFrictionAndRestitution(inBody2, inManifold.mSubShapeID2, friction2, restitution2);
// Use the default formulas for combining friction and restitution
ioSettings.mCombinedFriction = sqrt(friction1 * friction2);
ioSettings.mCombinedRestitution = max(restitution1, restitution2);
}
void FrictionPerTriangleTest::OnContactAdded(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings)
{
sOverrideContactSettings(inBody1, inBody2, inManifold, ioSettings);
}
void FrictionPerTriangleTest::OnContactPersisted(const Body &inBody1, const Body &inBody2, const ContactManifold &inManifold, ContactSettings &ioSettings)
{
sOverrideContactSettings(inBody1, inBody2, inManifold, ioSettings);
}
| 41.568421 | 232 | 0.767536 | [
"geometry",
"shape"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.