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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a2e546d7916b3d0cf317c060ba3dc45fe95b5c3d | 2,876 | cpp | C++ | VC2012Samples/Windows 8 samples/C++/Windows 8 app samples/ControlChannelTrigger StreamWebSocket sample (Windows 8)/C++/ControlChannelTriggerWithStreamWebSocket/ScenarioList.xaml.cpp | alonmm/VCSamples | 6aff0b4902f5027164d593540fcaa6601a0407c3 | [
"MIT"
] | 300 | 2019-05-09T05:32:33.000Z | 2022-03-31T20:23:24.000Z | VC2012Samples/Windows 8 samples/C++/Windows 8 app samples/ControlChannelTrigger StreamWebSocket sample (Windows 8)/C++/ControlChannelTriggerWithStreamWebSocket/ScenarioList.xaml.cpp | JaydenChou/VCSamples | 9e1d4475555b76a17a3568369867f1d7b6cc6126 | [
"MIT"
] | 9 | 2016-09-19T18:44:26.000Z | 2018-10-26T10:20:05.000Z | VC2012Samples/Windows 8 samples/C++/Windows 8 app samples/ControlChannelTrigger StreamWebSocket sample (Windows 8)/C++/ControlChannelTriggerWithStreamWebSocket/ScenarioList.xaml.cpp | JaydenChou/VCSamples | 9e1d4475555b76a17a3568369867f1d7b6cc6126 | [
"MIT"
] | 633 | 2019-05-08T07:34:12.000Z | 2022-03-30T04:38:28.000Z | //*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
//
// ScenarioList.xaml.cpp
// Implementation of the ScenarioList class
//
#include "pch.h"
#include "ScenarioList.xaml.h"
using namespace ControlChannelTrigger;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::Foundation;
using namespace CppSamplesUtils;
ScenarioList::ScenarioList()
{
InitializeComponent();
rootPage=nullptr;
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
void ScenarioList::OnNavigatedTo(NavigationEventArgs^ e)
{
// A pointer back to the main page. This is needed if you want to call methods in MainPage such
// as NotifyUser()
rootPage= dynamic_cast<MainPage^>(e->Parameter);
Scenarios->SelectionChanged += ref new SelectionChangedEventHandler(this, &ScenarioList::Scenarios_SelectionChanged);
ListBoxItem^ startingScenario = nullptr;
auto ps = SuspensionManager::SessionState();
if (ps->HasKey("SelectedScenario"))
{
PropertyValue^ pv;
String^ item = dynamic_cast<String^>(ps->Lookup("SelectedScenario"));
startingScenario = dynamic_cast<ListBoxItem^>(this->FindName(item));
}
Scenarios->SelectedItem = startingScenario != nullptr ? startingScenario : Scenario1;
}
void ScenarioList::Scenarios_SelectionChanged(Object^ sender, SelectionChangedEventArgs^ e)
{
if(Scenarios->SelectedItem != nullptr)
{
rootPage->NotifyUser("", NotifyType::StatusMessage);
ListBoxItem^ selectedListBoxItem = dynamic_cast<ListBoxItem^>(Scenarios->SelectedItem);
SuspensionManager::SessionState()->Insert("SelectedScenario", selectedListBoxItem->Name);
if (rootPage->InputFrame != nullptr && rootPage->OutputFrame != nullptr)
{
//Load the input and output pages for the current scenario into their respective frames
TypeName inputPage = { "ControlChannelTrigger" + "." + "ScenarioInput" + ((Scenarios->SelectedIndex + 1).ToString()), TypeKind::Custom };
TypeName outputPage = { "ControlChannelTrigger" + "." + "ScenarioOutput" + ((Scenarios->SelectedIndex + 1).ToString()), TypeKind::Custom };
rootPage->DoNavigation(inputPage, rootPage->InputFrame, outputPage, rootPage->OutputFrame);
}
}
}
| 37.842105 | 151 | 0.682197 | [
"object"
] |
a2ea07918d522b724be24a1d7ead3b7cd9b0e11d | 9,962 | cpp | C++ | minimal.cpp | eruffaldi/minOgreAR | e79ebfb0dd8983e9598b0daf7362135d0b65d46e | [
"Apache-2.0"
] | null | null | null | minimal.cpp | eruffaldi/minOgreAR | e79ebfb0dd8983e9598b0daf7362135d0b65d46e | [
"Apache-2.0"
] | null | null | null | minimal.cpp | eruffaldi/minOgreAR | e79ebfb0dd8983e9598b0daf7362135d0b65d46e | [
"Apache-2.0"
] | 1 | 2020-12-14T11:33:10.000Z | 2020-12-14T11:33:10.000Z | /**
Minimal AR, see also VISP vpAROgre
1) pick named monitor fullscreen
2) background image
3) camera from intrinsics
4) mesh rendered flat
*/
#include <Ogre.h>
#include <Eigen/Dense>
#include "capture.hpp"
using namespace Ogre;
void setVisionCameraProjection(Ogre::Camera *camera, int w, int h, float n, float f, float px, float py, float u0,
float v0) {
Ogre::Real f_m_n, f_p_n;
f_m_n = (Ogre::Real) (f - n);
f_p_n = (Ogre::Real) (f + n);
Ogre::Matrix4 Projection
= Ogre::Matrix4((Ogre::Real) (2.0 * px / w), 0, (Ogre::Real) (1.0 - 2.0 * (u0 / w)), 0,
0, (Ogre::Real) (2.0 * py / h), (Ogre::Real) (-1.0 + 2.0 * (v0 / h)), 0,
0, 0, (Ogre::Real) (-1.0 * f_p_n / f_m_n), (Ogre::Real) (-2.0 * f * n / f_m_n),
0, 0, -1.0, 0);
camera->setCustomProjectionMatrix(true, Projection);
}
void setVisionCameraProjection(Ogre::Camera *camera, Eigen::Vector2i size, Eigen::Vector2f nearfar, Eigen::Matrix3f K) {
setVisionCameraProjection(camera, size.x(), size.y(), nearfar.x(), nearfar.y(),
K(0, 0), K(1, 1), K(0, 2), K(1, 2));
}
void setCameraPose(Ogre::Camera *camera, Eigen::Matrix4f cMw) {
Ogre::Matrix4 ModelView
= Ogre::Matrix4((Ogre::Real) cMw(0, 0), (Ogre::Real) cMw(0, 1), (Ogre::Real) cMw(0, 2),
(Ogre::Real) cMw(0, 3),
(Ogre::Real) -cMw(1, 0), (Ogre::Real) -cMw(1, 1), (Ogre::Real) -cMw(1, 2),
(Ogre::Real) -cMw(1, 3),
(Ogre::Real) -cMw(2, 0), (Ogre::Real) -cMw(2, 1), (Ogre::Real) -cMw(2, 2),
(Ogre::Real) -cMw(2, 3),
(Ogre::Real) 0, (Ogre::Real) 0, (Ogre::Real) 0, (Ogre::Real) 1);
camera->setCustomViewMatrix(true, ModelView);
}
class ImageBackground {
public:
void setup(SceneManager *scene, int w, int h);
// get pixel buffer / update
protected:
int mBackgroundWidth, mBackgroundHeight;
Ogre::Rectangle2D *mBackground;
Ogre::SceneNode *mBackgroundNode;
Ogre::HardwarePixelBufferSharedPtr mPixelBuffer; /** Pointer to the pixel buffer */
};
void ImageBackground::setup(SceneManager *sceneMgr, int w, int h) {
mBackgroundWidth = w;
mBackgroundHeight = h;
// Create a rectangle to show the incoming images from the camera
mBackground = new Ogre::Rectangle2D(true); // true = textured
mBackground->setCorners(-1.0, 1.0, 1.0, -1.0); // Spread all over the window
mBackground->setBoundingBox(Ogre::AxisAlignedBox(-100000.0 * Ogre::Vector3::UNIT_SCALE,
100000.0 * Ogre::Vector3::UNIT_SCALE)); // To be shown everywhere
Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_NONE);
Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(1);
Ogre::TextureManager::getSingleton().createManual("BackgroundTexture",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
mBackgroundWidth,//width
mBackgroundHeight,//height
0, // num of mip maps
//Ogre::PF_BYTE_RGBA,
Ogre::PF_BYTE_BGRA,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
Ogre::TexturePtr dynTexPtr = Ogre::TextureManager::getSingleton().getByName("BackgroundTexture");
mPixelBuffer = dynTexPtr->getBuffer();
Ogre::MaterialPtr Backgroundmaterial = Ogre::MaterialManager::getSingleton().create("BackgroundMaterial",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Technique *Backgroundtechnique = Backgroundmaterial->createTechnique();
Backgroundtechnique->createPass();
Backgroundmaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false);
Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); // Background
Backgroundmaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); // Background
Backgroundmaterial->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTexture");
mBackground->setMaterial("BackgroundMaterial"); // Attach the material to the rectangle
mBackground->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); // To be rendered in Background
// Add the background to the Scene Graph so it will be rendered
mBackgroundNode = sceneMgr->getRootSceneNode()->createChildSceneNode("BackgoundNode");
mBackgroundNode->attachObject(mBackground);
}
class MinOgre {
public:
MinOgre();
~MinOgre();
void setCameraPose();
void setBackground();
void addMesh(std::string filename, std::string meshname);
SceneManager *sceneMgr;
Ogre::Root *root;
Camera *camera;
protected:
void initRoot();
void createCamera();
RenderWindow *window;
//OutputCapture capture;
ImageBackground background;
};
MinOgre::~MinOgre() {
delete root;
}
void MinOgre::initRoot() {
root = new Root("plugins.cfg"); // pluginsOGRE_BUILD_SUFFIX.cfg, "ogre.cfg", "Ogre.log");
bool canInit = true;
bool mshowConfigDialog = false;
if (mshowConfigDialog) {
root->restoreConfig();
if (!root->showConfigDialog())
canInit = false;
} else {
if (!root->restoreConfig())
canInit = false;
}
if (!root->isInitialised()) {
if (!canInit) { //We set the default renderer system
const Ogre::RenderSystemList &lRenderSystemList = root->getAvailableRenderers();
if (lRenderSystemList.size() == 0) {
std::cout << "No renderers\n;";
throw "ConfigDialog aborted"; // Exit the application on cancel
}
Ogre::RenderSystem *lRenderSystem = lRenderSystemList.at(0);
std::cout << "Using " << lRenderSystem->getName() << " as renderer." << std::endl;
root->setRenderSystem(lRenderSystem);
}
root->initialise(false);
}
std::cerr << "initialise done\n";
}
MinOgre::MinOgre() {
// MULTIPLE: Ogre::Root::getSingletonPtr()
initRoot();
ResourceGroupManager &resources = ResourceGroupManager::getSingleton();
resources.addResourceLocation(".", "FileSystem");
resources.initialiseAllResourceGroups();
std::cerr << "resource done\n";
sceneMgr = root->createSceneManager(ST_GENERIC);
window = root->initialise(true, "Simple Ogre App");
std::cerr << "window done\n";
createCamera();
std::cerr << "camera done\n";
// Ogre::Viewport* viewPort = window->addViewport(camera);
Ogre::Viewport *viewPort = camera->getViewport();
viewPort->setClearEveryFrame(true);
std::cerr << "viewport done\n";
std::cerr << "creating scene\n";
sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(camera);
std::cerr << "creating camera\n";
std::cerr << "creating background\n";
// background.setup(sceneMgr,128,128);
sceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
/*
mRoot->addFrameListener(this);
// Register as a Window listener
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
mInputManager = OIS::InputManager::createInputSystem( pl );
//Create all devices
// Here we only consider the keyboard input
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, bufferedKeys ));
if ( !bufferedKeys ) mKeyboard->setEventCallback ( this);
Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this);
#ifdef VISP_HAVE_OIS
// Get keyboard input
mKeyboard->capture();
if(mKeyboard->isKeyDown(OIS::KC_ESCAPE))
return false;
#endif
*/
std::cerr << "attach camera to scene\n";
}
void MinOgre::addMesh(std::string filename, std::string meshname) {
Ogre::Entity *newEntity = sceneMgr->createEntity(meshname, filename);
Ogre::SceneNode *newNode = sceneMgr->getRootSceneNode()->createChildSceneNode(meshname);
newNode->attachObject(newEntity);
}
void MinOgre::setCameraPose() {
}
void MinOgre::setBackground() {
//mPixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // Lock the buffer
//const Ogre::PixelBox& pixelBox = mPixelBuffer->getCurrentLock();
// TODO copy to buffer
//mPixelBuffer->unlock();
}
void MinOgre::createCamera() {
Camera *cam = sceneMgr->createCamera("SimpleCamera");
cam->setPosition(Vector3(0.0f, 0.0f, 500.0f));
cam->lookAt(Vector3(0.0f, 0.0f, 0.0f));
cam->setNearClipDistance(5.0f);
cam->setFarClipDistance(5000.0f);
Viewport *v = window->addViewport(cam);
v->setBackgroundColour(ColourValue(0.5, 0.5, 0.5));
cam->setAspectRatio(Real(v->getActualWidth()) / v->getActualHeight());
camera = cam;
}
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT){
#else
int main(int argc, char **argv) {
#endif
MinOgre mo;
mo.addMesh("rviz_cube.mesh", "test");
mo.camera->setPosition(0, 10, 50);
Ogre::Light *light = mo.sceneMgr->createLight();
light->setDiffuseColour(1, 1, 1); // scaled RGB values
light->setSpecularColour(1, 1, 1); // scaled RGB values
light->setPosition(-5, -5, 10);
light->setType(Ogre::Light::LT_POINT);
std::cout << "starting loop\n";
while (true) {
WindowEventUtilities::messagePump();
mo.root->renderOneFrame();
}
std::cout << "ending loop\n";
return 0;
} | 36.094203 | 145 | 0.617246 | [
"mesh"
] |
a2f895b9141f47147202662697046b29eccbfe7f | 1,123 | cpp | C++ | leetcode/840. Magic Squares In Grid/s1.cpp | zhuohuwu0603/leetcode_cpp_lzl124631x | 6a579328810ef4651de00fde0505934d3028d9c7 | [
"Fair"
] | 787 | 2017-05-12T05:19:57.000Z | 2022-03-30T12:19:52.000Z | leetcode/840. Magic Squares In Grid/s1.cpp | aerlokesh494/LeetCode | 0f2cbb28d5a9825b51a8d3b3a0ae0c30d7ff155f | [
"Fair"
] | 8 | 2020-03-16T05:55:38.000Z | 2022-03-09T17:19:17.000Z | leetcode/840. Magic Squares In Grid/s1.cpp | aerlokesh494/LeetCode | 0f2cbb28d5a9825b51a8d3b3a0ae0c30d7ff155f | [
"Fair"
] | 247 | 2017-04-30T15:07:50.000Z | 2022-03-30T09:58:57.000Z | // OJ: https://leetcode.com/problems/magic-squares-in-grid/
// Author: github.com/lzl124631x
// Time: O(MN)
// Space: O(1)
class Solution {
private:
bool isMagic(vector<vector<int>>& grid, int x, int y) {
if (grid[x + 1][y + 1] != 5) return false;
int cnt[9] = {0};
for (int i = 0; i < 3; ++i) {
int xSum = 0, ySum = 0;
for (int j = 0; j < 3; ++j) {
int v = grid[x + i][y + j];
if (v < 1 || v > 9 || cnt[v - 1]) return false;
cnt[v - 1]++;
xSum += v;
ySum += grid[x + j][y + i];
}
if (xSum != 15 || ySum != 15) return false;
}
return (grid[x][y] + grid[x + 2][y + 2] == 10)
&& (grid[x][y + 2] + grid[x + 2][y] == 10);
}
public:
int numMagicSquaresInside(vector<vector<int>>& grid) {
int M = grid.size(), N = grid[0].size(), cnt = 0;
for (int i = 0; i <= M - 3; ++i) {
for (int j = 0; j <= N - 3; ++j) {
if (isMagic(grid, i, j)) ++cnt;
}
}
return cnt;
}
}; | 33.029412 | 63 | 0.401603 | [
"vector"
] |
a2f95c92885c5cf4d81d0ed2025c3f41625cfce1 | 24,986 | cpp | C++ | scheduler.cpp | MUST-Quick-Fry/Process-Scheduler | da4de596fd05f4d75eb3e7067807f6971d296478 | [
"MIT"
] | 2 | 2021-09-04T03:39:22.000Z | 2021-09-08T03:29:00.000Z | Process-Scheduler/Scheduler/scheduler.cpp | MUST-Quick-Fry/Process-Scheduler | da4de596fd05f4d75eb3e7067807f6971d296478 | [
"MIT"
] | null | null | null | Process-Scheduler/Scheduler/scheduler.cpp | MUST-Quick-Fry/Process-Scheduler | da4de596fd05f4d75eb3e7067807f6971d296478 | [
"MIT"
] | 1 | 2021-09-03T02:43:35.000Z | 2021-09-03T02:43:35.000Z | #include "project.h"
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace Project;
using namespace std;
void Scheduler::set_total_time(int now)
{
this->total_time = now;
}
int Scheduler::get_total_time() const
{
return this->total_time;
}
int Scheduler::get_job_num() const
{
return this->job_num;
}
Scheduler::Scheduler(char *f, char *p) : policyInfo(p)
{
string tmp = Utils::readFile(f);
normalizeCheck(tmp);
splitToken(tmp);
job_num = job_queue.size();
choosePolicy();
//sort(job_queue.begin(),job_queue.end());
//schedulerDrive();
}
void Scheduler::find_dur_time(Job j, int& t){
long tps=sysconf(_SC_CLK_TCK);
tms start, end;
clock_t s, e;
s = times(&start);
int pID = fork();
if(pID == 0){ Monitor* monitor = new Monitor(j); exit(0);}
else{
waitpid(pID, 0, 0);
e = times(&end);
double realtime = (double)(e-s)/tps;
if(round(realtime)==0){t = 1;}
else{t= round(realtime);}
}
}
void Scheduler::normalizeCheck(string cont)
{
int arg_num = 0;
for (int i = 0; i < cont.length(); ++i)
{
if (cont[i] == '\n')
{
if (cont[i - 1] == '\n')
{
if (cont[i - 2] == '\t')
{
throw invalid_argument("Argument Error: Empty argument!");
}
continue;
}
if (cont[i - 1] == '\t')
{
throw invalid_argument("Argument Error: Empty argument!");
}
arg_num++;
if (arg_num > 3)
{
throw invalid_argument("Argument Error: Job description file has redundant arguments!");
}
if (arg_num < 3)
{
throw invalid_argument("Argument Error: Job description file has less arguments!");
}
arg_num = 0;
}
if (cont[i] == '\t')
{
arg_num++;
}
}
}
void Scheduler::splitToken(string str)
{
int cnt = 0;
char *strBuf = const_cast<char *>(str.c_str());
char *token = strtok(strBuf, "\t\n");
Job job = Job();
while (token != NULL)
{
cnt++;
if (cnt % 3 == 1)
{
job.ID = 1 + cnt/3; // assign job id
Utils::arg_check(token);
string buf(token);
job.set_arr_time(stoi(buf));
}
else if (cnt % 3 == 2)
{
string buf(token);
job.set_cmd(buf);
}
else
{
Utils::arg_check(token);
string buf(token);
job.set_dur_time(stoi(buf));
job_queue.push_back(job);
}
token = strtok(NULL, "\t\n");
}
}
void Scheduler::choosePolicy()
{
auto cho = policyMap.find(policyInfo);
if (cho == policyMap.end())
{
throw invalid_argument("Invalid policy!");
exit(-1);
}
switch (cho->second)
{
case Policy::FIFO:
/* FIFO function interface*/
driveFIFO();
break;
case Policy::NONPREEMSJF:
/*non-preetive SJF function interface*/
driveSJF1();
break;
case Policy::PREESJF:
/*preetive SJF function interface*/
driveSJF2();
break;
case Policy::RR:
/*RR function interface*/
driveRR();
break;
default:
throw invalid_argument("Invalid policy!");
break;
}
//cout << *this;
}
void Scheduler::driveFIFO()
{
// create a scheduler
vector<Job> pq_arr;
int len = get_job_num();
int time = 0;
// clear -1
for(int i = 0; i < len; ++i){
if(job_queue[i].get_dur_time()==-1){
int t = 0;
find_dur_time(job_queue[i], t);
//cout << t << endl;
job_queue[i].set_dur_time(t);
}
pq_arr.emplace_back(job_queue[i]);
}
sort(pq_arr.begin(), pq_arr.end());
time = pq_arr[0].get_arr_time();
for(int i = 0; i < len; ++i){
auto it = pq_arr[i];
time += it.get_dur_time();
scheduler.emplace(it);
}
// copy
set_total_time(time);
real_job_queue = scheduler;
cout << endl;
cout << endl;
cout << endl;
// execute
cout << "==================================================="<< endl;
cout << "Now start the Scheduler !!!"<< endl;
cout << "==================================================="<< endl;
int realtime = 0;
int pid = 1;
while(!stop_flag){
cout << "now time: " << realtime << " s" << endl;
while(!scheduler.empty() && realtime >= scheduler.front().get_arr_time()){
auto it = scheduler.front();
scheduler.pop();
if(monitor_map[it.ID]==0){
pid = fork();
if(pid == 0){
Monitor* monitor = new Monitor(it);
cout << "Terminate the Parent Process: " << getpid() <<endl;
//kill(getpid(), SIGKILL);
exit(0);
}
else{
monitor_map[it.ID]=pid;
}
}
if(pid !=0){
if(allow_preem){
allow_preem = false;
this_job = it;
signal(SIGALRM, signal_nonpreem);
alarm(it.get_dur_time());
}
else{
wait_queue.emplace(it);
kill(monitor_map[it.ID], SIGTSTP);
std::cout<<"Child Process Suspend" << std::endl;
}
}
}
if(pid!=0){
sleep(1);
realtime++;
}
}
if(pid !=0){
cout << "now time: " << realtime << " s" << endl;
sleep(2);
cout << endl;
cout << endl;
// draw Gantt diagram
Display(real_job_queue);
}
}
void Scheduler::driveSJF1()
{
// create a scheduler
priority_queue<Job,vector<Job>,greater<Job> > wait_q;
queue<Job> pq_arr;
int len = get_job_num();
int time = 0;
// clear -1
for(int i = 0; i < len; ++i){
if(job_queue[i].get_dur_time()==-1){
int t = 0;
find_dur_time(job_queue[i], t);
//cout << t << endl;
job_queue[i].set_dur_time(t);
}
}
sort(job_queue.begin(), job_queue.end(), [](const Job &a, const Job &b)->bool
{ if(a.get_arr_time() == b.get_arr_time()){return a.get_dur_time() < b.get_dur_time();}
else{return a.get_arr_time() < b.get_arr_time();}
});
for(int i = 0; i < len; ++i){
pq_arr.emplace(job_queue[i]);
}
time = pq_arr.front().get_arr_time();
while(true){
if(!wait_q.empty()){
auto it = wait_q.top();
wait_q.pop();
time += it.get_dur_time();
scheduler.emplace(it);
}
if(!pq_arr.empty()){
auto it = pq_arr.front();
pq_arr.pop();
time += it.get_dur_time();
scheduler.emplace(it);
while(!pq_arr.empty() && pq_arr.front().get_arr_time()<=time){
wait_q.emplace(pq_arr.front());
pq_arr.pop();
}
}
if(pq_arr.empty() && wait_q.empty()){break;}
}
// copy
set_total_time(time);
real_job_queue = scheduler;
cout << endl;
cout << endl;
cout << endl;
// execute
cout << "==================================================="<< endl;
cout << "Now start the Scheduler !!!"<< endl;
cout << "==================================================="<< endl;
int realtime = 0;
int pid = 1;
while(!stop_flag){
cout << "now time: " << realtime << " s" << endl;
while(!scheduler.empty() && realtime >= scheduler.front().get_arr_time()){
auto it = scheduler.front();
scheduler.pop();
if(monitor_map[it.ID]==0){
pid = fork();
if(pid == 0){
Monitor* monitor = new Monitor(it);
cout << "Terminate the Parent Process: " << getpid() <<endl;
//kill(getpid(), SIGKILL);
exit(0);
}
else{
monitor_map[it.ID]=pid;
}
}
if(pid !=0){
if(allow_preem){
allow_preem = false;
this_job = it;
signal(SIGALRM, signal_nonpreem);
alarm(it.get_dur_time());
}
else{
wait_queue.emplace(it);
kill(monitor_map[it.ID], SIGTSTP);
std::cout<<"Child Process Suspend" << std::endl;
}
}
}
if(pid!=0){
sleep(1);
realtime++;
}
}
if(pid !=0){
cout << "now time: " << realtime << " s" << endl;
sleep(2);
cout << endl;
cout << endl;
// draw Gantt diagram
Display(real_job_queue);
}
}
void Scheduler::driveRR(){
// create a schedule
queue<Job> pq_arr;
queue<Job> wait_q;
int len = get_job_num();
// clear -1
for(int i = 0; i < len; ++i){
if(job_queue[i].get_dur_time()==-1){
int t = 0;
find_dur_time(job_queue[i], t);
//cout << t << endl;
job_queue[i].set_dur_time(t);
}
}
sort(job_queue.begin(), job_queue.end());
for(int i = 0; i < len; ++i){
pq_arr.emplace(job_queue[i]);
}
int time = 0;
int wait_for_empty = 0;
while(true){
while(!pq_arr.empty() && time == pq_arr.front().get_arr_time()){
Job tmp = pq_arr.front();
pq_arr.pop();
if(tmp.get_dur_time() > QUANT){
tmp.service_time_left = tmp.get_dur_time();
scheduler.emplace(tmp);
scheduler.back().set_dur_time(QUANT);
tmp.set_dur_time(tmp.get_dur_time()-QUANT);
wait_q.emplace(tmp);
wait_for_empty += QUANT;
}
else{
tmp.service_time_left = tmp.get_dur_time();
scheduler.emplace(tmp);
wait_for_empty += tmp.get_dur_time();
}
}
if(wait_for_empty == 0){
if(wait_q.empty()){;}
else{
Job tmp2 = wait_q.front();
wait_q.pop();
tmp2.set_arr_time(time);
if(tmp2.get_dur_time() > QUANT){
tmp2.service_time_left = tmp2.get_dur_time();
scheduler.emplace(tmp2);
scheduler.back().set_dur_time(QUANT);
tmp2.set_dur_time(tmp2.get_dur_time()-QUANT);
wait_q.emplace(tmp2);
wait_for_empty += QUANT;
}
else{
tmp2.service_time_left = tmp2.get_dur_time();
scheduler.emplace(tmp2);
wait_for_empty += tmp2.get_dur_time();
}
}
}
time++;
if(wait_for_empty > 0){wait_for_empty--;}
if(wait_q.empty() && pq_arr.empty()){break;}
}
// copy
set_total_time(time);
real_job_queue = scheduler;
cout << endl;
cout << endl;
cout << endl;
// execute
cout << "==================================================="<< endl;
cout << "Now start the Scheduler !!!"<< endl;
cout << "==================================================="<< endl;
int realtime = 0;
int pid = 1;
while(!stop_flag){
cout << "now time: " << realtime << " s" << endl;
while(!scheduler.empty() && realtime == scheduler.front().get_arr_time()){
auto it = scheduler.front();
scheduler.pop();
if(monitor_map[it.ID]==0){
pid = fork();
if(pid == 0){
Monitor* monitor = new Monitor(it);
cout << "Terminate the Parent Process: " << getpid() <<endl;
//kill(getpid(), SIGKILL);
exit(0);
}
else{
monitor_map[it.ID]=pid;
}
}
if(pid !=0){
if(allow_preem){
allow_preem = false;
this_job = it;
kill(monitor_map[it.ID], SIGCONT);
signal(SIGALRM, signal_RR);
alarm(it.get_dur_time());
}
else{
wait_queue.emplace(it);
kill(monitor_map[it.ID], SIGTSTP);
std::cout<<"Child Process Suspend" << std::endl;
}
}
}
if(pid!=0){
sleep(1);
realtime++;
}
}
if(pid !=0){
cout << "now time: " << realtime << " s" << endl;
sleep(2);
cout << endl;
cout << endl;
// draw Gantt diagram
Display(real_job_queue);
}
}
void Scheduler::driveSJF2(){
// create a schedule
queue<Job> pq_arr;
priority_queue<Job,vector<Job>,greater<Job> > wait_q;
int len = get_job_num();
// clear -1
for(int i = 0; i < len; ++i){
if(job_queue[i].get_dur_time()==-1){
int t = 0;
find_dur_time(job_queue[i], t);
//cout << t << endl;
job_queue[i].set_dur_time(t);
}
}
sort(job_queue.begin(), job_queue.end(), [](const Job &a, const Job &b)->bool
{ if(a.get_arr_time() == b.get_arr_time()){return a.get_dur_time() < b.get_dur_time();}
else{return a.get_arr_time() < b.get_arr_time();}
});
for(int i = 0; i < len; ++i){
pq_arr.emplace(job_queue[i]);
}
int time = 0;
Job con;
con.ID = 0;
unordered_map<int, int> jobmap;
Job lastjob = con;
while(true){
while(!pq_arr.empty() && time == pq_arr.front().get_arr_time()){
Job tmp = pq_arr.front();
pq_arr.pop();
if(!wait_q.empty() && tmp.get_dur_time() < wait_q.top().get_dur_time() && wait_q.top().ID == lastjob.ID)
wait_q.pop();
wait_q.emplace(tmp);
}
if(!wait_q.empty()){
Job it = wait_q.top();
wait_q.pop();
if(lastjob.ID == it.ID || lastjob.ID == 0){
if(jobmap[it.ID] == 0){
scheduler.emplace(it);
jobmap[it.ID] = 1;
}
it.has_exp_time++;
it.set_dur_time(it.get_dur_time()-1);
if(it.get_dur_time() == 0){
scheduler.back().set_dur_time(it.has_exp_time);
scheduler.back().service_time_left = 2;
//cout << scheduler.back().ID << " arr " << scheduler.back().get_arr_time() << " dur "<< scheduler.back().get_dur_time()<< endl;
jobmap[it.ID] = 0;
lastjob = con;
}
else{
if(wait_q.empty() || it.get_dur_time() < wait_q.top().get_dur_time())
wait_q.emplace(it);
lastjob = it;
}
}
else{
scheduler.back().set_dur_time(lastjob.has_exp_time);
//cout << scheduler.back().ID << " arr " << scheduler.back().get_arr_time() << " dur "<< scheduler.back().get_dur_time()<< endl;
jobmap[lastjob.ID] = 0;
lastjob.has_exp_time = 0;
lastjob.set_arr_time(time);
wait_q.emplace(lastjob);
if(jobmap[it.ID] == 0){
scheduler.emplace(it);
jobmap[it.ID] = 1;
}
it.has_exp_time++;
it.set_dur_time(it.get_dur_time()-1);
if(it.get_dur_time() == 0){
scheduler.back().set_dur_time(it.has_exp_time);
scheduler.back().service_time_left = 2;
//cout << scheduler.back().ID << " arr " << scheduler.back().get_arr_time() << " dur "<< scheduler.back().get_dur_time()<< endl;
jobmap[it.ID] = 0;
lastjob = con;
}
else{
if(wait_q.empty() || it.get_dur_time() < wait_q.top().get_dur_time())
wait_q.emplace(it);
lastjob = it;
}
}
}
time++;
//cout << "now is " << time << " " << wait_q.size() << endl;
if(wait_q.empty() && pq_arr.empty()){break;}
}
// copy
set_total_time(time);
real_job_queue = scheduler;
cout << endl;
cout << endl;
cout << endl;
// execute
cout << "==================================================="<< endl;
cout << "Now start the Scheduler !!!"<< endl;
cout << "==================================================="<< endl;
int realtime = 0;
int pid = 1;
while(!stop_flag){
cout << "now time: " << realtime << " s" << endl;
while(!scheduler.empty() && realtime >= scheduler.front().get_arr_time()){
auto it = scheduler.front();
scheduler.pop();
if(monitor_map[it.ID]==0){
pid = fork();
if(pid == 0){
Monitor* monitor = new Monitor(it);
cout << "Terminate the Parent Process: " << getpid() <<endl;
//kill(getpid(), SIGKILL);
exit(0);
}
else{
monitor_map[it.ID]=pid;
}
}
if(pid !=0){
if(allow_preem){
allow_preem = false;
this_job = it;
kill(monitor_map[it.ID], SIGCONT);
signal(SIGALRM, signal_preemSJF);
alarm(it.get_dur_time());
}
else{
wait_queue.emplace(it);
kill(monitor_map[it.ID], SIGTSTP);
std::cout<<"Child Process Suspend" << std::endl;
}
}
}
if(pid!=0){
sleep(1);
realtime++;
}
}
if(pid !=0){
cout << "now time: " << realtime << " s" << endl;
sleep(2);
cout << endl;
cout << endl;
// draw Gantt diagram
Display(real_job_queue);
}
}
namespace Project
{
ostream &operator<<(ostream &out, const Scheduler &sc)
{
//out << "Totally " << sc.get_job_num() << " jobs\n";
//out << '\n';
//out << "-----------------------------------------------------------------------------------------------" << '\n';
//out << "Gantt Chart" << '\n';
//out << "-----------------------------------------------------------------------------------------------" << '\n';
//out << "Time" << setfill(' ') << setw(8) << '|';
//for (int i = 0; i <= sc.get_total_time() / 10; i++)
//{
//out << i;
//out << setfill(' ') << setw(20);
//}
//out << '\n';
//out << setfill(' ') << setw(12) << '|';
//for (int i = 0; i <= sc.get_total_time() / 10; i++)
//{
//for (int j = 0; j <= 9; j++)
//{
//out << j << ' ';
//}
//}
//out << '\n';
//for (int i = 0; i < sc.get_job_num(); i++)
//{
//out << "Job " << i + 1 << setfill(' ') << setw(7) << '|';
//for(int j=0;j<sc.job_queue[i].get_arr_time()-sc.job_queue[i].get_wait_time()
//;j++){
//out<<" ";
//}
//for(int j=0;j<sc.job_queue[i].get_wait_time();j++)
//{
//out<<". ";
//}
//for (int j = 0; j < sc.job_queue[i].get_dur_time(); j++)
//{
//out << "# ";
//}
//out << '\n';
//}
//out << "Mixed" << setfill(' ') << setw(7) << '|';
//for(int i=0;i<sc.job_queue[0].get_arr_time();i++)
//{
//out<<" ";
//}
//out << setfill(' ') << setw(sc.job_queue[0].get_arr_time() * 2);
//for (int i = 0; i < sc.get_job_num(); i++)
//{
//for (int j = 0; j < sc.job_queue[i].get_dur_time(); j++)
//{
//out << i + 1 << ' ';
//}
//}
//out << '\n';
}
}
void Scheduler::Display(queue<Job> q)
{
cout<<"Totally " << get_job_num() << " jobs, Time using: " << get_total_time()<<" s\n";
cout<<"======================================================================="<<'\n';
cout<<"Gantt Chart"<<'\n';
cout<<"======================================================================="<<'\n';
cout << "Time" << setfill(' ') << setw(5) << "|";
for (int i = 0; i <= get_total_time()/ 10; i++)
{
cout << i;
cout << setfill(' ') << setw(20);
}
cout << '\n';
cout << setfill(' ') << setw(9) << '|';
for (int i = 0; i <= get_total_time() / 10; i++)
{
for (int j = 0; j <= 9; j++){ cout << j << ' ';}
}
cout << '\n';
int stopindex = 0;
while(!q.empty())
{
auto it = q.front();
q.pop();
cout<<"Job " << it.ID <<setw(4) << "|";
int arr_time = it.get_arr_time();
int dur_time = it.get_dur_time();
for(int i=0; i<arr_time; ++i){ cout << " " << ' ';}
cout << "." << ' '; // arrive
for(int i=arr_time + 1; i<=get_total_time(); ++i){
if(i <= stopindex){cout << "." << ' ';}
else{
cout << "#" << ' ';
dur_time--;
if(dur_time==0){stopindex = i; break;}
}
}
for(int i=stopindex + 1; i<=get_total_time(); ++i){ cout << " " << ' ';}
cout << endl;
}
}
| 28.490308 | 148 | 0.380813 | [
"vector"
] |
a2fb3f3f655d1aaaf8c353b2a83c0811036077c1 | 2,350 | cpp | C++ | src/theory/builtin/theory_builtin_rewriter.cpp | FabianWolff/cvc4-debian | e38afe6cb10bdb79f0bae398b9605e4deae7578f | [
"BSL-1.0"
] | null | null | null | src/theory/builtin/theory_builtin_rewriter.cpp | FabianWolff/cvc4-debian | e38afe6cb10bdb79f0bae398b9605e4deae7578f | [
"BSL-1.0"
] | null | null | null | src/theory/builtin/theory_builtin_rewriter.cpp | FabianWolff/cvc4-debian | e38afe6cb10bdb79f0bae398b9605e4deae7578f | [
"BSL-1.0"
] | null | null | null | /********************* */
/*! \file theory_builtin_rewriter.cpp
** \verbatim
** Top contributors (to current version):
** Morgan Deters, Dejan Jovanovic, Tim King
** This file is part of the CVC4 project.
** Copyright (c) 2009-2016 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief [[ Add one-line brief description here ]]
**
** [[ Add lengthier description here ]]
** \todo document this file
**/
#include "theory/builtin/theory_builtin_rewriter.h"
#include "expr/chain.h"
using namespace std;
namespace CVC4 {
namespace theory {
namespace builtin {
Node TheoryBuiltinRewriter::blastDistinct(TNode in) {
Assert(in.getKind() == kind::DISTINCT);
if(in.getNumChildren() == 2) {
// if this is the case exactly 1 != pair will be generated so the
// AND is not required
Node eq = NodeManager::currentNM()->mkNode(kind::EQUAL, in[0], in[1]);
Node neq = NodeManager::currentNM()->mkNode(kind::NOT, eq);
return neq;
}
// assume that in.getNumChildren() > 2 => diseqs.size() > 1
vector<Node> diseqs;
for(TNode::iterator i = in.begin(); i != in.end(); ++i) {
TNode::iterator j = i;
while(++j != in.end()) {
Node eq = NodeManager::currentNM()->mkNode(kind::EQUAL, *i, *j);
Node neq = NodeManager::currentNM()->mkNode(kind::NOT, eq);
diseqs.push_back(neq);
}
}
Node out = NodeManager::currentNM()->mkNode(kind::AND, diseqs);
return out;
}
Node TheoryBuiltinRewriter::blastChain(TNode in) {
Assert(in.getKind() == kind::CHAIN);
Kind chainedOp = in.getOperator().getConst<Chain>().getOperator();
if(in.getNumChildren() == 2) {
// if this is the case exactly 1 pair will be generated so the
// AND is not required
return NodeManager::currentNM()->mkNode(chainedOp, in[0], in[1]);
} else {
NodeBuilder<> conj(kind::AND);
for(TNode::iterator i = in.begin(), j = i + 1; j != in.end(); ++i, ++j) {
conj << NodeManager::currentNM()->mkNode(chainedOp, *i, *j);
}
return conj;
}
}
}/* CVC4::theory::builtin namespace */
}/* CVC4::theory namespace */
}/* CVC4 namespace */
| 30.921053 | 80 | 0.630213 | [
"vector"
] |
0c06a039f29feab8f5dea214f612d10e740fad17 | 14,254 | hxx | C++ | Cores/Stella/PVStella/Stella/StellaCore/src/stella/FSNode.hxx | werminghoff/Provenance | de61b4a64a3eb8e2774e0a8ed53488c6c7aa6cb2 | [
"BSD-3-Clause"
] | 3,459 | 2015-01-07T14:07:09.000Z | 2022-03-25T03:51:10.000Z | Cores/Stella/PVStella/Stella/StellaCore/src/stella/FSNode.hxx | werminghoff/Provenance | de61b4a64a3eb8e2774e0a8ed53488c6c7aa6cb2 | [
"BSD-3-Clause"
] | 1,046 | 2018-03-24T17:56:16.000Z | 2022-03-23T08:13:09.000Z | Cores/Stella/PVStella/Stella/StellaCore/src/stella/FSNode.hxx | werminghoff/Provenance | de61b4a64a3eb8e2774e0a8ed53488c6c7aa6cb2 | [
"BSD-3-Clause"
] | 549 | 2015-01-07T14:07:15.000Z | 2022-01-07T16:13:05.000Z | //============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2011 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FSNode.hxx 2250 2011-06-09 14:00:30Z stephena $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#ifndef FS_NODE_HXX
#define FS_NODE_HXX
#include <algorithm>
/*
* The API described in this header is meant to allow for file system browsing in a
* portable fashions. To this ends, multiple or single roots have to be supported
* (compare Unix with a single root, Windows with multiple roots C:, D:, ...).
*
* To this end, we abstract away from paths; implementations can be based on
* paths (and it's left to them whether / or \ or : is the path separator :-);
* but it is also possible to use inodes or vrefs (MacOS 9) or anything else.
*
* NOTE: Backends still have to provide a way to extract a path from a FSIntern
*
* You may ask now: "isn't this cheating? Why do we go through all this when we use
* a path in the end anyway?!?".
* Well, for once as long as we don't provide our own file open/read/write API, we
* still have to use fopen(). Since all our targets already support fopen(), it should
* be possible to get a fopen() compatible string for any file system node.
*
* Secondly, with this abstraction layer, we still avoid a lot of complications based on
* differences in FS roots, different path separators, or even systems with no real
* paths (MacOS 9 doesn't even have the notion of a "current directory").
* And if we ever want to support devices with no FS in the classical sense (Palm...),
* we can build upon this.
*/
/*
* TODO - Instead of starting with getRoot(), we should rather add a getDefaultDir()
* call that on Unix might return the current dir or the users home dir...
* i.e. the root dir is usually not the best starting point for browsing.
*/
#include "Array.hxx"
#include "SharedPtr.hxx"
class FilesystemNode;
class AbstractFilesystemNode;
/**
* List of multiple file system nodes. E.g. the contents of a given directory.
* This is subclass instead of just a typedef so that we can use forward
* declarations of it in other places.
*/
class FSList : public Common::Array<FilesystemNode> { };
/**
* FilesystemNode provides an abstraction for file paths, allowing for portable
* file system browsing. To this ends, multiple or single roots have to be supported
* (compare Unix with a single root, Windows with multiple roots C:, D:, ...).
*
* To this end, we abstract away from paths; implementations can be based on
* paths (and it's left to them whether / or \ or : is the path separator :-);
* but it is also possible to use inodes or vrefs (MacOS 9) or anything else.
*
* NOTE: Backends still have to provide a way to extract a path from a FSIntern
*
* You may ask now: "isn't this cheating? Why do we go through all this when we use
* a path in the end anyway?!?".
* Well, for once as long as we don't provide our own file open/read/write API, we
* still have to use fopen(). Since all our targets already support fopen(), it should
* be possible to get a fopen() compatible string for any file system node.
*
* Secondly, with this abstraction layer, we still avoid a lot of complications based on
* differences in FS roots, different path separators, or even systems with no real
* paths (MacOS 9 doesn't even have the notion of a "current directory").
* And if we ever want to support devices with no FS in the classical sense (Palm...),
* we can build upon this.
*
* This class acts as a wrapper around the AbstractFilesystemNode class defined in backends/fs.
*/
class FilesystemNode
{
public:
/**
* Flag to tell listDir() which kind of files to list.
*/
enum ListMode {
kListFilesOnly = 1,
kListDirectoriesOnly = 2,
kListAll = 3
};
/**
* Create a new pathless FilesystemNode. Since there's no path associated
* with this node, path-related operations (i.e. exists(), isDirectory(),
* getPath()) will always return false or raise an assertion.
*/
FilesystemNode();
/**
* Create a new FilesystemNode referring to the specified path. This is
* the counterpart to the path() method.
*
* If path is empty or equals "." or "~", then a node representing the
* "home directory" will be created. If that is not possible (since e.g. the
* operating system doesn't support the concept), some other directory is
* used (usually the root directory).
*/
explicit FilesystemNode(const string& path);
virtual ~FilesystemNode() {}
/**
* Compare the name of this node to the name of another. Directories
* go before normal files.
*/
bool operator<(const FilesystemNode& node) const;
/**
* Indicates whether the object referred by this path exists in the filesystem or not.
*
* @return bool true if the path exists, false otherwise.
*/
virtual bool exists() const;
/**
* Return a list of child nodes of this directory node. If called on a node
* that does not represent a directory, false is returned.
*
* @return true if successful, false otherwise (e.g. when the directory does not exist).
*/
virtual bool getChildren(FSList &fslist, ListMode mode = kListDirectoriesOnly, bool hidden = false) const;
/**
* Return a human readable string for this node, usable for display (e.g.
* in the GUI code). Do *not* rely on it being usable for anything else,
* like constructing paths!
*
* @return the display name
*/
virtual string getDisplayName() const;
/**
* Return a string representation of the name of the file. This is can be
* used e.g. by detection code that relies on matching the name of a given
* file. But it is *not* suitable for use with fopen / File::open, nor
* should it be archived.
*
* @return the file name
*/
virtual string getName() const;
/**
* Return a string representation of the file with the following properties:
* 1) can be passed to fopen() if fqn is true
* 2) contains the '~' symbol (if applicable), and is suitable for archiving
* (i.e. writing to the config file) if fqn is false
*
* This will usually be a 'path' (hence the name of the method), but can
* be anything that fulfills the above criterions.
*
* @note Do not assume that this string contains (back)slashes or any
* other kind of 'path separators'.
*
* @return the 'path' represented by this filesystem node
*/
virtual string getPath(bool fqn = true) const;
/**
* Determine whether this node has a parent.
*/
bool hasParent() const;
/**
* Get the parent node of this node. If this node has no parent node,
* then it returns a duplicate of this node.
*/
FilesystemNode getParent() const;
/**
* Indicates whether the path refers to a directory or not.
*
* @todo Currently we assume that a node that is not a directory
* automatically is a file (ignoring things like symlinks or pipes).
* That might actually be OK... but we could still add an isFile method.
* Or even replace isDirectory by a getType() method that can return values like
* kDirNodeType, kFileNodeType, kInvalidNodeType.
*/
virtual bool isDirectory() const;
/**
* Indicates whether the object referred by this path can be read from or not.
*
* If the path refers to a directory, readability implies being able to read
* and list the directory entries.
*
* If the path refers to a file, readability implies being able to read the
* contents of the file.
*
* @return bool true if the object can be read, false otherwise.
*/
virtual bool isReadable() const;
/**
* Indicates whether the object referred by this path can be written to or not.
*
* If the path refers to a directory, writability implies being able to modify
* the directory entry (i.e. rename the directory, remove it or write files inside of it).
*
* If the path refers to a file, writability implies being able to write data
* to the file.
*
* @return bool true if the object can be written to, false otherwise.
*/
virtual bool isWritable() const;
private:
Common::SharedPtr<AbstractFilesystemNode> _realNode;
FilesystemNode(AbstractFilesystemNode* realNode);
};
/**
* Abstract file system node. Private subclasses implement the actual
* functionality.
*
* Most of the methods correspond directly to methods in class FSNode,
* so if they are not documented here, look there for more information about
* the semantics.
*/
typedef Common::Array<AbstractFilesystemNode *> AbstractFSList;
class AbstractFilesystemNode
{
protected:
friend class FilesystemNode;
typedef FilesystemNode::ListMode ListMode;
public:
/**
* Destructor.
*/
virtual ~AbstractFilesystemNode() {}
/*
* Indicates whether the object referred by this path exists in the filesystem or not.
*/
virtual bool exists() const = 0;
/**
* Return a list of child nodes of this directory node. If called on a node
* that does not represent a directory, false is returned.
*
* @param list List to put the contents of the directory in.
* @param mode Mode to use while listing the directory.
* @param hidden Whether to include hidden files or not in the results.
*
* @return true if succesful, false otherwise (e.g. when the directory does not exist).
*/
virtual bool getChildren(AbstractFSList& list, ListMode mode, bool hidden) const = 0;
/**
* Returns a human readable path string.
*
* @note By default, this method returns the value of getName().
*/
virtual string getDisplayName() const { return getName(); }
/**
* Returns the last component of the path pointed by this FilesystemNode.
*
* Examples (POSIX):
* /foo/bar.txt would return /bar.txt
* /foo/bar/ would return /bar/
*
* @note This method is very architecture dependent, please check the concrete implementation for more information.
*/
virtual string getName() const = 0;
/**
* Returns the 'path' of the current node, usable in fopen() or
containing '~' and for archiving.
*/
virtual string getPath(bool fqn = true) const = 0;
/**
* Indicates whether this path refers to a directory or not.
*/
virtual bool isDirectory() const = 0;
/**
* Indicates whether the object referred by this path can be read from or not.
*
* If the path refers to a directory, readability implies being able to read
* and list the directory entries.
*
* If the path refers to a file, readability implies being able to read the
* contents of the file.
*
* @return bool true if the object can be read, false otherwise.
*/
virtual bool isReadable() const = 0;
/**
* Indicates whether the object referred by this path can be written to or not.
*
* If the path refers to a directory, writability implies being able to modify
* the directory entry (i.e. rename the directory, remove it or write files inside of it).
*
* If the path refers to a file, writability implies being able to write data
* to the file.
*
* @return bool true if the object can be written to, false otherwise.
*/
virtual bool isWritable() const = 0;
/* TODO:
bool isFile();
*/
/**
Create a directory from the given path.
*/
static bool makeDir(const string& path);
/**
Rename the given file with a new name.
*/
static bool renameFile(const string& oldfile, const string& newfile);
/**
Create an absolute pathname from the given path (if it isn't already
absolute), pre-pending 'startpath' when necessary. If the path doesn't
have an extension matching 'ext', append it to the path.
*/
static string getAbsolutePath(const string& p, const string& startpath,
const string& ext);
protected:
/**
* The parent node of this directory.
* The parent of the root is the root itself.
*/
virtual AbstractFilesystemNode* getParent() const = 0;
/**
* Returns a node representing the "home directory".
*
* On Unix, this will be the value of $HOME.
* On Windows, it will be the 'My Documents' folder.
* Otherwise, it should just return the same value as getRoot().
*/
static AbstractFilesystemNode* makeHomeDirectoryFileNode();
/**
* Construct a node based on a path; the path is in the same format as it
* would be for calls to fopen().
*
* Furthermore getNodeForPath(oldNode.path()) should create a new node
* identical to oldNode. Hence, we can use the "path" value for persistent
* storage e.g. in the config file.
*
* @param path The path string to create a FilesystemNode for.
*/
static AbstractFilesystemNode* makeFileNodePath(const string& path);
/**
* Returns a special node representing the filesystem root.
* The starting point for any file system browsing.
*
* On Unix, this will be simply the node for / (the root directory).
* On Windows, it will be a special node which "contains" all drives (C:, D:, E:).
*/
static AbstractFilesystemNode* makeRootFileNode();
};
#endif
| 36.177665 | 119 | 0.656307 | [
"object"
] |
0c0d67e438b339d5229312606beebde1b9cf1179 | 7,484 | cpp | C++ | test/LockFreeQueue.cpp | cestlascorpion/Scorpion | c7175a0279f8d1eba2be7ba1758ddcd8fec25073 | [
"MIT"
] | null | null | null | test/LockFreeQueue.cpp | cestlascorpion/Scorpion | c7175a0279f8d1eba2be7ba1758ddcd8fec25073 | [
"MIT"
] | null | null | null | test/LockFreeQueue.cpp | cestlascorpion/Scorpion | c7175a0279f8d1eba2be7ba1758ddcd8fec25073 | [
"MIT"
] | null | null | null | #include "MPMCQueue.h"
#include "MPSCQueue.h"
#include "SPSCQueue.h"
#include <atomic>
#include <chrono>
#include <cstddef>
#include <memory>
#include <thread>
#include <vector>
using namespace std;
using namespace chrono;
using namespace scorpion;
constexpr const size_t kQueueSize = 1024;
constexpr const size_t kProducerNum = 10;
constexpr const size_t kConsumerNum = 10;
constexpr const size_t kTestCounter = 10240;
struct TestNode {
size_t num;
time_point<steady_clock> ts;
TestNode()
: num(0){};
explicit TestNode(size_t n)
: num(n)
, ts(steady_clock::now()) {}
TestNode(const TestNode &n) noexcept {
num = n.num;
ts = n.ts;
};
TestNode &operator=(const TestNode &n) noexcept {
if (&n == this) {
return *this;
}
num = n.num;
ts = n.ts;
return *this;
};
};
template <typename Queue, typename Node, size_t P, size_t C, size_t N>
class TestLockFreeQueueTemplate {
public:
TestLockFreeQueueTemplate()
: queue_(nullptr)
, push_(0)
, pop_(0)
, prod_done_(false)
, produces_(P)
, consumes_(C)
, prod_sum_(0)
, coms_sum_(0) {}
~TestLockFreeQueueTemplate() = default;
public:
void Execute(Queue queue) {
queue_ = queue;
for (vector<thread>::size_type idx = 0; idx < consumes_.size(); ++idx) {
consumes_[idx] = thread(&TestLockFreeQueueTemplate::consumer, this, idx);
}
for (vector<thread>::size_type idx = 0; idx < produces_.size(); ++idx) {
produces_[idx] = thread(&TestLockFreeQueueTemplate::producer, this, idx);
}
for (auto &t : produces_) {
if (t.joinable()) {
t.join();
}
}
prod_done_.store(true);
for (auto &t : consumes_) {
if (t.joinable()) {
t.join();
}
}
printf("done: Push %lu (%lu) Pop %lu (%lu)\n", push_.load(), prod_sum_.load(), pop_.load(), coms_sum_.load());
}
private:
static size_t uniqueNum() {
static atomic<size_t> increase_(1);
return increase_.fetch_add(1);
}
void consumer(size_t id) {
while (true) {
Node node;
if (!queue_->TryPop(node)) {
if (prod_done_.load()) {
break;
}
this_thread::sleep_for(nanoseconds(5));
} else {
coms_sum_ += node.num;
++pop_;
this_thread::sleep_for(nanoseconds(0));
}
}
{
Node node;
while (queue_->TryPop(node)) {
coms_sum_ += node.num;
++pop_;
}
}
printf("[%lu] consumer done!\n", id);
}
void producer(size_t id) {
while (true) {
auto node = Node(uniqueNum());
if (node.num > N) {
break;
}
while (!queue_->TryPush(node)) {
this_thread::sleep_for(nanoseconds(20));
}
prod_sum_ += node.num;
++push_;
this_thread::sleep_for(nanoseconds(10));
}
printf("[%lu] producer done!\n", id);
}
private:
Queue queue_;
atomic<size_t> push_;
atomic<size_t> pop_;
atomic<bool> prod_done_;
vector<thread> produces_;
vector<thread> consumes_;
atomic<size_t> prod_sum_;
atomic<size_t> coms_sum_;
};
template <typename Queue, typename Node, size_t P, size_t C, size_t N>
class TestLockFreeQueueBulkTemplate {
public:
TestLockFreeQueueBulkTemplate()
: queue_(nullptr)
, push_(0)
, pop_(0)
, prod_done_(false)
, produces_(P)
, consumes_(C)
, prod_sum_(0)
, coms_sum_(0) {}
~TestLockFreeQueueBulkTemplate() = default;
public:
void Execute(Queue queue) {
queue_ = queue;
for (vector<thread>::size_type idx = 0; idx < consumes_.size(); ++idx) {
consumes_[idx] = thread(&TestLockFreeQueueBulkTemplate::consumer, this, idx);
}
for (vector<thread>::size_type idx = 0; idx < produces_.size(); ++idx) {
produces_[idx] = thread(&TestLockFreeQueueBulkTemplate::producer, this, idx);
}
for (auto &t : produces_) {
if (t.joinable()) {
t.join();
}
}
prod_done_.store(true);
for (auto &t : consumes_) {
if (t.joinable()) {
t.join();
}
}
printf("done: Push %lu (%lu) Pop %lu (%lu)\n", push_.load(), prod_sum_.load(), pop_.load(), coms_sum_.load());
}
private:
static size_t uniqueNum() {
static atomic<size_t> increase_(1);
return increase_.fetch_add(1);
}
void consumer(size_t id) {
while (true) {
const auto bulk = queue_->TryPopBulk();
if (bulk.empty()) {
if (prod_done_.load()) {
break;
}
this_thread::sleep_for(nanoseconds(20));
} else {
for (const auto &node : bulk) {
coms_sum_ += node.num;
}
pop_ += bulk.size();
this_thread::sleep_for(nanoseconds(10));
}
}
{
Node node;
while (queue_->TryPop(node)) {
coms_sum_ += node.num;
++pop_;
}
}
printf("[%lu] consumer done!\n", id);
}
void producer(size_t id) {
while (true) {
auto node = Node(uniqueNum());
if (node.num > N) {
break;
}
while (!queue_->TryPush(node)) {
this_thread::sleep_for(nanoseconds(20));
}
prod_sum_ += node.num;
++push_;
this_thread::sleep_for(nanoseconds(10));
}
printf("[%lu] producer done!\n", id);
}
private:
Queue queue_;
atomic<size_t> push_;
atomic<size_t> pop_;
atomic<bool> prod_done_;
vector<thread> produces_;
vector<thread> consumes_;
atomic<size_t> prod_sum_;
atomic<size_t> coms_sum_;
};
void TestSPSC() {
auto queue(make_shared<SPSCQueue<TestNode>>(kQueueSize));
auto test(make_shared<TestLockFreeQueueTemplate<decltype(queue), TestNode, 1, 1, kTestCounter>>());
test->Execute(queue);
printf("spsc done!\n");
}
void TestMPMC() {
auto queue(make_shared<MPMCQueue<TestNode>>(kQueueSize));
auto test(
make_shared<TestLockFreeQueueTemplate<decltype(queue), TestNode, kProducerNum, kConsumerNum, kTestCounter>>());
test->Execute(queue);
printf("mpmc done!\n");
}
void TestMPSC() {
auto queue(make_shared<MPSCQueue<TestNode>>(kQueueSize));
auto test(make_shared<TestLockFreeQueueTemplate<decltype(queue), TestNode, kProducerNum, 1, kTestCounter>>());
test->Execute(queue);
printf("mpsc done!\n");
}
void TestMPSCBulk() {
auto queue(make_shared<MPSCQueue<TestNode>>(kQueueSize));
auto test(make_shared<TestLockFreeQueueBulkTemplate<decltype(queue), TestNode, kProducerNum, 1, kTestCounter>>());
test->Execute(queue);
printf("mpsc bulk done!\n");
}
int main() {
TestSPSC();
TestMPMC();
TestMPSC();
TestMPSCBulk();
this_thread::sleep_for(seconds(2));
return 0;
}
| 26.44523 | 119 | 0.536879 | [
"vector"
] |
0c0fd04f8f90470f71b0270491a1ebb283bac4a1 | 1,692 | cpp | C++ | homecontrol-learning/programManager.cpp | andreasfertl/homecontrol-learning | d7874a8b8124791ace3d7e7bb93085746cfd603f | [
"MIT"
] | null | null | null | homecontrol-learning/programManager.cpp | andreasfertl/homecontrol-learning | d7874a8b8124791ace3d7e7bb93085746cfd603f | [
"MIT"
] | null | null | null | homecontrol-learning/programManager.cpp | andreasfertl/homecontrol-learning | d7874a8b8124791ace3d7e7bb93085746cfd603f | [
"MIT"
] | null | null | null | #include <thread>
#include <chrono>
#include <atomic>
#include "programManager.h"
#include "logging.h"
#include "seriealizeFunctions.h"
#include "thread.h"
#include "iTread.h"
#include "queuedLogger.h"
class programManagerImpl {
public:
programManagerImpl() :
m_Run(true),
m_QueuedLogger(),
m_MyLogger(m_QueuedLogger),
manyThreads()
{
_logg(m_MyLogger, L"Startup");
for (unsigned int threadcount = 0; threadcount < 10; threadcount++) {
manyThreads.emplace_back([this]() {
_logg(m_MyLogger, "From Thread ID : " << std::this_thread::get_id());
});
}
}
~programManagerImpl() {
for (auto& thread : manyThreads) {
if (thread.joinable())
thread.join();
}
}
void run()
{
auto startupTime = std::chrono::system_clock::now();
while (m_Run) {
auto runningSince = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - startupTime);
_logg(m_MyLogger, L"Running since: " << runningSince.count() << L" milliseconds");
std::this_thread::sleep_for(std::chrono::seconds(2));
if (runningSince >= std::chrono::seconds(12))
stop();
}
}
void stop()
{
m_Run = false;
}
private:
std::atomic<bool> m_Run;
queuedLogger m_QueuedLogger;
ilogger& m_MyLogger;
std::vector<std::thread> manyThreads;
};
//------------------------------------------------------------------------------------------------------------------------
programManager::programManager() :
m_ProgramManager(std::make_unique<programManagerImpl>())
{
}
programManager::~programManager()
{
}
void programManager::run()
{
m_ProgramManager->run();
}
void programManager::stop()
{
m_ProgramManager->stop();
}
| 19.905882 | 125 | 0.624113 | [
"vector"
] |
0c1342e6752e4901d0cd1e21fe64c611ed6df60a | 12,486 | cpp | C++ | src/mist/it/SymmetricDelta.cpp | andbanman/mist | 2546fb41bccea1f89a43dbdbed7ce3a257926b54 | [
"MIT"
] | null | null | null | src/mist/it/SymmetricDelta.cpp | andbanman/mist | 2546fb41bccea1f89a43dbdbed7ce3a257926b54 | [
"MIT"
] | 4 | 2021-03-30T21:40:44.000Z | 2021-11-08T18:54:34.000Z | src/mist/it/SymmetricDelta.cpp | andbanman/mist | 2546fb41bccea1f89a43dbdbed7ce3a257926b54 | [
"MIT"
] | null | null | null | #include <stdexcept>
#include "it/SymmetricDelta.hpp"
using namespace mist;
using namespace mist::it;
using sub2 = SymmetricDelta::sub_calc_2d;
using sub3 = SymmetricDelta::sub_calc_3d;
using sub4 = SymmetricDelta::sub_calc_4d;
void
compute_2d(EntropyCalculator& ecalc, Variable::indexes const& vars, SymmetricDelta::result_type& res)
{
if (res.size() != (std::size_t)sub2::size) {
res.resize((std::size_t)sub2::size);
}
auto e0 = ecalc.entropy({ vars[0] });
auto e1 = ecalc.entropy({ vars[1] });
auto e01 = ecalc.entropy({ vars[0], vars[1] });
SymmetricDelta::data_t DD = e0 + e1 - e01;
res[(int)sub2::entropy0] = e0;
res[(int)sub2::entropy1] = e1;
res[(int)sub2::entropy01] = e01;
res[(int)sub2::symmetric_mist] = DD;
}
void
compute_2d(EntropyCalculator& ecalc,
Variable::indexes const& vars,
Entropy const& entropy,
SymmetricDelta::result_type &res)
{
if (res.size() != (std::size_t)sub2::size) {
res.resize((std::size_t)sub2::size);
}
auto e0 = entropy[(int)d2::e0];
auto e1 = entropy[(int)d2::e1];
auto e01 = entropy[(int)d2::e01];
SymmetricDelta::data_t DD = e0 + e1 - e01;
res[(int)sub2::entropy0] = e0;
res[(int)sub2::entropy1] = e1;
res[(int)sub2::entropy01] = e01;
res[(int)sub2::symmetric_mist] = DD;
}
void
compute_3d(EntropyCalculator& ecalc, Variable::indexes const& vars, SymmetricDelta::result_type& res)
{
if (res.size() != (std::size_t)sub3::size) {
res.resize((std::size_t)sub3::size);
}
auto e0 = ecalc.entropy({ vars[0] });
auto e1 = ecalc.entropy({ vars[1] });
auto e2 = ecalc.entropy({ vars[2] });
auto e01 = ecalc.entropy({ vars[0], vars[1] });
auto e02 = ecalc.entropy({ vars[0], vars[2] });
auto e12 = ecalc.entropy({ vars[1], vars[2] });
auto e012 = ecalc.entropy({ vars[0], vars[1], vars[2] });
auto I01 = e0 + e1 - e01;
auto I02 = e0 + e2 - e02;
auto I12 = e1 + e2 - e12;
auto I012 = e0 + e1 + e2 - e01 - e02 - e12 + e012;
auto D0 = I012 - I12;
auto D1 = I012 - I02;
auto D2 = I012 - I01;
auto DD = D0 * D1 * D2;
// sign change to force positive values
DD = (DD) ? -1 * DD : 0;
res[(int)sub3::entropy0] = e0;
res[(int)sub3::entropy1] = e1;
res[(int)sub3::entropy2] = e2;
res[(int)sub3::entropy01] = e01;
res[(int)sub3::entropy02] = e02;
res[(int)sub3::entropy12] = e12;
res[(int)sub3::entropy012] = e012;
res[(int)sub3::jointInfo01] = I01;
res[(int)sub3::jointInfo02] = I02;
res[(int)sub3::jointInfo12] = I12;
res[(int)sub3::jointInfo012] = I012;
res[(int)sub3::diffInfo0] = D0;
res[(int)sub3::diffInfo1] = D1;
res[(int)sub3::diffInfo2] = D2;
res[(int)sub3::symmetric_mist] = DD;
}
void
compute_3d(EntropyCalculator& ecalc,
Variable::indexes const& vars,
Entropy const& entropy,
SymmetricDelta::result_type& res)
{
if (res.size() != (std::size_t)sub3::size) {
res.resize((std::size_t)sub3::size);
}
auto e0 = entropy[(int)d3::e0];
auto e1 = entropy[(int)d3::e1];
auto e2 = entropy[(int)d3::e2];
auto e01 = entropy[(int)d3::e01];
auto e02 = entropy[(int)d3::e02];
auto e12 = entropy[(int)d3::e12];
auto e012 = entropy[(int)d3::e012];
auto I01 = e0 + e1 - e01;
auto I02 = e0 + e2 - e02;
auto I12 = e1 + e2 - e12;
auto I012 = e0 + e1 + e2 - e01 - e02 - e12 + e012;
auto D0 = I012 - I12;
auto D1 = I012 - I02;
auto D2 = I012 - I01;
auto DD = D0 * D1 * D2;
// sign change to force positive values
DD = (DD) ? -1 * DD : 0;
res[(int)sub3::entropy0] = e0;
res[(int)sub3::entropy1] = e1;
res[(int)sub3::entropy2] = e2;
res[(int)sub3::entropy01] = e01;
res[(int)sub3::entropy02] = e02;
res[(int)sub3::entropy12] = e12;
res[(int)sub3::entropy012] = e012;
res[(int)sub3::jointInfo01] = I01;
res[(int)sub3::jointInfo02] = I02;
res[(int)sub3::jointInfo12] = I12;
res[(int)sub3::jointInfo012] = I012;
res[(int)sub3::diffInfo0] = D0;
res[(int)sub3::diffInfo1] = D1;
res[(int)sub3::diffInfo2] = D2;
res[(int)sub3::symmetric_mist] = DD;
}
void
compute_4d(EntropyCalculator& ecalc, Variable::indexes const& vars, SymmetricDelta::result_type& res)
{
if (res.size() != (std::size_t)sub4::size) {
res.resize((std::size_t)sub4::size);
}
auto e0 = ecalc.entropy({ vars[0] });
auto e1 = ecalc.entropy({ vars[1] });
auto e2 = ecalc.entropy({ vars[2] });
auto e3 = ecalc.entropy({ vars[3] });
auto e01 = ecalc.entropy({ vars[0], vars[1] });
auto e02 = ecalc.entropy({ vars[0], vars[2] });
auto e03 = ecalc.entropy({ vars[0], vars[3] });
auto e12 = ecalc.entropy({ vars[1], vars[2] });
auto e13 = ecalc.entropy({ vars[1], vars[3] });
auto e23 = ecalc.entropy({ vars[2], vars[3] });
auto e012 = ecalc.entropy({ vars[0], vars[1], vars[2] });
auto e013 = ecalc.entropy({ vars[0], vars[1], vars[3] });
auto e023 = ecalc.entropy({ vars[0], vars[2], vars[3] });
auto e123 = ecalc.entropy({ vars[1], vars[2], vars[3] });
auto e0123 = ecalc.entropy({ vars[0], vars[1], vars[2], vars[3] });
auto I012 = e0 + e1 + e2 - e01 - e02 - e12 + e012;
auto I013 = e0 + e1 + e3 - e01 - e03 - e13 + e013;
auto I023 = e0 + e2 + e3 - e02 - e03 - e23 + e023;
auto I123 = e1 + e2 + e3 - e12 - e13 - e23 + e123;
auto I0123 = e0 + e1 + e2 + e3
- e01 - e02 - e03 - e12 - e13 - e23
+ e012 + e013 + e023 + e123
- e0123;
auto D0 = I0123 - I123;
auto D1 = I0123 - I023;
auto D2 = I0123 - I013;
auto D3 = I0123 - I012;
auto DD = D0 * D1 * D2 * D3;
res[(int)sub4::entropy0] = e0;
res[(int)sub4::entropy1] = e1;
res[(int)sub4::entropy2] = e2;
res[(int)sub4::entropy3] = e3;
res[(int)sub4::entropy01] = e01;
res[(int)sub4::entropy02] = e02;
res[(int)sub4::entropy03] = e03;
res[(int)sub4::entropy12] = e12;
res[(int)sub4::entropy13] = e13;
res[(int)sub4::entropy23] = e23;
res[(int)sub4::entropy012] = e012;
res[(int)sub4::entropy013] = e013;
res[(int)sub4::entropy023] = e023;
res[(int)sub4::entropy123] = e123;
res[(int)sub4::entropy0123] = e0123;
res[(int)sub4::jointInfo012] = I012;
res[(int)sub4::jointInfo013] = I013;
res[(int)sub4::jointInfo023] = I023;
res[(int)sub4::jointInfo123] = I123;
res[(int)sub4::diffInfo0] = D0;
res[(int)sub4::diffInfo1] = D1;
res[(int)sub4::diffInfo2] = D2;
res[(int)sub4::diffInfo3] = D3;
res[(int)sub4::symmetric_delta] = DD;
}
void
compute_4d(EntropyCalculator& ecalc,
Variable::indexes const& vars,
Entropy const& entropy,
SymmetricDelta::result_type& res)
{
if (res.size() != (std::size_t)sub4::size) {
res.resize((std::size_t)sub4::size);
}
auto e0 = entropy[(int)d4::e0];
auto e1 = entropy[(int)d4::e1];
auto e2 = entropy[(int)d4::e2];
auto e01 = entropy[(int)d4::e01];
auto e02 = entropy[(int)d4::e02];
auto e12 = entropy[(int)d4::e12];
auto e012 = entropy[(int)d4::e012];
auto e3 = ecalc.entropy({ vars[3] });
auto e03 = ecalc.entropy({ vars[0], vars[3] });
auto e13 = ecalc.entropy({ vars[1], vars[3] });
auto e23 = ecalc.entropy({ vars[2], vars[3] });
auto e013 = ecalc.entropy({ vars[0], vars[1], vars[3] });
auto e023 = ecalc.entropy({ vars[0], vars[2], vars[3] });
auto e123 = ecalc.entropy({ vars[1], vars[2], vars[3] });
auto e0123 = ecalc.entropy({ vars[0], vars[1], vars[2], vars[3] });
auto I012 = e0 + e1 + e2 - e01 - e02 - e12 + e012;
auto I013 = e0 + e1 + e3 - e01 - e03 - e13 + e013;
auto I023 = e0 + e2 + e3 - e02 - e03 - e23 + e023;
auto I123 = e1 + e2 + e3 - e12 - e13 - e23 + e123;
auto I0123 = e0 + e1 + e2 + e3
- e01 - e02 - e03 - e12 - e13 - e23
+ e012 + e013 + e023 + e123
- e0123;
auto D0 = I0123 - I123;
auto D1 = I0123 - I023;
auto D2 = I0123 - I013;
auto D3 = I0123 - I012;
auto DD = D0 * D1 * D2 * D3;
res[(int)sub4::entropy0] = e0;
res[(int)sub4::entropy1] = e1;
res[(int)sub4::entropy2] = e2;
res[(int)sub4::entropy3] = e3;
res[(int)sub4::entropy01] = e01;
res[(int)sub4::entropy02] = e02;
res[(int)sub4::entropy03] = e03;
res[(int)sub4::entropy12] = e12;
res[(int)sub4::entropy13] = e13;
res[(int)sub4::entropy23] = e23;
res[(int)sub4::entropy012] = e012;
res[(int)sub4::entropy013] = e013;
res[(int)sub4::entropy023] = e023;
res[(int)sub4::entropy123] = e123;
res[(int)sub4::entropy0123] = e0123;
res[(int)sub4::jointInfo012] = I012;
res[(int)sub4::jointInfo013] = I013;
res[(int)sub4::jointInfo023] = I023;
res[(int)sub4::jointInfo123] = I123;
res[(int)sub4::diffInfo0] = D0;
res[(int)sub4::diffInfo1] = D1;
res[(int)sub4::diffInfo2] = D2;
res[(int)sub4::diffInfo3] = D3;
res[(int)sub4::symmetric_delta] = DD;
}
SymmetricDelta::result_type
SymmetricDelta::compute(EntropyCalculator& ecalc,
Variable::indexes const& tuple) const
{
result_type result;
compute(ecalc, tuple, result);
return result;
}
void
SymmetricDelta::compute(EntropyCalculator& ecalc,
Variable::indexes const& tuple,
result_type &result) const
{
auto size = tuple.size();
switch (size) {
case 2:
compute_2d(ecalc, tuple, result);
break;
case 3:
compute_3d(ecalc, tuple, result);
break;
case 4:
compute_4d(ecalc, tuple, result);
break;
default:
throw SymmetricDeltaException("compute",
"Unsupported tuple size " +
std::to_string(size) +
", valid range [2,4]");
}
}
SymmetricDelta::result_type
SymmetricDelta::compute(EntropyCalculator& ecalc,
Variable::indexes const& tuple,
Entropy const& e) const
{
result_type result;
compute(ecalc, tuple, e, result);
return result;
}
void
SymmetricDelta::compute(EntropyCalculator& ecalc,
Variable::indexes const& tuple,
Entropy const& e,
result_type &result) const
{
auto size = tuple.size();
switch (size) {
case 2:
compute_2d(ecalc, tuple, e, result);
break;
case 3:
compute_3d(ecalc, tuple, e, result);
break;
case 4:
compute_4d(ecalc, tuple, e, result);
break;
default:
throw SymmetricDeltaException("compute",
"Unsupported tuple size " +
std::to_string(size) +
", valid range [2,4]");
}
}
const std::vector<std::string> names_d2 = {"v0","v1","SymmetricDelta"};
const std::vector<std::string> names_d3 = {"v0","v1","v2","SymmetricDelta"};
const std::vector<std::string> names_d4 = {"v0","v1","v2","v3","SymmetricDelta"};
const std::vector<std::string> names_d2_full = {"v0","v1","entropy0","entropy1","entropy01","SymmetricDelta"};
const std::vector<std::string> names_d3_full = {"v0","v1","v2",
"entropy0" ,"entropy1"
,"entropy2" ,"entropy01"
,"entropy02" ,"entropy12"
,"entropy012" ,"jointInfo01"
,"jointInfo02" ,"jointInfo12"
,"jointInfo012" ,"diffInfo0"
,"diffInfo1" ,"diffInfo2"
,"SymmetricDelta"};
const std::vector<std::string> names_d4_full = {"v0","v1","v2","v3"
,"entropy0" ,"entropy1" ,"entropy2" ,"entropy3"
,"entropy01" ,"entropy02" ,"entropy03" ,"entropy12"
,"entropy13" ,"entropy23" ,"entropy012" ,"entropy013"
,"entropy023" ,"entropy123" , "entropy0123" ,"jointInfo012"
,"jointInfo013" ,"jointInfo023" ,"jointInfo123"
,"diffInfo0" ,"diffInfo1" ,"diffInfo2" ,"diffInfo3"
,"SymmetricDelta"};
std::vector<std::string> const&
SymmetricDelta::names(int d, bool full_output) const
{
switch (d) {
case 2:
return (full_output) ? names_d2_full : names_d2;
break;
case 3:
return (full_output) ? names_d3_full : names_d3;
break;
case 4:
return (full_output) ? names_d4_full : names_d4;
break;
default:
throw SymmetricDeltaException("names",
"Unsupported tuple size " +
std::to_string(d) +
", valid range [2,4]");
}
}
std::string
SymmetricDelta::header(int d, bool full_output) const
{
auto n = names(d,full_output);
std::string h = n.front();
auto N = n.size();
for (int ii = 1; ii < N; ii++) {
h += "," + n[ii];
}
return h;
}
| 32.515625 | 110 | 0.585135 | [
"vector"
] |
0c18a3488bb6dc6518222fee73c2a655687e30df | 1,422 | cpp | C++ | src/app/shmurp/System/Collision.cpp | FranzPoize/shmurp | 354a70fd89d0cdd9b4336961ad01d1567ac22474 | [
"Unlicense"
] | 1 | 2021-04-06T08:48:31.000Z | 2021-04-06T08:48:31.000Z | src/app/shmurp/System/Collision.cpp | FranzPoize/shmurp | 354a70fd89d0cdd9b4336961ad01d1567ac22474 | [
"Unlicense"
] | null | null | null | src/app/shmurp/System/Collision.cpp | FranzPoize/shmurp | 354a70fd89d0cdd9b4336961ad01d1567ac22474 | [
"Unlicense"
] | 1 | 2021-03-31T13:17:54.000Z | 2021-03-31T13:17:54.000Z | #include "Collision.h"
#include <Components/Health.h>
namespace ad {
Collision::Collision(aunteater::Engine &aEngine,
EventQueue<shmurp::event::Impact> & aImpactEvents) :
mEngine(aEngine),
mImpactEvents(aImpactEvents),
mColliders(mEngine)
{}
void Collision::update(const aunteater::Timer aTimer)
{
for(auto attacker : mColliders)
{
for(auto defender : mColliders)
{
// Note: this loop currently tests each pair two times, since it is "ordered"
// (attacher-defender, then the defender becomes the attacker the second time around)
// This is a bad pessimisation, but saves us from testing the symmetric isAttacking
// during the same iteration
if( (attacker->get<Faction>().isAttacking(defender->get<Faction>()))
&& (attacker->get<Geometry>().isColliding(defender->get<Geometry>())) )
{
handleCollision(defender, attacker->get<Faction>());
}
}
}
}
void Collision::handleCollision(aunteater::weak_entity aDefender, const Faction & aAttackerFaction)
{
if (aDefender->has<Health>())
{
mImpactEvents.emplace_back(entityIdFrom(aDefender),
shmurp::event::Impact{aAttackerFaction.attackValue});
}
else
{
mEngine.markToRemove(aDefender);
}
}
} // namespace ad
| 27.882353 | 99 | 0.615331 | [
"geometry"
] |
0c1bdf708435f6d81ed76627b5cb49c24cd209f9 | 13,869 | hpp | C++ | include/eepp/graphics/csprite.hpp | dogtwelve/eepp | dd672ff0e108ae1e08449ca918dc144018fb4ba4 | [
"MIT"
] | null | null | null | include/eepp/graphics/csprite.hpp | dogtwelve/eepp | dd672ff0e108ae1e08449ca918dc144018fb4ba4 | [
"MIT"
] | null | null | null | include/eepp/graphics/csprite.hpp | dogtwelve/eepp | dd672ff0e108ae1e08449ca918dc144018fb4ba4 | [
"MIT"
] | null | null | null | #ifndef EE_GRAPHICSCSPRITE_HPP
#define EE_GRAPHICSCSPRITE_HPP
#include <eepp/graphics/base.hpp>
#include <eepp/graphics/ctexturefactory.hpp>
#include <eepp/graphics/csubtexture.hpp>
#include <eepp/graphics/ctextureatlas.hpp>
namespace EE { namespace Graphics {
/** @brief A Sprite controller class, can hold and control sprites animations. */
class EE_API cSprite {
public:
/// Event ID - Sprite - User Data
typedef cb::Callback3< void, Uint32, cSprite *, void * > SpriteCallback;
/** @brief SpriteEvents The events that can be reported by the Sprite */
enum SpriteEvents {
SPRITE_EVENT_LAST_FRAME,
SPRITE_EVENT_FIRST_FRAME,
SPRITE_EVENT_END_ANIM_TO,
SPRITE_EVENT_USER // User Events
};
/** Instanciate an empty sprite */
cSprite();
/** Creates an animated Sprite from a animation name. It will search for a pattern name.
* For example search for name "car" with extensions "png", i will try to find car00.png car01.png car02.png, and so on, it will continue if find something, otherwise it will stop ( it will always search at least for car00.png and car01.png ).
* @param name First part of the sub texture name
* @param extension Extension of the sub texture name ( if have one, otherwise is empty )
* @param SearchInTextureAtlas If you want only to search in a especific atlas ( NULL if you want to search in all atlases )
* @note Texture atlases saves the SubTextures names without extension by default.
* @see cTextureAtlasManager::GetSubTexturesByPattern
*/
cSprite( const std::string& name, const std::string& extension = "", cTextureAtlas * SearchInTextureAtlas = NULL );
/** Creates a Sprite from a SubTexture
** @param SubTexture The subtexture to use */
cSprite( cSubTexture * SubTexture );
/** Creates a Sprite instance that holds a new SubTexture from a texture already loaded.
* @param TexId The texture Id used to create the SubTexture
* @param DestSize The destination size of the SubTexture created
* @param Offset The offset added to the position of the frame ( the SubTexture )
* @param TexSector The sector of the texture used by the SubTexture to be rendered
*/
cSprite( const Uint32& TexId, const eeSizef &DestSize = eeSizef(0,0), const eeVector2i &Offset = eeVector2i(0,0), const eeRecti& TexSector = eeRecti(0,0,0,0) );
virtual ~cSprite();
cSprite& operator =( const cSprite& Other );
/** Set the x axis position */
void X( const eeFloat& X );
/** @return The x axis position */
eeFloat X() const;
/** Set the y axis position */
void Y( const eeFloat& Y );
/** @return The y axis position */
eeFloat Y() const;
/** Set the Angle for the rendered sprite */
void Angle( const eeFloat& Angle );
/** @return The Angle for the rendered sprite */
eeFloat Angle() const;
/** Rotates the sprite. Adds the new angle to the current rotation. Same as:
** @code sprite.Angle( sprite.Angle() + angle ); @endcode */
void Rotate( const eeFloat& angle );
/** Set the Scale for the rendered sprite */
void Scale( const eeFloat& Scale );
/** Set the Scale for the rendered sprite */
void Scale( const eeVector2f& Scale );
/** @return The Scale for the rendered sprite */
const eeVector2f& Scale() const;
/** @brief Set the local origin of the sprite
** The origin of an object defines the center point for
** all transformations (scale, rotation).
** The coordinates of this point must be relative to the
** top-left corner of the sprite.
** The default origin point is the center of the sprite. */
void Origin( const eeOriginPoint& origin );
/** @return The local origin of the sprite */
const eeOriginPoint& Origin() const;
/** Set the Frame Number Sprite Size
* @param Size The new size
* @param FrameNum If the Frame Number is 0 it will use the Current Frame Number
* @param SubFrame If the Sub Frame Number is 0 it will use the Current Sub Frame Number
*/
void Size( const eeSizef& Size, const eeUint& FrameNum, const eeUint& SubFrame );
/** Set the current SubTexture Size ( destination size ) */
void Size( const eeSizef& Size );
/** @return the Frame Number Sprite Size
* @param FrameNum If the Frame Number is 0 it will use the Current Frame Number
* @param SubFrame If the Sub Frame Number is 0 it will use the Current Sub Frame Number
*/
eeSizef Size( const eeUint& FrameNum, const eeUint& SubFrame );
/** @return The current Frame Size */
eeSizef Size();
/** Set the sprite animation speed ( AnimSpeed equals to Animation Frames per Second ) */
void AnimSpeed( const eeFloat& AnimSpeed );
/** @return The sprite animation speed ( AnimSpeed equals to Animation Frames per Second ) */
eeFloat AnimSpeed() const;
/** @return If the animation is paused */
bool AnimPaused() const;
/** Set the animation paused or not */
void AnimPaused( const bool& Pause );
/** Set the sprite color */
void Color( const eeColorA& Color);
/** @return The sprite color */
const eeColorA& Color() const;
/** Set the sprite Color Alpha */
void Alpha( const Uint8& Alpha );
/** @return The sprite Color Alpha */
const Uint8& Alpha() const;
/** Set the Current Frame */
void CurrentFrame( eeUint CurFrame );
/** @return The Current Frame */
const eeUint& CurrentFrame() const;
/** @return The Exact Current FrameData
* @return The eeFloat fpoint of the current frame, the exact position of the interpolation.
*/
const eeFloat& ExactCurrentFrame() const;
/** Set the exact current FrameData */
void ExactCurrentFrame( const eeFloat& CurrentFrame );
/** Set the Current Sub Frame */
void CurrentSubFrame( const eeUint &CurSubFrame );
/** @return The Current Sub Frame */
const eeUint& CurrentSubFrame() const;
/** Set the Render Type */
void RenderMode( const EE_RENDER_MODE& Effect );
/** @return The Render Type */
const EE_RENDER_MODE& RenderMode() const;
/** Set the Blend Mode */
void BlendMode( const EE_BLEND_MODE& Blend );
/** @return The Blend Mode */
const EE_BLEND_MODE& BlendMode() const;
/** Reset the sprite as a new one. */
void Reset();
/** @return The AABB (axis-aligned bounding box) */
eeAABB GetAABB();
/** Set the sprite position */
void Position( const eeFloat& x, const eeFloat& y );
/** Set the sprite position from a Vector */
void Position( const eeVector2f& NewPos );
/** @return The Position of the sprite */
const eeVector2f Position() const;
/** Update the colors of every vertex rendered of the sprite ( this will override the default color )
* @param Color0 The Left - Top vertex color
* @param Color1 The Left - Bottom vertex color
* @param Color2 The Right - Bottom vertex color
* @param Color3 The Right - Top vertex color
*/
void UpdateVertexColors( const eeColorA& Color0, const eeColorA& Color1, const eeColorA& Color2, const eeColorA& Color3 );
/** This will disable the vertex colors */
void DisableVertexColors();
/** Creates an static sprite (no animation)
* @param SubTexture The sprite SubTexture
* @return True if success
*/
bool CreateStatic( cSubTexture * SubTexture );
/** Creates an static sprite (no animation). It creates a new SubTexture.
* @param TexId The internal Texture Id
* @param DestSize The destination size of the SubTexture created
* @param Offset The offset added to the position of the frame ( the SubTexture )
* @param TexSector The texture sector to be rendered ( default all the texture )
* @return True if success
*/
bool CreateStatic(const Uint32& TexId, const eeSizef &DestSize = eeSizef(0,0), const eeVector2i &Offset = eeVector2i(0,0), const eeRecti& TexSector = eeRecti(0,0,0,0) );
/** Creates an animated sprite
* @param SubFramesNum The number of subframes of the sprite
*/
void CreateAnimation( const eeUint& SubFramesNum = 1 );
/** Add a frame to the sprite (on the current sub frame)
* @param TexId The internal Texture Id
* @param DestSize The destination size of the frame
* @param Offset The offset added to the position of the frame
* @param TexSector The texture sector to be rendered ( default all the texture )
* @return The frame position or 0 if fails
*/
eeUint AddFrame( const Uint32& TexId, const eeSizef& DestSize = eeSizef(0,0), const eeVector2i& Offset = eeVector2i(0,0), const eeRecti& TexSector = eeRecti(0,0,0,0) );
/** Add a frame to the sprite (on the current sub frame)
* @param SubTexture The SubTexture used in the frame
* @return The frame position or 0 if fails
*/
eeUint AddFrame( cSubTexture * SubTexture );
/** Add a vector of SubTexture as an animation.
* @param SubTextures The Frames
*/
bool AddFrames( const std::vector<cSubTexture*> SubTextures );
/** @see cTextureAtlasManager::GetSubTexturesByPattern */
bool AddFramesByPattern( const std::string& name, const std::string& extension = "", cTextureAtlas * SearchInTextureAtlas = NULL );
bool AddFramesByPatternId( const Uint32& SubTextureId, const std::string& extension, cTextureAtlas * SearchInTextureAtlas );
/** Add a frame on an specific subframe to the sprite
* @param TexId The internal Texture Id
* @param NumFrame The Frame Number
* @param NumSubFrame The Sub Frame Number
* @param DestSize The destination size of the frame
* @param Offset The offset added to the x position of the frame
* @param TexSector The texture sector to be rendered ( default all the texture )
* @return True if success
*/
bool AddSubFrame( const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeSizef& DestSize = eeSizef(0,0), const eeVector2i& Offset = eeVector2i(0,0), const eeRecti& TexSector = eeRecti(0,0,0,0) );
/** Add a frame on an specific subframe to the sprite
* @param SubTexture The SubTexture used in the frame
* @param NumFrame The Frame Number
* @param NumSubFrame The Sub Frame Number
* @return True if success
*/
bool AddSubFrame( cSubTexture * SubTexture, const eeUint& NumFrame, const eeUint& NumSubFrame );
/** Draw the sprite to the screen */
void Draw();
/** Draw the sprite to the screen forcing the Blend Mode and the Render Type
* @param Blend The Blend Mode
* @param Effect The Render Type
*/
void Draw( const EE_BLEND_MODE& Blend, const EE_RENDER_MODE& Effect );
/** Draw the sprite to the screen forcing the Blend Mode
* @param Blend The Blend Mode
*/
void Draw( const EE_BLEND_MODE& Blend );
/** Draw the sprite to the screen forcing the Render Type
* @param Effect The Render Type
*/
void Draw( const EE_RENDER_MODE& Effect );
/** Set the number of repeations of the animation. Any number below 0 the animation will loop. */
void SetRepeations( const int& Repeations );
/** Set if the class auto-animate the sprite ( default it's active ) */
void AutoAnimate( const bool& Autoanim );
/** @return If the class is auto-animated */
bool AutoAnimate() const;
/** @return The four vertex position of the Sprite */
eeQuad2f GetQuad();
/** @return The Offset of the current frame */
eeVector2i Offset();
/** Set the Offset of the current frame */
void Offset( const eeVector2i& offset );
/** Reverse the animation from last frame to first mFrames. */
void ReverseAnim( const bool& Reverse );
/** @return If the animation is reversed */
bool ReverseAnim() const;
/** @return The current last frame */
eeUint GetEndFrame();
/** @return The number of frames */
Uint32 GetNumFrames();
/** Will set Reverse active and set the first frame as the last frame */
void SetReverseFromStart();
/** @return The Current SubTexture */
cSubTexture * GetCurrentSubTexture();
/** @return The SubTexture Frame from the current sub frame */
cSubTexture * GetSubTexture( const eeUint& frame );
/** @return The SubTexture Frame from the SubFrame */
cSubTexture * GetSubTexture( const eeUint& frame, const eeUint& SubFrame );
/** Start playing from
** @param GoTo Frame that goes from 1 to Number of Frames
*/
void GoToAndPlay( Uint32 GoTo );
/** Go to a frame and stop
** @param GoTo Frame that goes from 1 to Number of Frames
*/
void GoToAndStop( Uint32 GoTo );
/** Animate to frame and when reach the frame stops */
void AnimToFrameAndStop( Uint32 GoTo );
/** Set the sprite events callback */
void SetEventsCallback( const SpriteCallback& Cb, void * UserData = NULL );
/** Removes the current callback */
void ClearCallback();
/** Creates a copy of the current sprite and return it */
cSprite * Copy();
/** Update the sprite animation */
void Update( const cTime& ElapsedTime );
/** Update the sprite animation using the current elapsed time provided by cEngine */
void Update();
/** Fire a User Event in the sprite */
void FireEvent( const Uint32& Event );
protected:
enum SpriteFlags {
SPRITE_FLAG_AUTO_ANIM = ( 1 << 0 ),
SPRITE_FLAG_REVERSE_ANIM = ( 1 << 1 ),
SPRITE_FLAG_ANIM_PAUSED = ( 1 << 2 ),
SPRITE_FLAG_ANIM_TO_FRAME_AND_STOP = ( 1 << 3 ),
SPRITE_FLAG_EVENTS_ENABLED = ( 1 << 4 )
};
Uint32 mFlags;
eeVector2f mPos;
eeOriginPoint mOrigin;
eeFloat mAngle;
eeVector2f mScale;
eeFloat mAnimSpeed;
eeColorA mColor;
eeColorA * mVertexColors;
eeInt mRepeations; //!< Number of repetions of the animation, default -1 that equals to loop.
EE_BLEND_MODE mBlend;
EE_RENDER_MODE mEffect;
eeUint mCurrentFrame;
eeFloat mfCurrentFrame;
eeUint mCurrentSubFrame;
eeUint mSubFrames;
eeUint mAnimTo;
SpriteCallback mCb;
void * mUserData;
class cFrame {
public:
std::vector<cSubTexture *> Spr;
};
std::vector<cFrame> mFrames;
eeUint FramePos();
void ClearFrame();
eeUint GetFrame( const eeUint& FrameNum );
eeUint GetSubFrame( const eeUint& SubFrame );
};
}}
#endif
| 34.414392 | 244 | 0.702718 | [
"render",
"object",
"vector"
] |
0c280c4a5c075507a4e8acd753ecc522078b6eec | 15,467 | cpp | C++ | C++/Solution.cpp | niyaoyao/leetcode-practice | 9377e14824d52b589fc9379a350c9f6c97c4c834 | [
"MIT"
] | 1 | 2019-12-26T02:11:38.000Z | 2019-12-26T02:11:38.000Z | C++/Solution.cpp | niyaoyao/leetcode-practice | 9377e14824d52b589fc9379a350c9f6c97c4c834 | [
"MIT"
] | null | null | null | C++/Solution.cpp | niyaoyao/leetcode-practice | 9377e14824d52b589fc9379a350c9f6c97c4c834 | [
"MIT"
] | null | null | null | // Solution.cpp
#include "Solution.h"
#include <cmath>
void printMap (std::map<char, int> stringMap) {
for (auto &v : stringMap) {
cout << v.first;
}
cout << "\n";
for (auto &v : stringMap) {
cout << v.second << " ";
}
cout << "\n" << endl;
}
vector<int> Solution::twoSum(vector<int>& nums, int target) {
std::vector<int> result;
std::map<int, int> temp;
for (std::vector<int>::iterator i = nums.begin(); i != nums.end(); ++i)
{
int diff = target - *i;
cout << "diff:" << diff << " = " << target << "-" << *i << endl;
// vector<int>::iterator ite1 = find(nums.begin(), nums.end(), *i);
// auto index = std::distance(std::begin(nums), ite1);
int index = i - nums.begin();
if (temp.find(diff) != temp.end()) {
int key = temp[diff];
cout << "Found:" << " nums[" << index << "] = " << *i << " + " << nums[key] << "=" << target << endl;
if (nums[key] + *i == target)
{
result.push_back(key);
result.push_back(index);
return result;
} else {
continue;
}
}
temp[*i] = index;
cout << "*i" << ":" << *i << " temp["<< diff <<"]:" << temp[diff] << " index:" << index << endl;
}
return result;
}
ListNode* Solution::addTwoNumbers(ListNode* l1, ListNode* l2) {
ListNode *dummyHead = new ListNode(0);
ListNode *p = l1;
ListNode *q = l2;
ListNode *current = dummyHead;
int carry = 0;
while (p != NULL || q != NULL) {
int x = (p != NULL) ? p->val : 0;
int y = (q != NULL) ? q->val : 0;
int sum = carry + x + y;
carry = sum / 10;
current->next = new ListNode(sum % 10);
current = current->next;
if (p != NULL)
{
p = p->next;
}
if (q != NULL)
{
q = q->next;
}
}
if (carry > 0)
{
current->next = new ListNode(carry);
}
return current;
}
ListNode* Solution::ny_addTwoNumbers(ListNode* l1, ListNode* l2) {
ListNode *p = l1;
ListNode *q = p;
ListNode *k = l2;
ListNode *j = k;
ListNode *l = NULL;
ListNode *h = l;
ListNode *w = h;
int upNum = 0;
while(p != NULL || k != NULL || upNum > 0) {
int sum = 0;
sum += upNum;
upNum = 0;
if (p != NULL) {
sum += p->val;
q = p;
p = p->next;
}
if (k != NULL) {
sum += k->val;
j = k;
k = k->next;
}
int value = sum;
if (sum >= 10) {
upNum = sum / 10;
int left = sum - upNum * 10;
left = abs(left);
value = left;
}
ListNode *n = new ListNode(value);
if (l == NULL) {
l = n;
h = l;
w = h;
} else {
h->next = n;
w = h;
h = h -> next;
}
}
return l;
}
int Solution::ny_lengthOfLongestSubstring(string s) {
int maxLength = 0;
std::map<char, int> stringMap;
int sameIndex = 0;
cout << "NY String:" << s << endl;
for (int i = 0; i < s.length(); i++) {
cout << "\nCurrent: s[i]=" << s[i] << endl;
if (stringMap[s[i]])
{
sameIndex = stringMap[s[i]];
i = sameIndex;
stringMap = map<char, int>();
} else {
stringMap[s[i]] = i;
}
maxLength = stringMap.size() > maxLength ? stringMap.size() : maxLength;
}
return maxLength;
}
int Solution::lengthOfLongestSubstring(string s) {
int maxLength = 0, i = 0, j = 0;
std::set<char> characterSet;
cout << "\nString: " << s << endl;
while (i < s.length() && j < s.length()) {
cout << "Current: s[i]=" << s[i] << " Current s[j]=" << s[j] << endl;
if (!(characterSet.find(s[j]) != characterSet.end()))
{
cout << "Not Contain Character" << endl;
characterSet.insert(s[j++]);
maxLength = max(maxLength, j-i);
} else {
characterSet.erase(s[i++]);
}
set<char>::iterator it;
for(it = characterSet.begin(); it != characterSet.end(); it++)
cout << (*it);
cout << " " << endl;
}
return maxLength;
}
int Solution::lengthOfLongestSubstringOptimize(string s) {
int maxLength = 0;
std::map<char, int> charMap;
cout << "\nString: " << s << endl;
int n = s.length();
for (int i = 0, j = 0; j < n; j++)
{
cout << "\nCurrent: s[i("<<i<<")]=" << s[i] << " Current s[j("<<j<<")]=" << s[j] << endl;
if (charMap.find(s[j]) != charMap.end())
{
cout << "Contain:" << s[j] << " charMap["<< s[j] <<"]=" << charMap[s[j]] << " i=" << i << endl;
i = max(charMap[s[j]], i);
}
maxLength = max(maxLength, j - i + 1);
cout << "Max Length:" << maxLength << endl;
charMap[s[j]] = j + 1;
}
return maxLength;
}
void Solution::insertTreeNode(TreeNode *&p, int val) {
cout << "Insert:" << val << endl;
if (p == NULL) {
p = new TreeNode(val);
}
else if (val <= p->val) {
insertTreeNode(p->left, val);
}
else {
insertTreeNode(p->right, val);
return;
}
}
void Solution::traverseTree(TreeNode *t) {
if (t != NULL)
{ // In-Order Traversal
traverseTree(t->left);
cout << t->val << "/";
traverseTree(t->right);
}
}
void Solution::sortArray(TreeNode *t, std::vector<int> &v) {
if (t != NULL)
{
sortArray(t->left, v);
v.push_back(t->val);
sortArray(t->right, v);
}
}
double Solution::medianOfSortedArray(vector<int>& nums) {
double result = 0.0;
if (nums.size() % 2 == 1)
{
int index = (nums.size() + 1) / 2 - 1;
result = (double)nums.at(index);
cout << "Odd Number:" << nums.at(index) << endl;
} else {
int i0 = nums.size() / 2 - 1;
int i1 = nums.size() / 2;
double sum = (double)nums.at(i0) + (double)nums.at(i1);
cout << "sum: " << sum << endl;
result = (double)(sum) / 2.0;
cout << "Even Number: 1/2*(" << nums.at(i0) << "+" << nums.at(i1) << ") = " << result << endl;
}
return result;
}
double Solution::ny_findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
double result = 0.0;
std::vector<int> unsortVector;
unsortVector.insert(unsortVector.end(), nums1.begin(), nums1.end());
unsortVector.insert(unsortVector.end(), nums2.begin(), nums2.end());
TreeNode *t = NULL;
for (std::vector<int>::iterator i = unsortVector.begin(); i < unsortVector.end(); ++i)
{
insertTreeNode(t, *i);
}
std::vector<int> sortedArray;
sortArray(t, sortedArray);
cout << "====== Finish Sort ======" << endl;
for (std::vector<int>::iterator i = sortedArray.begin(); i != sortedArray.end(); ++i)
{
cout << *i << " ";
}
result = medianOfSortedArray(sortedArray);
return result;
}
double Solution::findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
double result = 0.0;
std::vector<int> unsortVector;
unsortVector.insert(unsortVector.end(), nums1.begin(), nums1.end());
unsortVector.insert(unsortVector.end(), nums2.begin(), nums2.end());
TreeNode *t = NULL;
for (std::vector<int>::iterator i = unsortVector.begin(); i < unsortVector.end(); ++i)
{
insertTreeNode(t, *i);
}
std::vector<int> sortedArray;
sortArray(t, sortedArray);
result = medianOfSortedArray(sortedArray);
return result;
}
/// sortArrayMinimum
void Solution::sortArrayMinimum(TreeNode *t, std::vector<int> &v, int &min) {
if (t != NULL)
{
sortArrayMinimum(t->left, v, min);
if (v.size() > 0 && (t->val - v.back() < min)) {
min = t->val - v.back();
cout << "sort min:" << min << endl;
}
v.push_back(t->val);
sortArrayMinimum(t->right, v, min);
}
}
vector<vector<int>> Solution::minimumAbsDifference(vector<int>& arr) {
vector<vector<int>> v;
TreeNode *t = NULL;
int maxDiff = 0;
for (std::vector<int>::iterator i = arr.begin(); i < arr.end(); ++i)
{
insertTreeNode(t, *i);
if (i != arr.begin()) {
int diff = (*i - *(i-1));
if (diff > maxDiff) {
maxDiff = diff;
}
}
}
std::vector<int> sortedArray;
int minDiff = maxDiff;
cout << "min:" << minDiff << endl;
sortArrayMinimum(t, sortedArray, minDiff);
cout << "min:" << minDiff << endl;
for (std::vector<int>::iterator i = sortedArray.begin(); i != sortedArray.end(); ++i)
{
cout << "" << *i << " ";
std::vector<int> pair;
if (i != sortedArray.begin()) {
int diff = *i - *(i-1);
if ( diff <= minDiff ) {
pair.push_back(*(i-1));
pair.push_back(*(i));
v.push_back(pair);
}
}
}
cout << "\n" << endl;
for (std::vector<vector<int>>::iterator i = v.begin(); i != v.end(); ++i)
{
std::vector<int> temp = *i;
cout << "[";
for (std::vector<int>::iterator j = temp.begin(); j != temp.end(); ++j)
{
cout << *j;
cout << ",";
}
cout << "]";
}
return v;
}
/**
* Longest Palindrome
*/
string longestPalindrome(string s) {
string result;
return result;
}
int Solution::maxScore(string s) {
int maxScore = 0;
int leftScore = 0;
int leftOneCount = 0;
int rightScore = 0;
int zeroCount = 0;
int oneCount = 0;
char one = '1';
char zero = '0';
printf("1:%d 0:%d \n", one, zero);
for (int i = 0; i < s.length(); ++i)
{
printf("%c\t", s[i]);
char c = s[i];
if (c == zero)
{
zeroCount++;
} else if (c == one) {
oneCount++;
}
}
printf("\nCount one:%d zero:%d \n", oneCount, zeroCount);
int leftStringCount, rightStringCount = 0;
for (int i = 0; i < s.length(); ++i)
{
char c = s[i];
if (c == zero)
{
leftScore++;
leftStringCount++;
} else if (c == one) {
leftOneCount++;
}
leftStringCount = i + 1;
rightStringCount = s.length() - leftStringCount;
int currentScore = 0;
if ((leftStringCount > 0 && leftStringCount < s.length()) || (rightStringCount > 0 && rightStringCount < s.length()))
{
rightScore = oneCount - leftOneCount;
int currentScore = leftScore + rightScore;
maxScore = currentScore > maxScore ? currentScore : maxScore;
}
printf("current:%c leftScore:%d rightScore:%d leftOneCount:%d currentScore:%d maxScore:%d leftString:%d right:%d \n", s[i], leftScore, rightScore, leftOneCount, currentScore, maxScore, leftStringCount, rightStringCount);
}
return maxScore;
}
int Solution::singleNumber(vector<int>& nums) {
int result;
std::map<int, int> charMap;
for (std::vector<int>::iterator i = nums.begin(); i != nums.end(); ++i)
{
if (!charMap[*i])
{
charMap[*i] = 1;
} else {
charMap[*i] += 1;
}
}
for (auto &v : charMap) {
if (v.second == 1)
{
result = v.first;
}
}
return result;
}
bool Solution::isHappy(int n) {
cout << "n:" << n << endl;
std::map<int, int> numberMap;
while(n > 1 && numberMap[n] == 0) {
numberMap[n] = n;
n = perfectDigitalInvariant(n, 10);
cout << "number: " << n << endl;
}
return n == 1;
}
int Solution::perfectDigitalInvariant(int number, int base) {
int total = 0;
while(number > 0) {
total = total + pow(number % base, 2);
cout << "total:" << total << endl;
number = number / base;
}
return total;
}
int Solution::maxSubArray(vector<int>& nums) {
int sum = 0;
int max = nums.at(0);
for (std::vector<int>::iterator i = nums.begin(); i != nums.end(); ++i)
{
max = *i > max ? *i : max;
cout << "max:" << max << endl;
}
return max;
}
vector<int> Solution::shuffle(vector<int>& nums, int n) {
int i = 0;
int j = i + n;
std::vector<int> v;
while(v.size() < 2 * n) {
v.push_back(nums[i]);
j = i + n;
v.push_back(nums[j]);
++i;
}
return v;
}
ListNode* Solution::reverseList(ListNode* head) {
cout << "h:" << head->val << endl;
ListNode *result = NULL;
ListNode *p = head;
ListNode *q = p;
ListNode *l = NULL;
cout << "p:" << p << endl;
std::stack<int> temp;
while(p != NULL) {
cout << "p->v:" << p->val << endl;
cout << p->val << endl;
temp.push(p->val);
q = p;
p = p->next;
}
while(!temp.empty()) {
cout << temp.top() << endl;
if (result == NULL)
{
/* code */
result = new ListNode(temp.top());
p = result;
q = result;
} else {
l = new ListNode(temp.top());
p->next = l;
q = p;
p = p->next;
}
temp.pop();
}
return result;
}
Node* Solution::copyRandomList(Node* head) {
Node *p = head;
Node *q = NULL;
Node *result = NULL;
Node *l = NULL;
Node *m = NULL;
Node *n = NULL;
std::vector<Node *> randomNodes;
std::vector<Node *> copiedNodes;
std::map<Node *, int> nodeIndex;
std::vector<int> randomNodeIndex;
int i = 0;
while(p != NULL) {
int v = p->val;
nodeIndex[p] = i+1;
randomNodes.push_back(p->random);
cout <<"\np: " << p << " p->val: " << v << " p->random: " << p->random << endl;
q = p;
p = p->next;
// cout << "\n\ncreate copy list:" << endl;
if (i == 0) {
result = new Node(v);
m = result;
copiedNodes.push_back(result);
} else {
l = new Node(v);
m->next = l;
n = m;
m = m->next;
copiedNodes.push_back(l);
}
++i;
}
for (std::vector<Node *>::iterator it = randomNodes.begin(); it != randomNodes.end(); ++it) {
int index = -1;
if (nodeIndex[*it] > 0) {
index = nodeIndex[*it] - 1;
}
randomNodeIndex.push_back(index);
}
// for (std::vector<int>::iterator it = randomNodeIndex.begin(); it != randomNodeIndex.end(); ++it) {
// cout << "randomNodeIndex: " << *it << endl;
// }
p = result;
i = 0;
while (p != NULL) {
int index = randomNodeIndex[i];
p->random = index < 0 ? NULL : copiedNodes[index];
cout << "\n" << "result: " << p << " result->v: " << p->val << " result->random: "<< p->random << endl;
q = p;
p = p->next;
++i;
}
return result;
}
int Solution::maxLength(vector<string>& arr) {
int maxL = 0;
string s = string();
cout << "s: " << s << "size:" << s.length() << endl;
for (std::vector<string>::iterator it = arr.begin(); it != arr.end(); it++ ) {
cout << *it << endl;
s = s + *it;
}
cout << "s: " << s << " size:" << s.length() << endl;
return maxL;
}
| 24.987076 | 228 | 0.477339 | [
"vector"
] |
0c328595ea42fce9308702f5309656d4a511191f | 1,103 | cpp | C++ | jobs/source/UpdateJobExecutionSubscriptionRequest.cpp | chsajjwal/aws-iot-device-sdk-cpp-v2 | 4cce62fc5f35589c3476f3542329ac4fa56722ec | [
"Apache-2.0"
] | 11 | 2019-03-14T06:20:44.000Z | 2019-10-14T21:55:17.000Z | jobs/source/UpdateJobExecutionSubscriptionRequest.cpp | chsajjwal/aws-iot-device-sdk-cpp-v2 | 4cce62fc5f35589c3476f3542329ac4fa56722ec | [
"Apache-2.0"
] | 50 | 2019-02-22T08:34:49.000Z | 2019-11-21T03:44:11.000Z | jobs/source/UpdateJobExecutionSubscriptionRequest.cpp | chsajjwal/aws-iot-device-sdk-cpp-v2 | 4cce62fc5f35589c3476f3542329ac4fa56722ec | [
"Apache-2.0"
] | 7 | 2019-02-28T17:32:18.000Z | 2019-09-27T18:02:46.000Z | /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*
* This file is generated
*/
#include <aws/iotjobs/UpdateJobExecutionSubscriptionRequest.h>
namespace Aws
{
namespace Iotjobs
{
void UpdateJobExecutionSubscriptionRequest::LoadFromObject(
UpdateJobExecutionSubscriptionRequest &val,
const Aws::Crt::JsonView &doc)
{
(void)val;
(void)doc;
}
void UpdateJobExecutionSubscriptionRequest::SerializeToObject(Aws::Crt::JsonObject &object) const
{
(void)object;
}
UpdateJobExecutionSubscriptionRequest::UpdateJobExecutionSubscriptionRequest(const Crt::JsonView &doc)
{
LoadFromObject(*this, doc);
}
UpdateJobExecutionSubscriptionRequest &UpdateJobExecutionSubscriptionRequest::operator=(
const Crt::JsonView &doc)
{
*this = UpdateJobExecutionSubscriptionRequest(doc);
return *this;
}
} // namespace Iotjobs
} // namespace Aws
| 27.575 | 110 | 0.640979 | [
"object"
] |
0c35dfc7fffdb3ee7f9cee510c6f470025548423 | 1,871 | cpp | C++ | day16/CPP/day16_A.cpp | prabhigupta/instaBlog | 02f219ea278d85c7799d739294c664aa5a47719a | [
"Apache-2.0"
] | null | null | null | day16/CPP/day16_A.cpp | prabhigupta/instaBlog | 02f219ea278d85c7799d739294c664aa5a47719a | [
"Apache-2.0"
] | 1 | 2021-12-25T19:22:09.000Z | 2021-12-25T19:22:09.000Z | day16/CPP/day16_A.cpp | prabhigupta/AOC2021 | 02f219ea278d85c7799d739294c664aa5a47719a | [
"Apache-2.0"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int final_answer = 0;
vector<int> hex_to_bin(string &hex){
vector<int> answer;
for(auto i : hex){
int value;
if('0' <= i && i <= '9'){
value = i - '0';
}
else{
value = 10 + i - 'A';
}
vector<int> dummy;
for(int i = 0; i < 4; i++){
dummy.push_back(value % 2);
value /= 2;
}
reverse(dummy.begin(), dummy.end());
for(int i = 0; i < 4; i++){
answer.push_back(dummy[i]);
}
}
return answer;
}
int bin_to_dec(vector<int>& binary, int src, int end){
int answer = 0;
int counter = 1;
for(int i = end; i >= src; i--){
answer += binary[i] * counter;
counter *= 2;
}
return answer;
}
int parse(vector<int>& binary, int src){
int index = src;
int packet_version = bin_to_dec(binary, index, index + 2);
final_answer += packet_version;
index += 3;
int type_id = bin_to_dec(binary, index, index + 2);
index = index + 3;
if(type_id == 4){
vector<int> dummy;
while(index <= binary.size()){
for(int i = 1; i <= 4; i++){
dummy.push_back(binary[index + i]);
}
if(binary[index] == 1){
index += 5;
}
else{
index += 5;
break;
}
}
}
else{
int length_type = binary[index++];
if(length_type == 0){
int length = bin_to_dec(binary, index, index + 14);
index += 15;
int next = index;
while(next < index + length){
next = parse(binary, next);
}
index = next;
}
else{
int length = bin_to_dec(binary, index, index + 10);
index += 11;
int next = index;
for(int i = 0; i < length; i++){
next = parse(binary, next);
}
index = next;
}
}
return index;
}
int main(){
ios_base::sync_with_stdio(false);
ifstream input_file("../Input/day16.txt");
string input;
input_file >> input;
vector<int> binary = hex_to_bin(input);
parse(binary, 0);
cout << "Puzzle 1: " << final_answer << endl;
} | 18.71 | 59 | 0.575094 | [
"vector"
] |
0c3a3621f8d92f51a1e7337d4ac68948ef266f52 | 6,248 | cpp | C++ | src/concurrency/lock_manager.cpp | star013/peloton | 0e1c5f32fde00529f19f7ff5f5e7d5b4979f06ef | [
"Apache-2.0"
] | null | null | null | src/concurrency/lock_manager.cpp | star013/peloton | 0e1c5f32fde00529f19f7ff5f5e7d5b4979f06ef | [
"Apache-2.0"
] | null | null | null | src/concurrency/lock_manager.cpp | star013/peloton | 0e1c5f32fde00529f19f7ff5f5e7d5b4979f06ef | [
"Apache-2.0"
] | null | null | null | //===----------------------------------------------------------------------===//
//
// Peloton
//
// lock_manager.cpp
//
// Identification: src/concurrency/lock_manager.cpp
//
// Copyright (c) 2015-18, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#include <boost/thread/shared_mutex.hpp>
#include "concurrency/lock_manager.h"
namespace peloton {
namespace concurrency {
//===--------------------------------------------------------------------===//
// Lock manager
//===--------------------------------------------------------------------===//
/**
* @brief Get the global variable instance of lock manager
* @return Pointer to the global lock manager instance
*/
LockManager *LockManager::GetInstance() {
static LockManager global_lm;
return &global_lm;
}
/**
* @brief Initialize lock for given oid
* @details Initialize lock for given oid. Currently,
* only supports read/write lock
* @param oid The oid of data table
* @param type The type of lock to initialize
* @return bool true if successful, false if not
*/
bool LockManager::InitLock(oid_t oid, LockManager::LockType /*type*/) {
// Need to lock internal lock to protect internal lock map
internal_rw_lock_.lock();
// Try to find the lock in table
boost::upgrade_mutex *lock = GetLock(oid);
if (lock != nullptr) {
internal_rw_lock_.unlock();
LOG_TRACE("Init lock failed, lock oid is %u.", oid);
return false;
}
// Initialize new lock for the object
std::pair<oid_t, std::shared_ptr<boost::upgrade_mutex> > p;
p.first = oid;
p.second = std::make_shared<boost::upgrade_mutex>();
// Insert lock into map
lock_map_.insert(p);
// Unlock internal lock
internal_rw_lock_.unlock();
LOG_TRACE("Init lock success.");
return true;
}
/**
* @brief Remove the lock specified by oid from data structure
* @param oid The oid of data table
* @return bool true if successful, false if not
*/
bool LockManager::RemoveLock(oid_t oid) {
// Need to lock internal lock to protect internal lock map
internal_rw_lock_.lock();
boost::upgrade_mutex *rw_lock = GetLock(oid);
if (rw_lock == nullptr) {
internal_rw_lock_.unlock();
LOG_TRACE("Remove lock failed, lock oid is %u.", oid);
return false;
}
lock_map_.erase(oid);
internal_rw_lock_.unlock();
LOG_TRACE("Remove lock success.");
return true;
}
/**
* @brief Acquire shared lock for RW_LOCK(blocking)
* @param oid The oid of data table
* @return bool true if successful, false if not
*/
bool LockManager::LockShared(oid_t oid) {
// Need to lock internal lock to protect internal lock map
internal_rw_lock_.lock_shared();
boost::upgrade_mutex *rw_lock = GetLock(oid);
if (rw_lock == nullptr) {
internal_rw_lock_.unlock_shared();
LOG_TRACE("Shared lock failed, lock oid is %u.", oid);
return false;
}
rw_lock->lock_shared();
internal_rw_lock_.unlock_shared();
LOG_TRACE("Shared lock success.");
return true;
}
/**
* @brief Acquire exclusive lock for RW_LOCK(blocking)
* @param oid The oid of data table
* @return bool true if successful, false if not
*/
bool LockManager::LockExclusive(oid_t oid) {
// Need to lock internal lock to protect internal lock map
internal_rw_lock_.lock_shared();
boost::upgrade_mutex *rw_lock = GetLock(oid);
if (rw_lock == nullptr) {
internal_rw_lock_.unlock_shared();
LOG_TRACE("Exclusive lock failed, lock oid is %u.", oid);
return false;
}
rw_lock->lock();
internal_rw_lock_.unlock_shared();
LOG_TRACE("Exclusive lock success.");
return true;
}
/**
* @brief Acquire exclusive lock for RW_LOCK(blocking)
* @param oid The oid of data table
* @return bool true if successful, false if not
*/
bool LockManager::LockToShared(oid_t oid) {
// Need to lock internal lock to protect internal lock map
internal_rw_lock_.lock_shared();
boost::upgrade_mutex *rw_lock = GetLock(oid);
if (rw_lock == nullptr) {
internal_rw_lock_.unlock_shared();
LOG_TRACE("Change to shared lock failed, lock oid is %u.", oid);
return false;
}
rw_lock->unlock_and_lock_shared();
internal_rw_lock_.unlock_shared();
LOG_TRACE("Change to shared lock success.");
return true;
}
/**
* @brief Unlock and lock to exclusive for RW_LOCK(blocking)
* @param oid The oid of data table
* @return bool true if successful, false if not
*/
bool LockManager::LockToExclusive(oid_t oid) {
// Need to lock internal lock to protect internal lock map
internal_rw_lock_.lock_shared();
boost::upgrade_mutex *rw_lock = GetLock(oid);
if (rw_lock == nullptr) {
internal_rw_lock_.unlock_shared();
LOG_TRACE("Change to exclusive lock failed, lock oid is %u.", oid);
return false;
}
rw_lock->unlock_shared();
rw_lock->lock();
internal_rw_lock_.unlock_shared();
LOG_TRACE("Change to exclusive lock success.");
return true;
}
/**
* @brief Unlock shared lock
* @param oid The oid of data table
* @return bool true if successful, false if not
*/
bool LockManager::UnlockShared(oid_t oid) {
// Need to lock internal lock to protect internal lock map
internal_rw_lock_.lock_shared();
boost::upgrade_mutex *rw_lock = GetLock(oid);
if (rw_lock == nullptr) {
internal_rw_lock_.unlock_shared();
LOG_DEBUG("Unlock shared lock failed, lock oid is %u.", oid);
return false;
}
rw_lock->unlock_shared();
internal_rw_lock_.unlock_shared();
LOG_TRACE("Unlock shared lock success.");
return true;
}
/**
* @brief Unlock exclusive lock
* @param oid The oid of data table
* @return bool true if successful, false if not
*/
bool LockManager::UnlockExclusive(oid_t oid) {
// Need to lock internal lock to protect internal lock map
internal_rw_lock_.lock_shared();
boost::upgrade_mutex *rw_lock = GetLock(oid);
if (rw_lock == nullptr) {
internal_rw_lock_.unlock_shared();
LOG_DEBUG("Unlock exclusive lock failed, lock oid is %u.", oid);
return false;
}
rw_lock->unlock();
internal_rw_lock_.unlock_shared();
LOG_TRACE("Unlock exclusive lock success.");
return true;
}
} // namespace concurrency
} // namespace peloton
| 30.038462 | 80 | 0.661172 | [
"object"
] |
0c3b0b482aa9b632e138141682b63effc430d054 | 14,120 | cpp | C++ | src/DakotaGraphics.cpp | jnnccc/Dakota-orb | 96488e723be9c67f0f85be8162b7af52c312b770 | [
"MIT"
] | null | null | null | src/DakotaGraphics.cpp | jnnccc/Dakota-orb | 96488e723be9c67f0f85be8162b7af52c312b770 | [
"MIT"
] | null | null | null | src/DakotaGraphics.cpp | jnnccc/Dakota-orb | 96488e723be9c67f0f85be8162b7af52c312b770 | [
"MIT"
] | null | null | null | /* _______________________________________________________________________
DAKOTA: Design Analysis Kit for Optimization and Terascale Applications
Copyright 2014 Sandia Corporation.
This software is distributed under the GNU Lesser General Public License.
For more information, see the README file in the top Dakota directory.
_______________________________________________________________________ */
//- Class: Graphics
//- Description: Implementation code for the Graphics class
//- Owner: Brian Dennis, Sandia National Laboratories
#include "DakotaGraphics.hpp"
#ifdef HAVE_X_GRAPHICS
#include "Graphics.hpp"
#endif // HAVE_X_GRAPHICS
#include "DakotaVariables.hpp"
#include "DakotaResponse.hpp"
namespace Dakota {
Graphics::Graphics():
#ifdef HAVE_X_GRAPHICS
graphics2D(NULL),
#endif
win2dOn(false) //, win3dOn(false)
{ }
// Since the Graphics instance is global, it's destruction occurs after
// main(). Similar to CommonIO within UTILIB, use of system resources in this
// destructor can lead to problems (e.g., hanging of the graphics thread).
// Therefore, Graphics::close() is now called explicitly (from the
// ParallelLibrary destructor which is invoked at the bottom of main()).
Graphics::~Graphics()
{ }
/** Sets up a single event loop for duration of the dakotaGraphics object,
continuously adding data to a single window. There is no reset.
To start over with a new data set, you need a new object (delete old and
instantiate new). */
void Graphics::create_plots_2d(const Variables& vars, const Response& response)
{
#ifdef HAVE_X_GRAPHICS
StringMultiArrayConstView cv_labels = vars.continuous_variable_labels();
StringMultiArrayConstView div_labels = vars.discrete_int_variable_labels();
StringMultiArrayConstView drv_labels = vars.discrete_real_variable_labels();
const StringArray& fn_labels = response.function_labels();
int i, num_cv = vars.cv(), num_div = vars.div(), num_drv = vars.drv(),
num_fns = response.num_functions();
if (win2dOn) { // graphics already active
// TO DO: sanity checking for change in number of plot windows
}
else { // protect multple calls to create_plots_2d
graphics2D = new Graphics2D; // instantiate the graphics object
graphics2D->create_plots2d(num_fns+num_cv+num_div+num_drv);// set # of plots
}
// set title and plot line RGB color codes (see /usr/lib/X11/rgb.txt)
// for all fns and all vars.
int num_obj_fns = 0, num_nln_ineq_con = 0, num_nln_eq_con = 0,
num_lsq_terms = 0, num_resp_fns = 0;
char title[25];
// Since the user can specify arbitrary response labels, regular
// expression matching is preferable to using label.contains().
boost::regex obj_re("obj_fn_[1-9][0-9]*"),lsq_re("least_sq_term_[1-9][0-9]*"),
resp_re( "response_fn_[1-9][0-9]*"), ineq_re( "nln_ineq_con_[1-9][0-9]*"),
eq_re( "nln_eq_con_[1-9][0-9]*");
for (i=0; i<num_fns; ++i) {
const std::string& label = fn_labels[i];
if (label == "obj_fn") {
std::strcpy(title, "Objective Fn");
graphics2D->change_line_color2d(i, 0, 0, 192); // blue
}
else if (label == re_match(label, obj_re)) {
std::sprintf(title, "Objective %d", ++num_obj_fns);
graphics2D->change_line_color2d(i, 0, 0, 192); // blue
}
else if (label == re_match(label, lsq_re)) {
std::sprintf(title, "Least Square Term %d", ++num_lsq_terms);
graphics2D->change_line_color2d(i, 0, 0, 192); // blue
}
else if (label == re_match(label, resp_re)) {
std::sprintf(title, "Response Function %d", ++num_resp_fns);
graphics2D->change_line_color2d(i, 0, 0, 192); // blue
}
else if (label == re_match(label, ineq_re)) {
std::sprintf(title, "Ineq Constraint %d", ++num_nln_ineq_con);
graphics2D->change_line_color2d(i, 0, 192, 0); // green
}
else if (label == re_match(label, eq_re)) {
std::sprintf(title, "Eq Constraint %d", ++num_nln_eq_con);
graphics2D->change_line_color2d(i, 0, 192, 0); // green
}
else { // user-defined response descriptor
std::strcpy(title, fn_labels[i].c_str());
graphics2D->change_line_color2d(i, 0, 0, 192); // blue
}
graphics2D->set_y_label2d(i, label.data());
graphics2D->set_title2d(i, title);
}
int num_cdv = 0, num_cuv = 0, num_csv = 0, num_ddriv = 0, num_ddsiv = 0,
num_ddsrv = 0, num_duiv = 0, num_durv = 0, num_dsriv = 0, num_dssiv = 0,
num_dssrv = 0;
// Since the user can specify arbitrary variable labels, regular
// expression matching is preferable to using label.contains().
boost::regex cdv_re( "cdv_[1-9][0-9]*"), ddriv_re("ddriv_[1-9][0-9]*"),
ddsiv_re("ddsiv_[1-9][0-9]*"), ddsrv_re("ddsrv_[1-9][0-9]*"),
uv_re( "uv_[1-9][0-9]*"), csv_re( "csv_[1-9][0-9]*"),
dsriv_re("dsriv_[1-9][0-9]*"), dssiv_re("dssiv_[1-9][0-9]*"),
dssrv_re("dssrv_[1-9][0-9]*"); // TO DO
for(i=0; i<num_cv; ++i) {
const std::string& label = cv_labels[i];
if (label == re_match(label, cdv_re))
std::sprintf(title, "Cont Des Variable %d", ++num_cdv);
else if (label == re_match(label, uv_re))
std::sprintf(title, "Cont Unc Variable %d", ++num_cuv);
else if (label == re_match(label, csv_re))
std::sprintf(title, "Cont State Variable %d", ++num_csv);
else
std::strcpy(title, label.c_str());
graphics2D->set_title2d(i+num_fns, title);
graphics2D->set_y_label2d(i+num_fns, label.data());
graphics2D->change_line_color2d(i+num_fns, 192, 0, 0); // red
}
for(i=0; i<num_div; ++i) {
const std::string& label = div_labels[i];
if (label == re_match(label, ddriv_re))
std::sprintf(title, "Disc Range Des Var %d", ++num_ddriv);
else if (label == re_match(label, ddsiv_re))
std::sprintf(title, "Disc Set Int Des Var %d", ++num_ddsiv);
else if (label == re_match(label, uv_re))
std::sprintf(title, "Disc Int Unc Var %d", ++num_duiv);
else if (label == re_match(label, dsriv_re))
std::sprintf(title, "Disc Range State Var %d", ++num_dsriv);
else if (label == re_match(label, dssiv_re))
std::sprintf(title, "Disc Set Int State Var %d", ++num_dssiv);
else
std::strcpy(title, label.c_str());
graphics2D->set_title2d(i+num_fns+num_cv, title);
graphics2D->set_y_label2d(i+num_fns+num_cv, label.data());
graphics2D->change_line_color2d(i+num_fns+num_cv, 192, 0, 0); // red
}
for(i=0; i<num_drv; ++i) {
const std::string& label = drv_labels[i];
if (label == re_match(label, ddsrv_re))
std::sprintf(title, "Disc Set Real Des Var %d", ++num_ddsrv);
else if (label == re_match(label, uv_re))
std::sprintf(title, "Disc Real Unc Var %d", ++num_durv);
else if (label == re_match(label, dssrv_re))
std::sprintf(title, "Disc Set Real State Var %d", ++num_dssrv);
else
std::strcpy(title, label.c_str());
graphics2D->set_title2d(i+num_fns+num_cv+num_div, title);
graphics2D->set_y_label2d(i+num_fns+num_cv+num_div, label.data());
graphics2D->change_line_color2d(i+num_fns+num_cv+num_div, 192, 0, 0); // red
}
// spawn thread to create window; only call go() once per object.
// The go function calls pthread_create, which causes a separate thread to be
// created which is configured with a 2 sec callback. So every 2 sec, data
// from arrays published in add_datapoint2d will be added to the plots.
if (!win2dOn) {
graphics2D->go();
win2dOn = true;
}
#else
Cerr << "\nWarning: Dakota not compiled with X Windows support; consider "
<< "removing\n \"graphics\" keyword from input file."
<< std::endl;
#endif // HAVE_X_GRAPHICS
}
/** Adds data to each 2d plot and each tabular data column (one for
each active variable and for each response function).
graphicsCntr is used for the x axis in the graphics and the first
column in the tabular data. */
void Graphics::add_datapoint(int graphics_cntr,
const Variables& vars, const Response& response)
{
#ifdef HAVE_X_GRAPHICS
if (win2dOn) {
const RealVector& c_vars = vars.continuous_variables();
const IntVector& di_vars = vars.discrete_int_variables();
const RealVector& dr_vars = vars.discrete_real_variables();
const ShortArray& asv = response.active_set_request_vector();
const RealVector& fn_vals = response.function_values();
int i, num_cv = c_vars.length(), num_div = di_vars.length(),
num_drv = dr_vars.length(), num_fns = asv.size();
for (i=0; i<num_fns; ++i) // add to each function graph
if (asv[i] & 1) // better to skip a value than have a meaningless 0
graphics2D->add_datapoint2d(i, (double)graphics_cntr, fn_vals[i]);
for (i=0; i<num_cv; ++i) // add to each variable graph
graphics2D->add_datapoint2d(i+num_fns, (double)graphics_cntr, c_vars[i]);
for (i=0; i<num_div; ++i) // add to each variable graph
graphics2D->add_datapoint2d(i+num_fns+num_cv, (double)graphics_cntr,
(double)di_vars[i]);
for (i=0; i<num_drv; ++i) // add to each variable graph
graphics2D->add_datapoint2d(i+num_fns+num_cv+num_div,
(double)graphics_cntr, dr_vars[i]);
}
#endif // HAVE_X_GRAPHICS
}
/** Adds data to a single 2d plot. Allows complete flexibility in
defining other kinds of x-y plotting in the 2D graphics. */
void Graphics::add_datapoint(int i, double x, double y)
{
#ifdef HAVE_X_GRAPHICS
if (win2dOn)
graphics2D->add_datapoint2d(i, x, y);
#endif // HAVE_X_GRAPHICS
// Problem with this is that calls to this function may fill in the table
// by columns -> data may require caching or a reorganization of the table
//if (tabularDataFlag)
// tabularDataFStream << setw(8) << i << ' ' << x << ' ' << y;
}
/** Used for displaying multiple data sets within the same plot. */
void Graphics::new_dataset(int i)
{
#ifdef HAVE_X_GRAPHICS
if (win2dOn)
graphics2D->new_dataset2d(i);
#endif // HAVE_X_GRAPHICS
}
/* 3D plotting clears data set and builds from scratch each time show_data3d
is called. This still involves an event loop waiting for a mouse click
(right button) to continue. X = 1-D x grid values only and
Y = 1-D Y grid values only [X and Y are _not_ (X,Y) pairs].
F = 2-d grid of values for a single function for all (X,Y) combinations.
void Graphics::
show_data_3d(const RealVector& X, const RealVector& Y,
const RealMatrix& F)
{
int num_axis_pts = X.length();
if (!num_axis_pts)
return;
#ifdef HAVE_X_GRAPHICS
if (!win3dOn) {
plsdev("xwin");
plinit();
win3dOn = true;
}
// create a matrix to store the values to be displayed
int i, j;
PLFLT **vis_mat = new PLFLT * [num_axis_pts];
for (i=0; i<num_axis_pts; ++i)
vis_mat[i] = new PLFLT [num_axis_pts];
PLFLT *x = new PLFLT [num_axis_pts];
PLFLT *y = new PLFLT [num_axis_pts];
// load matrix with points
PLFLT zhigh = -DBL_MAX, zlow = DBL_MAX; // PLFLT typedef defined in plplot.h
for (i=0; i<num_axis_pts; ++i) {
x[i] = X[i];
y[i] = Y[i];
for (j=0; j<num_axis_pts; ++j) {
vis_mat[i][j] = F(j,i);
if (vis_mat[i][j] > zhigh)
zhigh = vis_mat[i][j];
if (vis_mat[i][j] < zlow)
zlow = vis_mat[i][j];
}
}
// ensure that a suitable plot range is defined for z
// (important when plotting z = constant).
if ( std::fabs(zhigh-zlow) < 1.0e-6 ) {
zhigh += 1.0e-6;
zlow -= 1.0e-6;
}
// X and Y are monotonic so their min/max values are at the ends
PLFLT xl_ = (X[0] < X[num_axis_pts-1]) ? X[0] : X[num_axis_pts-1];
PLFLT xu_ = (X[0] < X[num_axis_pts-1]) ? X[num_axis_pts-1] : X[0];
PLFLT yl_ = (Y[0] < Y[num_axis_pts-1]) ? Y[0] : Y[num_axis_pts-1];
PLFLT yu_ = (Y[0] < Y[num_axis_pts-1]) ? Y[num_axis_pts-1] : Y[0];
// Now generate the 3D PLPLOT window
plvsta(); // set to standard device independent viewport
plwind(-1.0, 1.0, -.80, 1.4); // sets the world coordinates of the view port
plcol(1); // set the current pen color
// 45 deg. altitude, 45 deg azimuth
plw3d(1.0, 1.0, 1.0, xl_, xu_, yl_, yu_, zlow, zhigh, 45, 45);
plbox3("bnstu", "x axis", 0.0, 0, "bnstu", "y axis", 0.0, 0,
"bcdmnstuv", "z axis", 0.0, 0); // draw the axes, labels, etc.
plcol(1);
static const char *t = "#frApproximation Surface";
plmtex("t", -1.0, 0.5, 0.5, t); // add a title to the plot
//plmtex("t", -2.5, 0.5, 0.5, t); // add a title to the plot
plcol(2);
plot3d(x, y, vis_mat, num_axis_pts, num_axis_pts, 3, 0); // make the 3D plot
pladv(0); // advance to the next page, overwriting existing plot
// clean up
for (i=0; i<num_axis_pts; ++i)
delete [] vis_mat[i];
delete [] vis_mat;
delete [] x;
delete [] y;
#endif // HAVE_X_GRAPHICS
}
*/
void Graphics::close()
{
#ifdef HAVE_X_GRAPHICS
//if (win3dOn)
// plend(); // 3D
if (win2dOn) {
// hold for user action so graphics don't close too quickly
Cout << "Exit graphics window to terminate DAKOTA." << std::endl;
graphics2D->thread_wait(); // wait for user to exit the graphics thread
delete graphics2D; // 2D
// reset member data since this Graphics is currently global
win2dOn = false;
}
#endif // HAVE_X_GRAPHICS
}
void Graphics::set_x_labels2d(const char* x_label)
{
#ifdef HAVE_X_GRAPHICS
if (win2dOn) {
int num_2d_plots = graphics2D->num_2d_plots();
for (int i=0; i<num_2d_plots; ++i)
graphics2D->set_x_label2d(i, x_label);
}
#endif // HAVE_X_GRAPHICS
}
void Graphics::set_y_labels2d(const char* y_label)
{
#ifdef HAVE_X_GRAPHICS
if (win2dOn) {
int num_2d_plots = graphics2D->num_2d_plots();
for (int i=0; i<num_2d_plots; ++i)
graphics2D->set_y_label2d(i, y_label);
}
#endif // HAVE_X_GRAPHICS
}
void Graphics::set_x_label2d(int i, const char* x_label)
{
#ifdef HAVE_X_GRAPHICS
if (win2dOn)
graphics2D->set_x_label2d(i, x_label);
#endif // HAVE_X_GRAPHICS
}
void Graphics::set_y_label2d(int i, const char* y_label)
{
#ifdef HAVE_X_GRAPHICS
if (win2dOn)
graphics2D->set_y_label2d(i, y_label);
#endif // HAVE_X_GRAPHICS
}
} // namespace Dakota
| 37.255937 | 80 | 0.662535 | [
"object",
"3d"
] |
0c3e80c8926f06a5264fcfdcefdce34b0ba45400 | 7,696 | cpp | C++ | ReactAndroid/build/third-party-ndk/folly/folly/io/async/test/EventHandlerTest.cpp | kimwoongkyu/react-native-0-36-1-woogie | 4fb2d44945a6305ae3ca87be3872f9432d16f1fb | [
"BSD-3-Clause"
] | 199 | 2016-09-08T03:44:56.000Z | 2022-03-19T04:18:30.000Z | ReactAndroid/build/third-party-ndk/folly/folly/io/async/test/EventHandlerTest.cpp | kimwoongkyu/react-native-0-36-1-woogie | 4fb2d44945a6305ae3ca87be3872f9432d16f1fb | [
"BSD-3-Clause"
] | 50 | 2016-09-07T23:44:14.000Z | 2022-02-16T16:50:25.000Z | ReactAndroid/build/third-party-ndk/folly/folly/io/async/test/EventHandlerTest.cpp | kimwoongkyu/react-native-0-36-1-woogie | 4fb2d44945a6305ae3ca87be3872f9432d16f1fb | [
"BSD-3-Clause"
] | 67 | 2016-09-19T10:18:45.000Z | 2022-02-16T09:42:47.000Z | /*
* Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <bitset>
#include <future>
#include <thread>
#include <folly/MPMCQueue.h>
#include <folly/ScopeGuard.h>
#include <folly/io/async/EventBase.h>
#include <folly/io/async/EventHandler.h>
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>
#include <folly/portability/Sockets.h>
#include <sys/eventfd.h>
using namespace std;
using namespace folly;
using namespace testing;
void runInThreadsAndWait(
size_t nthreads, function<void(size_t)> cb) {
vector<thread> threads(nthreads);
for (size_t i = 0; i < nthreads; ++i) {
threads[i] = thread(cb, i);
}
for (size_t i = 0; i < nthreads; ++i) {
threads[i].join();
}
}
void runInThreadsAndWait(vector<function<void()>> cbs) {
runInThreadsAndWait(cbs.size(), [&](size_t k) { cbs[k](); });
}
class EventHandlerMock : public EventHandler {
public:
EventHandlerMock(EventBase* eb, int fd) : EventHandler(eb, fd) {}
// gmock can't mock noexcept methods, so we need an intermediary
MOCK_METHOD1(_handlerReady, void(uint16_t));
void handlerReady(uint16_t events) noexcept override {
_handlerReady(events);
}
};
class EventHandlerTest : public Test {
public:
int efd = 0;
void SetUp() override {
efd = eventfd(0, EFD_SEMAPHORE);
ASSERT_THAT(efd, Gt(0));
}
void TearDown() override {
if (efd > 0) {
close(efd);
}
efd = 0;
}
void efd_write(uint64_t val) {
write(efd, &val, sizeof(val));
}
uint64_t efd_read() {
uint64_t val = 0;
read(efd, &val, sizeof(val));
return val;
}
};
TEST_F(EventHandlerTest, simple) {
const size_t writes = 4;
size_t readsRemaining = writes;
EventBase eb;
EventHandlerMock eh(&eb, efd);
eh.registerHandler(EventHandler::READ | EventHandler::PERSIST);
EXPECT_CALL(eh, _handlerReady(_))
.Times(writes)
.WillRepeatedly(Invoke([&](uint16_t /* events */) {
efd_read();
if (--readsRemaining == 0) {
eh.unregisterHandler();
}
}));
efd_write(writes);
eb.loop();
EXPECT_EQ(0, readsRemaining);
}
TEST_F(EventHandlerTest, many_concurrent_producers) {
const size_t writes = 200;
const size_t nproducers = 20;
size_t readsRemaining = writes;
runInThreadsAndWait({
[&] {
EventBase eb;
EventHandlerMock eh(&eb, efd);
eh.registerHandler(EventHandler::READ | EventHandler::PERSIST);
EXPECT_CALL(eh, _handlerReady(_))
.Times(writes)
.WillRepeatedly(Invoke([&](uint16_t /* events */) {
efd_read();
if (--readsRemaining == 0) {
eh.unregisterHandler();
}
}));
eb.loop();
},
[&] {
runInThreadsAndWait(nproducers,
[&](size_t /* k */) {
for (size_t i = 0; i < writes / nproducers; ++i) {
this_thread::sleep_for(chrono::milliseconds(1));
efd_write(1);
}
});
},
});
EXPECT_EQ(0, readsRemaining);
}
TEST_F(EventHandlerTest, many_concurrent_consumers) {
const size_t writes = 200;
const size_t nproducers = 8;
const size_t nconsumers = 20;
atomic<size_t> writesRemaining(writes);
atomic<size_t> readsRemaining(writes);
MPMCQueue<nullptr_t> queue(writes / 10);
runInThreadsAndWait({
[&] {
runInThreadsAndWait(
nconsumers,
[&](size_t /* k */) {
size_t thReadsRemaining = writes / nconsumers;
EventBase eb;
EventHandlerMock eh(&eb, efd);
eh.registerHandler(EventHandler::READ | EventHandler::PERSIST);
EXPECT_CALL(eh, _handlerReady(_))
.WillRepeatedly(Invoke([&](uint16_t /* events */) {
nullptr_t val;
if (!queue.readIfNotEmpty(val)) {
return;
}
efd_read();
--readsRemaining;
if (--thReadsRemaining == 0) {
eh.unregisterHandler();
}
}));
eb.loop();
});
},
[&] {
runInThreadsAndWait(nproducers,
[&](size_t /* k */) {
for (size_t i = 0; i < writes / nproducers; ++i) {
this_thread::sleep_for(chrono::milliseconds(1));
queue.blockingWrite(nullptr);
efd_write(1);
--writesRemaining;
}
});
},
});
EXPECT_EQ(0, writesRemaining);
EXPECT_EQ(0, readsRemaining);
}
#ifdef EV_PRI
TEST(EventHandlerSocketTest, EPOLLPRI) {
std::promise<decltype(sockaddr_in::sin_port)> serverReady;
std::thread t([serverReadyFuture = serverReady.get_future()]() mutable {
// client
LOG(INFO) << "Server is ready";
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
SCOPE_EXIT {
close(sockfd);
};
struct hostent* he;
struct sockaddr_in server;
const char hostname[] = "localhost";
he = gethostbyname(hostname);
PCHECK(he);
memcpy(&server.sin_addr, he->h_addr_list[0], he->h_length);
server.sin_family = AF_INET;
server.sin_port = serverReadyFuture.get();
PCHECK(::connect(sockfd, (struct sockaddr*)&server, sizeof(server)) == 0);
LOG(INFO) << "Server connection available";
char buffer[] = "banana";
int n = send(sockfd, buffer, strlen(buffer) + 1, MSG_OOB);
PCHECK(n > 0);
});
SCOPE_EXIT {
t.join();
};
// make the server.
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
SCOPE_EXIT {
close(sockfd);
};
PCHECK(sockfd != -1) << "unable to open socket";
struct sockaddr_in sin;
sin.sin_port = htons(0);
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_family = AF_INET;
PCHECK(bind(sockfd, (struct sockaddr*)&sin, sizeof(sin)) >= 0)
<< "Can't bind to port";
listen(sockfd, 5);
struct sockaddr_in findSockName;
socklen_t sz = sizeof(findSockName);
getsockname(sockfd, (struct sockaddr*)&findSockName, &sz);
serverReady.set_value(findSockName.sin_port);
socklen_t clilen;
struct sockaddr_in cli_addr;
clilen = sizeof(cli_addr);
int newsockfd = accept(sockfd, (struct sockaddr*)&cli_addr, &clilen);
PCHECK(newsockfd >= 0) << "can't accept";
SCOPE_EXIT {
close(newsockfd);
};
EventBase eb;
struct SockEvent : public EventHandler {
SockEvent(EventBase* eb, int fd) : EventHandler(eb, fd), fd_(fd) {}
void handlerReady(uint16_t events) noexcept override {
EXPECT_TRUE(EventHandler::EventFlags::PRI & events);
char buffer[256];
int n = read(fd_, buffer, 255);
EXPECT_EQ(6, n);
EXPECT_EQ("banana", std::string(buffer));
}
private:
int fd_;
} sockHandler(&eb, newsockfd);
sockHandler.registerHandler(EventHandler::EventFlags::PRI);
LOG(INFO) << "Registered Handler";
eb.loop();
}
#endif
| 28.294118 | 80 | 0.590956 | [
"vector"
] |
0c3f2507148dc1ea577b9618c5b9db2ea83f29b8 | 1,040 | cpp | C++ | attn/attn_main.cpp | openbmc/openpower-hw-diags | d94291aa2f3248cd829b29a91caa137b24aea5e1 | [
"Apache-2.0"
] | null | null | null | attn/attn_main.cpp | openbmc/openpower-hw-diags | d94291aa2f3248cd829b29a91caa137b24aea5e1 | [
"Apache-2.0"
] | 1 | 2021-05-05T14:27:26.000Z | 2021-05-06T20:46:56.000Z | attn/attn_main.cpp | openbmc/openpower-hw-diags | d94291aa2f3248cd829b29a91caa137b24aea5e1 | [
"Apache-2.0"
] | null | null | null | #include <attn/attn_monitor.hpp>
namespace attn
{
/**
* @brief Attention handler application main()
*/
int attnDaemon(Config* i_config)
{
int rc = 0; // assume success
gpiod_line* line; // gpio line to monitor
boost::asio::io_service io; // async io monitoring service
// GPIO line configuration (falling edge, active low)
struct gpiod_line_request_config config
{
"attention", GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE, 0
};
// get handle to attention GPIO line
line = gpiod_line_find("checkstop");
if (nullptr == line)
{
rc = 1; // error
}
else
{
// Creating a vector of one gpio to monitor
std::vector<std::unique_ptr<attn::AttnMonitor>> gpios;
gpios.push_back(
std::make_unique<attn::AttnMonitor>(line, config, io, i_config));
io.run(); // start GPIO monitor
// done with line, manually close chip (per gpiod api comments)
gpiod_line_close_chip(line);
}
return rc;
}
} // namespace attn
| 22.12766 | 77 | 0.630769 | [
"vector"
] |
0c403443f065feca88776b2fad73675669c7b33a | 4,403 | cpp | C++ | ui/luxrender2/advancedinfowidget.cpp | LuxRender/LuxRays | edb001ddeb744b534f6fe98c7b789d4635196718 | [
"Apache-2.0"
] | null | null | null | ui/luxrender2/advancedinfowidget.cpp | LuxRender/LuxRays | edb001ddeb744b534f6fe98c7b789d4635196718 | [
"Apache-2.0"
] | null | null | null | ui/luxrender2/advancedinfowidget.cpp | LuxRender/LuxRays | edb001ddeb744b534f6fe98c7b789d4635196718 | [
"Apache-2.0"
] | null | null | null | /***************************************************************************
* Copyright (C) 1998-2013 by authors (see AUTHORS.txt) *
* *
* This file is part of LuxRender. *
* *
* Lux Renderer is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* Lux Renderer 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 program. If not, see <http://www.gnu.org/licenses/>. *
* *
* This project is based on PBRT ; see http://www.pbrt.org *
* Lux Renderer website : http://www.luxrender.net *
***************************************************************************/
//#include "api.h"
#include "advancedinfowidget.hxx"
using namespace std;
AdvancedInfoWidget::AdvancedInfoWidget(QWidget *parent) : QWidget(parent), ui(new Ui::AdvancedInfoWidget)
{
ui->setupUi(this);
}
AdvancedInfoWidget::~AdvancedInfoWidget()
{
}
void AdvancedInfoWidget::updateWidgetValues()
{
QStringList info;
info.append("<html>");
info.append("<head>");
info.append("<style type=\"text/css\">");
info.append("td { border-style: solid; padding-right: 0.5em; }");
info.append("</style>");
info.append("</head");
info.append("<body>");
info.append("<h3>Renderer</h3>");
info.append("<p><table>");
info.append("<tr>");
info.append(QString("<td>Type:</td><td>%1</td>").arg(
getStringAttribute("renderer", "name")));
info.append("</tr>");
info.append("<tr>");
info.append(QString("<td>Surface integrator:</td><td>%1</td>").arg(
getStringAttribute("surfaceintegrator", "name")));
info.append("</tr>");
info.append("<tr>");
info.append(QString("<td>Volume integrator:</td><td>%1</td>").arg(
getStringAttribute("volumeintegrator", "name")));
info.append("</tr>");
info.append("</table></p>");
info.append("<h3>Film</h3>");
info.append("<p><table>");
info.append("<tr>");
info.append(QString("<td>Resolution:</td><td>%1x%2</td>").arg(
luxGetIntAttribute("film", "xResolution")).arg(
luxGetIntAttribute("film", "yResolution")));
info.append("</tr>");
info.append("<tr>");
info.append(QString("<td>Effective resolution:</td><td>%1x%2</td>").arg(
luxGetIntAttribute("film", "xPixelCount")).arg(
luxGetIntAttribute("film", "yPixelCount")));
info.append("</tr>");
info.append("<tr>");
info.append(QString("<td>Premult. alpha:</td><td>%1</td>").arg(
luxGetBoolAttribute("film", "premultiplyAlpha") ? tr("Yes") : tr("No")));
info.append("</tr>");
info.append("<tr>");
info.append(QString("<td>Output:</td><td>\"%1\"</td>").arg(
getStringAttribute("film", "filename")));
info.append("</tr>");
info.append("<tr>");
info.append(QString("<td>Write EXR:</td><td>%1</td>").arg(
luxGetBoolAttribute("film", "write_EXR") ? tr("Yes") : tr("No")));
info.append("</tr>");
info.append("<tr>");
info.append(QString("<td>Write PNG:</td><td>%1, %2</td>").arg(
luxGetBoolAttribute("film", "write_PNG") ? tr("Yes") : tr("No")).arg(
luxGetBoolAttribute("film", "write_PNG_16bit") ? tr("16bit") : tr("8bit")));
info.append("</tr>");
info.append("<tr>");
info.append(QString("<td>Write FLM:</td><td>%1</td>").arg(
luxGetBoolAttribute("film", "writeResumeFlm") ? tr("Yes") : tr("No")));
info.append("</tr>");
info.append("</table></p>");
info.append("</body></html>");
ui->textAdvancedInfo->setHtml(info.join("\n"));
}
void AdvancedInfoWidget::showEvent(QShowEvent *event)
{
updateWidgetValues();
QWidget::showEvent(event);
}
| 39.666667 | 105 | 0.546446 | [
"solid"
] |
0c405a90d8dde79e48379ab90ad2837f74f56592 | 452 | hpp | C++ | gui/include/templates/TabBrowser.hpp | alex999990009/ample | 71336c2fb69748b8c2f27a6810e7cc047cbab359 | [
"MIT"
] | 33 | 2020-03-03T11:52:16.000Z | 2022-01-12T01:47:45.000Z | gui/include/templates/TabBrowser.hpp | alex999990009/ample | 71336c2fb69748b8c2f27a6810e7cc047cbab359 | [
"MIT"
] | 3 | 2020-04-06T10:00:04.000Z | 2021-11-07T13:02:38.000Z | gui/include/templates/TabBrowser.hpp | alex999990009/ample | 71336c2fb69748b8c2f27a6810e7cc047cbab359 | [
"MIT"
] | 7 | 2020-01-24T22:54:26.000Z | 2020-12-07T04:50:57.000Z | #pragma once
namespace ample::gui
{
template <class T>
TabObjectBrowser<T>::TabObjectBrowser(std::shared_ptr<T> object)
: _browserTarget(object) {}
template <class T>
std::shared_ptr<T> TabObjectBrowser<T>::browserTarget() const noexcept
{
return _browserTarget;
}
template <class T>
std::shared_ptr<filing::NamedObject> TabObjectBrowser<T>::browserTargetNamedObject() const noexcept
{
return _browserTarget;
}
} // namespace ample::gui
| 21.52381 | 99 | 0.752212 | [
"object"
] |
0c474a99801f08f82134b030faaa5b781557da0f | 585 | cc | C++ | elang/vm/machine_code_function.cc | eval1749/elang | 5208b386ba3a3e866a5c0f0271280f79f9aac8c4 | [
"Apache-2.0"
] | 1 | 2018-01-27T22:40:53.000Z | 2018-01-27T22:40:53.000Z | elang/vm/machine_code_function.cc | eval1749/elang | 5208b386ba3a3e866a5c0f0271280f79f9aac8c4 | [
"Apache-2.0"
] | 1 | 2016-01-29T00:54:49.000Z | 2016-01-29T00:54:49.000Z | elang/vm/machine_code_function.cc | eval1749/elang | 5208b386ba3a3e866a5c0f0271280f79f9aac8c4 | [
"Apache-2.0"
] | null | null | null | // Copyright 2014-2015 Project Vogue. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "elang/vm/machine_code_function.h"
#include "base/logging.h"
namespace elang {
namespace vm {
MachineCodeFunction::MachineCodeFunction(
EntryPoint entry_point,
size_t code_size,
const std::vector<MachineCodeAnnotation>& annotations)
: annotations_(annotations),
entry_point_(entry_point),
code_size_(code_size) {
DCHECK(entry_point_);
}
} // namespace vm
} // namespace elang
| 24.375 | 73 | 0.736752 | [
"vector"
] |
0c47eca06dfa3b1e2fb49e71b25c819b9c77cabf | 7,907 | hpp | C++ | bitstream.hpp | pboutan/u3d | 18d1b1997b5cb24bd6ca2ac52413b0a2c4812289 | [
"Unlicense"
] | null | null | null | bitstream.hpp | pboutan/u3d | 18d1b1997b5cb24bd6ca2ac52413b0a2c4812289 | [
"Unlicense"
] | null | null | null | bitstream.hpp | pboutan/u3d | 18d1b1997b5cb24bd6ca2ac52413b0a2c4812289 | [
"Unlicense"
] | null | null | null | #pragma once
#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <string.h>
#include "types.hpp"
namespace U3D
{
enum ContextEnum {
cZero = 0, cShading, cDiffuseCount, cDiffuseColorSign, cColorDiffR, cColorDiffG, cColorDiffB, cColorDiffA, cSpecularCount,
cSpecularColorSign, cTexCoordCount, cTexCoordSign, cTexCDiffU, cTexCDiffV, cTexCDiffS, cTexCDiffT, cFaceCnt, cFaceOrnt,
cThrdPosType, cLocal3rdPos, cStayMove0, cStayMove1, cStayMove2, cStayMove3, cStayMove4, cDiffuseKeepChange, cDiffuseChangeType,
cDiffuseChangeIndexNew, cDiffuseChangeIndexLocal,
cDiffuseChangeIndexGlobal, cSpecularKeepChange, cSpecularChangeType, cSpecularChangeIndexNew, cSpecularChangeIndexLocal,
cSpecularChangeIndexGlobal, cTCKeepChange, cTCChangeType, cTCChangeIndexNew, cTCChangeIndexLocal, cTCChangeIndexGlobal,
cColorDup, cColorIndexType, cColorIndexLocal, cColorIndexGlobal, cTexCDup, cTexCIndexType, cTextureIndexLocal,
cTextureIndexGlobal, cPosDiffSign, cPosDiffX, cPosDiffY, cPosDiffZ, cNormalCnt, cDiffNormalSign, cDiffNormalX, cDiffNormalY,
cDiffNormalZ, cNormalIdx, cPointCnt, cDiffDup, cSpecDup, cLineCnt, NumContexts
};
class BitStreamReader
{
class DynamicContext
{
std::vector<uint16_t> symbol_count;
uint16_t total_symbol_count;
public:
DynamicContext() : symbol_count(256, 0), total_symbol_count(1)
{
symbol_count[0] = 1;
}
void reset()
{
symbol_count.resize(256);
std::fill(symbol_count.begin(), symbol_count.end(), 0);
symbol_count[0] = 1;
total_symbol_count = 1;
}
void add_symbol(uint32_t symbol)
{
if(symbol <= 0xFFFF) {
if(symbol >= symbol_count.size()) {
symbol_count.resize(symbol + 1, 0);
}
if(total_symbol_count >= 0x1FFF) {
total_symbol_count = 1;
for(size_t i = 0; i < symbol_count.size(); i++) {
symbol_count[i] >>= 1;
total_symbol_count += symbol_count[i];
}
symbol_count[0]++;
}
symbol_count[symbol]++;
total_symbol_count++;
}
}
uint32_t get_symbol_frequency(uint32_t symbol) const
{
if(symbol >= symbol_count.size()) {
return 0;
} else {
return symbol_count[symbol];
}
}
uint32_t get_total_symbol_frequency() const
{
return total_symbol_count;
}
uint32_t get_symbol_from_frequency(uint32_t frequency, uint32_t *cum_freq) const
{
uint32_t symbol = 0, cum_freq_counter = 0;
for(; symbol < symbol_count.size(); symbol++) {
if(cum_freq_counter + symbol_count[symbol] > frequency) {
break;
}
cum_freq_counter += symbol_count[symbol];
}
*cum_freq = cum_freq_counter;
return symbol;
}
};
public:
class SubBlock
{
BitStreamReader& reader;
uint32_t type;
uint32_t data_size, metadata_size;
size_t origin;
public:
SubBlock(BitStreamReader& reader) : reader(reader)
{
reader >> type >> data_size >> metadata_size;
origin = reader.bit_position;
}
uint32_t get_type() const { return type; }
~SubBlock()
{
reader.bit_position = origin + ((data_size + 3) / 4 + (metadata_size + 3) / 4) * 32;
}
};
private:
std::ifstream ifs;
size_t bit_position;
uint32_t high, low, underflow, type;
uint32_t data_size, metadata_size;
uint32_t *data_buffer, *metadata_buffer;
static const uint8_t bit_reverse_table[256];
DynamicContext dynamic_contexts[NumContexts];
private:
uint32_t read_word_direct()
{
uint32_t ret;
ifs.read(reinterpret_cast<char *>(&ret), 4);
return ret;
}
public:
BitStreamReader(const std::string& filename);
~BitStreamReader()
{
if(data_buffer != NULL) delete[] data_buffer;
if(metadata_buffer != NULL) delete[] metadata_buffer;
}
bool open_block();
template<typename T> T read()
{
T ret;
uint8_t *p = reinterpret_cast<uint8_t *>(&ret);
for(unsigned int i = 0; i < sizeof(T); i++) {
p[i] = read_byte();
}
return ret;
}
void reset()
{
for(int i = 0; i < NumContexts; i++) {
dynamic_contexts[i].reset();
}
high = 0xFFFF, low = 0, underflow = 0;
}
template<typename T> BitStreamReader& operator>>(T& val)
{
val = read<T>();
return *this;
}
BitStreamReader& operator>>(std::string& val)
{
uint16_t size = read<uint16_t>();
for(unsigned int i = 0; i < size; i++) {
val.push_back(read<char>());
}
return *this;
}
uint32_t read_bits(unsigned int n)
{
uint64_t buffer = ((uint64_t)data_buffer[bit_position / 32 + 1] << 32) | data_buffer[bit_position / 32];
uint32_t ret = (buffer >> (bit_position % 32)) & (((uint64_t)1 << n) - 1);
bit_position += n;
return ret;
}
uint32_t read_bit()
{
uint32_t ret = (data_buffer[bit_position / 32] >> (bit_position % 32)) & 1;
bit_position++;
return ret;
}
std::string read_str()
{
std::string ret;
*this >> ret;
return ret;
}
void align_to_word()
{
bit_position = ((bit_position + 31) / 32) * 32;
}
uint32_t get_type() const { return type; }
uint32_t read_static_symbol(uint32_t context);
uint32_t read_dynamic_symbol(uint32_t context);
uint32_t read_byte()
{
uint32_t symbol = read_static_symbol(256);
return bit_reverse_table[symbol - 1];
}
uint32_t read_remainder(void *ptr, uint32_t n)
{
uint32_t size = data_size - (bit_position + 7) / 8;
if(size > n) size = n;
memcpy(ptr, (uint8_t *)data_buffer + ((bit_position + 7) / 8), size);
return size;
}
class ContextAdapter
{
BitStreamReader& reader;
uint32_t context;
public:
ContextAdapter(BitStreamReader& reader, uint32_t context) : reader(reader), context(context) {}
template<typename T> T read()
{
if(context < 0x3FFF) {
uint32_t symbol = reader.read_static_symbol(context);
if(symbol == 0) {
return reader.read<T>();
} else {
return static_cast<T>(symbol - 1);
}
} else if(context == 0x3FFF) {
return reader.read<T>();
} else {
uint32_t symbol = reader.read_dynamic_symbol(context - 0x4000);
if(symbol == 0) {
T value = reader.read<T>();
reader.dynamic_contexts[context - 0x4000].add_symbol(static_cast<uint32_t>(value) + 1);
return value;
} else {
return static_cast<T>(symbol - 1);
}
}
}
template<typename T> ContextAdapter& operator>>(T& val)
{
val = read<T>();
return *this;
}
};
ContextAdapter operator[](uint32_t context)
{
if(context < 0x3FFF) {
return ContextAdapter(*this, context);
} else {
return ContextAdapter(*this, 0x3FFF);
}
}
ContextAdapter operator[](ContextEnum context)
{
return ContextAdapter(*this, static_cast<uint32_t>(context) + 0x4000);
}
};
}
| 32.273469 | 131 | 0.564184 | [
"vector"
] |
0c480a4f56cd49f8012a274495c6345eb96249e8 | 8,887 | cpp | C++ | temporal_monitor/src/main.cpp | kyberszittya/safety-critical-robotics | 7638a262da3740e07e2301a4438ee2339dd7d12f | [
"BSD-3-Clause"
] | null | null | null | temporal_monitor/src/main.cpp | kyberszittya/safety-critical-robotics | 7638a262da3740e07e2301a4438ee2339dd7d12f | [
"BSD-3-Clause"
] | null | null | null | temporal_monitor/src/main.cpp | kyberszittya/safety-critical-robotics | 7638a262da3740e07e2301a4438ee2339dd7d12f | [
"BSD-3-Clause"
] | null | null | null | /*
* main.cpp
*
* Created on: Sep 10, 2019
* Author: kyberszittya
*/
#include <limits>
#include <memory>
#include <ros/ros.h>
#include <Eigen/Dense>
#include <autoware_msgs/CloudClusterArray.h>
#include <autoware_msgs/Lane.h>
#include <autoware_msgs/LaneArray.h>
#include <geometry_msgs/PoseStamped.h>
#include <geometry_msgs/TwistStamped.h>
#include <geometry_msgs/PointStamped.h>
#include <monitoring_msgs/MonitorFeedback.h>
#include <monitoring_msgs/MonitorFeedbackArray.h>
#include <visualization_msgs/Marker.h>
#include <std_msgs/Int32.h>
#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_listener.h>
#include <geometry_msgs/TransformStamped.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>
#include <tf2/transform_datatypes.h>
#include <planner_msgs/LocalPlannerObjectDetection.h>
class RobotFirstOrderState
{
public:
Eigen::Vector3d pos;
Eigen::Quaterniond ori;
};
const double MAX_LATERAL_DISTANCE = 1.4;
const double MAX_LATERAL_DISTANCE_SQR = MAX_LATERAL_DISTANCE * MAX_LATERAL_DISTANCE;
const double MAX_LOOKAHEAD_DISTANCE = 16.8;
const double MAX_LOOKAHEAD_DISTANCE_SQR = MAX_LOOKAHEAD_DISTANCE * MAX_LOOKAHEAD_DISTANCE;
// Avoidance constants
const double AVOIDANCE_TRAJECTORY_POINT_LENGTH = 37;
class RobotFirstOrderStateSubscriber
{
private:
std::unique_ptr<RobotFirstOrderState> state;
std::shared_ptr<ros::NodeHandle> nh;
// State subscribers
std::string topic_name_current_pose;
ros::Subscriber sub_current_pose;
std::string topic_name_current_velocity;
ros::Subscriber sub_current_velocity;
geometry_msgs::TransformStamped _tr_base_link;
geometry_msgs::TransformStamped _tr_velodyne;
tf2_ros::Buffer _buffer;
tf2_ros::TransformListener _listener;
geometry_msgs::PoseStamped pose;
geometry_msgs::PointStamped last_detected_object;
// Pose
ros::Publisher pub_obstacle_lane_id;
public:
RobotFirstOrderStateSubscriber(std::shared_ptr<ros::NodeHandle> nh): state(new RobotFirstOrderState()), nh(nh), _listener(_buffer) {}
void cbCurrentPose(const geometry_msgs::PoseStamped::ConstPtr& msg)
{
pose = *msg;
state->pos << msg->pose.position.x, msg->pose.position.y, msg->pose.position.z;
}
void cbCurrentVelocity(const geometry_msgs::TwistStamped::ConstPtr& msg)
{
}
void init(std::shared_ptr<ros::NodeHandle> nh)
{
// TODO: with parameters
// State subscribers
sub_current_velocity = nh->subscribe("current_velocity", 100, &RobotFirstOrderStateSubscriber::cbCurrentVelocity, this);
sub_current_pose = nh->subscribe("current_pose", 100, &RobotFirstOrderStateSubscriber::cbCurrentPose, this);
}
void distanceBetweenPointAndWaypoint(const geometry_msgs::PointStamped& point, const autoware_msgs::Lane& lane,
const int& closest_waypoint_id,
double& longitudinal_distance,
double& lateral_distance,
unsigned int& lane_id)
{
lateral_distance = std::numeric_limits<double>::infinity();
longitudinal_distance = std::numeric_limits<double>::infinity();
double lookahead_distance = 0.0;
try
{
int target_waypoints;
if (closest_waypoint_id + AVOIDANCE_TRAJECTORY_POINT_LENGTH > lane.waypoints.size())
{
target_waypoints = lane.waypoints.size();
}
else
{
target_waypoints = closest_waypoint_id + AVOIDANCE_TRAJECTORY_POINT_LENGTH;
}
for (unsigned int i = closest_waypoint_id; i < target_waypoints; i++)
{
geometry_msgs::PoseStamped waypoint_transformed;
geometry_msgs::PointStamped point_transformed;
_tr_base_link = _buffer.lookupTransform("base_link", "map", pose.header.stamp, ros::Duration(10.0));
_tr_velodyne = _buffer.lookupTransform("velodyne", "base_link", pose.header.stamp, ros::Duration(10.0));
tf2::doTransform(lane.waypoints[i].pose, waypoint_transformed, _tr_base_link);
tf2::doTransform(point, point_transformed, _tr_velodyne);
double _d_obsx = point_transformed.point.x;
double _d_obsy = point_transformed.point.y;
double dx = (waypoint_transformed.pose.position.x - point_transformed.point.x);
double dy = (waypoint_transformed.pose.position.y - point_transformed.point.y);
double d_dist = sqrt(dx*dx + dy*dy);
//lookahead_distance += d_dist;
if (d_dist < 2.0)
{
lateral_distance = waypoint_transformed.pose.position.y - point_transformed.point.y;
longitudinal_distance = _d_obsx;
ROS_INFO_STREAM("Obstacle detected near to the waypoint" << lateral_distance << '\t' <<
longitudinal_distance << '\t' << _d_obsy);
last_detected_object = point_transformed;
lane_id = i;
break;
}
}
}
catch (tf2::LookupException& e)
{
ROS_ERROR_STREAM("Unable to find transform: " << e.what());
}
}
friend class ObstacleMonitor;
};
class ObstacleMonitor
{
private:
std::shared_ptr<ros::NodeHandle> nh;
std::unique_ptr<RobotFirstOrderStateSubscriber> ego_state_subscriber;
ros::Subscriber sub_detected_object_topic;
ros::Subscriber sub_closest_waypoint_id;
ros::Subscriber sub_base_waypoints;
std::atomic<unsigned int> closest_waypoint_id;
autoware_msgs::Lane msg_current_base_lane;
// Publish event stream
monitoring_msgs::MonitorFeedback event_detected_object;
ros::Publisher pub_event_detected_object;
ros::Publisher pub_local_planner_object_detection; ///< Publish planner object detection
ros::Publisher pub_detected_object_marker;
// Autoware lane
public:
ObstacleMonitor(std::shared_ptr<ros::NodeHandle> nh): nh(nh), ego_state_subscriber(new RobotFirstOrderStateSubscriber(nh)) {}
void cbClosestLaneId(const std_msgs::Int32::ConstPtr& msg)
{
closest_waypoint_id = msg->data;
ROS_DEBUG_STREAM("Closest waypoint: " << closest_waypoint_id);
}
void cbBaseWaypoints(const autoware_msgs::Lane::ConstPtr& msg)
{
msg_current_base_lane = *msg;
}
void cbDetectedObject(const autoware_msgs::CloudClusterArray::ConstPtr& msg)
{
for (const auto& cluster: msg->clusters)
{
double lateral_distance;
double longitudinal_distance;
unsigned int lane_id;
ego_state_subscriber->distanceBetweenPointAndWaypoint(cluster.centroid_point,
msg_current_base_lane, closest_waypoint_id,
longitudinal_distance,
lateral_distance,
lane_id);
if (longitudinal_distance < MAX_LOOKAHEAD_DISTANCE && lateral_distance < MAX_LATERAL_DISTANCE)
{
auto event_time = ros::Time::now();
monitoring_msgs::MonitorFeedback event;
// Publish local planner object detection
planner_msgs::LocalPlannerObjectDetection localplanner_msg;
localplanner_msg.avoidance_start_index = closest_waypoint_id;
localplanner_msg.avoidance_end_index = closest_waypoint_id + AVOIDANCE_TRAJECTORY_POINT_LENGTH;
localplanner_msg.header.stamp = event_time;
localplanner_msg.event.signal_id = "LANE_OBJECT_DETECTED";
localplanner_msg.event.header.stamp = event_time;
localplanner_msg.event.val = abs(2.0);
localplanner_msg.event.severity = monitoring_msgs::MonitorFeedback::SEVERITY_WARNING;
localplanner_msg.event.eval = 1;
pub_local_planner_object_detection.publish(localplanner_msg);
visualization_msgs::Marker object_marker;
object_marker.header.frame_id = "base_link";
object_marker.header.stamp = ros::Time::now();
object_marker.color.a = 1.0;
object_marker.color.r = 1.0;
object_marker.color.g = 0.0;
object_marker.color.b = 0.0;
object_marker.type = visualization_msgs::Marker::SPHERE;
object_marker.scale.x = 1.0;
object_marker.scale.y = 1.0;
object_marker.scale.z = 1.0;
object_marker.pose.position.x = ego_state_subscriber->last_detected_object.point.x;
object_marker.pose.position.y = ego_state_subscriber->last_detected_object.point.y;
object_marker.pose.position.z = ego_state_subscriber->last_detected_object.point.z;
pub_detected_object_marker.publish(object_marker);
ROS_INFO_STREAM("Obstacle detected at: " << lateral_distance << '\t' << longitudinal_distance << '\n');
}
}
}
void init()
{
// Event stream
pub_local_planner_object_detection =
nh->advertise<planner_msgs::LocalPlannerObjectDetection>("/monitor/events/local_planner/object_detection", 1000);
pub_detected_object_marker =
nh->advertise<visualization_msgs::Marker>("monitor/events/local_planner/detected_object/marker", 10);
sub_detected_object_topic = nh->subscribe("/detection/lidar_detector/cloud_clusters", 10, &ObstacleMonitor::cbDetectedObject, this);
// Autoware specific
sub_closest_waypoint_id = nh->subscribe("/closest_waypoint", 10, &ObstacleMonitor::cbClosestLaneId, this);
sub_base_waypoints = nh->subscribe("/base_waypoints", 10, &ObstacleMonitor::cbBaseWaypoints, this);
}
};
int main(int argc, char ** argv)
{
ros::init(argc, argv, "ros_object_detection_monitor");
std::shared_ptr<ros::NodeHandle> nh(new ros::NodeHandle);
ObstacleMonitor monitor(nh);
monitor.init();
ROS_INFO("Node initialized: object detection monitor");
ros::spin();
return 0;
}
| 35.548 | 134 | 0.76415 | [
"object",
"transform"
] |
0c48f5b6e97ea9b895bc23f46fdf6f1be0ca021e | 334 | cpp | C++ | Source/NIIC/Private/NightSphereInheritance.cpp | ameyghan/Night | fb84d69ee9c7a804bc0671c7308b20cc79b0e65d | [
"MIT"
] | null | null | null | Source/NIIC/Private/NightSphereInheritance.cpp | ameyghan/Night | fb84d69ee9c7a804bc0671c7308b20cc79b0e65d | [
"MIT"
] | null | null | null | Source/NIIC/Private/NightSphereInheritance.cpp | ameyghan/Night | fb84d69ee9c7a804bc0671c7308b20cc79b0e65d | [
"MIT"
] | null | null | null | #include "NightSphereInheritance.h"
ANightSphereInheritance::ANightSphereInheritance(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void ANightSphereInheritance::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
}
void ANightSphereInheritance::Used(APawn* Pawn)
{
}
| 17.578947 | 93 | 0.811377 | [
"transform"
] |
0c49f1c8ec0e7f91d9b1bf7e418837b7948cf8e9 | 2,291 | cpp | C++ | Source/Interpolant.cpp | BlueLort/Lort-Renderer | f0698af318e7b17a363dd31d5c9ee8870527fe0c | [
"MIT"
] | 3 | 2019-08-23T10:59:40.000Z | 2021-12-25T21:32:41.000Z | Source/Interpolant.cpp | BlueLort/Software-Renderer | f0698af318e7b17a363dd31d5c9ee8870527fe0c | [
"MIT"
] | null | null | null | Source/Interpolant.cpp | BlueLort/Software-Renderer | f0698af318e7b17a363dd31d5c9ee8870527fe0c | [
"MIT"
] | 1 | 2022-03-29T15:37:49.000Z | 2022-03-29T15:37:49.000Z | #include "Interpolant.h"
/*
p0-----p4
/| \ /
/ | p1
/ | /
/ p3
/ /
/ / <----- assume that is a line
/ /
//
p3
*/
///INTERPOLATING ACCORDING TO THE SHAPE ABOVE...
// p1,p2,p3,p4 same line.
// p0,p1,p2 are the triangle points, p4 & p3 helping points.
// dc/dx = (c4-c0)/(x4-x0) , dc/dy = (c3-c0)/(y3-y0);
// From these we can make our interpolation formula.
Interpolant::Interpolant(const Vertex & minYVert, const Vertex & midYVert, const Vertex & maxYVert)
{
float oneOverW = 1.0f / minYVert.pos[3];
this->elements[0].setVec(minYVert.texCoords[0] * oneOverW, //u
minYVert.texCoords[1] * oneOverW, // v
minYVert.pos[2], // depth
oneOverW); //oneOverW
oneOverW = 1.0f / midYVert.pos[3];
this->elements[1].setVec(midYVert.texCoords[0] * oneOverW,//u
midYVert.texCoords[1] * oneOverW,// v
midYVert.pos[2],// depth
oneOverW);//oneOverW
oneOverW = 1.0f / maxYVert.pos[3];
this->elements[2].setVec(maxYVert.texCoords[0] * oneOverW,//u
maxYVert.texCoords[1] * oneOverW,// v
maxYVert.pos[2],// depth
oneOverW);//oneOverW
float x0 = minYVert.pos[0]; float y0 = minYVert.pos[1];
float x1 = midYVert.pos[0]; float y1 = midYVert.pos[1];
float x2 = maxYVert.pos[0]; float y2 = maxYVert.pos[1];
float dotVal = dot(minYVert.normal, lightDir);
light[0] = clampValue(dotVal, 0.0f, 1.0f) * 0.95f + 0.05f;
dotVal = dot(midYVert.normal, lightDir);
light[1] = clampValue(dotVal, 0.0f, 1.0f) * 0.95f + 0.05f;
dotVal = dot(maxYVert.normal, lightDir);
light[2] = clampValue(dotVal, 0.0f, 1.0f) * 0.95f + 0.05f;
float oneOver_dx = 1.0f /(((x1 - x2)*(y0 -y2))-((x0 - x2)*(y1 - y2)));
float oneOver_dy = - oneOver_dx;
elementsXStep= (((elements[1] - elements[2])*(y0 - y2)) - ((elements[0] - elements[2])*(y1 - y2))) * oneOver_dx;
elementsYStep= (((elements[1] - elements[2])*(x0 - x2)) - ((elements[0] - elements[2])*(x1 - x2))) * oneOver_dy;
lightXStep = (((light[1] - light[2])*(y0 - y2)) - ((light[0] - light[2])*(y1 - y2))) * oneOver_dx;
lightYStep = (((light[1] - light[2])*(x0 - x2)) - ((light[0] - light[2])*(x1 - x2))) * oneOver_dy;
}
Interpolant::~Interpolant()
{
}
| 34.19403 | 114 | 0.574858 | [
"shape"
] |
31c0917edb1b0d5aba61758d14b991bf455d5861 | 822 | cpp | C++ | Template/Template/CastleVania/GCamera.cpp | funny622/Game2020Plus | 50dad4afe2d3dd538fec4ffe7d4f652d3d226901 | [
"MIT"
] | null | null | null | Template/Template/CastleVania/GCamera.cpp | funny622/Game2020Plus | 50dad4afe2d3dd538fec4ffe7d4f652d3d226901 | [
"MIT"
] | null | null | null | Template/Template/CastleVania/GCamera.cpp | funny622/Game2020Plus | 50dad4afe2d3dd538fec4ffe7d4f652d3d226901 | [
"MIT"
] | null | null | null | #include "GCamera.h"
GCamera::GCamera()
{
viewport.x = 1;
viewport.y = G_ScreenHeight;
}
void GCamera::SetSizeMap(int _max, int _min)
{
_maxSize = _max;
_minSize = _min;
}
D3DXVECTOR2 GCamera::Transform(int x, int y)
{
D3DXMATRIX matrix;
D3DXMatrixIdentity (&matrix);
matrix._22 = -1;
matrix._41 = -viewport.x;
matrix._42 = viewport.y;
D3DXVECTOR3 pos3(x ,y ,1);
D3DXVECTOR4 MatrixResult;
D3DXVec3Transform (&MatrixResult,&pos3,&matrix);
D3DXVECTOR2 result = D3DXVECTOR2 (MatrixResult.x,MatrixResult.y);
return result;
}
D3DXVECTOR3 GCamera::CenterSprite(int x, int y)
{
D3DXVECTOR3 pCenter = D3DXVECTOR3(x/2, y/2, 0);
return pCenter;
}
void GCamera::UpdateCamera(int x)
{
//Tự viết dự vào hướng dẫn của GV LT
}
void GCamera::UpdateCamera(int &w, int &h)
{
//Tự viết dự vào hướng dẫn của GV LT
} | 18.681818 | 66 | 0.709246 | [
"transform"
] |
31c110f4083a476dd40c3ccd1246fa4cc66443a7 | 5,918 | cxx | C++ | Pando/src/JobQueue.cxx | jjzhang166/Pando | ab9b37eeaefdd6ee06b38b590e1fa60912e7aca9 | [
"FSFAP"
] | null | null | null | Pando/src/JobQueue.cxx | jjzhang166/Pando | ab9b37eeaefdd6ee06b38b590e1fa60912e7aca9 | [
"FSFAP"
] | null | null | null | Pando/src/JobQueue.cxx | jjzhang166/Pando | ab9b37eeaefdd6ee06b38b590e1fa60912e7aca9 | [
"FSFAP"
] | null | null | null | // SciTE - Scintilla based Text Editor
/** @file JobQueue.cxx
** Define job queue
**/
// SciTE & Scintilla copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// Copyright 2007 by Neil Hodgson <neilh@scintilla.org>, from April White <april_white@sympatico.ca>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <time.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include "Scintilla.h"
#include "GUI.h"
#include "SString.h"
#include "StringHelpers.h"
#include "FilePath.h"
#include "PropSetFile.h"
#include "SciTE.h"
#include "Mutex.h"
#include "JobQueue.h"
JobSubsystem SubsystemFromChar(char c) {
if (c == '1')
return jobGUI;
else if (c == '2')
return jobShell;
else if (c == '3')
return jobExtension;
else if (c == '4')
return jobHelp;
else if (c == '5')
return jobOtherHelp;
else if (c == '7')
return jobImmediate;
return jobCLI;
}
JobMode::JobMode(PropSetFile &props, int item, const char *fileNameExt) : jobType(jobCLI), saveBefore(0), isFilter(false), flags(0) {
bool quiet = false;
int repSel = 0;
bool groupUndo = false;
const std::string itemSuffix = StdStringFromInteger(item) + ".";
std::string propName = std::string("command.mode.") + itemSuffix;
std::string modeVal(props.GetNewExpandString(propName.c_str(), fileNameExt));
modeVal.erase(std::remove(modeVal.begin(), modeVal.end(),' '), modeVal.end());
std::vector<std::string> modes = StringSplit(modeVal, ',');
for (std::vector<std::string>::iterator it=modes.begin(); it != modes.end(); ++it) {
std::vector<std::string> optValue = StringSplit(*it, ':');
const std::string opt = optValue[0];
const std::string value = (optValue.size() > 1) ? optValue[1] : std::string();
if (opt == "subsystem" && !value.empty()) {
if (value[0] == '0' || value == "console")
jobType = jobCLI;
else if (value[0] == '1' || value == "windows")
jobType = jobGUI;
else if (value[0] == '2' || value == "shellexec")
jobType = jobShell;
else if (value[0] == '3' || value == "lua" || value == "director")
jobType = jobExtension;
else if (value[0] == '4' || value == "htmlhelp")
jobType = jobHelp;
else if (value[0] == '5' || value == "winhelp")
jobType = jobOtherHelp;
else if (value[0] == '7' || value == "immediate")
jobType = jobImmediate;
}
if (opt == "quiet") {
if (value.empty() || value[0] == '1' || value == "yes")
quiet = true;
else if (value[0] == '0' || value == "no")
quiet = false;
}
if (opt == "savebefore") {
if (value.empty() || value[0] == '1' || value == "yes")
saveBefore = 1;
else if (value[0] == '0' || value == "no")
saveBefore = 2;
else if (value == "prompt")
saveBefore = 0;
}
if (opt == "filter") {
if (value.empty() || value[0] == '1' || value == "yes")
isFilter = true;
else if (value[0] == '0' || value == "no")
isFilter = false;
}
if (opt == "replaceselection") {
if (value.empty() || value[0] == '1' || value == "yes")
repSel = 1;
else if (value[0] == '0' || value == "no")
repSel = 0;
else if (value == "auto")
repSel = 2;
}
if (opt == "groupundo") {
if (value.empty() || value[0] == '1' || value == "yes")
groupUndo = true;
else if (value[0] == '0' || value == "no")
groupUndo = false;
}
}
// The mode flags also have classic properties with similar effect.
// If the classic property is specified, it overrides the mode.
// To see if the property is absent (as opposed to merely evaluating
// to nothing after variable expansion), use GetWild for the
// existence check. However, for the value check, use GetNewExpandString.
propName = "command.save.before.";
propName += itemSuffix;
if (props.GetWild(propName.c_str(), fileNameExt).length())
saveBefore = atoi(props.GetNewExpandString(propName.c_str(), fileNameExt).c_str());
propName = "command.is.filter.";
propName += itemSuffix;
if (props.GetWild(propName.c_str(), fileNameExt).length())
isFilter = (props.GetNewExpandString(propName.c_str(), fileNameExt) == "1");
propName = "command.subsystem.";
propName += itemSuffix;
if (props.GetWild(propName.c_str(), fileNameExt).length()) {
std::string subsystemVal = props.GetNewExpandString(propName.c_str(), fileNameExt);
jobType = SubsystemFromChar(subsystemVal[0]);
}
propName = "command.input.";
propName += itemSuffix;
if (props.GetWild(propName.c_str(), fileNameExt).length()) {
input = props.GetNewExpandString(propName.c_str(), fileNameExt);
flags |= jobHasInput;
}
propName = "command.quiet.";
propName += itemSuffix;
if (props.GetWild(propName.c_str(), fileNameExt).length())
quiet = props.GetNewExpandString(propName.c_str(), fileNameExt) == "1";
if (quiet)
flags |= jobQuiet;
propName = "command.replace.selection.";
propName += itemSuffix;
if (props.GetWild(propName.c_str(), fileNameExt).length())
repSel = atoi(props.GetNewExpandString(propName.c_str(), fileNameExt).c_str());
if (repSel == 1)
flags |= jobRepSelYes;
else if (repSel == 2)
flags |= jobRepSelAuto;
if (groupUndo)
flags |= jobGroupUndo;
}
void JobQueue::ClearJobs() {
for (int ic = 0; ic < commandMax; ic++) {
jobQueue[ic].Clear();
}
commandCurrent = 0;
}
void JobQueue::AddCommand(const std::string &command, const FilePath &directory, JobSubsystem jobType, const std::string &input, int flags) {
if ((commandCurrent < commandMax) && (command.length())) {
if (commandCurrent == 0)
jobUsesOutputPane = false;
jobQueue[commandCurrent] = Job(command, directory, jobType, input, flags);
commandCurrent++;
if (jobType == jobCLI)
jobUsesOutputPane = true;
// For jobExtension, the Trace() method shows output pane on demand.
}
}
| 30.193878 | 141 | 0.647178 | [
"vector"
] |
31c716feda5deb95cd421602376b33b7b76a803a | 1,663 | hpp | C++ | __unit_tests/gv_framework_unit_test/unit_test_gesture_2d.hpp | dragonsn/gv_game_engine | dca6c1fb1f8d96e9a244f157a63f8a69da084b0f | [
"MIT"
] | 2 | 2018-12-03T13:17:31.000Z | 2020-04-08T07:00:02.000Z | __unit_tests/gv_framework_unit_test/unit_test_gesture_2d.hpp | dragonsn/gv_game_engine | dca6c1fb1f8d96e9a244f157a63f8a69da084b0f | [
"MIT"
] | null | null | null | __unit_tests/gv_framework_unit_test/unit_test_gesture_2d.hpp | dragonsn/gv_game_engine | dca6c1fb1f8d96e9a244f157a63f8a69da084b0f | [
"MIT"
] | null | null | null | #include "gv_base/gesture/gv_gesture.h"
namespace unit_test_gesture_2d
{
int tick_count = 0;
class gv_unit_test_gesture_2d : public gv_unit_test_with_renderer
{
public:
gv_int m_max_frame;
gv_bool m_drag_started;
gvt_array< gv_vector2 > path;
gv_gesture gesture;
gv_string last_gesture;
gv_float last_score;
virtual gv_string name()
{
return "unit_test_gesture_2d";
}
virtual void initialize()
{
if (gv_global::command_line_options.size())
{
gv_global::command_line_options[0] >> m_max_frame;
}
else
m_max_frame = 1000;
m_drag_started = false;
last_score = 0;
};
virtual void render()
{
//gv_string_tmp s=" a GESTURE test ====>>" ;
//s<<"last==>:"<<last_gesture <<"last score==>:"<<last_score;
//gv_global::debug_draw.get()->draw_string(*s,gv_vector2i(100,120),gv_color::GREEN());
gv_vector2i cu_pos;
gv_global::input->get_mouse_pos(cu_pos);
gv_vector2 pos2;
pos2 = cu_pos;
gv_bool lb_down = gv_global::input->is_key_down(e_key_lbutton);
if (!m_drag_started && lb_down)
{
m_drag_started = true;
path.clear();
}
if (m_drag_started)
{
path.push_back(pos2);
for (int i = 0; i < path.size() - 1; i++)
{
gv_vector3 v = path[i];
v.set_z(0.5);
gv_vector3 v2 = path[i + 1];
v2.set_z(0.5);
gv_global::debug_draw.get()->draw_line(v, v2, gv_color::RED(), gv_color::BLUE());
}
}
if (m_drag_started && !lb_down)
{
m_drag_started = false;
gesture.recognize(path, last_score, last_gesture);
}
tick_count++;
};
virtual bool is_finished()
{
if (tick_count < m_max_frame)
return false;
return true;
}
} test;
gv_unit_test_with_renderer* ptest = &test;
};
| 22.780822 | 88 | 0.678292 | [
"render"
] |
31d3733d40e1fef0446b6ba75902621bb066d331 | 2,764 | cpp | C++ | external/mesh-fusion/libfusioncpu/fusion.cpp | FooVizDevs/occupancy_networks | 8668618123449cbd77ddb539e1902682b738086d | [
"MIT"
] | 801 | 2019-05-04T19:14:54.000Z | 2022-03-29T08:47:12.000Z | external/mesh-fusion/libfusioncpu/fusion.cpp | FooVizDevs/occupancy_networks | 8668618123449cbd77ddb539e1902682b738086d | [
"MIT"
] | 106 | 2019-05-05T15:27:07.000Z | 2022-03-22T23:01:23.000Z | external/mesh-fusion/libfusioncpu/fusion.cpp | FooVizDevs/occupancy_networks | 8668618123449cbd77ddb539e1902682b738086d | [
"MIT"
] | 202 | 2019-05-05T08:42:30.000Z | 2022-03-29T08:47:15.000Z | #include "fusion.h"
#include <cmath>
#include <vector>
#if defined(_OPENMP)
#include <omp.h>
#endif
template <typename FusionFunctorT>
void fusion_cpu(const Views& views, const FusionFunctorT functor, float vx_size, int n_threads, Volume& vol) {
int vx_res3 = vol.depth_ * vol.height_ * vol.width_;
#if defined(_OPENMP)
omp_set_num_threads(n_threads);
#endif
#pragma omp parallel for
for(int idx = 0; idx < vx_res3; ++idx) {
int d,h,w;
fusion_idx2dhw(idx, vol.width_,vol.height_, d,h,w);
float x,y,z;
fusion_dhw2xyz(d,h,w, vx_size, x,y,z);
functor.before_sample(&vol, d,h,w);
bool run = true;
int n_valid_views = 0;
for(int vidx = 0; vidx < views.n_views_ && run; ++vidx) {
float ur, vr, vx_d;
fusion_project(&views, vidx, x,y,z, ur,vr,vx_d);
int u = int(ur + 0.5f);
int v = int(vr + 0.5f);
// printf(" vx %d,%d,%d has center %f,%f,%f and projects to uvd=%f,%f,%f\n", w,h,d, x,y,z, ur,vr,vx_d);
if(u >= 0 && v >= 0 && u < views.cols_ && v < views.rows_) {
int dm_idx = (vidx * views.rows_ + v) * views.cols_ + u;
float dm_d = views.depthmaps_[dm_idx];
// printf(" is on depthmap[%d,%d] with depth=%f, diff=%f\n", views.cols_,views.rows_, dm_d, dm_d - vx_d);
run = functor.new_sample(&vol, vx_d, dm_d, d,h,w, &n_valid_views);
}
} // for vidx
functor.after_sample(&vol, d,h,w, n_valid_views);
}
}
void fusion_projectionmask_cpu(const Views& views, float vx_size, bool unknown_is_free, int n_threads, Volume& vol) {
ProjectionMaskFusionFunctor functor(unknown_is_free);
fusion_cpu(views, functor, vx_size, n_threads, vol);
}
void fusion_occupancy_cpu(const Views& views, float vx_size, float truncation, bool unknown_is_free, int n_threads, Volume& vol) {
OccupancyFusionFunctor functor(truncation, unknown_is_free);
fusion_cpu(views, functor, vx_size, n_threads, vol);
}
void fusion_tsdfmask_cpu(const Views& views, float vx_size, float truncation, bool unknown_is_free, int n_threads, Volume& vol) {
TsdfMaskFusionFunctor functor(truncation, unknown_is_free);
fusion_cpu(views, functor, vx_size, n_threads, vol);
}
void fusion_tsdf_cpu(const Views& views, float vx_size, float truncation, bool unknown_is_free, int n_threads, Volume& vol) {
TsdfFusionFunctor functor(truncation, unknown_is_free);
fusion_cpu(views, functor, vx_size, n_threads, vol);
}
void fusion_tsdf_hist_cpu(const Views& views, float vx_size, float truncation, bool unknown_is_free, float* bin_centers, int n_bins, bool unobserved_is_occupied, int n_threads, Volume& vol) {
TsdfHistFusionFunctor functor(truncation, unknown_is_free, bin_centers, n_bins, unobserved_is_occupied);
fusion_cpu(views, functor, vx_size, n_threads, vol);
}
| 38.929577 | 191 | 0.700434 | [
"vector"
] |
31d407fc1507a0f84824a298e249c0f621867b07 | 8,335 | cpp | C++ | common/src/math/algebra/point/Point3.cpp | petitg1987/urchinEngine | a14a57ac49a19237d748d2eafc7c2a38a45b95d6 | [
"BSL-1.0"
] | 18 | 2020-06-12T00:04:46.000Z | 2022-01-11T14:56:19.000Z | common/src/math/algebra/point/Point3.cpp | petitg1987/urchinEngine | a14a57ac49a19237d748d2eafc7c2a38a45b95d6 | [
"BSL-1.0"
] | null | null | null | common/src/math/algebra/point/Point3.cpp | petitg1987/urchinEngine | a14a57ac49a19237d748d2eafc7c2a38a45b95d6 | [
"BSL-1.0"
] | 6 | 2020-08-16T15:58:41.000Z | 2022-03-05T13:17:50.000Z | #include <math/algebra/point/Point3.h>
namespace urchin {
template<class T> Point3<T>::Point3() :
X(0), Y(0), Z(0) {
}
template<class T> Point3<T>::Point3(T Xu, T Yu, T Zu) :
X(Xu), Y(Yu), Z(Zu) {
}
template<class T> Point3<T>::Point3(const Point2<T>& p, T Zu) :
X(p.X), Y(p.Y), Z(Zu) {
}
template<class T> Point3<T>::Point3(const Vector2<T>& vector, T Zu) :
X(vector.X), Y(vector.Y), Z(Zu) {
}
template<class T> Point3<T>::Point3(const Vector3<T>& vector) :
X(vector.X), Y(vector.Y), Z(vector.Z) {
}
template<class T> void Point3<T>::setValues(T Xu, T Yu, T Zu) {
X = Xu;
Y = Yu;
Z = Zu;
}
template<class T> void Point3<T>::setNull() {
X = Y = Z = 0;
}
template<class T> T Point3<T>::distance(const Point3<T>& p) const {
return (T)std::sqrt(((X - p.X) * (X - p.X)) + ((Y - p.Y) * (Y - p.Y)) + ((Z - p.Z) * (Z - p.Z)));
}
template<class T> T Point3<T>::squareDistance(const Point3<T>& p) const {
return (T)(((X - p.X) * (X - p.X)) + ((Y - p.Y) * (Y - p.Y)) + ((Z - p.Z) * (Z - p.Z)));
}
template<class T> Vector3<T> Point3<T>::vector(const Point3<T>& target) const {
return Vector3<T>(target.X - X, target.Y - Y, target.Z - Z);
}
/**
* @return Vector from origin (0.0, 0.0, 0.0) to this point
*/
template<class T> Vector3<T> Point3<T>::toVector() const {
return Vector3<T>(X, Y, Z);
}
template<class T> Point3<T> Point3<T>::translate(const Vector3<T>& v) const {
return Point3<T>(X + v.X, Y + v.Y, Z + v.Z);
}
template<class T> Point3<T> Point3<T>::divideByZ() const {
if (Z != 0.0) {
return Point3<T>(X / Z, Y / Z, 1);
}
return *this;
}
template<class T> Point2<T> Point3<T>::toPoint2XY() const {
return Point2<T>(X, Y);
}
template<class T> Point2<T> Point3<T>::toPoint2XZ() const {
return Point2<T>(X, Z);
}
template<class T> Point2<T> Point3<T>::toPoint2YZ() const {
return Point2<T>(Y, Z);
}
template<class T> Point3<T> Point3<T>::operator +() const {
return Point3<T>(X, Y, Z);
}
template<class T> Point3<T> Point3<T>::operator -() const {
return Point3<T>(-X, -Y, -Z);
}
template<class T> Point3<T> Point3<T>::operator +(const Point3<T>& p) const {
return Point3<T>( X + p.X,
Y + p.Y,
Z + p.Z);
}
template<class T> Point3<T> Point3<T>::operator -(const Point3<T>& p) const {
return Point3<T>( X - p.X,
Y - p.Y,
Z - p.Z);
}
template<class T> const Point3<T>& Point3<T>::operator +=(const Point3<T>& p) {
X += p.X;
Y += p.Y;
Z += p.Z;
return *this;
}
template<class T> const Point3<T>& Point3<T>::operator -=(const Point3<T>& p) {
X -= p.X;
Y -= p.Y;
Z -= p.Z;
return *this;
}
template<class T> const Point3<T>& Point3<T>::operator *=(T t) {
X *= t;
Y *= t;
Z *= t;
return *this;
}
template<class T> const Point3<T>& Point3<T>::operator /=(T t) {
X /= t;
Y /= t;
Z /= t;
return *this;
}
template<class T> const Point3<T>& Point3<T>::operator +=(T t) {
X += t;
Y += t;
Z += t;
return *this;
}
template<class T> const Point3<T>& Point3<T>::operator -=(T t) {
X -= t;
Y -= t;
Z -= t;
return *this;
}
template<class T> bool Point3<T>::operator ==(const Point3<T>& p) const {
return (X == p.X && Y == p.Y && Z == p.Z);
}
template<class T> bool Point3<T>::operator !=(const Point3<T>& p) const {
return !(this->operator==(p));
}
template<class T> bool Point3<T>::operator <(const Point3<T>& p) const {
return X < p.X || (X == p.X && Y < p.Y) || (X == p.X && Y == p.Y && Z < p.Z);
}
template<class T> T& Point3<T>::operator [](std::size_t i) {
return (&X)[i];
}
template<class T> const T& Point3<T>::operator [](std::size_t i) const {
return (&X)[i];
}
template<class T> Point3<T>::operator T*() {
return &X;
}
template<class T> Point3<T>::operator const T*() const {
return &X;
}
template<class T> template<class NEW_TYPE> Point3<NEW_TYPE> Point3<T>::cast() const {
return Point3<NEW_TYPE>((NEW_TYPE)X, (NEW_TYPE)Y, (NEW_TYPE)Z);
}
template<class T> Point3<T> operator *(const Point3<T>& p, T t) {
return Point3<T>(p.X * t, p.Y * t, p.Z * t);
}
template<class T> Point3<T> operator *(T t, const Point3<T>& p) {
return p * t;
}
template<class T> Point3<T> operator /(const Point3<T>& p, T t) {
return Point3<T>(p.X / t, p.Y / t, p.Z / t);
}
template<class T> Point3<T> operator +(const Point3<T>& p, T t) {
return Point3<T>(p.X + t, p.Y + t, p.Z + t);
}
template<class T> Point3<T> operator -(const Point3<T>& p, T t) {
return Point3<T>(p.X - t, p.Y - t, p.Z - t);
}
template<class T> Point3<T> operator *(const Matrix3<T>& m, const Point3<T>& p) {
return Point3<T>( m.a11 * p.X + m.a12 * p.Y + m.a13 * p.Z,
m.a21 * p.X + m.a22 * p.Y + m.a23 * p.Z,
m.a31 * p.X + m.a32 * p.Y + m.a33 * p.Z);
}
template<class T> Point3<T> operator *(const Point3<T>& p, const Matrix3<T>& m) {
return m * p;
}
template<class T> std::ostream& operator <<(std::ostream& stream, const Point3<T>& p) {
return stream << p.X << ", " << p.Y << ", " << p.Z;
}
//explicit template
template class Point3<float>;
template Point3<float> Point3<float>::cast() const;
template Point3<double> Point3<float>::cast() const;
template Point3<int> Point3<float>::cast() const;
template Point3<float> operator *<float>(const Point3<float>&, float);
template Point3<float> operator *<float>(float t, const Point3<float>&);
template Point3<float> operator /<float>(const Point3<float>&, float);
template Point3<float> operator +<float>(const Point3<float>&, float);
template Point3<float> operator -<float>(const Point3<float>&, float);
template Point3<float> operator *<float>(const Matrix3<float>&, const Point3<float>&);
template Point3<float> operator *<float>(const Point3<float>&, const Matrix3<float>&);
template std::ostream& operator <<<float>(std::ostream&, const Point3<float>&);
template class Point3<double>;
template Point3<float> Point3<double>::cast() const;
template Point3<double> Point3<double>::cast() const;
template Point3<int> Point3<double>::cast() const;
template Point3<double> operator *<double>(const Point3<double>&, double);
template Point3<double> operator *<double>(double t, const Point3<double>&);
template Point3<double> operator /<double>(const Point3<double>&, double);
template Point3<double> operator +<double>(const Point3<double>&, double);
template Point3<double> operator -<double>(const Point3<double>&, double);
template Point3<double> operator *<double>(const Matrix3<double>&, const Point3<double>&);
template Point3<double> operator *<double>(const Point3<double>&, const Matrix3<double>&);
template std::ostream& operator <<<double>(std::ostream&, const Point3<double>&);
template class Point3<int>;
template Point3<float> Point3<int>::cast() const;
template Point3<double> Point3<int>::cast() const;
template Point3<int> Point3<int>::cast() const;
template Point3<int> operator *<int>(const Point3<int>&, int);
template Point3<int> operator *<int>(int t, const Point3<int>&);
template Point3<int> operator /<int>(const Point3<int>&, int);
template Point3<int> operator +<int>(const Point3<int>&, int);
template Point3<int> operator -<int>(const Point3<int>&, int);
template Point3<int> operator *<int>(const Matrix3<int>&, const Point3<int>&);
template Point3<int> operator *<int>(const Point3<int>&, const Matrix3<int>&);
template std::ostream& operator <<<int>(std::ostream&, const Point3<int>&);
}
| 32.431907 | 105 | 0.55009 | [
"vector"
] |
31dafa94bb5e8c155e6811ae823325291a2d65d5 | 4,557 | cpp | C++ | tests/horner_evaluation_test.cpp | mtao/core | 91f9bc6e852417989ed62675e2bb372e6afc7325 | [
"MIT"
] | null | null | null | tests/horner_evaluation_test.cpp | mtao/core | 91f9bc6e852417989ed62675e2bb372e6afc7325 | [
"MIT"
] | 4 | 2020-04-18T16:16:05.000Z | 2020-04-18T16:17:36.000Z | tests/horner_evaluation_test.cpp | mtao/core | 91f9bc6e852417989ed62675e2bb372e6afc7325 | [
"MIT"
] | null | null | null | #include <iostream>
#include <array>
#include <mtao/algebra/horner_evaluation.hpp>
#include "mtao/geometry/grid/grid_utils.h"
#include <Eigen/Dense>
#include <iterator>
int main() {
std::array<int,3> coeffs{{1,1,0}};
for(int i = 0; i < 10; ++i) {
std::cout << mtao::algebra::horner_evaluate(i,coeffs) << std::endl;
}
{
std::array<int,2> coeffs{{3,4}};
for(int i = 0; i < coeffs[0]; ++i) {
for(int j = 0; j < coeffs[1]; ++j) {
std::cout << mtao::algebra::horner_rowminor_index(std::array<int,2>{{i,j}},coeffs) << " ";
}
std::cout << std::endl;
}
}
std::cout << std::endl << std::endl;
{
std::array<int,2> coeffs{{3,4}};
for(int i = 0; i < coeffs[0]; ++i) {
for(int j = 0; j < coeffs[1]; ++j) {
std::cout << mtao::algebra::horner_rowmajor_index(std::array<int,2>{{i,j}},coeffs) << " ";
}
std::cout << std::endl;
}
}
{
std::array<int,3> coeffs{{3,4,5}};
for(int i = 0; i < coeffs[0]; ++i) {
for(int j = 0; j < coeffs[1]; ++j) {
for(int k = 0; k < coeffs[2]; ++k) {
std::cout << mtao::algebra::horner_rowminor_index(std::array<int,3>{{i,j,k}},coeffs) << " ";
}
std::cout << std::endl;
}
std::cout << std::endl;
}
}
std::cout << std::endl << std::endl;
{
std::array<int,3> coeffs{{3,4,5}};
for(int i = 0; i < coeffs[0]; ++i) {
for(int j = 0; j < coeffs[1]; ++j) {
for(int k = 0; k < coeffs[2]; ++k) {
std::cout << mtao::algebra::horner_rowmajor_index(std::array<int,3>{{i,j,k}},coeffs) << " ";
}
std::cout << std::endl;
}
std::cout << std::endl;
}
}
{
Eigen::Matrix<int,3,4,Eigen::ColMajor> A;
for(int i = 0; i < A.rows(); ++i) {
for(int j = 0; j < A.cols(); ++j) {
A(i,j) = &A(i,j) - A.data();
}
}
std::array<int,2> coeffs{{3,4}};
for(int i = 0; i < coeffs[0]; ++i) {
for(int j = 0; j < coeffs[1]; ++j) {
std::cout << mtao::algebra::horner_rowminor_index(std::array<int,2>{{i,j}},coeffs) << ":" << A(i,j) << " ";
}
std::cout << std::endl;
}
}
std::cout << std::endl << std::endl;
{
Eigen::Matrix<int,3,4,Eigen::RowMajor> A;
for(int i = 0; i < A.rows(); ++i) {
for(int j = 0; j < A.cols(); ++j) {
A(i,j) = &A(i,j) - A.data();
}
}
std::array<int,2> coeffs{{3,4}};
for(int i = 0; i < coeffs[0]; ++i) {
for(int j = 0; j < coeffs[1]; ++j) {
std::cout << mtao::algebra::horner_rowmajor_index(std::array<int,2>{{i,j}},coeffs) << ":" << A(i,j) << " ";
}
std::cout << std::endl;
}
}
auto arrstr = [](auto&& idx) {
using ArrType = mtao::types::remove_cvref_t<decltype(idx)>;
using VT = typename ArrType::value_type;
std::stringstream ss;
std::copy(idx.begin(),idx.end(),std::ostream_iterator<VT>(ss,","));
return ss.str();
};
using namespace mtao::algebra;
auto test_inversing = [&](auto&& coeffs) {
std::cout << "Minor" << coeffs.size() << std::endl;
mtao::geometry::grid::utils::multi_loop(coeffs,[&](auto&& ij) {
int idx = horner_rowminor_index(ij,coeffs);
auto arr = horner_rowminor_inverse_index(idx,coeffs);
std::cout << arrstr(ij) << " => " << idx << " => " << arrstr(arr) << std::endl;
assert(ij == arr);
});
std::cout << std::endl;
std::cout << "Major" << coeffs.size() << std::endl;
mtao::geometry::grid::utils::multi_loop(coeffs,[&](auto&& ij) {
int idx = horner_rowmajor_index(ij,coeffs);
auto arr = horner_rowmajor_inverse_index(idx,coeffs);
std::cout << arrstr(ij) << " => " << idx << " => " << arrstr(arr) << std::endl;
assert(ij == arr);
});
};
test_inversing(std::array<int,2>{{3,4}});
std::cout << std::endl;
std::cout << std::endl;
test_inversing(std::array<int,3>{{3,4,5}});
std::cout << std::endl;
std::cout << std::endl;
test_inversing(std::array<int,4>{{3,4,5,7}});
}
| 33.755556 | 124 | 0.44503 | [
"geometry"
] |
31db47bcf4a9e46af8f55a23d0e79b77a078ef00 | 5,578 | hpp | C++ | src/xor/container/xor_queue.hpp | tum-db/partitioned-filters | 56c20102715a442cbec9ecb732d41de15b31c828 | [
"MIT"
] | 5 | 2021-08-16T17:48:45.000Z | 2022-03-10T22:53:54.000Z | src/xor/container/xor_queue.hpp | tum-db/partitioned-filters | 56c20102715a442cbec9ecb732d41de15b31c828 | [
"MIT"
] | null | null | null | src/xor/container/xor_queue.hpp | tum-db/partitioned-filters | 56c20102715a442cbec9ecb732d41de15b31c828 | [
"MIT"
] | null | null | null | #pragma once
#include <cstdint>
#include <cstddef>
#include <bloom/bloom_parameter.hpp>
#include "xor_set.hpp"
namespace filters::nxor {
template<Variant variant, typename Hasher, typename Vector, typename Addresser>
struct XorQueue {
};
template<typename Hasher, typename Vector, typename Addresser>
struct XorQueue<Variant::Standard, Hasher, Vector, Addresser> {
using Set = XorSet<Variant::Standard, Hasher, Vector, Addresser>;
using T = typename Vector::T;
using M = typename Vector::M;
std::array<Vector, 3> begins;
std::array<Vector, 3> ends;
T *queue;
XorQueue(const Addresser &addresser, const size_t index) {
T last_offset = 0;
for (size_t i = 0; i < Vector::n_elements; i++) {
const size_t n_blocks = addresser.get_size(index + i);
for (size_t j = 0; j < begins.size(); j++) {
begins[j].elements[i] = last_offset;
ends[j].elements[i] = last_offset;
last_offset += n_blocks;
}
}
size_t n_bytes = simd::valign<Vector>(last_offset * sizeof(T));
queue = simd::valloc<Vector>(n_bytes);
}
~XorQueue() {
free(queue);
}
template<size_t set>
forceinline
void clear() {
ends[set] = begins[set];
}
template<size_t set>
forceinline
Vector size() const {
return ends[set] - begins[set];
}
template<size_t set>
forceinline
void scan_for_single(const Set &xor_set) {
const Vector one = Vector(1);
const Vector two = Vector(2);
// begin of current set (needs to be incremented by factor 2)
Vector set_begin = xor_set.begins[set] << 1;
const Vector set_length = xor_set.size();
const Vector set_end = set_begin + (set_length << 1);
// end of current queue
Vector &queue_ends = ends[set];
for (M mask; (mask = set_begin < set_end); set_begin = set_begin + two) {
const Vector entry_counter = (set_begin + one).gather(xor_set.set, mask);
mask &= (entry_counter == one);
// for scalar we need to check the mask manually
if constexpr (not Vector::avx) {
if (not mask) {
continue;
}
}
const Vector entry_hash = set_begin.gather(xor_set.set, mask);
// we could write offsets into the queue
// but the hash is more effective
// when building the stack we reduce the number of loads on the critical path to one
// when using the offset we first have to load the hash and when we perform
// another load based on the address computed from the hash
entry_hash.scatter(queue, queue_ends, mask);
// increment size of xor queue
queue_ends = queue_ends.add_mask(one, mask);
}
}
forceinline
void fill(const Set &xor_set) {
scan_for_single<0>(xor_set);
scan_for_single<1>(xor_set);
scan_for_single<2>(xor_set);
}
};
template<typename Hasher, typename Vector, typename Addresser>
struct XorQueue<Variant::Fuse, Hasher, Vector, Addresser> {
using Set = XorSet<Variant::Fuse, Hasher, Vector, Addresser>;
using T = typename Vector::T;
using M = typename Vector::M;
Vector begins;
Vector ends;
T *queue;
XorQueue(const Addresser &addresser, const size_t index) {
T last_offset = 0;
for (size_t i = 0; i < Vector::n_elements; i++) {
const size_t n_blocks = addresser.get_size(index + i);
begins.elements[i] = last_offset;
ends.elements[i] = last_offset;
last_offset += n_blocks * (FUSE_SEGMENTS + 2);
}
size_t n_bytes = simd::valign<Vector>(last_offset * sizeof(T));
queue = simd::valloc<Vector>(n_bytes);
}
~XorQueue() {
free(queue);
}
forceinline
void clear() {
ends = begins;
}
forceinline
Vector size() const {
return ends - begins;
}
forceinline
void fill(const Set &xor_set) {
const Vector one = Vector(1);
const Vector two = Vector(2);
// begin of current set (needs to be incremented by factor 2)
Vector set_begin = xor_set.begins[0] << 1;
const Vector set_length = xor_set.size();
const Vector set_end = set_begin + (set_length << 1);
for (M mask; (mask = set_begin < set_end); set_begin = set_begin + two) {
const Vector entry_counter = (set_begin + one).gather(xor_set.set, mask);
mask &= (entry_counter == one);
// for scalar we need to check the mask manually
if constexpr (not Vector::avx) {
if (not mask) {
continue;
}
}
xor_set.get_address(set_begin >> 1).scatter(queue, ends, mask);
// increment size of xor queue
ends = ends.add_mask(one, mask);
}
}
};
} // filters::nxor
| 33.005917 | 100 | 0.529222 | [
"vector"
] |
31dcf44465e4bdccbd26a470a045d3c3ff3baffc | 88,552 | cpp | C++ | com/netfx/src/clr/jit/il/lclvars.cpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | com/netfx/src/clr/jit/il/lclvars.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | com/netfx/src/clr/jit/il/lclvars.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | // ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX XX
XX LclVarsInfo XX
XX XX
XX The variables to be used by the code generator. XX
XX XX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/
#include "jitpch.h"
#pragma hdrstop
#include "emit.h"
/*****************************************************************************/
#if DOUBLE_ALIGN
#ifdef DEBUG
/* static */
unsigned Compiler::s_lvaDoubleAlignedProcsCount = 0;
#endif
#endif
/*****************************************************************************/
void Compiler::lvaInit()
{
/* We haven't allocated stack variables yet */
lvaDoneFrameLayout = 0;
}
/*****************************************************************************/
void Compiler::lvaInitTypeRef()
{
/* Set compArgsCount and compLocalsCount */
info.compArgsCount = info.compMethodInfo->args.numArgs;
/* Is there a 'this' pointer */
if (!info.compIsStatic)
info.compArgsCount++;
info.compILargsCount = info.compArgsCount;
/* Is there a hidden pointer to the return value ? */
info.compRetBuffArg = -1; // indicates not present
if (info.compMethodInfo->args.hasRetBuffArg())
{
info.compRetBuffArg = info.compIsStatic ? 0:1;
info.compArgsCount++;
}
/* There is a 'hidden' cookie pushed last when the
calling convention is varargs */
if (info.compIsVarArgs)
info.compArgsCount++;
lvaCount =
info.compLocalsCount = info.compArgsCount +
info.compMethodInfo->locals.numArgs;
info.compILlocalsCount = info.compILargsCount +
info.compMethodInfo->locals.numArgs;
/* Now allocate the variable descriptor table */
lvaTableCnt = lvaCount * 2;
if (lvaTableCnt < 16)
lvaTableCnt = 16;
lvaTable = (LclVarDsc*)compGetMemArray(lvaTableCnt, sizeof(*lvaTable));
size_t tableSize = lvaTableCnt * sizeof(*lvaTable);
memset(lvaTable, 0, tableSize);
//-------------------------------------------------------------------------
// Count the arguments and initialize the resp. lvaTable[] entries
//
// First the implicit arguments
//-------------------------------------------------------------------------
LclVarDsc * varDsc = lvaTable;
unsigned varNum = 0;
unsigned regArgNum = 0;
compArgSize = 0;
/* Is there a "this" pointer ? */
if (!info.compIsStatic)
{
varDsc->lvIsParam = 1;
#if ASSERTION_PROP
varDsc->lvSingleDef = 1;
#endif
DWORD clsFlags = eeGetClassAttribs(info.compClassHnd);
if (clsFlags & CORINFO_FLG_VALUECLASS)
varDsc->lvType = TYP_BYREF;
else
varDsc->lvType = TYP_REF;
if (tiVerificationNeeded)
{
varDsc->lvVerTypeInfo = verMakeTypeInfo(info.compClassHnd);
if (varDsc->lvVerTypeInfo.IsValueClass())
varDsc->lvVerTypeInfo.MakeByRef();
}
else
varDsc->lvVerTypeInfo = typeInfo();
// Mark the 'this' pointer for the method
varDsc->lvVerTypeInfo.SetIsThisPtr();
varDsc->lvIsRegArg = 1;
assert(regArgNum == 0);
varDsc->lvArgReg = (regNumberSmall) genRegArgNum(0);
varDsc->setPrefReg(varDsc->lvArgReg, this);
regArgNum++;
#ifdef DEBUG
if (verbose&&0) printf("'this' passed in register\n");
#endif
compArgSize += sizeof(void *);
varNum++;
varDsc++;
}
#if RET_64BIT_AS_STRUCTS
/* Figure out whether we need to add a secret "retval addr" argument */
fgRetArgUse = false;
fgRetArgNum = 0xFFFF;
if (genTypeStSz(info.compDeclRetType) > 1)
{
/* Yes, we have to add the retvaladdr argument */
fgRetArgUse = true;
/* "this" needs to stay as argument 0, if present */
fgRetArgNum = info.compIsStatic ? 0 : 1;
varDsc->lvType = TYP_REF;
varDsc->lvIsParam = 1;
varDsc->lvIsRegArg = 1;
#if ASSERTION_PROP
varDsc->lvSingleDef = 1;
#endif
assert(regArgNum < maxRegArg);
varDsc->lvArgReg = (regNumberSmall)genRegArgNum(regArgNum);
varDsc->setPrefReg(varDsc->lvArgReg, this);
regArgNum++;
lvaCount++;
/* Update the total argument size, count and varDsc */
compArgSize += sizeof(void *);
varNum++;
varDsc++;
}
#endif
/* If we have a hidden return-buffer parameter, that comes here */
if (info.compRetBuffArg >= 0)
{
assert(regArgNum < MAX_REG_ARG);
varDsc->lvType = TYP_BYREF;
varDsc->lvIsParam = 1;
varDsc->lvIsRegArg = 1;
#if ASSERTION_PROP
varDsc->lvSingleDef = 1;
#endif
varDsc->lvArgReg = (regNumberSmall)genRegArgNum(regArgNum);
varDsc->setPrefReg(varDsc->lvArgReg, this);
regArgNum++;
#ifdef DEBUG
if (verbose&&0) printf("'__retBuf' passed in register\n");
#endif
/* Update the total argument size, count and varDsc */
compArgSize += sizeof(void*);
varNum++;
varDsc++;
}
//-------------------------------------------------------------------------
// Now walk the function signature for the explicit arguments
//-------------------------------------------------------------------------
// Only (some of) the implicit args are enregistered for varargs
unsigned maxRegArg = info.compIsVarArgs ? regArgNum : MAX_REG_ARG;
CORINFO_ARG_LIST_HANDLE argLst = info.compMethodInfo->args.args;
unsigned argSigLen = info.compMethodInfo->args.numArgs;
unsigned i;
for ( i = 0;
i < argSigLen;
i++, varNum++, varDsc++, argLst = eeGetArgNext(argLst))
{
CORINFO_CLASS_HANDLE typeHnd;
var_types type = JITtype2varType(strip(info.compCompHnd->getArgType(&info.compMethodInfo->args, argLst, &typeHnd)));
varDsc->lvIsParam = 1;
#if ASSERTION_PROP
varDsc->lvSingleDef = 1;
#endif
lvaInitVarDsc(varDsc, varNum, type, typeHnd, argLst, &info.compMethodInfo->args);
if (regArgNum < maxRegArg && isRegParamType(varDsc->TypeGet()))
{
/* Another register argument */
varDsc->lvIsRegArg = 1;
varDsc->lvArgReg = (regNumberSmall) genRegArgNum(regArgNum);
varDsc->setPrefReg(varDsc->lvArgReg, this);
regArgNum++;
#ifdef DEBUG
if (verbose&&0) printf("Arg #%3u passed in register\n", varNum);
#endif
}
compArgSize += eeGetArgSize(argLst, &info.compMethodInfo->args);
if (info.compIsVarArgs)
varDsc->lvStkOffs = compArgSize;
}
/* If the method is varargs, process the varargs cookie */
if (info.compIsVarArgs)
{
varDsc->lvType = TYP_I_IMPL;
varDsc->lvIsParam = 1;
varDsc->lvAddrTaken = 1;
#if ASSERTION_PROP
varDsc->lvSingleDef = 1;
#endif
/* Update the total argument size, count and varDsc */
compArgSize += sizeof(void*);
varNum++;
varDsc++;
// Allocate a temp to point at the beginning of the args
unsigned lclNum = lvaGrabTemp();
assert(lclNum == lvaVarargsBaseOfStkArgs);
lvaTable[lclNum].lvType = TYP_I_IMPL;
}
/* We set info.compArgsCount in compCompile() */
assert(varNum == info.compArgsCount);
assert(regArgNum <= MAX_REG_ARG);
rsCalleeRegArgNum = regArgNum;
/* The total argument size must be aligned. */
assert((compArgSize % sizeof(int)) == 0);
#if TGT_x86
/* We cant pass more than 2^16 dwords as arguments as the "ret"
instruction can only pop 2^16 arguments. Could be handled correctly
but it will be very difficult for fully interruptible code */
if (compArgSize != (size_t)(unsigned short)compArgSize)
NO_WAY("Too many arguments for the \"ret\" instruction to pop");
#endif
/* Does it fit into LclVarDsc.lvStkOffs (which is a signed short) */
if (compArgSize != (size_t)(signed short)compArgSize)
NO_WAY("Arguments are too big for the jit to handle");
//-------------------------------------------------------------------------
// Finally the local variables
//-------------------------------------------------------------------------
CORINFO_ARG_LIST_HANDLE localsSig = info.compMethodInfo->locals.args;
for( i = 0;
i < info.compMethodInfo->locals.numArgs;
i++, varNum++, varDsc++, localsSig = eeGetArgNext(localsSig))
{
CORINFO_CLASS_HANDLE typeHnd;
CorInfoTypeWithMod corInfoType = info.compCompHnd->getArgType(&info.compMethodInfo->locals, localsSig, &typeHnd);
varDsc->lvPinned = ((corInfoType & CORINFO_TYPE_MOD_PINNED) != 0);
lvaInitVarDsc(varDsc, varNum, JITtype2varType(strip(corInfoType)), typeHnd, localsSig, &info.compMethodInfo->locals);
}
#ifdef DEBUG
if (verbose)
lvaTableDump(true);
#endif
}
/*****************************************************************************/
void Compiler::lvaInitVarDsc(LclVarDsc * varDsc,
unsigned varNum,
var_types type,
CORINFO_CLASS_HANDLE typeHnd,
CORINFO_ARG_LIST_HANDLE varList,
CORINFO_SIG_INFO * varSig)
{
assert(varDsc == &lvaTable[varNum]);
varDsc->lvType = type;
if (varTypeIsGC(type))
varDsc->lvStructGcCount = 1;
if (type == TYP_STRUCT)
lvaSetStruct(varNum, typeHnd);
else if (tiVerificationNeeded)
{
varDsc->lvVerTypeInfo = verParseArgSigToTypeInfo(varSig, varList);
// Disallow byrefs to byref like objects (ArgTypeHandle)
// techncally we could get away with just not setting them
if (varDsc->lvVerTypeInfo.IsByRef() && verIsByRefLike(DereferenceByRef(varDsc->lvVerTypeInfo)))
varDsc->lvVerTypeInfo = typeInfo();
}
#if OPT_BOOL_OPS
if (type == TYP_BOOL)
varDsc->lvIsBoolean = true;
#endif
}
/*****************************************************************************
* Returns our internal varNum for a given IL variable.
* asserts assume it is called after lvaTable[] has been set up.
* Returns -1 if it cant be mapped.
*/
unsigned Compiler::compMapILvarNum(unsigned ILvarNum)
{
assert(ILvarNum < info.compILlocalsCount ||
ILvarNum == ICorDebugInfo::VARARGS_HANDLE);
unsigned varNum;
if (ILvarNum == ICorDebugInfo::VARARGS_HANDLE)
{
// The varargs cookie is the last argument in lvaTable[]
assert(info.compIsVarArgs);
varNum = lvaVarargsHandleArg;
assert(lvaTable[varNum].lvIsParam);
}
else if (ILvarNum == RETBUF_ILNUM)
{
assert(info.compRetBuffArg >= 0);
varNum = unsigned(info.compRetBuffArg);
}
else if (ILvarNum >= info.compLocalsCount)
{
varNum = -1;
}
else if (ILvarNum < info.compILargsCount)
{
// Parameter
varNum = compMapILargNum(ILvarNum);
assert(lvaTable[varNum].lvIsParam);
}
else
{
// Local variable
unsigned lclNum = ILvarNum - info.compILargsCount;
varNum = info.compArgsCount + lclNum;
assert(!lvaTable[varNum].lvIsParam);
}
assert(varNum < info.compLocalsCount);
return varNum;
}
/*****************************************************************************
* Returns the IL variable number given our internal varNum.
* Special return values are
* VARG_ILNUM (-1)
* RETBUF_ILNUM (-2)
* UNKNOWN_ILNUM (-3)
*
* Returns UNKNOWN_ILNUM if it can't be mapped.
*/
unsigned Compiler::compMap2ILvarNum(unsigned varNum)
{
assert(varNum < lvaCount);
assert(ICorDebugInfo::VARARGS_HANDLE == VARG_ILNUM);
if (varNum == (unsigned) info.compRetBuffArg)
return RETBUF_ILNUM;
// Is this a varargs function?
if (info.compIsVarArgs)
{
// We create an extra argument for the varargs handle at the
// end of the other arguements in lvaTable[].
if (varNum == lvaVarargsHandleArg)
return VARG_ILNUM;
else if (varNum > lvaVarargsHandleArg)
varNum--;
}
if (varNum >= info.compLocalsCount)
return UNKNOWN_ILNUM; // Cannot be mapped
/* Is there a hidden argument for the return buffer.
Note that this code works because if the retBuf is not present,
compRetBuffArg will be negative, which when cast to an unsigned
is larger than any possible varNum */
if (varNum > (unsigned) info.compRetBuffArg)
varNum--;
return varNum;
}
/*****************************************************************************
* Returns true if "ldloca" was used on the variable
*/
bool Compiler::lvaVarAddrTaken(unsigned varNum)
{
assert(varNum < lvaCount);
return lvaTable[varNum].lvAddrTaken;
}
/*****************************************************************************
* Returns the handle to the class of the local variable lclNum
*/
CORINFO_CLASS_HANDLE Compiler::lvaGetStruct(unsigned varNum)
{
return lvaTable[varNum].lvVerTypeInfo.GetClassHandleForValueClass();
}
/*****************************************************************************
* Set the lvClass for a local variable of TYP_STRUCT */
void Compiler::lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd)
{
assert(varNum < lvaCount);
LclVarDsc * varDsc = &lvaTable[varNum];
varDsc->lvType = TYP_STRUCT;
if (tiVerificationNeeded) {
varDsc->lvVerTypeInfo = verMakeTypeInfo(CORINFO_TYPE_VALUECLASS, typeHnd);
// If we have a bad sig, treat it as dead, but don't call back to the EE
// to get its particulars, since the EE will assert.
if (varDsc->lvVerTypeInfo.IsDead())
{
varDsc->lvType = TYP_VOID;
return;
}
}
else
varDsc->lvVerTypeInfo = typeInfo(TI_STRUCT, typeHnd);
varDsc->lvSize = roundUp(info.compCompHnd->getClassSize(typeHnd), sizeof(void*));
varDsc->lvGcLayout = (BYTE*) compGetMemA(varDsc->lvSize / sizeof(void*) * sizeof(BYTE));
unsigned numGCVars = eeGetClassGClayout(typeHnd, varDsc->lvGcLayout);
if (numGCVars >= 8)
numGCVars = 7;
varDsc->lvStructGcCount = numGCVars;
}
/*****************************************************************************
* Returns the array of BYTEs containing the GC layout information
*/
BYTE * Compiler::lvaGetGcLayout(unsigned varNum)
{
assert(lvaTable[varNum].lvType == TYP_STRUCT);
return lvaTable[varNum].lvGcLayout;
}
/*****************************************************************************
* Return the number of bytes needed for a local varable
*/
size_t Compiler::lvaLclSize(unsigned varNum)
{
var_types varType = lvaTable[varNum].TypeGet();
switch(varType)
{
case TYP_STRUCT:
case TYP_BLK:
return lvaTable[varNum].lvSize;
case TYP_LCLBLK:
assert(lvaScratchMem > 0);
assert(varNum == lvaScratchMemVar);
return lvaScratchMem;
default: // This is a primitve var. Fall out of switch statement
break;
}
return genTypeStSz(varType)*sizeof(int);
}
/*****************************************************************************
*
* Callback used by the tree walker to call lvaDecRefCnts
*/
Compiler::fgWalkResult Compiler::lvaDecRefCntsCB(GenTreePtr tree, void *p)
{
assert(p);
((Compiler *)p)->lvaDecRefCnts(tree);
return WALK_CONTINUE;
}
/*****************************************************************************
*
* Helper passed to the tree walker to decrement the refCnts for
* all local variables in an expression
*/
void Compiler::lvaDecRefCnts(GenTreePtr tree)
{
unsigned lclNum;
LclVarDsc * varDsc;
if ((tree->gtOper == GT_CALL) && (tree->gtFlags & GTF_CALL_UNMANAGED))
{
/* Get the special variable descriptor */
lclNum = info.compLvFrameListRoot;
assert(lclNum <= lvaCount);
varDsc = lvaTable + lclNum;
/* Decrement the reference counts twice */
varDsc->decRefCnts(compCurBB->bbWeight, this);
varDsc->decRefCnts(compCurBB->bbWeight, this);
}
else
{
/* This must be a local variable */
assert(tree->gtOper == GT_LCL_VAR || tree->gtOper == GT_LCL_FLD);
/* Get the variable descriptor */
lclNum = tree->gtLclVar.gtLclNum;
assert(lclNum < lvaCount);
varDsc = lvaTable + lclNum;
/* Decrement its lvRefCnt and lvRefCntWtd */
varDsc->decRefCnts(compCurBB->bbWeight, this);
}
}
/*****************************************************************************
*
* Callback used by the tree walker to call lvaIncRefCnts
*/
Compiler::fgWalkResult Compiler::lvaIncRefCntsCB(GenTreePtr tree, void *p)
{
assert(p);
((Compiler *)p)->lvaIncRefCnts(tree);
return WALK_CONTINUE;
}
/*****************************************************************************
*
* Helper passed to the tree walker to increment the refCnts for
* all local variables in an expression
*/
void Compiler::lvaIncRefCnts(GenTreePtr tree)
{
unsigned lclNum;
LclVarDsc * varDsc;
if ((tree->gtOper == GT_CALL) && (tree->gtFlags & GTF_CALL_UNMANAGED))
{
/* Get the special variable descriptor */
lclNum = info.compLvFrameListRoot;
assert(lclNum <= lvaCount);
varDsc = lvaTable + lclNum;
/* Increment the reference counts twice */
varDsc->incRefCnts(compCurBB->bbWeight, this);
varDsc->incRefCnts(compCurBB->bbWeight, this);
}
else
{
/* This must be a local variable */
assert(tree->gtOper == GT_LCL_VAR || tree->gtOper == GT_LCL_FLD);
/* Get the variable descriptor */
lclNum = tree->gtLclVar.gtLclNum;
assert(lclNum < lvaCount);
varDsc = lvaTable + lclNum;
/* Increment its lvRefCnt and lvRefCntWtd */
varDsc->incRefCnts(compCurBB->bbWeight, this);
}
}
/*****************************************************************************
*
* Compare function passed to qsort() by Compiler::lclVars.lvaSortByRefCount().
* when generating SMALL_CODE.
* Return positive if dsc2 has a higher ref count
* Return negative if dsc1 has a higher ref count
* Return zero if the ref counts are the same
* lvPrefReg is only used to break ties
*/
/* static */
int __cdecl Compiler::RefCntCmp(const void *op1, const void *op2)
{
LclVarDsc * dsc1 = *(LclVarDsc * *)op1;
LclVarDsc * dsc2 = *(LclVarDsc * *)op2;
/* Make sure we preference tracked variables over untracked variables */
if (dsc1->lvTracked != dsc2->lvTracked)
{
return (dsc2->lvTracked) ? +1 : -1;
}
unsigned weight1 = dsc1->lvRefCnt;
unsigned weight2 = dsc2->lvRefCnt;
/* Make sure we preference int/long/ptr over floating point types */
#if TGT_x86
if (dsc1->lvType != dsc2->lvType)
{
if (weight2 && isFloatRegType(dsc1->lvType))
return +1;
if (weight1 && isFloatRegType(dsc2->lvType))
return -1;
}
#endif
int diff = weight2 - weight1;
if (diff != 0)
return diff;
/* The unweighted ref counts were the same */
/* If the weighted ref counts are different then use their difference */
diff = dsc2->lvRefCntWtd - dsc1->lvRefCntWtd;
if (diff != 0)
return diff;
/* We have equal ref counts and weighted ref counts */
/* Break the tie by: */
/* Increasing the weight by 2 if we have exactly one bit set in lvPrefReg */
/* Increasing the weight by 1 if we have more than one bit set in lvPrefReg */
/* Increasing the weight by 0.5 if we were enregistered in the previous pass */
if (weight1)
{
if (dsc1->lvPrefReg)
{
if ( (dsc1->lvPrefReg & ~RBM_BYTE_REG_FLAG) && genMaxOneBit((unsigned)dsc1->lvPrefReg))
weight1 += 2 * BB_UNITY_WEIGHT;
else
weight1 += 1 * BB_UNITY_WEIGHT;
}
if (dsc1->lvRegister)
weight1 += BB_UNITY_WEIGHT / 2;
}
if (weight2)
{
if (dsc2->lvPrefReg)
{
if ( (dsc2->lvPrefReg & ~RBM_BYTE_REG_FLAG) && genMaxOneBit((unsigned)dsc2->lvPrefReg))
weight2 += 2 * BB_UNITY_WEIGHT;
else
weight2 += 1 * BB_UNITY_WEIGHT;
}
if (dsc2->lvRegister)
weight2 += BB_UNITY_WEIGHT / 2;
}
diff = weight2 - weight1;
return diff;
}
/*****************************************************************************
*
* Compare function passed to qsort() by Compiler::lclVars.lvaSortByRefCount().
* when not generating SMALL_CODE.
* Return positive if dsc2 has a higher weighted ref count
* Return negative if dsc1 has a higher weighted ref count
* Return zero if the ref counts are the same
*/
/* static */
int __cdecl Compiler::WtdRefCntCmp(const void *op1, const void *op2)
{
LclVarDsc * dsc1 = *(LclVarDsc * *)op1;
LclVarDsc * dsc2 = *(LclVarDsc * *)op2;
/* Make sure we preference tracked variables over untracked variables */
if (dsc1->lvTracked != dsc2->lvTracked)
{
return (dsc2->lvTracked) ? +1 : -1;
}
unsigned weight1 = dsc1->lvRefCntWtd;
unsigned weight2 = dsc2->lvRefCntWtd;
/* Make sure we preference int/long/ptr over float/double */
#if TGT_x86
if (dsc1->lvType != dsc2->lvType)
{
if (weight2 && isFloatRegType(dsc1->lvType))
return +1;
if (weight1 && isFloatRegType(dsc2->lvType))
return -1;
}
#endif
/* Increase the weight by 2 if we have exactly one bit set in lvPrefReg */
/* Increase the weight by 1 if we have more than one bit set in lvPrefReg */
if (weight1 && dsc1->lvPrefReg)
{
if ( (dsc1->lvPrefReg & ~RBM_BYTE_REG_FLAG) && genMaxOneBit((unsigned)dsc1->lvPrefReg))
weight1 += 2 * BB_UNITY_WEIGHT;
else
weight1 += 1 * BB_UNITY_WEIGHT;
}
if (weight2 && dsc2->lvPrefReg)
{
if ( (dsc2->lvPrefReg & ~RBM_BYTE_REG_FLAG) && genMaxOneBit((unsigned)dsc2->lvPrefReg))
weight2 += 2 * BB_UNITY_WEIGHT;
else
weight2 += 1 * BB_UNITY_WEIGHT;
}
int diff = weight2 - weight1;
if (diff != 0)
return diff;
/* We have equal weighted ref counts */
/* If the unweighted ref counts are different then use their difference */
diff = dsc2->lvRefCnt - dsc1->lvRefCnt;
if (diff != 0)
return diff;
/* If one was enregistered in the previous pass then it wins */
if (dsc1->lvRegister != dsc2->lvRegister)
{
if (dsc1->lvRegister)
diff = -1;
else
diff = +1;
}
return diff;
}
/*****************************************************************************
*
* Sort the local variable table by refcount and assign tracking indices.
*/
void Compiler::lvaSortOnly()
{
/* Now sort the variable table by ref-count */
qsort(lvaRefSorted, lvaCount, sizeof(*lvaRefSorted),
(compCodeOpt() == SMALL_CODE) ? RefCntCmp
: WtdRefCntCmp);
lvaSortAgain = false;
#ifdef DEBUG
if (verbose && lvaCount)
{
printf("refCnt table for '%s':\n", info.compMethodName);
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
if (!lvaRefSorted[lclNum]->lvRefCnt)
break;
printf(" ");
gtDispLclVar(lvaRefSorted[lclNum] - lvaTable);
printf(" [%6s]: refCnt = %4u, refCntWtd = %6u",
varTypeName(lvaRefSorted[lclNum]->TypeGet()),
lvaRefSorted[lclNum]->lvRefCnt,
lvaRefSorted[lclNum]->lvRefCntWtd);
unsigned pref = lvaRefSorted[lclNum]->lvPrefReg;
if (pref)
{
printf(" pref ");
if (pref & 0x01) printf("EAX ");
if (pref & 0x02) printf("ECX ");
if (pref & 0x04) printf("EDX ");
if (pref & 0x08) printf("EBX ");
if (pref & 0x20) printf("EBP ");
if (pref & 0x40) printf("ESI ");
if (pref & 0x80) printf("EDI ");
if (pref & 0x10) printf("byteable ");
}
printf("\n");
}
printf("\n");
}
#endif
}
/*****************************************************************************
*
* Sort the local variable table by refcount and assign tracking indices.
*/
void Compiler::lvaSortByRefCount()
{
lvaTrackedCount = 0;
lvaTrackedVars = 0;
if (lvaCount == 0)
return;
unsigned lclNum;
LclVarDsc * varDsc;
LclVarDsc * * refTab;
/* We'll sort the variables by ref count - allocate the sorted table */
lvaRefSorted = refTab = (LclVarDsc **) compGetMemArray(lvaCount, sizeof(*refTab));
/* Fill in the table used for sorting */
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
/* Append this variable to the table for sorting */
*refTab++ = varDsc;
/* If we have JMP or JMPI, all arguments must have a location
* even if we don't use them inside the method */
if (varDsc->lvIsParam && compJmpOpUsed)
{
/* ...except when we have varargs and the argument is
passed on the stack. In that case, it's important
for the ref count to be zero, so that we don't attempt
to track them for GC info (which is not possible since we
don't know their offset in the stack). See the assert at the
end of raMarkStkVars and bug #28949 for more info. */
if (!raIsVarargsStackArg(lclNum))
{
varDsc->incRefCnts(1, this);
}
}
/* For now assume we'll be able to track all locals */
varDsc->lvTracked = 1;
/* If the ref count is zero */
if (varDsc->lvRefCnt == 0)
{
/* Zero ref count, make this untracked */
varDsc->lvTracked = 0;
varDsc->lvRefCntWtd = 0;
}
// If the address of the local var was taken, mark it as volatile
// All structures are assumed to have their address taken
// Also pinned locals must be untracked
// All untracked locals later get lvMustInit set as well
//
if (varDsc->lvAddrTaken ||
varDsc->lvType == TYP_STRUCT ||
varDsc->lvPinned)
{
varDsc->lvVolatile = 1;
varDsc->lvTracked = 0;
}
// Are we not optimizing and we have exception handlers?
// if so mark all args and locals as volatile, so that they
// won't ever get enregistered.
//
if (opts.compMinOptim && info.compXcptnsCount)
{
varDsc->lvVolatile = 1;
continue;
}
var_types type = genActualType(varDsc->TypeGet());
switch (type)
{
#if CPU_HAS_FP_SUPPORT
case TYP_FLOAT:
case TYP_DOUBLE:
#endif
case TYP_INT:
case TYP_LONG:
case TYP_REF:
case TYP_BYREF:
break;
case TYP_UNDEF:
case TYP_UNKNOWN:
assert(!"lvType not set correctly");
varDsc->lvType = TYP_INT;
/* Fall through */
default:
varDsc->lvTracked = 0;
}
}
/* Now sort the variable table by ref-count */
lvaSortOnly();
/* Decide which variables will be worth tracking */
if (lvaCount > lclMAX_TRACKED)
{
/* Mark all variables past the first 'lclMAX_TRACKED' as untracked */
for (lclNum = lclMAX_TRACKED; lclNum < lvaCount; lclNum++)
{
lvaRefSorted[lclNum]->lvTracked = 0;
}
}
#ifdef DEBUG
// Re-Initialize to -1 for safety in debug build.
memset(lvaTrackedToVarNum, -1, sizeof(lvaTrackedToVarNum));
#endif
/* Assign indices to all the variables we've decided to track */
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
if (varDsc->lvTracked)
{
assert(varDsc->lvRefCnt > 0);
/* This variable will be tracked - assign it an index */
lvaTrackedVars |= genVarIndexToBit(lvaTrackedCount);
lvaTrackedToVarNum[lvaTrackedCount] = lclNum;
varDsc->lvVarIndex = lvaTrackedCount++;
}
}
}
/*****************************************************************************
*
* This is called by lvaMarkLclRefsCallback() to do variable ref marking
*/
void Compiler::lvaMarkLclRefs(GenTreePtr tree)
{
#if INLINE_NDIRECT
/* Is this a call to unmanaged code ? */
if (tree->gtOper == GT_CALL && tree->gtFlags & GTF_CALL_UNMANAGED)
{
/* Get the special variable descriptor */
unsigned lclNum = info.compLvFrameListRoot;
assert(lclNum <= lvaCount);
LclVarDsc * varDsc = lvaTable + lclNum;
/* Increment the ref counts twice */
varDsc->incRefCnts(lvaMarkRefsWeight, this);
varDsc->incRefCnts(lvaMarkRefsWeight, this);
}
#endif
/* Is this an assigment? */
if (tree->OperKind() & GTK_ASGOP)
{
GenTreePtr op1 = tree->gtOp.gtOp1;
GenTreePtr op2 = tree->gtOp.gtOp2;
#if TGT_x86
/* Set target register for RHS local if assignment is of a "small" type */
if (varTypeIsByte(tree->gtType))
{
unsigned lclNum;
LclVarDsc * varDsc = NULL;
/* GT_CHS is special it doesn't have a valid op2 */
if (tree->gtOper == GT_CHS)
{
if (op1->gtOper == GT_LCL_VAR)
{
lclNum = op1->gtLclVar.gtLclNum;
assert(lclNum < lvaCount);
varDsc = &lvaTable[lclNum];
}
}
else
{
if (op2->gtOper == GT_LCL_VAR)
{
lclNum = op2->gtLclVar.gtLclNum;
assert(lclNum < lvaCount);
varDsc = &lvaTable[lclNum];
}
}
if (varDsc)
varDsc->addPrefReg(RBM_BYTE_REG_FLAG, this);
}
#endif
#if OPT_BOOL_OPS
/* Is this an assignment to a local variable? */
if (op1->gtOper == GT_LCL_VAR && op2->gtType != TYP_BOOL)
{
/* Only simple assignments allowed for booleans */
if (tree->gtOper != GT_ASG)
goto NOT_BOOL;
/* Is the RHS clearly a boolean value? */
switch (op2->gtOper)
{
unsigned lclNum;
case GT_LOG0:
case GT_LOG1:
/* The result of log0/1 is always a true boolean */
break;
#if 0
// @TODO [CONSIDER] [04/16/01] []: Allow assignments of other lvIsBoolean variables.
// We have to find the closure of such variables.
case GT_LCL_VAR:
lclNum = op2->gtLclVar.gtLclNum;
if (lvaTable[lclNum].lvIsBoolean)
break;
else
goto NOT_BOOL;
#endif
case GT_CNS_INT:
if (op2->gtIntCon.gtIconVal == 0)
break;
if (op2->gtIntCon.gtIconVal == 1)
break;
// Not 0 or 1, fall through ....
default:
if (op2->OperIsCompare())
break;
NOT_BOOL:
lclNum = op1->gtLclVar.gtLclNum;
assert(lclNum < lvaCount);
lvaTable[lclNum].lvIsBoolean = false;
break;
}
}
#endif
}
#if FANCY_ARRAY_OPT
/* Special case: assignment node */
if (tree->gtOper == GT_ASG)
{
if (tree->gtType == TYP_INT)
{
unsigned lclNum1;
LclVarDsc * varDsc1;
GenTreePtr op1 = tree->gtOp.gtOp1;
if (op1->gtOper != GT_LCL_VAR)
return;
lclNum1 = op1->gtLclVar.gtLclNum;
assert(lclNum1 < lvaCount);
varDsc1 = lvaTable + lclNum1;
if (varDsc1->lvAssignOne)
varDsc1->lvAssignTwo = true;
else
varDsc1->lvAssignOne = true;
}
return;
}
#endif
#if TGT_x86
/* Special case: integer shift node by a variable amount */
if (tree->gtOper == GT_LSH ||
tree->gtOper == GT_RSH ||
tree->gtOper == GT_RSZ)
{
if (tree->gtType == TYP_INT)
{
GenTreePtr op2 = tree->gtOp.gtOp2;
if (op2->gtOper == GT_LCL_VAR)
{
unsigned lclNum = op2->gtLclVar.gtLclNum;
assert(lclNum < lvaCount);
lvaTable[lclNum].setPrefReg(REG_ECX, this);
}
}
return;
}
#endif
#if TGT_SH3
if (tree->gtOper == GT_IND)
{
/* Indexed address modes work well with r0 */
int rev;
unsigned mul;
unsigned cns;
GenTreePtr adr;
GenTreePtr idx;
if (genCreateAddrMode(tree->gtOp.gtOp1, // address
0, // mode
false, // fold
0, // reg mask
#if!LEA_AVAILABLE
tree->TypeGet(), // operand type
#endif
&rev, // reverse ops
&adr, // base addr
&idx, // index val
#if SCALED_ADDR_MODES
&mul, // scaling
#endif
&cns, // displacement
true)) // don't generate code
{
unsigned varNum;
LclVarDsc * varDsc;
if (!adr || !idx)
goto NO_R0;
if (idx->gtOper == GT_CNS_INT)
goto NO_R0;
if (adr->gtOper == GT_LCL_VAR)
varNum = adr->gtLclVar.gtLclNum;
else if (idx->gtOper == GT_LCL_VAR)
varNum = idx->gtLclVar.gtLclNum;
else
goto NO_R0;
assert(varNum < lvaCount);
varDsc = lvaTable + varNum;
varDsc->lvPrefReg |= RBM_r00;
}
NO_R0:;
}
#endif
if ((tree->gtOper != GT_LCL_VAR) && (tree->gtOper != GT_LCL_FLD))
return;
/* This must be a local variable reference */
assert((tree->gtOper == GT_LCL_VAR) || (tree->gtOper == GT_LCL_FLD));
unsigned lclNum = tree->gtLclVar.gtLclNum;
assert(lclNum < lvaCount);
LclVarDsc * varDsc = lvaTable + lclNum;
/* Increment the reference counts */
varDsc->incRefCnts(lvaMarkRefsWeight, this);
if (lvaVarAddrTaken(lclNum))
varDsc->lvIsBoolean = false;
if (tree->gtOper == GT_LCL_FLD)
return;
#if ASSERTION_PROP
/* Exclude the normal entry block */
if (fgDomsComputed && fgEnterBlks &&
(lvaMarkRefsCurBlock->bbNum != 1) &&
(lvaMarkRefsCurBlock->bbDom != NULL))
{
/* Check if fgEntryBlk dominates compCurBB */
for (unsigned i=0; i < fgPerBlock; i++)
{
unsigned domMask = lvaMarkRefsCurBlock->bbDom[i] & fgEnterBlks[i];
if (i == 0)
domMask &= ~1; // Exclude the normal entry block
if (domMask)
varDsc->lvVolatileHint = 1;
}
}
/* Record if the variable has a single def or not */
if (!varDsc->lvDisqualify)
{
if (tree->gtFlags & GTF_VAR_DEF)
{
/* This is a def of our var */
if (varDsc->lvSingleDef || (tree->gtFlags & GTF_COLON_COND))
{
// We can't have multiple definitions or
// definitions that occur inside QMARK-COLON trees
goto DISQUALIFY_LCL_VAR;
}
else
{
varDsc->lvSingleDef = true;
varDsc->lvDefStmt = lvaMarkRefsCurStmt;
}
if (tree->gtFlags & GTF_VAR_USEASG)
goto REF_OF_LCL_VAR;
}
else // This is a ref of our variable
{
REF_OF_LCL_VAR:
unsigned blkNum = lvaMarkRefsCurBlock->bbNum;
if (blkNum < 32)
{
varDsc->lvRefBlks |= (1 << (blkNum-1));
}
else
{
DISQUALIFY_LCL_VAR:
varDsc->lvDisqualify = true;
varDsc->lvSingleDef = false;
varDsc->lvDefStmt = NULL;
}
}
}
#endif // ASSERTION_PROP
/* Variables must be used as the same type throughout the method */
assert(tiVerificationNeeded ||
varDsc->lvType == TYP_UNDEF || tree->gtType == TYP_UNKNOWN ||
genActualType(varDsc->TypeGet()) == genActualType(tree->gtType) ||
(tree->gtType == TYP_BYREF && varDsc->TypeGet() == TYP_I_IMPL) ||
(tree->gtType == TYP_I_IMPL && varDsc->TypeGet() == TYP_BYREF) ||
(tree->gtFlags & GTF_VAR_CAST) ||
varTypeIsFloating(varDsc->TypeGet()) && varTypeIsFloating(tree->gtType));
/* Remember the type of the reference */
if (tree->gtType == TYP_UNKNOWN || varDsc->lvType == TYP_UNDEF)
{
varDsc->lvType = tree->gtType;
assert(genActualType(varDsc->TypeGet()) == tree->gtType); // no truncation
}
#ifdef DEBUG
if (tree->gtFlags & GTF_VAR_CAST)
{
// it should never be bigger than the variable slot
assert(genTypeSize(tree->TypeGet()) <= genTypeSize(varDsc->TypeGet()));
}
#endif
}
/*****************************************************************************
*
* Helper passed to Compiler::fgWalkTreePre() to do variable ref marking.
*/
/* static */
Compiler::fgWalkResult Compiler::lvaMarkLclRefsCallback(GenTreePtr tree, void *p)
{
assert(p);
((Compiler*)p)->lvaMarkLclRefs(tree);
return WALK_CONTINUE;
}
/*****************************************************************************
*
* Update the local variable reference counts for one basic block
*/
void Compiler::lvaMarkLocalVars(BasicBlock * block)
{
#if ASSERTION_PROP
lvaMarkRefsCurBlock = block;
#endif
lvaMarkRefsWeight = block->bbWeight;
#ifdef DEBUG
if (verbose)
printf("*** marking local variables in block BB%02d (weight=%d)\n",
block->bbNum, lvaMarkRefsWeight);
#endif
for (GenTreePtr tree = block->bbTreeList; tree; tree = tree->gtNext)
{
assert(tree->gtOper == GT_STMT);
#if ASSERTION_PROP
lvaMarkRefsCurStmt = tree;
#endif
#ifdef DEBUG
if (verbose)
gtDispTree(tree);
#endif
fgWalkTreePre(tree->gtStmt.gtStmtExpr,
Compiler::lvaMarkLclRefsCallback,
(void *) this,
false);
}
}
/*****************************************************************************
*
* Create the local variable table and compute local variable reference
* counts.
*/
void Compiler::lvaMarkLocalVars()
{
#ifdef DEBUG
if (verbose)
printf("*************** In lvaMarkLocalVars()\n");
#endif
#if INLINE_NDIRECT
/* If there is a call to an unmanaged target, we already grabbed a
local slot for the current thread control block.
*/
if (info.compCallUnmanaged != 0)
{
assert(info.compLvFrameListRoot >= info.compLocalsCount &&
info.compLvFrameListRoot < lvaCount);
lvaTable[info.compLvFrameListRoot].lvType = TYP_I_IMPL;
/* Set the refCnt, it is used in the prolog and return block(s) */
lvaTable[info.compLvFrameListRoot].lvRefCnt = 2 * BB_UNITY_WEIGHT;
lvaTable[info.compLvFrameListRoot].lvRefCntWtd = 2 * BB_UNITY_WEIGHT;
info.compNDFrameOffset = lvaScratchMem;
/* make room for the inlined frame and some spill area */
/* return value */
lvaScratchMem += eeGetEEInfo()->sizeOfFrame + (2*sizeof(int));
}
#endif
/* If there is a locspace region, we would have already grabbed a slot for
the dummy var for the locspace region. Set its lvType in the lvaTable[].
*/
if (lvaScratchMem)
{
assert(lvaScratchMemVar >= info.compLocalsCount &&
lvaScratchMemVar < lvaCount);
lvaTable[lvaScratchMemVar].lvType = TYP_LCLBLK;
}
BasicBlock * block;
#if OPT_BOOL_OPS
if (USE_GT_LOG && fgMultipleNots && (opts.compFlags & CLFLG_TREETRANS))
{
for (block = fgFirstBB; block; block = block->bbNext)
{
GenTreePtr tree;
for (tree = block->bbTreeList; tree; tree = tree->gtNext)
{
GenTreePtr expr;
int logVar;
int nxtVar;
assert(tree->gtOper == GT_STMT); expr = tree->gtStmt.gtStmtExpr;
/* Check for "lclVar = log0(lclVar);" */
logVar = expr->IsNotAssign();
if (logVar != -1)
{
GenTreePtr next;
GenTreePtr temp;
/* Look for any consecutive assignments */
for (next = tree->gtNext; next; next = next->gtNext)
{
assert(next->gtOper == GT_STMT); temp = next->gtStmt.gtStmtExpr;
/* If we don't have another assignment to a local, bail */
nxtVar = temp->IsNotAssign();
if (nxtVar == -1)
{
/* It could be a "nothing" node we put in earlier */
if (temp->IsNothingNode())
continue;
else
break;
}
/* Do we have an assignment to the same local? */
if (nxtVar == logVar)
{
LclVarDsc * varDsc;
unsigned lclNum;
assert(tree->gtOper == GT_STMT);
assert(next->gtOper == GT_STMT);
/* Change the first "log0" to "log1" */
assert(expr-> gtOper == GT_ASG);
assert(expr->gtOp.gtOp2-> gtOper == GT_LOG0);
assert(expr->gtOp.gtOp2->gtOp.gtOp1->gtOper == GT_LCL_VAR);
expr->gtOp.gtOp2->SetOper(GT_LOG1);
/* Special case: is the variable a boolean? */
lclNum = expr->gtOp.gtOp1->gtLclVar.gtLclNum;
assert(lclNum < lvaCount);
varDsc = lvaTable + lclNum;
/* If the variable is boolean, toss the assignment */
if (varDsc->lvIsBoolean)
tree->gtStmt.gtStmtExpr = gtNewNothingNode();
/* Get rid of the second "log0" assignment */
next->gtStmt.gtStmtExpr = gtNewNothingNode();
break;
}
}
}
}
}
}
#endif
#if defined(DEBUGGING_SUPPORT) || defined(DEBUG)
// Assign slot numbers to all variables
// If compiler generated local variables, slot numbers will be
// invalid (out of range of info.compLocalVars)
// Also have to check if variable was not reallocated to another
// slot in which case we have to register the original slot #
// We dont need to do this for IL, but this keeps lvSlotNum consistent
#ifndef DEBUG
if (opts.compScopeInfo && info.compLocalVarsCount>0)
#endif
{
unsigned lclNum;
LclVarDsc * varDsc;
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
varDsc->lvSlotNum = lclNum;
}
}
#endif
/* Mark all local variable references */
for (block = fgFirstBB;
block;
block = block->bbNext)
{
lvaMarkLocalVars(block);
}
/* For incoming register arguments, if there are reference in the body
* then we will have to copy them to the final home in the prolog
* This counts as an extra reference with a weight of 2
*/
if (rsCalleeRegArgNum > 0)
{
unsigned lclNum;
LclVarDsc * varDsc;
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
if (lclNum >= info.compArgsCount)
break; // early exit for loop
if ((varDsc->lvIsRegArg) && (varDsc->lvRefCnt > 0))
{
varDsc->lvRefCnt += 1 * BB_UNITY_WEIGHT;
varDsc->lvRefCntWtd += 2 * BB_UNITY_WEIGHT;
}
}
}
#if ASSERTION_PROP
if (!opts.compMinOptim && !opts.compDbgCode)
optAddCopies();
#endif
lvaSortByRefCount();
}
/*****************************************************************************
*
* Compute stack frame offsets for arguments, locals and optionally temps.
*
* The frame is laid out as follows :
*
* ESP frames EBP frames
*
* | | | |
* |-----------------------| |-----------------------|
* | incoming | | incoming |
* | arguments | | arguments |
* +=======================+ +=======================+
* | Temps | | incoming EBP |
* |-----------------------| EBP ----->|-----------------------|
* | locspace | | security object |
* |-----------------------| |-----------------------|
* | | | |
* | Variables | | Variables |
* | | | |
* |-----------------------| |-----------------------|
* |Callee saved registers | | locspace |
* |-----------------------| |-----------------------|
* | Arguments for the | | Temps |
* ~ next function ~ <----- ESP |-----------------------|
* | | |Callee saved registers |
* | | | |-----------------------|
* | | Stack grows | | localloc |
* | downward |-----------------------|
* V | Arguments for the |
* ~ next function ~
* | |
* | | |
* | | Stack grows |
* | downward
* V
*/
void Compiler::lvaAssignFrameOffsets(bool final)
{
unsigned lclNum;
LclVarDsc * varDsc;
/* For RISC targets we assign offsets in order of ref count */
#if TGT_RISC
#define ASSIGN_FRAME_OFFSETS_BY_REFCNT 1
#else
#define ASSIGN_FRAME_OFFSETS_BY_REFCNT 0
#endif
#if ASSIGN_FRAME_OFFSETS_BY_REFCNT
LclVarDsc * * refTab;
unsigned refNum;
#endif
unsigned hasThis;
CORINFO_ARG_LIST_HANDLE argLst;
int argOffs, firstStkArgOffs;
#ifdef DEBUG
const char * fprName;
const char * sprName;
#if TGT_x86
fprName = "EBP";
sprName = "ESP";
#elif TGT_SH3
fprName = "R14";
sprName = " sp";
#else
#error Unexpected target
#endif
#endif
#if TGT_RISC
/* For RISC targets we asign frame offsets exactly once */
assert(final);
#endif
assert(lvaDoneFrameLayout < 2);
lvaDoneFrameLayout = 1+final;
/*-------------------------------------------------------------------------
*
* First process the arguments.
* For frameless methods, the argument offsets will need to be patched up
* after we know how many locals/temps are on the stack.
*
*-------------------------------------------------------------------------
*/
#if TGT_x86
/* Figure out the base frame offset */
if (!DOUBLE_ALIGN_NEED_EBPFRAME)
{
/*
Assume all callee-saved registers will be pushed. Why, you
may ask? Well, if we're not conservative wrt stack offsets,
we may end up generating a byte-displacement opcode and
later discover that because we need to push more registers
the larger offset doesn't fit in a byte. So what we do is
assume the worst (largest offsets) and if we end up not
pushing all registers we'll go back and reduce all the
offsets by the appropriate amount.
In addition to the pushed callee-saved registers we also
need to count the return address on the stack in order to
get to the first argument.
*/
assert(compCalleeRegsPushed * sizeof(int) <= CALLEE_SAVED_REG_MAXSZ);
firstStkArgOffs = (compCalleeRegsPushed * sizeof(int)) + sizeof(int);
}
else
{
firstStkArgOffs = FIRST_ARG_STACK_OFFS;
}
#else // not TGT_x86
// RISC target
regMaskTP regUse;
/*
The argument frame offset will depend on how many callee-saved
registers we use. This is kind of hard to predict, though, so
we use the following approach:
If there are no arguments that are not enregistered and
are used within the body of the method, it doesn't matter
how many callee-saved registers we use.
If we do have arguments that are on the stack and are also
used within the method, we'll use the set of callee-saved
registers holding register variables as our estimate of
which callee-saved registers we'll use. We'll assign frame
offsets based on this estimate and prevent any temps from
being stored in any other callee-saved registers.
*/
genEstRegUse = regUse = genEstRegUse & RBM_CALLEE_SAVED;
/* See if we have any used stack-based arguments */
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
/* Is this an argument that lives on the frame and is used? */
if (varDsc->lvIsParam && varDsc->lvOnFrame)
{
/* We'll commit to a callee-saved reg area size right now */
genFixedArgBase = true;
/* Figure out the base frame offset */
firstStkArgOffs = FIRST_ARG_STACK_OFFS;
/* Each bit in the "regUse" mask represents a saved register */
while (regUse)
{
regUse -= genFindLowestBit(regUse);
firstStkArgOffs += sizeof(int);
}
/* If this is a non-leaf method we'll have to save the retaddr */
if (genNonLeaf)
firstStkArgOffs += sizeof(int);
// printf("NOTE: Callee-saved area size fixed at %u bytes\n", firstStkArgOffs);
goto DONE_CSR;
}
}
/* We have found no used stack-based args */
// printf("NOTE: Callee-saved area size not predicted\n");
firstStkArgOffs = FIRST_ARG_STACK_OFFS;
genEstRegUse = ~(regMaskTP)0;
genFixedArgBase = false;
DONE_CSR:
#endif // not TGT_x86 (RISC target)
/*
Assign stack offsets to arguments (in reverse order of passing).
This means that if we pass arguments left->right, we start at
the end of the list and work backwards, for right->left we start
with the first argument and move forward.
*/
#if ARG_ORDER_R2L
argOffs = firstStkArgOffs;
#else
argOffs = firstStkArgOffs + compArgSize;
#endif
#if !STK_FASTCALL
/* Update the argOffs to reflect arguments that are passed in registers */
assert(rsCalleeRegArgNum <= MAX_REG_ARG);
assert(compArgSize >= rsCalleeRegArgNum * sizeof(void *));
argOffs -= rsCalleeRegArgNum * sizeof(void *);
#endif
/* Is there a "this" argument? */
hasThis = 0;
if (!info.compIsStatic)
{
hasThis++;
}
lclNum = hasThis;
#if RET_64BIT_AS_STRUCTS
/* Are we adding a secret "retval addr" argument? */
if (fgRetArgUse)
{
assert(fgRetArgNum == lclNum); lclNum++;
}
#endif
argLst = info.compMethodInfo->args.args;
unsigned argSigLen = info.compMethodInfo->args.numArgs;
/* if we have a hidden buffer parameter, that comes here */
if (info.compRetBuffArg >= 0 )
{
#if ARG_ORDER_R2L
assert(!"Did not implement hidden param for R2L case");
#endif
assert(lclNum < info.compArgsCount); // this param better be there
assert(lclNum == (unsigned) info.compRetBuffArg); // and be where I expect
assert(lvaTable[lclNum].lvIsRegArg);
lclNum++;
}
for(unsigned i = 0; i < argSigLen; i++)
{
#if ARG_ORDER_L2R
assert(eeGetArgSize(argLst, &info.compMethodInfo->args));
argOffs -= eeGetArgSize(argLst, &info.compMethodInfo->args);
#endif
varDsc = lvaTable + lclNum;
assert(varDsc->lvIsParam);
#if !STK_FASTCALL
if (varDsc->lvIsRegArg)
{
/* Argument is passed in a register, don't count it
* when updating the current offset on the stack */
assert(eeGetArgSize(argLst, &info.compMethodInfo->args) == sizeof(void *));
argOffs += sizeof(void *);
}
else
#endif
varDsc->lvStkOffs = argOffs;
#if ARG_ORDER_R2L
assert(eeGetArgSize(argLst, &info.compMethodInfo->args));
argOffs += eeGetArgSize(argLst, &info.compMethodInfo->args);
#endif
assert(lclNum < info.compArgsCount);
lclNum += 1;
argLst = eeGetArgNext(argLst);
}
if (info.compIsVarArgs)
{
argOffs -= sizeof(void*);
lvaTable[lclNum].lvStkOffs = argOffs;
}
#if RET_64BIT_AS_STRUCTS
/* Are we adding a secret "retval addr" argument? */
if (fgRetArgUse)
{
#if ARG_ORDER_L2R
argOffs -= sizeof(void *);
#endif
lvaTable[fgRetArgNum].lvStkOffs = argOffs;
#if ARG_ORDER_R2L
argOffs += sizeof(void *);
#endif
}
#endif // RET_64BIT_AS_STRUCTS
if (hasThis)
{
#if !STK_FASTCALL
/* The "this" pointer is always passed in a register */
assert(lvaTable[0].lvIsRegArg);
assert(lvaTable[0].lvArgReg == genRegArgNum(0));
#else
/* The "this" pointer is pushed last (smallest offset) */
#if ARG_ORDER_L2R
argOffs -= sizeof(void *);
#endif
lvaTable[0].lvStkOffs = argOffs;
#if ARG_ORDER_R2L
argOffs += sizeof(void *);
#endif
#endif // !STK_FASTCALL
}
#if ARG_ORDER_R2L
assert(argOffs == firstStkArgOffs + (int)compArgSize);
#else
assert(argOffs == firstStkArgOffs);
#endif
/*-------------------------------------------------------------------------
*
* Now compute stack offsets for any variables that don't live in registers
*
*-------------------------------------------------------------------------
*/
#if TGT_x86
size_t calleeSavedRegsSize = 0;
if (!genFPused)
{
// If FP is not used, the locals live beyond the callee-saved
// registers. Need to add that size while accessing locals
// relative to SP
calleeSavedRegsSize = compCalleeRegsPushed * sizeof(int);
assert(calleeSavedRegsSize <= CALLEE_SAVED_REG_MAXSZ);
}
compLclFrameSize = 0;
#else
/* Make sure we leave enough room for outgoing arguments */
if (genNonLeaf && genMaxCallArgs < MIN_OUT_ARG_RESERVE)
genMaxCallArgs = MIN_OUT_ARG_RESERVE;
compLclFrameSize = genMaxCallArgs;
#endif
/* If we need space for a security token, reserve it now */
if (opts.compNeedSecurityCheck)
{
/* This can't work without an explicit frame, so make sure */
assert(genFPused);
/* Reserve space on the stack by bumping the frame size */
compLclFrameSize += sizeof(void *);
}
/* If we need space for slots for shadow SP, reserve it now */
if (info.compXcptnsCount || compLocallocUsed)
{
assert(genFPused); // else offsets of locals of frameless methods will be incorrect
if (compLocallocUsed)
compLclFrameSize += sizeof(void *);
if (info.compXcptnsCount)
compLclFrameSize += sizeof(void *); // end-of-last-executed-filter (lvaLastFilterOffs())
compLclFrameSize += sizeof(void *);
lvaShadowSPfirstOffs = compLclFrameSize;
// plus 1 for zero-termination
if (info.compXcptnsCount)
compLclFrameSize += (info.compXcptnsCount + 1) * sizeof(void*);
}
/*
If we're supposed to track lifetimes of pointer temps, we'll
assign frame offsets in the following order:
non-pointer local variables (also untracked pointer variables)
pointer local variables
pointer temps
non-pointer temps
*/
bool assignDone = false; // false in first pass, true in second
bool assignNptr = true; // First pass, assign offsets to non-ptr
bool assignPtrs = false; // Second pass, assign offsets to tracked ptrs
bool assignMore = false; // Are there any tracked ptrs (else 2nd pass not needed)
/* We will use just one pass, and assign offsets to all variables */
if (opts.compDbgEnC)
assignPtrs = true;
AGAIN1:
#if ASSIGN_FRAME_OFFSETS_BY_REFCNT
for (refNum = 0, refTab = lvaRefSorted;
refNum < lvaCount;
refNum++ , refTab++)
{
assert(!opts.compDbgEnC); // For EnC, vars have to be assigned as they appear in the locals-sig
varDsc = *refTab;
#else
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
#endif
/* Ignore variables that are not on the stack frame */
if (!varDsc->lvOnFrame)
{
/* For EnC, all variables have to be allocated space on the
stack, even though they may actually be enregistered. This
way, the frame layout can be directly inferred from the
locals-sig.
*/
if(!opts.compDbgEnC)
continue;
else if (lclNum >= info.compLocalsCount) // ignore temps for EnC
continue;
}
if (varDsc->lvIsParam)
{
/* A register argument that is not enregistred ends up as
a local variable which will need stack frame space,
*/
if (!varDsc->lvIsRegArg)
continue;
}
/* Make sure the type is appropriate */
if (varTypeIsGC(varDsc->TypeGet()) && varDsc->lvTracked)
{
if (!assignPtrs)
{
assignMore = true;
continue;
}
}
else
{
if (!assignNptr)
{
assignMore = true;
continue;
}
}
#if TGT_x86
if (!genFPused)
{
#if DOUBLE_ALIGN
/* Need to align the offset? */
if (genDoubleAlign && varDsc->lvType == TYP_DOUBLE)
{
assert((compLclFrameSize & 3) == 0);
/* This makes the offset of the double divisible by 8 */
compLclFrameSize += (compLclFrameSize & 4);
}
#endif
/* The stack offset is positive relative to ESP */
varDsc->lvStkOffs = +(int)compLclFrameSize + calleeSavedRegsSize;
}
#else // not TGT_x86
// RISC target
/* Just save the offset, we'll figure out the rest later */
varDsc->lvStkOffs = compLclFrameSize;
#endif // not TGT_x86
/* Reserve the stack space for this variable */
compLclFrameSize += lvaLclSize(lclNum);
assert(compLclFrameSize % sizeof(int) == 0);
#if TGT_x86
/* Record the stack offset */
if (genFPused)
{
/* The stack offset is negative relative to EBP */
varDsc->lvStkOffs = -(int)compLclFrameSize;
}
#endif // TGT_x86
}
/* If we've only assigned one type, go back and do the others now */
if (!assignDone && assignMore)
{
assignNptr = !assignNptr;
assignPtrs = !assignPtrs;
assignDone = true;
goto AGAIN1;
}
/*-------------------------------------------------------------------------
*
* Now the temps
*
*-------------------------------------------------------------------------
*/
#if TGT_RISC
assert(!"temp allocation NYI for RISC");
#endif
size_t tempsSize = 0; // total size of all the temps
/* Allocate temps */
assignPtrs = true;
if (TRACK_GC_TEMP_LIFETIMES)
{
/* first pointers, then non-pointers in second pass */
assignNptr = false;
assignDone = false;
}
else
{
/* Pointers and non-pointers together in single pass */
assignNptr = true;
assignDone = true;
}
AGAIN2:
for (TempDsc * temp = tmpListBeg();
temp;
temp = tmpListNxt(temp))
{
size_t size;
/* Make sure the type is appropriate */
if (!assignPtrs && varTypeIsGC(temp->tdTempType()))
continue;
if (!assignNptr && !varTypeIsGC(temp->tdTempType()))
continue;
size = temp->tdTempSize();
tempsSize += size;
/* Figure out and record the stack offset of the temp */
if (genFPused)
{
/* The stack offset is negative relative to EBP */
compLclFrameSize += size;
temp->tdOffs = -(int)compLclFrameSize;
}
else
{
/* The stack offset is positive relative to ESP */
temp->tdOffs = compLclFrameSize + calleeSavedRegsSize;
compLclFrameSize += size;
}
}
/* If we've only assigned some temps, go back and do the rest now */
if (!assignDone)
{
assignNptr = !assignNptr;
assignPtrs = !assignPtrs;
assignDone = true;
goto AGAIN2;
}
/*-------------------------------------------------------------------------
*
* For frameless methods, patch the argument offsets
*
*-------------------------------------------------------------------------
*/
#if TGT_x86
if (compLclFrameSize && !DOUBLE_ALIGN_NEED_EBPFRAME)
#else
#if DOUBLE_ALIGN
if (compLclFrameSize && !genDoubleAlign)
#endif
#endif
{
/* Adjust the argument offsets by the size of the locals/temps */
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
if (varDsc->lvIsParam)
{
if (varDsc->lvIsRegArg)
continue;
varDsc->lvStkOffs += (int)compLclFrameSize;
}
}
}
/*-------------------------------------------------------------------------
*
* Now do some final stuff
*
*-------------------------------------------------------------------------
*/
#if TGT_RISC
/* If we have to set up an FP frame, the FP->SP distance isn't known */
assert(genFPused == false || genFPtoSP == 0);
/*
We can now figure out what base register (frame vs. stack
pointer) each variable will be addressed off of, and what
the final offset will be.
We'll count how many variables are beyond "direct" reach
from the stack pointer, and if there are many we'll try
to set up an FP register even if we don't have to.
*/
if (!genFPused && !genFPcant)
{
/* We haven't decided to use FP but the option is still open */
unsigned varOffs;
unsigned minOffs = 0xFFFF;
unsigned loffCnt = 0;
/* Count the references that are too far from SP */
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
/* Ignore variables that are not on the stack frame */
if (!varDsc->lvOnFrame)
continue;
assert(varDsc->lvFPbased == false);
/* Get hold of the SP offset of this variable */
varOffs = varDsc->lvStkOffs; assert((int)varOffs >= 0);
/* Is the offset of this variable very large? */
if (varOffs > MAX_SPBASE_OFFS)
{
loffCnt += varDsc->lvRefCnt;
/* Keep track of the closest variable above the limit */
if (minOffs > varOffs)
minOffs = varOffs;
}
}
if (loffCnt > 8) // arbitrary heuristic
{
/*
The variables whose offset is less than or equal to
MAX_SPBASE_OFFS will be addressed off of SP, others
will be addressed off of FP (which will be set to
the value "SP + minOffs".
*/
genFPused = true;
/* The value "minOffs" becomes the distance from SP to FP */
genFPtoSP = minOffs;
assert(minOffs < compLclFrameSize);
assert(minOffs > MAX_SPBASE_OFFS);
/* Mark all variables with high offsets to be FP-relative */
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
/* Ignore variables that are not on the stack frame */
if (!varDsc->lvOnFrame)
continue;
assert(varDsc->lvFPbased == false);
/* Get hold of the SP offset of this variable */
varOffs = varDsc->lvStkOffs; assert((int)varOffs >= 0);
/* Is the offset of this variable very large? */
if (varOffs > MAX_SPBASE_OFFS)
{
assert(varOffs >= minOffs);
/* This variable will live off of SP */
varDsc->lvFPbased = true;
varDsc->lvStkOffs = varOffs - minOffs;
}
}
}
}
#endif // TGT_RISC
}
#ifdef DEBUG
/*****************************************************************************
*
* dump the lvaTable
*/
void Compiler::lvaTableDump(bool early)
{
printf("; %s local variable assignments\n;",
early ? "Initial" : "Final");
unsigned lclNum;
LclVarDsc * varDsc;
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
var_types type = varDsc->TypeGet();
if (early)
{
printf("\n; ");
gtDispLclVar(lclNum);
printf(" %7s ", varTypeName(type));
}
else
{
if (varDsc->lvRefCnt == 0)
continue;
printf("\n; ");
gtDispLclVar(lclNum);
printf("[V%02u", lclNum);
if (varDsc->lvTracked) printf(",T%02u]", varDsc->lvVarIndex);
else printf(" ]");
printf(" (%3u,%4u%s)",
varDsc->lvRefCnt,
varDsc->lvRefCntWtd/2,
(varDsc->lvRefCntWtd & 1)?".5":" ");
printf(" %7s -> ", varTypeName(type));
if (varDsc->lvRegister)
{
if (varTypeIsFloating(type))
{
printf("fpu stack ");
}
else if (isRegPairType(type))
{
assert(varDsc->lvRegNum != REG_STK);
if (varDsc->lvOtherReg != REG_STK)
{
/* Fully enregistered long */
printf("%3s:%3s ",
getRegName(varDsc->lvOtherReg), // hi32
getRegName(varDsc->lvRegNum)); // lo32
}
else
{
/* Partially enregistered long */
int offset = varDsc->lvStkOffs+4;
printf("[%1s%02XH]:%3s",
(offset < 0 ? "-" : "+"),
(offset < 0 ? -offset : offset),
getRegName(varDsc->lvRegNum)); // lo32
}
}
else
{
printf("%3s ", getRegName(varDsc->lvRegNum));
}
}
else
{
int offset = varDsc->lvStkOffs;
printf("[%3s%1s%02XH] ",
(varDsc->lvFPbased ? "EBP" : "ESP"),
(offset < 0 ? "-" : "+"),
(offset < 0 ? -offset : offset));
}
}
if (varDsc->lvVerTypeInfo.IsThisPtr()) printf(" this");
if (varDsc->lvPinned) printf(" pinned");
if (varDsc->lvVolatile) printf(" volatile");
if (varDsc->lvRefAssign) printf(" ref-asgn");
if (varDsc->lvAddrTaken) printf(" addr-taken");
if (varDsc->lvMustInit) printf(" must-init");
}
if (lvaCount > 0)
printf("\n");
}
#endif
/*****************************************************************************
*
* Conservatively estimate the layout of the stack frame.
*/
size_t Compiler::lvaFrameSize()
{
size_t result;
#if TGT_x86
/* Layout the stack frame conservatively.
Assume all callee-saved registers are spilled to stack */
compCalleeRegsPushed = CALLEE_SAVED_REG_MAXSZ/sizeof(int);
lvaAssignFrameOffsets(false);
result = compLclFrameSize + CALLEE_SAVED_REG_MAXSZ;
#else
lvaAssignFrameOffsets(true);
result = compLclFrameSize;
#endif
return result;
}
/*****************************************************************************/
#if 0
/*****************************************************************************
*
* Based on variable interference levels computed earlier, adjust reference
* counts for all variables. The idea is that any variable that interferes
* with lots of other variables will cost more to enregister, and this way
* variables with e.g. short lifetimes (such as compiler temps) will have
* precedence over long-lived variables.
*/
inline
int genAdjRefCnt(unsigned refCnt, unsigned refLo,
unsigned refHi,
unsigned intCnt, unsigned intLo,
unsigned intHi)
{
/*
multiplier total size
0.0 803334
0.1 803825
0.2 803908
0.3 803959
0.5 804205
0.7 804736
1.0 806632
*/
#if DEBUG
if (verbose && 0)
{
printf("ref=%4u [%04u..%04u] , int=%04u [%04u..%04u]",
refCnt, refLo, refHi, intCnt, intLo, intHi);
printf(" ratio=%lf , log = %lf\n", intCnt/(double)intHi,
log(1+intCnt/(double)intHi));
}
#endif
return (int)(refCnt * (1 - 0.1 * log(1 + intCnt / (double)intHi) ));
}
/*****************************************************************************/
void Compiler::lvaAdjustRefCnts()
{
LclVarDsc * v1Dsc;
unsigned v1Num;
LclVarDsc * v2Dsc;
unsigned v2Num;
unsigned refHi;
unsigned refLo;
unsigned intHi;
unsigned intLo;
if ((opts.compFlags & CLFLG_MAXOPT) != CLFLG_MAXOPT)
return;
/* Compute interference counts for all live variables */
for (v1Num = 0, v1Dsc = lvaTable, refHi = 0, refLo = UINT_MAX;
v1Num < lvaCount;
v1Num++ , v1Dsc++)
{
VARSET_TP intf;
if (!v1Dsc->lvTracked)
continue;
/* Figure out the range of ref counts */
if (refHi < v1Dsc->lvRefCntWtd)
refHi = v1Dsc->lvRefCntWtd;
if (refLo > v1Dsc->lvRefCntWtd)
refLo = v1Dsc->lvRefCntWtd;
/* Now see what variables we interfere with */
intf = lvaVarIntf[v1Dsc->lvVarIndex];
for (v2Num = 0, v2Dsc = lvaTable;
v2Num < v1Num;
v2Num++ , v2Dsc++)
{
if (!v2Dsc->lvTracked)
continue;
if (intf & genVarIndexToBit(v2Dsc->lvVarIndex))
v1Dsc->lvIntCnt += v2Dsc->lvRefCntWtd;
}
}
refHi -= refLo;
/* Figure out the range of int counts */
for (v1Num = 0, v1Dsc = lvaTable, intHi = 0, intLo = UINT_MAX;
v1Num < lvaCount;
v1Num++ , v1Dsc++)
{
if (v1Dsc->lvTracked)
{
if (intHi < v1Dsc->lvIntCnt)
intHi = v1Dsc->lvIntCnt;
if (intLo > v1Dsc->lvIntCnt)
intLo = v1Dsc->lvIntCnt;
}
}
/* Now compute the adjusted ref counts */
for (v1Num = 0, v1Dsc = lvaTable;
v1Num < lvaCount;
v1Num++ , v1Dsc++)
{
if (v1Dsc->lvTracked)
{
long refs = genAdjRefCnt(v1Dsc->lvRefCntWtd,
refLo,
refHi,
v1Dsc->lvIntCnt,
intLo,
intHi);
if (refs <= 0)
refs = 1;
#ifdef DEBUG
if (verbose)
{
printf("Var #%02u ref=%4u [%04u..%04u] , int=%04u [%04u..%04u] ==> %4u\n",
v1Num,
v1Dsc->lvRefCntWtd,
refLo,
refHi,
v1Dsc->lvIntCnt,
intLo,
intHi,
refs);
}
#endif
v1Dsc->lvRefCntWtd = refs;
}
}
/* Re-sort the variable table by ref-count */
lvaSortByRefCount()
}
#endif // 0
/*****************************************************************************/
#ifdef DEBUG
/*****************************************************************************
* Pick a padding size at "random" for the local.
* 0 means that it should not be converted to a GT_LCL_FLD
*/
static
unsigned LCL_FLD_PADDING(unsigned lclNum)
{
// Convert every 2nd variable
if (lclNum % 2)
return 0;
// Pick a padding size at "random"
unsigned size = lclNum % 7;
return size;
}
/*****************************************************************************
*
* Callback for fgWalkAllTreesPre()
* Convert as many GT_LCL_VAR's to GT_LCL_FLD's
*/
/* static */
Compiler::fgWalkResult Compiler::lvaStressLclFldCB(GenTreePtr tree, void * p)
{
genTreeOps oper = tree->OperGet();
GenTreePtr lcl;
switch(oper)
{
case GT_LCL_VAR:
lcl = tree;
break;
case GT_ADDR:
if (tree->gtOp.gtOp1->gtOper != GT_LCL_VAR)
return WALK_CONTINUE;
lcl = tree->gtOp.gtOp1;
break;
default:
return WALK_CONTINUE;
}
Compiler * pComp = (Compiler*)p;
assert(lcl->gtOper == GT_LCL_VAR);
unsigned lclNum = lcl->gtLclVar.gtLclNum;
var_types type = lcl->TypeGet();
LclVarDsc * varDsc = &pComp->lvaTable[lclNum];
// Ignore arguments and temps
if (varDsc->lvIsParam || lclNum >= pComp->info.compLocalsCount)
return WALK_SKIP_SUBTREES;
#ifdef DEBUG
// Fix for lcl_fld stress mode
if (varDsc->lvKeepType)
{
return WALK_SKIP_SUBTREES;
}
#endif
// Cant have GC ptrs in TYP_BLK.
// @TODO [CONSIDER] [04/16/01] []: making up a class to hold these
// Also, we will weed out non-primitives
if (!varTypeIsArithmetic(type))
return WALK_SKIP_SUBTREES;
// Weed out "small" types like TYP_BYTE as we dont mark the GT_LCL_VAR
// node with the accurate small type. If we bash lvaTable[].lvType,
// then there will be no indication that it was ever a small type
var_types varType = varDsc->TypeGet();
if (varType != TYP_BLK &&
genTypeSize(varType) != genTypeSize(genActualType(varType)))
return WALK_SKIP_SUBTREES;
assert(varDsc->lvType == lcl->gtType || varDsc->lvType == TYP_BLK);
// Offset some of the local variable by a "random" non-zero amount
unsigned padding = LCL_FLD_PADDING(lclNum);
if (padding == 0)
return WALK_SKIP_SUBTREES;
// Bash the variable to a TYP_BLK
if (varType != TYP_BLK)
{
varDsc->lvType = TYP_BLK;
varDsc->lvSize = roundUp(padding + genTypeSize(varType));
varDsc->lvAddrTaken = 1;
}
tree->gtFlags |= GTF_GLOB_REF;
/* Now morph the tree appropriately */
if (oper == GT_LCL_VAR)
{
/* Change lclVar(lclNum) to lclFld(lclNum,padding) */
tree->ChangeOper(GT_LCL_FLD);
tree->gtLclFld.gtLclOffs = padding;
}
else
{
/* Change addr(lclVar) to addr(lclVar)+padding */
assert(oper == GT_ADDR);
GenTreePtr newAddr = pComp->gtNewNode(GT_NONE, TYP_UNKNOWN);
newAddr->CopyFrom(tree);
tree->ChangeOper(GT_ADD);
tree->gtOp.gtOp1 = newAddr;
tree->gtOp.gtOp2 = pComp->gtNewIconNode(padding);
lcl->gtType = TYP_BLK;
}
return WALK_SKIP_SUBTREES;
}
/*****************************************************************************/
void Compiler::lvaStressLclFld()
{
if (opts.compDbgInfo) // Since we need to bash lvaTable[].lvType
return;
if (!compStressCompile(STRESS_LCL_FLDS, 5))
return;
fgWalkAllTreesPre(lvaStressLclFldCB, (void*)this);
}
/*****************************************************************************
*
* Callback for fgWalkAllTreesPre()
* Convert as many TYP_INT locals to TYP_DOUBLE. Hopefully they will get
* enregistered on the FP stack.
*/
/* static */
Compiler::fgWalkResult Compiler::lvaStressFloatLclsCB(GenTreePtr tree, void * p)
{
Compiler * pComp = (Compiler*)p;
genTreeOps oper = tree->OperGet();
GenTreePtr lcl;
switch(oper)
{
case GT_LCL_VAR:
if (tree->gtFlags & GTF_VAR_DEF)
return WALK_CONTINUE;
lcl = tree;
break;
case GT_ASG:
if (tree->gtOp.gtOp1->gtOper != GT_LCL_VAR)
return WALK_CONTINUE;
lcl = tree->gtOp.gtOp1;
assert(lcl->gtFlags & GTF_VAR_DEF);
break;
default:
return WALK_CONTINUE;
}
assert(tree == lcl || (lcl->gtFlags & GTF_VAR_DEF));
unsigned lclNum = lcl->gtLclVar.gtLclNum;
LclVarDsc * varDsc = &pComp->lvaTable[lclNum];
if (varDsc->lvIsParam ||
varDsc->lvType != TYP_INT ||
varDsc->lvAddrTaken ||
varDsc->lvKeepType)
{
return WALK_CONTINUE;
}
// Leave some TYP_INTs unconverted for variety
if ((lclNum % 4) == 0)
return WALK_CONTINUE;
// Mark it
varDsc->lvDblWasInt = true;
if (tree == lcl)
{
tree->ChangeOper(GT_COMMA);
tree->gtOp.gtOp1 = pComp->gtNewNothingNode();
tree->gtOp.gtOp2 = pComp->gtNewCastNodeL(TYP_INT,
pComp->gtNewLclvNode(lclNum, TYP_DOUBLE),
TYP_INT);
return WALK_SKIP_SUBTREES;
}
else
{
assert(oper == GT_ASG);
assert(genActualType(tree->gtOp.gtOp2->gtType) == TYP_INT ||
genActualType(tree->gtOp.gtOp2->gtType) == TYP_BYREF);
tree->gtOp.gtOp2 = pComp->gtNewCastNode(TYP_DOUBLE,
tree->gtOp.gtOp2,
TYP_DOUBLE);
tree->gtType =
lcl->gtType = TYP_DOUBLE;
return WALK_CONTINUE;
}
}
/*****************************************************************************/
void Compiler::lvaStressFloatLcls()
{
if (opts.compDbgInfo) // Since we need to bash lvaTable[].lvType
return;
if (!compStressCompile(STRESS_ENREG_FP, 15))
return;
// Change the types of all the TYP_INT local variable nodes
fgWalkAllTreesPre(lvaStressFloatLclsCB, (void*)this);
// Also, change lvaTable accordingly
for (unsigned lcl = 0; lcl < lvaCount; lcl++)
{
LclVarDsc * varDsc = &lvaTable[lcl];
if (varDsc->lvIsParam ||
varDsc->lvType != TYP_INT ||
varDsc->lvAddrTaken)
{
assert(!varDsc->lvDblWasInt);
continue;
}
if (varDsc->lvDblWasInt)
varDsc->lvType = TYP_DOUBLE;
}
}
/*****************************************************************************/
#endif // DEBUG
/*****************************************************************************
*
* A little routine that displays a local variable bitset.
* 'set' is mask of variables that have to be displayed
* 'allVars' is the complete set of interesting variables (blank space is
* inserted if it corresponding bit is not in 'set').
*/
#ifdef DEBUG
void Compiler::lvaDispVarSet(VARSET_TP set, VARSET_TP allVars)
{
printf("{");
for (unsigned index = 0; index < VARSET_SZ; index++)
{
if (set & genVarIndexToBit(index))
{
unsigned lclNum;
LclVarDsc * varDsc;
/* Look for the matching variable */
for (lclNum = 0, varDsc = lvaTable;
lclNum < lvaCount;
lclNum++ , varDsc++)
{
if ((varDsc->lvVarIndex == index) && varDsc->lvTracked)
break;
}
printf("V%02u ", lclNum);
}
else if (allVars & genVarIndexToBit(index))
{
printf(" ");
}
}
printf("}");
}
#endif
| 29.458417 | 126 | 0.492784 | [
"object"
] |
31e301d9901566d44f67d27a43261e062cf86878 | 1,045 | cpp | C++ | src/debug_gui/types/pose2d.cpp | degarashi/revenant | 9e671320a5c8790f6bdd1b14934f81c37819f7b3 | [
"MIT"
] | null | null | null | src/debug_gui/types/pose2d.cpp | degarashi/revenant | 9e671320a5c8790f6bdd1b14934f81c37819f7b3 | [
"MIT"
] | null | null | null | src/debug_gui/types/pose2d.cpp | degarashi/revenant | 9e671320a5c8790f6bdd1b14934f81c37819f7b3 | [
"MIT"
] | null | null | null | #include "beat/src/pose2d.hpp"
#include "debug_gui/types/vector.hpp"
#include "../../imgui/imgui.h"
#include "../indent.hpp"
#include "../entry_field.hpp"
#include "../spacing.hpp"
namespace rev {
namespace debug {
namespace inner {
namespace {
const char *lb_pose2d = "Pose2D",
*lb_offset = "Offset",
*lb_scale = "Scale",
*lb_rotation = "Rotation";
}
void _Show(const ::beat::g2::Pose& p) {
auto f = EntryField(lb_pose2d, false);
f.show(lb_offset, p.getOffset());
f.show(lb_scale, p.getScaling());
f.show(lb_rotation, p.getRotation());
}
bool _Edit(::beat::g2::Pose& p) {
auto f = EntryField(lb_pose2d, true);
{
auto tmp = p.getOffset();
if(f.edit(lb_offset, tmp)) {
p.setOffset(tmp);
}
}
{
auto tmp = p.getScaling();
if(f.edit(lb_scale, tmp)) {
p.setScaling(tmp);
}
}
{
auto tmp = p.getRotation();
if(f.edit(lb_rotation, tmp)) {
p.setRotation(tmp);
}
}
return f.modified();
}
}
}
}
| 21.770833 | 42 | 0.566507 | [
"vector"
] |
31ead736c86b6b4bbe2423d8a10de1f24096325a | 7,710 | cpp | C++ | src/particle_filter.cpp | RaulDa/CarND-Kidnapped-Vehicle-P8 | fd20f5ece8655bcdc6a8e7f2622c973403bcf7f6 | [
"MIT"
] | null | null | null | src/particle_filter.cpp | RaulDa/CarND-Kidnapped-Vehicle-P8 | fd20f5ece8655bcdc6a8e7f2622c973403bcf7f6 | [
"MIT"
] | null | null | null | src/particle_filter.cpp | RaulDa/CarND-Kidnapped-Vehicle-P8 | fd20f5ece8655bcdc6a8e7f2622c973403bcf7f6 | [
"MIT"
] | null | null | null | /*
* particle_filter.cpp
*
* Created on: Dec 12, 2016
* Author: Tiffany Huang / Raul Davila
*/
#include <random>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <math.h>
#include <iostream>
#include <sstream>
#include <string>
#include <iterator>
#include "particle_filter.h"
using namespace std;
void ParticleFilter::init(double x, double y, double theta, double std[]) {
// define number of particles
num_particles = 100;
// local particle and random engine
Particle particle;
default_random_engine gen;
// GPS uncertainties (x, y in meters. theta in radians)
// Only used in initialization (simulator deviations used in prediction step)
std_GPS_x = 2;
std_GPS_y = 2;
std_GPS_theta = 0.2;
// normal distribution for each coordinate
normal_distribution<double> dist_x(x, std_GPS_x);
normal_distribution<double> dist_y(y, std_GPS_y);
normal_distribution<double> dist_theta(theta, std_GPS_theta);
for (int i=0;i<num_particles;i++){
// initialize particles with Gaussian distribution
particle.x = dist_x(gen);
particle.y = dist_y(gen);
particle.theta = dist_theta(gen);
particle.weight = 1;
particle.id = i;
// add initialized particle to vector
particles.push_back(particle);
// add initialized weight to vector (for resampling step)
weights.push_back(particle.weight);
// set initialized flag to true
is_initialized = true;
}
}
void ParticleFilter::prediction(double delta_t, double std_pos[], double velocity, double yaw_rate) {
// local coordinates and random engine
double x, y, theta;
default_random_engine gen;
// avoid division by zero during prediction
if(yaw_rate<0.00001 && yaw_rate>-0.00001){
if (yaw_rate>=0){
yaw_rate = 0.00001;
}
else{
yaw_rate = -0.00001;
}
}
for (int i=0;i<num_particles;i++){
// predict state according to estimated velocity and yaw rate
x = particles[i].x + (velocity/yaw_rate)*(sin(particles[i].theta + yaw_rate*delta_t) - sin(particles[i].theta));
y = particles[i].y + (velocity/yaw_rate)*(cos(particles[i].theta) - cos(particles[i].theta + yaw_rate*delta_t));
theta = particles[i].theta + yaw_rate*delta_t;
// normal distribution for each coordinate
normal_distribution<double> dist_x(x, std_pos[0]);
normal_distribution<double> dist_y(y, std_pos[1]);
normal_distribution<double> dist_theta(theta, std_pos[2]);
// apply Gaussian noise
particles[i].x = dist_x(gen);
particles[i].y = dist_y(gen);
particles[i].theta = dist_theta(gen);
}
}
void ParticleFilter::updateWeights(double sensor_range, double std_landmark[],
const std::vector<LandmarkObs> &observations, const Map &map_landmarks) {
// x and y map coordinates for single particle observations
vector<double> x_map_obs;
vector<double> y_map_obs;
// associated id for single particle observations
vector<int> associated_id;
vector<int> map_landmark_index_vector;
// local variables for association calculation
double lower_distance;
int id;
int map_landmark_index;
// local variables for weight calculation
double gauss_norm;
double exponent;
double weight;
for(int i=0;i<num_particles;i++){
// observations transformed from vehicle to map coordinate system
for (int j=0;j<observations.size();j++){
x_map_obs.push_back(particles[i].x + (cos(particles[i].theta)*observations[j].x) - (sin(particles[i].theta)*observations[j].y));
y_map_obs.push_back(particles[i].y + (sin(particles[i].theta)*observations[j].x) + (cos(particles[i].theta)*observations[j].y));
}
// observations associated with corresponding map landmarks
for (int j=0;j<observations.size();j++){
// initialize locals
lower_distance = 9999999999;
id = 2147483647;
map_landmark_index = 2147483647;
// for each map landmark calculate distance to observation. store lower one and corresponding id
for(int k=0;k<map_landmarks.landmark_list.size();k++){
double distance = dist(x_map_obs[j], y_map_obs[j], map_landmarks.landmark_list[k].x_f, map_landmarks.landmark_list[k].y_f);
if(distance<lower_distance){
lower_distance = distance;
id = map_landmarks.landmark_list[k].id_i;
map_landmark_index = k;
}
}
// store id of nearest map landmark
associated_id.push_back(id);
map_landmark_index_vector.push_back(map_landmark_index);
}
// calculation of particle weight by applying multivariate Gaussian probability density function
for(int j=0;j<observations.size();j++){
// gaussian normalization factor
gauss_norm = (1/(2 * M_PI * std_landmark[0] * std_landmark[1]));
// exponent
exponent = (((x_map_obs[j] - map_landmarks.landmark_list[map_landmark_index_vector[j]].x_f)*(x_map_obs[j] - map_landmarks.landmark_list[map_landmark_index_vector[j]].x_f))
/(2 * std_landmark[0] * std_landmark[0])) +
(((y_map_obs[j] - map_landmarks.landmark_list[map_landmark_index_vector[j]].y_f)*(y_map_obs[j] - map_landmarks.landmark_list[map_landmark_index_vector[j]].y_f))
/(2 * std_landmark[1] * std_landmark[1]));
// weight calculation
weight = weight * gauss_norm * exp(-exponent);
}
// store calculated weight
particles[i].weight = weight;
weights[i] = weight;
// clearing of vectors and variables for next particle
x_map_obs.clear();
y_map_obs.clear();
associated_id.clear();
map_landmark_index_vector.clear();
weight = 1;
}
}
void ParticleFilter::resample() {
// set of current particles
std::vector<Particle> particles_;
// normalize weights
double sum_weights = std::accumulate(weights.begin(), weights.end(), 0.0);
for(int i=0;i<weights.size();i++){
weights[i] = weights[i] / sum_weights;
particles[i].weight = particles[i].weight / sum_weights;
}
// implementation of resampling wheel algorithm
int index = rand() % num_particles;
double beta = 0.0;
double mw = *max_element(weights.begin(), weights.end());
for(int i=0;i<num_particles;i++){
beta += ((double) rand() / RAND_MAX) * 2.0 * mw;
while(beta>weights[index]){
beta -= weights[index];
index = (index+1)%num_particles;
}
particles_.push_back(particles[index]);
}
// set particle vector to result after resampling
particles = particles_;
}
Particle ParticleFilter::SetAssociations(Particle& particle, const std::vector<int>& associations,
const std::vector<double>& sense_x, const std::vector<double>& sense_y)
{
//particle: the particle to assign each listed association, and association's (x,y) world coordinates mapping to
// associations: The landmark id that goes along with each listed association
// sense_x: the associations x mapping already converted to world coordinates
// sense_y: the associations y mapping already converted to world coordinates
particle.associations= associations;
particle.sense_x = sense_x;
particle.sense_y = sense_y;
}
string ParticleFilter::getAssociations(Particle best)
{
vector<int> v = best.associations;
stringstream ss;
copy( v.begin(), v.end(), ostream_iterator<int>(ss, " "));
string s = ss.str();
s = s.substr(0, s.length()-1); // get rid of the trailing space
return s;
}
string ParticleFilter::getSenseX(Particle best)
{
vector<double> v = best.sense_x;
stringstream ss;
copy( v.begin(), v.end(), ostream_iterator<float>(ss, " "));
string s = ss.str();
s = s.substr(0, s.length()-1); // get rid of the trailing space
return s;
}
string ParticleFilter::getSenseY(Particle best)
{
vector<double> v = best.sense_y;
stringstream ss;
copy( v.begin(), v.end(), ostream_iterator<float>(ss, " "));
string s = ss.str();
s = s.substr(0, s.length()-1); // get rid of the trailing space
return s;
}
| 30.717131 | 174 | 0.70869 | [
"vector"
] |
31ed0b3697aadc568723c89380202081a1117439 | 9,688 | cpp | C++ | Shaders.cpp | tszalay/darkvis | 1513ada5ea7af9702f16adf0215a7cc9df1ad4d4 | [
"MIT"
] | null | null | null | Shaders.cpp | tszalay/darkvis | 1513ada5ea7af9702f16adf0215a7cc9df1ad4d4 | [
"MIT"
] | null | null | null | Shaders.cpp | tszalay/darkvis | 1513ada5ea7af9702f16adf0215a7cc9df1ad4d4 | [
"MIT"
] | null | null | null | #include <string>
#include "Render.h"
// This file contains the shader program code for all shaders
string FRAG_LOGSCALE = "\
/* the input floating-point buffer texture */ \
uniform sampler2D src; \
/* and the color table texture */ \
uniform sampler2D ctable; \
\
uniform vec2 logminscl; \
uniform vec2 selminscl; \
uniform float vdispmax; \
\
vec4 hsv_to_rgb(vec3 hsv) \
{ \
int hint = (int)floor(hsv.r); \
float hfrac = hsv.r-hint; \
hint = hint % 6; \
float p = hsv.b * (1.0-hsv.g); \
float q = hsv.b * (1.0-(hsv.g*hfrac)); \
float t = hsv.b * (1.0-(hsv.g*(1.0-hfrac))); \
if (hint == 0) \
return vec4(hsv.b, t, p, 1); \
else if (hint == 1) \
return vec4(q, hsv.b, p, 1); \
else if (hint == 2) \
return vec4(p, hsv.b, t, 1); \
else if (hint == 3) \
return vec4(p, q, hsv.b, 1); \
else if (hint == 4) \
return vec4(t, p, hsv.b, 1); \
else if (hint == 5) \
return vec4(hsv.b, p, q, 1); \
return vec4(0,0,0,0); \
} \
\
vec4 hsl_to_rgb(vec3 hsl) \
{ \
if (hsl.b == 0.0) \
return vec4(0,0,0,1); \
if (hsl.g == 0.0) \
return vec4(hsl.b,hsl.b,hsl.b,1); \
\
float t2; \
if (hsl.b <= 0.5) \
t2 = hsl.b*(1+hsl.g); \
else \
t2 = hsl.b+hsl.g-(hsl.b*hsl.g); \
\
float t1 = 2*hsl.b - t2; \
\
vec3 tmp3 = vec3(hsl.r+1.0/3.0, hsl.r, hsl.r-1.0/3.0); \
\
vec4 rgb; \
\
for (int i=0; i<3; i++) \
{ \
if (tmp3[i] < 0) tmp3[i] += 1.0; \
if (tmp3[i] > 1) tmp3[i] -= 1.0; \
if (6*tmp3[i] < 1) rgb[i] = t1 + (t2-t1)*6*tmp3[i]; \
else if (2*tmp3[i] < 1) rgb[i] = t2; \
else if (3*tmp3[i] < 2) rgb[i] = t1 + (t2-t1)*((2.0/3.0)-tmp3[i])*6; \
else rgb[i] = t1; \
} \
rgb.a = 1; \
return rgb; \
} \
\
void main() \
{ \
vec4 color = texture2D(src,gl_TexCoord[0].st); \
float dens = clamp(log(color.r/logminscl.x)/logminscl.y,0.0,1.0); \
float sigma = clamp(log2(1+color.g / color.r / vdispmax),0.0,1.0); \
gl_FragColor = hsl_to_rgb(vec3(sigma-0.5,0.6*dens,dens*dens)); \
/*gl_FragColor = texture2D(ctable, vec2(dens*0.99,sigma));*/ \
/* any points selected? */ \
if (selminscl.x > 0) \
{ \
float dens = clamp(log(color.b/selminscl.x)/selminscl.y,0.0,1.0); \
if (dens == 0.0) \
gl_FragColor *= 0.35; \
else \
gl_FragColor *= 0.5 + 0.5*dens; \
} \
} \
\
";
// These are our min/max finding shaders
string FRAG_MINMAX = "\
uniform sampler2D tex;\
uniform int xscale;\
uniform int yscale;\
uniform int width;\
uniform int height;\
\
void main()\
{\
int x;\
int y;\
vec4 color;\
vec2 loc = vec2(gl_FragCoord.x,gl_FragCoord.y)-0.5;\
loc.s *= xscale;\
loc.t *= yscale;\
loc += 0.5;\
gl_FragColor = texture2D(tex,vec2(loc.s/width,loc.t/height));\
\
for (x=0;x<xscale;x++)\
{\
for (y=0;y<yscale;y++)\
{\
color = texture2D(tex,vec2((loc.s+x)/width,(loc.t+y)/height)); \
if (color.r != 0) \
{ \
gl_FragColor.r = min(color.r, gl_FragColor.r); \
gl_FragColor.g = min(color.g, gl_FragColor.g); \
gl_FragColor.b = max(color.b, gl_FragColor.b); \
gl_FragColor.a = max(color.a, gl_FragColor.a); \
} \
}\
}\
}\
";
// This is for the first minmax step, from original image
string FRAG_MINMAXSTART = "\
uniform sampler2D tex; \
uniform float width; \
uniform float height; \
\
void main() \
{ \
float x; \
float y; \
vec4 color; \
vec2 loc = vec2(gl_FragCoord.x,gl_FragCoord.y)-0.5; \
loc.s *= 4; \
loc.t *= 4; \
loc += 0.5; \
gl_FragColor = vec4(0,0,0,0); \
\
float dx, dy; \
for (dx=0.0;dx<3.5;dx+=1.0) \
{ \
for (dy=0.0;dy<3.5;dy+=1.0) \
{ \
color = texture2D(tex,vec2((loc.s+dx)/width,(loc.t+dy)/height)); \
/* if pixel is black, discard entire block */ \
if (color.r == 0) \
{ \
gl_FragColor.r = 1e36; \
} \
/* otherwise, take max of 4x4 block */ \
gl_FragColor.r = max(color.r, gl_FragColor.r); \
gl_FragColor.g = max(color.b, gl_FragColor.g); \
gl_FragColor.b = max(color.r, gl_FragColor.b); \
} \
} \
gl_FragColor.a = gl_FragColor.g; \
/* did this block have any selected in it? */ \
if (gl_FragColor.g == 0) \
{ \
gl_FragColor.g = 1e36; \
gl_FragColor.a = 0; \
} \
} \
";
// This is the basic point sprite shader
string VERT_PSPRITE = "\
\
/* these three are obvious */ \
attribute vec3 pos; \
attribute vec3 vel; \
attribute vec3 acc; \
/* hsml.x is current hsml, hsml.y is next */ \
attribute vec2 hsml; \
/* clr is (densq, vdisp), nclr is next */ \
attribute vec2 clr; \
attribute vec2 nclr; \
/* componentwise bytes of pid */ \
attribute vec4 pid; \
\
uniform vec3 pmin; \
uniform vec3 vmin; \
uniform vec3 amin; \
uniform float hmin; \
uniform vec2 cmin; \
\
uniform vec3 pscl; \
uniform vec3 vscl; \
uniform vec3 ascl; \
uniform float hscl; \
uniform vec2 cscl; \
\
uniform float dt; \
uniform float hsmlscale; \
uniform sampler2D seltex; \
uniform int numSel; \
\
int isSelected(int ipid) \
{ \
int beg=0; \
int end=numSel; \
int mid=numSel/2; \
int selpid; \
int n = numSel; \
\
vec4 samp = texture2D(seltex, vec2(float(mid%"SELTEXDIM_STR")+0.5, \
floor(float(mid/"SELTEXDIM_STR"))+0.5)/"SELTEXDIM_STR".0); \
selpid = int(samp.r*255.0 + 0.2); \
selpid += 256*int(samp.g*255.0 + 0.2); \
selpid += 256*256*int(samp.b*255 + 0.2); \
selpid += 256*256*256*int(samp.a*255.0 + 0.2); \
\
while((beg <= end) && (ipid != selpid)) \
{ \
if (ipid < selpid) \
{ \
end = mid - 1; \
n = n/2; \
mid = beg + n/2; \
} \
else \
{ \
beg = mid + 1; \
n = n/2; \
mid = beg + n/2; \
} \
samp = texture2D(seltex, vec2(float(mid%"SELTEXDIM_STR")+0.5, \
floor(float(mid/"SELTEXDIM_STR"))+0.5)/"SELTEXDIM_STR".0); \
selpid = int(samp.r*255.0+0.2); \
selpid += 256*int(samp.g*255.0+0.2); \
selpid += 256*256*int(samp.b*255.0+0.2); \
selpid += 256*256*256*int(samp.a*255.0+0.2); \
} \
\
if (ipid == selpid) \
return 1; \
\
return 0; \
} \
\
void main() \
{ \
/* compute actual pid */ \
int ipid = int(pid.x+0.2); \
ipid += 256*int(pid.y+0.2); \
ipid += 256*256*int(pid.z+0.2); \
ipid += 256*256*256*int(pid.w+0.2); \
/* scale all attr. values correctly */ \
pos = (pos*pscl) + pmin; \
vel = (vel*vscl) + vmin; \
acc = (acc*ascl) + amin; \
clr = (clr*cscl) + cmin; \
nclr = (nclr*cscl) + cmin; \
hsml = (hsml*hscl) + hmin; \
/* interpolate density, veldisp, hsml correctly */ \
clr = clr*(1-dt) + nclr*dt; \
hsml.x = hsml.x*(1-dt) + hsml.y*dt; \
/* these two are log-compressed */ \
gl_FrontColor.r = exp(clr.r); \
gl_FrontColor.g = exp(clr.g); \
/* update pos by vel, acc */ \
pos += vel*dt + 0.5*acc*dt*dt; \
/* transform projection to eye coords */ \
gl_Position = gl_ModelViewMatrix*vec4(pos,1); \
gl_Position.w = 0; \
float pdist = length(gl_Position); \
gl_Position.w = 1; \
/* set point size as hsml scaled by dist (*2 for radius) */ \
gl_PointSize = 2*hsmlscale*hsml.x/pdist; \
/* finish transforming pos */ \
gl_Position = gl_ProjectionMatrix*gl_Position; \
/* limit point size */ \
gl_PointSize = floor(clamp(gl_PointSize, 1.1, "PSSTR".1)); \
/* is the point selected? */ \
if (numSel > 0 && isSelected(ipid) != 0) \
gl_FrontColor.b = gl_FrontColor.r; \
else \
gl_FrontColor.b = 0; \
gl_FrontColor /= (pdist*pdist*pdist*pdist); \
/* secretly pass point size to fragment shader */ \
gl_FrontColor.a = gl_PointSize; \
} \
";
// and this is the point sprite fragment shader
string FRAG_PSPRITE = "\
/* normalization factors for point sizes, up to max pt. size */ \
uniform float nfac["PSSTR"]; \
\
void main() \
{ \
gl_FragColor = gl_Color; \
/* integer point size, to check array */ \
/* since point size is hidden in color.a */ \
int ind = (int)(gl_Color.a+0.5); \
/* set p as the pixel coordinate, going from 0...size-1 */ \
vec2 p = floor(gl_Color.a*vec2(gl_TexCoord[0].s,gl_TexCoord[0].t)); \
/* scale to 0...1*/ \
p = (p+0.5) / gl_Color.a; \
/* and to -1...1 */ \
p = 2*(p-0.5); \
/* now compute weight */ \
float u = length(p); \
/* don't draw if outside a sensible radius */ \
if (u > 1) discard; \
\
float fac; \
if (u < 0.5) \
fac = (2.546479089470 + 15.278874536822*(u-1)*u*u); \
else \
fac = 5.092958178941*(1.0-u)*(1.0-u)*(1.0-u); \
/* compute final point color */ \
gl_FragColor *= fac/nfac[ind-1]; \
} \
";
| 30.275 | 73 | 0.491123 | [
"render",
"transform"
] |
31f12f1828774d118c2b32d435c20a130e3887c4 | 9,285 | hpp | C++ | include/processing.hpp | frc5431/Copernicus | f68dda55231b2d6503f8f87425f4150df0176918 | [
"MIT"
] | null | null | null | include/processing.hpp | frc5431/Copernicus | f68dda55231b2d6503f8f87425f4150df0176918 | [
"MIT"
] | null | null | null | include/processing.hpp | frc5431/Copernicus | f68dda55231b2d6503f8f87425f4150df0176918 | [
"MIT"
] | null | null | null | /*------------------------------------------------------------------------------||
| |
| Copyright (C) 2017 by Titan Robotics |
| License Date: 01/23/2017 |
| Modifiers: none |
| |
| Permission is hereby granted, free of charge, to any person obtaining a copy |
| of this software and associated documentation files (the "Software"), to deal |
| in the Software without restriction, including without limitation the rights |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| copies of the Software, and to permit persons to whom the Software is |
| furnished to do so, subject to the following conditions: |
| |
| The above copyright notice and this permission notice shall be included in all |
| copies or substantial portions of the Software. |
| |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| SOFTWARE. |
| |
||------------------------------------------------------------------------------*/
/**
*
* @file processing.hpp
* @date 01/23/2017
* @brief Header to control the processing of Perception
*
* @details This header file contains all the definitions for the vision
* processing of Perception and its components. The reason why the functions
* are just in a namespace is to shorten the compile time by just the symbols
* so we don't have to recompile main code every single time.
*/
//OPENCV INCLUDES
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/video.hpp>
#include <opencv2/photo.hpp>
#include <opencv2/calib3d.hpp>
//BOOST INCLUDES
#include <boost/thread.hpp>
#include <boost/chrono.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/function.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/bind.hpp>
#include <MACE/Utility/Math.h>
//STANDARD INCLUDES
#include <functional>
#include <memory>
#include <vector>
#define _USE_MATH_DEFINES 1
#include <cmath>
//NTCORE INCLUDES
#include <networktables/NetworkTable.h>
//PERCEPTION INCLUDES
//OLDSRC
//#include "kinect.hpp"
#include "log.hpp"
#ifndef INCLUDE_PROCESSING_HPP_
#define INCLUDE_PROCESSING_HPP_
#define MUTEX_S_LOCK(X) boost::mutex::scoped_lock(X)
//Settings definitions
#define PROCESSING_LOG_TAG "PROCER" //Logger processing namespace
#define PROCESSING_LOOP_TIME 2000 //Milliseconds to delay between each setting loop
#define PROCESSING_LOOP_TAG "proc_time" //Network table processing tag
//PreProcessing definitions
#define PROCESSING_MIN_THRESH_H 49 //Minimum Hue value
#define PROCESSING_MIN_THRESH_S 100 //Minimum Saturation value
#define PROCESSING_MIN_THRESH_V 46 //Minimum Value value
#define PROCESSING_MAX_THRESH_H 82 //Maximum Hue value
#define PROCESSING_MAX_THRESH_S 255 //Maximum Saturation value
#define PROCESSING_MAX_THRESH_V 201 //Maximum Value value
#define PROCESSING_MEDIAN_BLUR 7 //The median blur level (must be an odd number)
#define PROCESSING_DILATION_SIZE 1 //The dilation size for target detection
//Extra details for the boiler
#define PROCESSING_BOILER_HEIGHT 80.25f //The boiler tape centered height in inches
#define PROCESSING_BOILER_OFFSET 10.2f //The distance (in inches) that the base of the boiler is from the tape
//Extra details for camera
#define PROCESSING_CAMERA_WIDTH 640.0f //Camera dimension width in pixels
#define PROCESSING_CAMERA_HEIGHT 480.0f //Camera dimension height in pixels
#define PROCESSING_CAMERA_FPS 15.0f //Camera stream fps
#define PROCESSING_CAMERA_FOV 71.63f //Camera field of view in degrees
#define PROCESSING_CAMERA_FOCAL 2.8f //The camera focal length in millimeters
#define PROCESSING_CAMERA_VFOV 51.35f //The camera vertical field of view
#define PROCESSING_CAMERA_ANGLE 50.9f //The current angle of the camera (Back is positive and forward is negative angle)
#define PROCESSING_CAMERA_R_HEIGHT 23.75f //The current camera height from the ground to the center of the lense
#define PROCESSING_CAMERA_DEG_PIXEL (PROCESSING_CAMERA_FOV / PROCESSING_CAMERA_WIDTH) //Camera degrees per pixel (IT'S FOV DIVIDED BY PIXEL WIDTH)
#define PROCESSING_CAMERA_VDEG_PIXEL (PROCESSING_CAMERA_VFOV / PROCESSING_CAMERA_HEIGHT) //Camera degreed per pixel vertically
#define PROCESSING_CAMERA_HALF_SCREEN ((PROCESSING_CAMERA_WIDTH / 2.0f) - 0.5f) //Camera half screen angle calculation
/*#define PROCESSING_CAMERA_UNDISTORT {270.8238366, 0.0, 157.45643041, 0.0, \
272.6589298370, 129.04290129, 0.0, 0.0, 1.0}
#define PROCESSING_CAMERA_D_UNDISTORT {0.0, 0.0, 0.0, 0.0}
#define PROCESSING_CAMERA_GET_OPTIMAL(X, Y) cv::getOptimalNewCameraMatrix(X, Y, \
cv::Size(PROCESSING_CAMERA_WIDTH, PROCESSING_CAMERA_HEIGHT), 0)*/
#define PROCESSING_CAMERA_HALF_VERT (PROCESSING_CAMERA_VFOV / 2) //Vertical camera split height
#define PROCESSING_CAMERA_HEIGHT_DIFF (PROCESSING_BOILER_HEIGHT - PROCESSING_CAMERA_R_HEIGHT) //The camera delta difference from the boiler height and camera ground height
#define PROCESSING_CAMERA_REAL_ANGLE (180 - (PROCESSING_CAMERA_ANGLE + (90 - PROCESSING_CAMERA_HALF_VERT) + PROCESSING_CAMERA_VFOV)) // 15//; (PROCESSING_CAMERA_ANGLE - PROCESSING_CAMERA_HALF_VERT) //The camera displacement angle in real life
#define PROCESSING_GET_DISTANCE(X) (PROCESSING_CAMERA_HEIGHT_DIFF / (tan((mc::math::pi() * (X + PROCESSING_CAMERA_REAL_ANGLE)) / 180))) - PROCESSING_BOILER_OFFSET //Get the distance of the robot from the tower
#define PROCESSING_GET_DEGREES(X) (X - PROCESSING_CAMERA_HALF_SCREEN) * PROCESSING_CAMERA_DEG_PIXEL //Get current angle horizontally
#define PROCESSING_GET_VDEGREES(X) (X * PROCESSING_CAMERA_VDEG_PIXEL) //Get current angle vertically
//Processing definitions to check if the contour could be a possible target
#define PROCESSING_MIN_AREA 300 //Minimum pixels squared of target
#define PROCESSING_MAX_AREA 3000 //Maximum pixels squared of target
//We don't want blobs so lets put a minimum and maximum blob count
#define PROCESSING_MIN_SIDES 2 //Minimum side count for contour
#define PROCESSING_MAX_SIDES 9 //Maximum side count for contour
//Fix obscurely long contours (ratio calculator should handle it on its own)
#define PROCESSING_MIN_PERIM 25 //Minimum perimeter length of contour in pixels
#define PROCESSING_MAX_PERIM 2000 //Maximum perimeter length of contour in pixels
//Remove obscure contours that will ruin our ratio calculation
#define PROCESSING_MAX_HEIGHT 500 //Maximum height of contour in pixels
#define PROCESSING_WIDTH_RATIO 1.1f //The width to height ratio
//Region of interest
#define PROCESSING_MID_MIN_Y 0 //(PROCESSING_CAMERA_HEIGHT / 6) //Minimum pixel height for contour to be in
#define PROCESSING_MID_MAX_Y PROCESSING_CAMERA_HEIGHT //(PROCESSING_CAMERA_HEIGHT - 20) //Maximium pixel height for contour to be in
//Double tape detection and ratio calculations
#define PROCESSING_TAPE_WIDTH 16.0f //How many inches wide is the real tape
#define PROCESSING_TAPE_HEIGHT 2.0f //How many inches tall is the tape
#define PROCESSING_TAPE_VERT_DIFF 7.0f //The vertical inches differential between the tapes
#define PROCESSING_TAPE_FIX_DIFF 20 //The amount of pixels (vertically) to accommodate for the errors in the height differential
#define PROCESSING_WIDTH_FIX_DIFF 50 //The amount of pixel width differential allowed between the higher and lower object
#define PROCESSING_OFFSET_FIX_DIFF 30 //The amount of pixels difference allowed in the x coordinate location (offsets)
//Declare processing namespace
namespace processing {
class Target {
public:
unsigned int area, sides, perim, x, y;
float width, height, distance, horz_angle, vert_angle;
bool found;
};
//All documentation provided in source file
template<typename T>
void inline PLOG(T, bool error = false);
//OLDSRC
//void kinectDepth2Mat(cv::Mat &, const kinect::DepthData &, const float);
//void kinectScalar(cv::Mat &, cv::Mat &);
void preProcessing(cv::Mat &, cv::Mat &);
void processFrame(cv::Mat &, std::vector<Target> &, cv::Mat &);
void processTargets(std::vector<Target> &, Target &);
void settingsUpdate(std::shared_ptr<NetworkTable>);
} /* namespace processing */
#endif /* INCLUDE_PROCESSING_HPP_ */
| 52.162921 | 244 | 0.709208 | [
"object",
"vector"
] |
ee0497d6547db13c6f761f03496093aa031a7ae6 | 667 | cpp | C++ | source/scene/node.cpp | LavenSun/LSRViewer | 615dcb63ec913c40bdfba6b1096365c6a0391206 | [
"MIT"
] | 1 | 2021-05-18T01:38:52.000Z | 2021-05-18T01:38:52.000Z | source/scene/node.cpp | LavenSun/LSRViewer | 615dcb63ec913c40bdfba6b1096365c6a0391206 | [
"MIT"
] | null | null | null | source/scene/node.cpp | LavenSun/LSRViewer | 615dcb63ec913c40bdfba6b1096365c6a0391206 | [
"MIT"
] | null | null | null | #include <scene/node.h>
#include <scene/scene.h>
namespace chaf
{
Node::Node(Scene& scene, const std::string& name) :
scene{ scene },
name{ name },
handle{ scene.registry.create() }
{
}
void Node::setParent(Node& node)
{
parent = &node;
}
void Node::addChild(Node& node)
{
children.push_back(&node);
}
const std::vector<Node*>& Node::getChildren() const
{
return children;
}
Node* Node::getParent() const
{
return parent;
}
const uint32_t Node::getID() const
{
return static_cast<uint32_t>(handle);
}
const Scene& Node::getScene() const
{
return scene;
}
const std::string& Node::getName() const
{
return name;
}
}
| 13.895833 | 52 | 0.643178 | [
"vector"
] |
ee05e062c9d78784e7d18ef789e1d3bbb21019ec | 2,541 | cpp | C++ | src/Boid.cpp | nventuro/boids | 468b3deba2be2a5a4ff47c5808b2538d7aa71a27 | [
"MIT"
] | 1 | 2019-12-30T16:30:40.000Z | 2019-12-30T16:30:40.000Z | src/Boid.cpp | nventuro/boids | 468b3deba2be2a5a4ff47c5808b2538d7aa71a27 | [
"MIT"
] | null | null | null | src/Boid.cpp | nventuro/boids | 468b3deba2be2a5a4ff47c5808b2538d7aa71a27 | [
"MIT"
] | null | null | null | #include "Boid.h"
#include "ofMath.h"
#include "ofGraphics.h"
#include "Behaviour.h"
#include <ctgmath>
Boid::Boid(BoidMisc::Type type, const std::vector<Behaviour*> &behaviours):
type(type), config(Config::boids_by_type[type]), behaviours(behaviours)
{
id = getNextID();
pos.x = ofRandom(Config::width);
pos.y = ofRandom(Config::height);
speed.x = ofRandom(-1, 1);
speed.y = ofRandom(-1, 1);
speed = speed.getNormalized() * (config.max_speed / 3);
accel.x = 0;
accel.y = 0;
}
void Boid::calculateUpdate(const std::vector<Boid> &flock)
{
std::vector<const Boid*> nearby_boids;
for (const auto &boid : flock) {
if ((this->id != boid.getId()) && isPointInFOV(boid.getPos())) {
nearby_boids.push_back(&boid);
}
}
next_accel = accel;
for (const auto &behaviour : behaviours) {
next_accel += behaviour->apply(this, nearby_boids);
}
next_accel /= behaviours.size() + 1; // +1 because we're also taking into account our old acceleration
}
void Boid::update(float framerate)
{
framerate /= 30;
accel = next_accel;
speed += accel / framerate;
if (speed.length() > config.max_speed) {
speed = speed.getNormalized() * config.max_speed;
}
pos += speed / framerate;
// Horizontal wrap-around
if (pos.x > Config::width) {
pos.x -= Config::width;
} else if (pos.x < 0) {
pos.x += Config::width;
}
// Vertical wrap-around
if (pos.y > Config::height) {
pos.y -= Config::height;
} else if (pos.y < 0) {
pos.y += Config::height;
}
}
void Boid::draw(void) const
{
ofSetColor(config.graphics.color);
ofDrawCircle(pos, config.graphics.size);
if (config.graphics.draw_head) {
ofSetLineWidth(std::ceil(config.graphics.size / 2));
ofDrawLine(pos, pos + (speed.getNormalized() * config.graphics.size * 2));
}
}
ofVec2f Boid::getPos(void) const
{
return pos;
}
ofVec2f Boid::getSpeed(void) const
{
return speed;
}
ofVec2f Boid::getAccel(void) const
{
return accel;
}
BoidMisc::Type Boid::getType(void) const
{
return type;
}
bool Boid::isPointInFOV(ofVec2f point) const
{
float sq_infl_max_dist = config.infl_max_dist * config.infl_max_dist;
return (this->pos.squareDistance(point) < sq_infl_max_dist) && (abs(speed.angle(point - this->pos)) < (config.angle_of_view / 2));
}
int Boid::getId(void) const
{
return id;
}
int Boid::getNextID(void)
{
return id_gen++;
}
int Boid::id_gen;
| 21.533898 | 134 | 0.624557 | [
"vector"
] |
ee104591ba5860ce9ac09085c3281dcda0d1b9b7 | 382 | cpp | C++ | cpp_source/ch15/text_query/main.cpp | nhyilin/Cpp_Primer_Practice | f66beedaa138d08b7a1ab6f590ccc1112c49b372 | [
"MIT"
] | null | null | null | cpp_source/ch15/text_query/main.cpp | nhyilin/Cpp_Primer_Practice | f66beedaa138d08b7a1ab6f590ccc1112c49b372 | [
"MIT"
] | null | null | null | cpp_source/ch15/text_query/main.cpp | nhyilin/Cpp_Primer_Practice | f66beedaa138d08b7a1ab6f590ccc1112c49b372 | [
"MIT"
] | null | null | null |
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <fstream>
#include "queryresult.h"
#include "textquery.h"
#include "query_base.h"
#include "query.h"
#include "andquery.h"
#include "orquery.h"
int main()
{
std::ifstream file("storyDataFile.txt");
TextQuery tQuery(file);
Query q = Query("hello") | Query("am");
return 0;
}
| 14.148148 | 44 | 0.662304 | [
"vector"
] |
ee15b304c2aa7596e86a3c3a15a7319332d08112 | 2,542 | cpp | C++ | main.cpp | pyth/tabs_player | 12ff22f03afad6dc164f530f04e698d2dabe682e | [
"MIT"
] | 1 | 2020-03-09T08:54:23.000Z | 2020-03-09T08:54:23.000Z | main.cpp | pyth/tabs_player | 12ff22f03afad6dc164f530f04e698d2dabe682e | [
"MIT"
] | null | null | null | main.cpp | pyth/tabs_player | 12ff22f03afad6dc164f530f04e698d2dabe682e | [
"MIT"
] | null | null | null | #include <iostream>
#include <chrono>
#include <thread>
#include <fstream>
#include <vector>
#include <string>
#ifdef __linux__
#include <AL/al.h>
#include <AL/alut.h>
#elif WIN32
#include <al.h>
#include <alut.h>
#endif
#include "notes.h"
static void play(std::vector<ALfloat>& freq, ALfloat duration) {
if(freq.size() == 0) {
std::this_thread::sleep_for(std::chrono::duration<float>(duration));
return;
}
std::vector<ALuint> buf(freq.size());
std::vector<ALuint> sources(freq.size());
alGenSources(sources.size(), sources.data());
for(unsigned int i = 0; i < freq.size(); i++) {
buf[i] = alutCreateBufferWaveform(ALUT_WAVEFORM_SINE, freq[i], 0, duration);
alSourcef(sources[i], AL_PITCH, 1.0);
alSourcef(sources[i], AL_GAIN, 1.0f / 3);
alSourcei(sources[i], AL_LOOPING, 0);
alSource3f(sources[i], AL_POSITION, 0, 0, 0);
alSource3f(sources[i], AL_VELOCITY, 0, 0, 0);
alSourcei(sources[i], AL_BUFFER, buf[i]);
}
alSourcePlayv(freq.size(), sources.data());
std::this_thread::sleep_for(std::chrono::duration<float>(duration + 0.05f));
alSourceStop(sources[0]);
alDeleteSources(freq.size(), sources.data());
alDeleteBuffers(freq.size(), buf.data());
}
int main(int argc, char **argv) {
if(argc != 2)
return -1;
alutInit(&argc, argv);
ALfloat ori[] = {0, 0, 1, 0, 1, 0};
alListener3f(AL_POSITION, 0, 0, 0);
alListener3f(AL_VELOCITY, 0, 0, 0);
alListenerfv(AL_ORIENTATION, ori);
std::ifstream file(argv[1], std::ifstream::in);
size_t index1;
size_t index2;
std::string line;
while(!file.eof()) {
std::getline(file, line);
if(line[0] == '#')
continue;
guitar_chord chord;
int line_type;
index1 = 0;
index2 = 0;
while(index2 != std::string::npos) {
index2 = line.find(" ", index1);
if(index2 != std::string::npos) {
std::string s = line.substr(index1, index2 - index1);
if(index1 == 0) {
if (s == "b")
line_type = 0;
else if(s == "n")
line_type = 1;
else if(s == "c")
line_type = 2;
} else {
if(line_type == 0) {
chord.notes = {};
} else if(line_type == 1) {
chord.notes.push_back(note_map[s]);
} else {
chord.notes = chord_map[s];
}
}
index1 = index2 + 1;
} else if(index1 != 0) {
std::string s = line.substr(index1);
chord.duration = std::atof(s.c_str());
}
}
play(chord.notes, chord.duration);
}
file.close();
alutExit();
return 0;
}
| 23.109091 | 79 | 0.59284 | [
"vector"
] |
ee2821141c55192227e5d23bbd68183f05c4fa0b | 2,570 | hpp | C++ | OcularCore/include/Performance/ProfilerNode.hpp | ssell/OcularEngine | c80cc4fcdb7dd7ce48d3af330bd33d05312076b1 | [
"Apache-2.0"
] | 8 | 2017-01-27T01:06:06.000Z | 2020-11-05T20:23:19.000Z | OcularCore/include/Performance/ProfilerNode.hpp | ssell/OcularEngine | c80cc4fcdb7dd7ce48d3af330bd33d05312076b1 | [
"Apache-2.0"
] | 39 | 2016-06-03T02:00:36.000Z | 2017-03-19T17:47:39.000Z | OcularCore/include/Performance/ProfilerNode.hpp | ssell/OcularEngine | c80cc4fcdb7dd7ce48d3af330bd33d05312076b1 | [
"Apache-2.0"
] | 4 | 2019-05-22T09:13:36.000Z | 2020-12-01T03:17:45.000Z | /**
* Copyright 2014-2017 Steven T Sell (ssell@vertexfragment.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.
*/
#pragma once
#ifndef __H__OCULAR_CORE_PERFORMANCE_PROFILER_NODE__H__
#define __H__OCULAR_CORE_PERFORMANCE_PROFILER_NODE__H__
#include <string>
#include <vector>
#include <stdint.h>
//------------------------------------------------------------------------------------------
/**
* \addtogroup Ocular
* @{
*/
namespace Ocular
{
/**
* \addtogroup Core
* @{
*/
namespace Core
{
class ProfilerNode
{
public:
ProfilerNode(ProfilerNode* parent, std::string const& name, std::string const& segment);
~ProfilerNode();
bool operator==(ProfilerNode const* rhs);
//------------------------------------------------------------
// Variables
std::string name; ///< Name of this node (fully qualified method/function name)
std::string segment; ///< Segment name of this node
uint32_t totalCalls; ///< Total amount of times this node has been profiled
uint32_t blockDepth; ///< Depth of the block (used for printing)
uint32_t recursiveDepth; ///< If in a recursive function, the current depth
uint64_t blockStart; ///< Start time (ns) of the latest block
uint64_t localElapsed; ///< Amount of time elapsed in the local block
uint64_t totalElapsed; ///< Total amount of time elapsed
ProfilerNode* parent; ///< Parent node (null if root)
std::vector<ProfilerNode*> children; ///< Children nodes
protected:
private:
};
}
/**
* @} End of Doxygen Groups
*/
}
/**
* @} End of Doxygen Groups
*/
//------------------------------------------------------------------------------------------
#endif | 32.125 | 114 | 0.531907 | [
"vector"
] |
0c58c5f4f918da3b1b65f1ef2301c6460db79f6a | 40,404 | hpp | C++ | include/Lucena-Utilities/lulFeatureSetup.hpp | bitweeder/Lucena-Utilities | e651cb55557cc785b7a75e0a12c4acb34d0dc5f4 | [
"BSD-3-Clause",
"MIT"
] | null | null | null | include/Lucena-Utilities/lulFeatureSetup.hpp | bitweeder/Lucena-Utilities | e651cb55557cc785b7a75e0a12c4acb34d0dc5f4 | [
"BSD-3-Clause",
"MIT"
] | null | null | null | include/Lucena-Utilities/lulFeatureSetup.hpp | bitweeder/Lucena-Utilities | e651cb55557cc785b7a75e0a12c4acb34d0dc5f4 | [
"BSD-3-Clause",
"MIT"
] | null | null | null | /*------------------------------------------------------------------------------
Lucena Utilities Library
“FeatureSetup.hpp”
Copyright © 2018 Lucena
All Rights Reserved
This file is distributed under the University of Illinois Open Source
License. See license/License.txt for details.
lulFeatureSetup.hpp is a metaheader which includes various detail headers
to handle feature detection and macro configuration for the compiler, the
Standard Library implementation, and platform details that impact the build
environment. Users should include <Lucena-Utilities/Lucena-Utilities.hpp>,
which includes this, in favor of attempting to cherry-pick headers.
The goal of this header is to safeguard a functionality baseline for the
build environment in terms of compiler and Standard Library features. We
currently require C++17 compiler support - or at least close emulation
thereof. Note that the detail headers may evolve in compatibility-breaking
ways in the future as we track compliance with newer language features,
but such changes should be documented and restricted to point releases.
Note that we set all preprocessor conditionals unless we explicitly state
otherwise in the conditional description; those whose requirements are not
met get set to 0. By default, we set conditionals that are met to 1, but
they could conceivably be set to any non-0 number, and tests need to
reflect that.
Generally, we don’t bother testing for things that are guaranteed by our
minimum-supported compilers. For example, all supported compilers have C99-
style ints, so we don’t test for the presence of support. This may change
in the future if a compiler we’d like to support violates this standard.
As a general rule, if a feature is available and stable, it is assumed to
be used. This is not boost, and we do not seek to incent or support
thousands of micro-variants on the Standard. The sole objective of this
library is to facilitate interoperability between otherwise-conforming
modern compilers and their libraries.
LUL_COMPILER_IDENTIFIER
LUL_STANDARD_LIBRARY_IDENTIFIER
These are human-readable strings which identify the tools used for
compilation. They may include version infrmation as part of the string, but
are not required to do so.
LUL_TARGET_CPU
LUL_TARGET_CPU_IDENTIFIER
These conditionals specify which microprocessor instruction set is being
generated. At most one of these is 1, the rest are 0.
SEEME There used to be more of these, but they’ve been largely mooted.
Candidates for additions include console-specific processors/families, and
explicit differentiation for AMD processors/families.
LUL_TARGET_CPU_X86 generic 32-bit x86
LUL_TARGET_CPU_X86_64 generic 64-bit x86
LUL_TARGET_CPU_IA64 generic 64-bit Itanium
LUL_TARGET_CPU_ARM generic 32-bit ARM
LUL_TARGET_CPU_ARM_64 generic 64-bit ARM
LUL_TARGET_CPU_ARM_FAMILY
LUL_TARGET_CPU_X86_FAMILY
LUL_TARGET_CPU_IDENTIFIER is a human-readable string broadly identifying
the target CPU, as per the above macros.
LUL_TARGET_VEC
These conditionals specify which vector instruction set is being generated,
if any. Multiple conditionals may be true, but some are mutually exclusive.
LUL_TARGET_VEC_SSE
LUL_TARGET_VEC_SSE2
LUL_TARGET_VEC_SSE3
LUL_TARGET_VEC_SSE41
LUL_TARGET_VEC_SSE42
LUL_TARGET_VEC_AVX
LUL_TARGET_VEC_AVX2
Note that there is no corresponding test for AVX-512, as it’s not a
monolithic instruction set, and we don’t have the operational experience
needed to evaluate a meaningful breakdown beyond just mirroring any
predfined macros the compiler may happen to have.
// LUL_TARGET_VEC_AVX512
SEEME We don’t currently independently check for SSE-Math and similar
instruction splits; this may be a defect.
SEEME There used to be more of these, but they’ve been largely mooted.
Candidates for additions include console-specific vector instruction sets,
and explicit differentiation for AMD instruction sets.
LUL_TARGET_OS
LUL_TARGET_OS_IDENTIFIER
These conditionals specify in which Operating System the generated code
will run. At most one of the these is 1, the rest are 0 (except for
LUL_TARGET_OS_IOS, which is set whenever LUL_TARGET_OS_IOS_SIM is set, but
can also be set alone).
SEEME Candidates for additions include console-specific operating systems,
Android, tvOS, and watchOS. BSD could conceivably have its own flag, but we
currently roll it in under LUL_TARGET_OS_X11.
SEEME These focus primarily on UI characteristics, as opposed to system
internals, which is why we have LUL_TARGET_OS_X11 and not
LUL_TARGET_OS_POSIX. A case could be made that we realistically need to
track both, but in practice - during the implementation of Lucena PAL - no
practical need was found. It’s possible that once additional platform
support is added to that library, we’ll find we need to revisit this design
decision.
LUL_TARGET_OS_X11
LUL_TARGET_OS_OSX
LUL_TARGET_OS_WIN
LUL_TARGET_OS_IOS
LUL_TARGET_OS_IOS_SIM
LUL_TARGET_OS_IDENTIFIER is a human-readable string. It may identify the
minimum supported version of the target OS, but is not required to do so.
LUL_TARGET_RT
These conditionals specify in which runtime the generated code will
run. This is needed when the OS and CPU support more than one runtime
(e.g. MacOS X on PPC supports CFM and Mach-O). Note that values are
descriptive; if the condition is met, the value will be 1, otherwise 0.
SEEME The executable format conditionals are somewhat arbitrary, but we’ve
only bothered to define them for cases we’ve encountered in practice.
Additional operations experience (and supported platforms) will probably
lead to some changes.
LUL_TARGET_RT_LITTLE_ENDIAN
LUL_TARGET_RT_BIG_ENDIAN
LUL_TARGET_RT_32_BIT
LUL_TARGET_RT_64_BIT
LUL_TARGET_RT_COFF
LUL_TARGET_RT_ELF
LUL_TARGET_RT_MACHO
LUL_TARGET_RT_WASM
LUL_TARGET_API
These conditionals are used to differentiate between sets of API’s on
the same processor under the same OS. The first section after _API_ is
the OS. The second section is the API set. Unlike LUL_TARGET_OS and
LUL_TARGET_CPU, these conditionals are not mutally exclusive. This header
will attempt to auto-configure all LUL_TARGET_API values, but will often
need a LUL_TARGET_API value predefined (e.g., in a .prop or .xcconfig file)
in order to disambiguate. Note that values are descriptive; if the
condition is met, the value will be 1, otherwise 0.
SEEME This is not intended to be an exhaustive list of APIs. Originally,
it was useful for differentiating between possible supported and available
Apple API (e.g., QuickDraw, Carbon, Cocoa, and whatever other flavor of the
week floats in), but it’s academic on platforms that don’t deprecate their
APIs with abandon. Further operational experience might find us wanting to
differentiate between other available OS-level APIs.
LUL_TARGET_API_COCOA
LUL_TARGET_API_COCOA_TOUCH
LUL_TARGET_API_WIN32
LUL_TARGET_API_WIN64
LUL_TARGET_API_X11
LUL_PRAGMA
These conditionals specify whether the compiler supports particular
#pragma’s. Arguably, these are gratuitous since compilers should ignore
unrecongnized #pragmas, but besides preventing noisy warnings, these could
be useful to indicate, for example, the NON-availability of some requisite
feature, such as tight struct packing.
LUL_PRAGMA_STRUCT_ALIGN #pragma options align=mac68k/power/reset
LUL_PRAGMA_STRUCT_PACKPUSH #pragma pack(push, n)/pack(pop)
LUL_TYPE
These identify characteristics of certain POD types for a given compiler;
preprocessor definitions are used since sizeof of other operators can’t be
used by the preprocessor (reliably).
LUL_TYPE_HAS_INT64
// 64-bit ints, as int64_t and uint64_t (and possibly long long)
LUL_TYPE_HAS_INT128
// 128-bit ints, as __int128_t and __uint128_t
LUL_TYPE_EXACT_WIDTH_INTEGERS
// availability of C99 exact width int types
LUL_TYPE_DOUBLE_GT_FLOAT
// double is distinct from float
LUL_TYPE_LONG_DOUBLE_GT_DOUBLE
// long double is distinct from double
LUL_TYPE_WCHAR_T_IS_16_BITS
// wchar_t is assumed to be a 32-bit integer type if 0 or unset
LUL_TYPE_HAS_C99_FLOATS
// availability of float_t and double_t
LUL_STDC99
For compilers that support C99, C99 functions are in the std namespace.
Compilers that don’t fully support C99 often have C99 functions, but keep
them in the global namespace. Whenever a C99 function is used, refer to it
as LUL_STDC99::<func_xxx>, where <func_xxx> is the function name.
LUL_FEATURE
Some compilers and platforms do things in a peculiar way that we may need
to work around or otherwise deal with. Those features are noted here.
LUL_FEATURE_UTF16_FILE_SYSTEM
// It is assumed that the file system uses UTF-8 unless this
// feature conditional is set. Really only necessary for Windows.
// FIXME We can probably retire this after updating the code to
// always use the relevant std::filesystem path types instead of
// doing our own conversions.
LUL_CPPxx
LUL_Cxx
Language feature availability flags to indicate whether a given C++ feature
is supported by the current compiler. Each one is set to a non-zero value
if available and 0 otherwise; every macro is always set to some value after
this header has been preprocessed.
Note that these flags are neither exhaustive nor bounded:
* Features that are available in all supported compilers do not have
flags. Currently, features that could conceivably be manually disabled
in a given compiler (e.g., exception handling) are not tracked, though
they could be, if necessary.
* Features that have become universally supported since the inception
of their feature flag will eventually have their flag removed. This
library is not intended to be backwards-compatible for all time, only
to smooth out cross-platform interoperability between current compiler
versions. This is unlikely to change, but sane user policies regarding
freezes for libraries and supported compilers for project milestones -
or even lifetimes - should mitigate this.
* Features we (the developers) have not had cause to use or care about
are often not represented right away. Eventually, all language features
accepted into the Standard are likely to appear here, assuming
universal support doesn’t come so quickly that a feature flag becomes
mooted, as per the above criteria.
* Features from proposals to the Standard may have flags here; in some
cases, this may occur for proposed features that have not been accepted
into the standard, even as part of a Technical Specification. This
typically happens with de facto standards (e.g., variants on symbol
visibility handling) when it relates to language features. This sort of
thing is much more common for proposed library features (e.g., <span>
support was made available long before it was formally voted in).
Note that the macro names mimic those of the equivalent SD-6 macros, where
available; similarly, the macro values will either be:
- 0, to indicate no availability, or
- the SD-6 value equivalent to the available feature support, or
- 1, if there is no equivalent SD-6 macro
SEEME Note that this leaves an ambiguous case where a feature may have been
updated, e.g., as a result of a Defect Report, but a new SD-6 value has not
been assigned; this can be further complicated if the DR resolution is not
finalized, meaning that the available feature is in an intermediate state.
Currently, we have no policy for dealing with this situation, as it has not
arisen yet in practice. Most likely it would be addressed by assigning an
arbitrary value (e.g., “last known good value +1”). This comes with its own
problems, namely that there is no formal policy regarding bumping SD-6
macro values vs. creating new macros, for example in the case where
backwards compatibility is affected by a breaking change, which would
complicate a simple greater-than test against a macro value.
APIME Previous iterations of this header also attempted to determine
whether various C99 and C11 features were available. This turned out to be
impractical and a bit pointless. As a result, such features are only
tracked - if they are tracked at all - in the context of their
applicability to a given C++ Standard, e.g., support for the C99
preprocessor as required by C++11.
C++98
These are here only because compilers can be made to disable specific
features for various reasons and we want to have a universal way of
determining whether that’s happened.
LUL_CPP98_EXCEPTIONS
There -was- an SD-6 macro for this, but it’s been removed for
standardization. Set to 1 if exceptions are enabled, 0 otherwise.
LUL_CPP98_RTTI
There -was- an SD-6 macro for this, but it’s been removed for
standardization. Set to 1 if RTTI is enabled, 0 otherwise.
C++11
Note that all supported compilers support all required features of C++11.
LUL_CPP11_MINIMAL_GARBAGE_COLLECTION
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm>
There is currently no SD-6 macro for this.
LUL_CPP11_THREADSAFE_STATIC_INIT
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm>
__cpp_threadsafe_static_init
Some compiler can disable this feature if asked; will be set to 0
if that has happened.
C++14
All supported compilers support all features of C++14, but some of them may
require that certain features be explicitly enabled.
LUL_CPP14_SIZED_DEALLOCATION
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3778.html>
__cpp_sized_deallocation
Some compilers disable this by default since it’s an ABI-breaking
change; clang, in particular, does this.
C++17
All supported compilers support all features of C++17, but some of them may
require that certain features be explicitly enabled.
LUL_CPP17_TEMPLATE_TEMPLATE_ARGS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0522r0.html>
__cpp_template_template_args
The proposal this is from is intended to resolve a Defect Report,
but unfortunately introduces a defect of its own. Some compilers
are disabling this until a revised patch is in.
C++2a
These are often difficult or impossible to emulate correctly, so the norm
is to not bother. However, when it -has- been done, we note it, as well as
how to make use of the emulated feature.
SEEME Somewhat awkwardly, a lot of proposed new language and library
features and fixes don’t include SD-6 macros (yet?); this makes identifying
availability more challenging than it needs to be. Note that a proposal to
standardize SD-6 macros was accepted for C++2a, but the current SD-6 itself
is pretty out-of-date, and it’s unclear whether there will be a fix-up
prior to FDIS. As a result, most of these are either placeholders awaiting
testing or depend on compiler version-differentiated activation.
LUL_CPP2A_ALLOW_LAMBDA_CAPTURE_EQUALS_THIS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0409r2.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_ATTRIBUTE_NO_UNIQUE_ADDRESS
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0840r2.html>
__has_cpp_attribute(no_unique_address)
LUL_CPP2A_ATTRIBUTE_LIKELY
LUL_CPP2A_ATTRIBUTE_UNLIKELY
LUL_CPP2A_ATTRIBUTES_LIKELY_AND_UNLIKELY
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0479r5.html>
__has_cpp_attribute(likely)
__has_cpp_attribute(unlikely)
We track the availability of each attribute separately, as well as
provide an aggregate to test for compliance. The aggregate’s value
will be 0 if either attribute is unavailable, or 1 otherwise.
LUL_CPP2A_CLASS_TYPES_AS_NON_TYPE_TEMPLATE_PARAMETERS
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0732r2.pdf>
__cpp_nontype_template_parameter_class
LUL_CPP2A_CONCEPTS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0734r0.pdf>
__cpp_concepts
LUL_CPP2A_CONST_REF_QUALIFIED_POINTERS_TO_MEMBERS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0704r1.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_CONSTEXPR_VIRTUAL_FUNCTION
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1064r0.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_ATTRIBUTE_ASSERT
LUL_CPP2A_ATTRIBUTE_ENSURES
LUL_CPP2A_ATTRIBUTE_EXPECTS
LUL_CPP2A_CONTRACTS
__has_cpp_attribute(assert)
__has_cpp_attribute(ensures)
__has_cpp_attribute(expects)
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0542r5.html>
This is actually a bundle of attributes using a new syntax; the
syntax has no SD-6 macro, so we rely on the presence of the
attributes to determine support. We track the availability of each
attribute separately, as well as provide an aggregate to test for
compliance. The aggregate’s value will be 0 if any attribute is
unavailable, or 1 otherwise.
LUL_CPP2A_COROUTINES
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0912r1.html>
__cpp_coroutines
Note that this is just language support for the <coroutine> header.
LUL_CPP2A_DEFAULT_CONSTRUCTIBLE_AND_ASSIGNABLE_STATELESS_LAMBDAS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0624r2.pdf>
There is currently no SD-6 macro for this.
LUL_CPP2A_DEFAULT_MEMBER_INITIALIZERS_FOR_BIT_FIELDS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0683r1.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_DESIGNATED_INITIALIZERS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0329r4.pdf>
There is currently no SD-6 macro for this.
LUL_CPP2A_EFFICIENT_SIZED_DELETE_FOR_VARIABLE_SIZED_CLASSES
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0722r3.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_EXPLICIT_BOOL
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0892r2.html>
__cpp_explicit_bool
LUL_CPP2A_INIT_STATEMENTS_FOR_RANGE_BASED_FOR
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0614r1.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_INITIALIZER_LIST_CONSTRUCTORS_IN_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0702r1.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_INTEGRATING_OUR_FEATURE_TEST_MACROS
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0941r2.html>
There is currently no SD-6 macro for this (ironically). It appears
this is only here to get Microsoft to support SD-6, as the other
major compilers de facto meet the requirement.
LUL_CPP2A_PACK_EXPANSION_IN_LAMBDA_INIT_CAPTURE
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0780r2.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_THREE_WAY_COMPARISON_OPERATOR
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0515r0.pdf>
There is currently no SD-6 macro for this.
LUL_CPP2A_TEMPLATE_PARAMETER_LIST_FOR_GENERIC_LAMBDAS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0428r2.pdf>
There is currently no SD-6 macro for this.
LUL_CPP2A_TYPENAME_OPTIONAL
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0634r2.html>
There is currently no SD-6 macro for this.
LUL_CPP2A_VA_OPT
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0306r4.html>
There is currently no SD-6 macro for this.
Technical Specifications and Proposals
Most of these will eventually migrate to one of the above sections, at
which time the associated macro will be renamed (and possibly aliased).
LUL_C99
Feature availability macros to indicate whether a given C99 feature is
supported by the current compiler. Each one is set to 1 if available and 0
otherwise.
LUL_C99_PREPROCESSOR
SEEME Only MSVS is known to have problems with this, and it appears
progress is finally being made to fully address it, at which point this
flag will be retired. Note that if support requires having a particular
compiler switch set to get compatibility, setting the switch will
likely be mandated.
LUL_LIBCPPxx_xxx
LUL_LIBCPPxx_xxx_EXP
These relate to library features. They’re mostly set in lulVersion.hpp, but
they’re documented here since they may be overridden depending on the build
environment. Note that features that are unambiguously available (e.g.,
almost the entirety of the C++11 STL) don’t have macros. Generally, a
Library feature detection macro is only set to 0 here if we know that a
feature is broken or unavailable, and that it would otherwise be falsely
recognized as available. A macro is only set to a non-zero value if we
know that a feature -should- be available, but normal feature detection
would fail to assign the correct SD-6 macro value; note that in this case,
the macro may be reset to 0 later if header detection fails. See the notes
above for LUL_CPPxx as well as in lulVersion.hpp for additional
information.
Note that some of these -also- require language support, or have some other
dependencies. We try to note such cases when the dependencies exist outside
of the current Standard baseline, e.g., a C++2a library feature that
depends on C++2a language support, when the baseline is C++17.
There is some ambiguity in whether we track the experimental version of a
feature. Generally, we don’t bother if:
- no major compiler ever shipped an experimental version
- the experimental version is/was completely broken
- we’re transitioning to a new baseline and looking to eliminate cruft
SEEME Note that regardless of how these macros are set, a feature may be
available, anyway, if there is a reference implementation for it; see the
lulConfig.hpp header for details of how this works, and see the relevant
Wrapper header, if there is one.
C++17
LUL_LIBCPP17_ANY
__cpp_lib_any
Only needed because of older Apple platforms. Note that we neither
track nor use experimental versions of this.
LUL_LIBCPP17_ELEMENTARY_STRING_CONVERSIONS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0067r5.html>
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0682r1.html>
__cpp_lib_to_chars
No wrapper is provided, though a <charconv> wrapper would be a
reasonable thing to add. Note that this got weird since the
functions got moved to their own header and their signatures were
altered, post-Standardization, all as part of a Defect Report
resolution.
LUL_LIBCPP17_EXECUTION
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0024r2.html>
__cpp_lib_execution
No wrapper is provided; the functionality would be good to have,
but challenging to implement effectively. Note that by itself, this
macro does not measure compliance with the referenced Working Group
paper; use LUL_LIBCPP17_STANDARDIZATION_OF_PARALLELISM_TS. Note
that we neither track nor use experimental versions of this.
LUL_LIBCPP17_FILESYSTEM
LUL_LIBCPP17_FILESYSTEM_EXP
__cpp_lib_filesystem
__cpp_lib_experimental_filesystem
Only missing on Apple platforms. Unfortunately, we fall back to
boost for a reference implementation, and the boost version differs
substantially from the Standard. Also, note that the experimental
version differs in many ways from the final version, but it’s all
that is offered until gcc 8 and clang 7.
LUL_LIBCPP17_HARDWARE_INTERFERENCE_SIZE
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html>
__cpp_lib_thread_hardware_interference_size
This is set in this header; no wrapper is provided, though the
functionality would be a reasonable thing to add. Note that we
neither track nor use experimental versions of this.
LUL_LIBCPP17_LAUNDER
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0137r1.html>
__cpp_lib_launder
AKA, “Replacement of class objects containing reference members.”
No wrapper is provided, though the functionality would be a
reasonable thing to add. Note that we neither track nor use
experimental versions of this.
LUL_LIBCPP17_OPTIONAL
__cpp_lib_optional
Only needed because of older Apple platforms. Note that we neither
track nor use experimental versions of this.
LUL_LIBCPP17_PARALLEL_ALGORITHM
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0024r2.html>
__cpp_lib_parallel_algorithm
This is set in this header. No wrapper is provided; the
functionality would be good to have, but challenging and messy to
implement effectively. Note that by itself, this macro does not
measure compliance with the Working Group paper; for that, use
LUL_LIBCPP17_STANDARDIZATION_OF_PARALLELISM_TS. Note that we
neither track nor use experimental versions of this.
LUL_LIBCPP17_SPLICING_MAPS_AND_SETS
<http://wg21.link/p0083r3>
__cpp_lib_node_extract
This is set in this header; no wrapper is provided, as we’re
just testing for the presense of member functions in pre-existing
standard headers. Note that we neither track nor use experimental
versions of this.
LUL_LIBCPP17_STANDARDIZATION_OF_PARALLELISM_TS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0024r2.html>
Note that this macro tracks compliance with the Standard as it
relates to implementing the referenced Working Group paper; there
is no correspoding SD-6 macro, or rather, there are -two- relevant
macros which each track the different features required for
compliance. We actually track both of those, as well as this,
separately. As such, this macro is an aggregate: if both
LUL_LIBCPP17_EXECUTION and LUL_LIBCPP17_PARALLEL_ALGORITHM indicate
compliance, this gets set to 1; otherwise, it’s set to 0. Note that
we neither track nor use experimental versions of this, partly
because the Draft versions tracked a different set of features, in
different places, which were refactored/replaced.
LUL_LIBCPP17_VARIANT
__cpp_lib_variant
Only needed because of older Apple platforms. Note that we neither
track nor use experimental versions of this.
C++2a
These are all taken from features that have been incorporated into the
draft Standard currently called C++2a and likely to become C++20.
LUL_LIBCPP2A_BIT_CAST
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0476r2.html>
__cpp_lib_bit_cast
A reference implementation is available, and is mostly compatible
(lack of constepxr memcpy or equivalent makes full compliance
challenging).
LUL_LIBCPP2A_CALENDAR_AND_TIMEZONE
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0355r7.html>
This is set in this header; no wrapper is provided, though the
functionality would be nice to add if we didn’t have to write the
reference implementation ourselves.
LUL_LIBCPP2A_CONCEPT_LIBRARY
LUL_LIBCPP2A_CONCEPT_LIBRARY_EXP
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0898r3.pdf>
__cpp_lib_concepts
__cpp_lib_experimental_concepts
No wrapper is provided, though the functionality would be a
reasonable thing to add.
LUL_LIBCPP2A_CONSTEXPR_FOR_ALGORITHM_AND_UTILITY
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0202r3.html>
This is set in this header; no wrapper is provided, as we would
have to reimplement both headers and work around the potential
lack of cstring-equivalent compiler intrinsics.
LUL_LIBCPP2A_COROUTINES
LUL_LIBCPP2A_COROUTINES_EXP
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4736.pdf>
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4760.pdf>
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0912r2.html>
__cpp_coroutines (SEEME proxy)
This does not currently have its own SD-6 macro. No wrapper is
provided. Note that <coroutine> requires language support.
SEEME Confusingly, n4736 was voted into the Standard, but n4760 is
the fixed version of it.
LUL_LIBCPP2A_EXTENDING_MAKE_SHARED_TO_SUPPORT_ARRAYS
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0674r1.html>
This is set in this header; no wrapper is provided, though the
functionality would be a reasonable thing to add.
LUL_LIBCPP2A_FLOATING_POINT_ATOMIC
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0020r6.html>
This is set in this header; no wrapper is provided, though the
functionality would be a reasonable thing to add.
LUL_LIBCPP2A_LIST_REMOVE_RETURN_TYPE
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0646r1.pdf>
__cpp_lib_list_remove_return_type
__cpp_lib_experimental_list_remove_return_type
No wrapper is provided, as we would have to fully reimplement
<list> and <forward_list> just to tweak a few member functions.
LUL_LIBCPP2A_MORE_CONSTEXPR_FOR_COMPLEX
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0415r1.html>
__cpp_lib_constexpr_complex
__cpp_lib_experimental_constexpr_complex
No wrapper is provided, as we would have to reimplement <complex>.
LUL_LIBCPP2A_SPAN
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0122r7.pdf>
There is no SD-6 macro, yet. A reference implementation is
provided and accessible through lulSpanWrapper.hpp.
LUL_LIBCPP2A_STD_ATOMIC_REF
<http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0019r8.html>
__cpp_lib_atomic_ref
No wrapper is provided, as a correct reference implementation will
require significant expertise in the problem domain.
LUL_LIBCPP2A_STD_ENDIAN
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0463r1.html>
This is set in this header; no wrapper is provided, though the
functionality would be a reasonable thing to add; however a general
implementation may be impossible without compiler/language support
(because middle-endian, amirite?).
LUL_LIBCPP2A_STD_REMOVE_CVREF
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0550r2.pdf>
This is set in this header; a reference implementation is provided
and accessible through lulTypeTraitsWrapper.hpp.
LUL_LIBCPP2A_STRING_PREFIX_AND_SUFFIX_CHECKING
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0457r2.html>
This is set in this header. No wrapper is provided, as we would
have to reimplement two headers; these should have been free
functions anyway, rationale in the proposal notwithstanding.
LUL_LIBCPP2A_SYNCHRONIZED_BUFFERED_OSTREAM
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0053r7.pdf>
__cpp_lib_syncstream
No wrapper is provided.
LUL_LIBCPP2A_THREE_WAY_COMPARISON_OPERATOR_SUPPORT_COMPARE
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0515r3.pdf>
This is set in this header; no wrapper will be provided, as
<compare> is interdependent with the operator <=> language feature.
LUL_LIBCPP2A_TYPE_IDENTITY
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0887r1.pdf>
This is set in this header; no wrapper is provided, though an
implementation would be trivial (cf., std::remove_cvref).
LUL_LIBCPP2A_UTILITY_TO_CONVERT_A_POINTER_TO_A_RAW_POINTER
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0653r2.html>
This is set in this header; no wrapper is provided, though the
functionality would be a reasonable thing to add.
LUL_LIBCPP2A_VERSION
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0754r2.pdf>
This is effectively provided by lulVersion.hpp, which works in
conjunction with this header to identify all of the available
Standard Library functionality. Note that unlike <version>, the
wrapper actually tracks “correct” implementations only (so, for
example, Xcode’s false positives for <any> and friends won’t be
reported as support for the library feature); this behavior will be
carried forward, and so, unlike other wrappers, it is recommended
to -always- include lulVersion.hpp, even when including <version>
directly, and rely on the LUL_LIBCPP_xxx macros where they are
available. See lulVersion.hpp for details.
C++ Technical Specifications
These are all taken from Technical Specifications that have not (yet?) been
Standardized. Generally, they are either very far along and likely to clear
the bar, or very useful and simple enough to implement trivially.
Generally, these will eventually be aliased (and then moved) into
LUL_LIBCPP2A_xxx, LUL_LIBCPP20_xxx, LUL_LIBCPP23_xxx, and the like.
SEEME The TSs can be highly mutable, and support should be considered very
experimental. No effort at all will be expended to maintain backwards-
compatibility with a TS once a feature has been voted in.
LUL_LIBCPPTS_NETWORKING
LUL_LIBCPPTS_NETWORKING_EXP
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4734.pdf>
__cpp_lib_net
__cpp_lib_experimental_net
Unfortunately, we use boost for a reference implementation, so
compatibility with the Standard is not guaranteed. Note that the
wrapper for this feature is lulNetworkingWrapper.hpp.
LUL_LIBCPPTS_NETWORKING_EXTENSIBLE
LUL_LIBCPPTS_NETWORKING_EXTENSIBLE_EXP
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4734.pdf>
__cpp_lib_net_extensible
__cpp_lib_experimental_net_extensible
Unfortunately, we use boost for a reference implementation, so
compatibility with the Standard is not guaranteed. Note that the
wrapper for this feature is lulNetworkingWrapper.hpp.
LUL_LIBCPPTS_OBSERVER_PTR
LUL_LIBCPPTS_OBSERVER_PTR_EXP
<http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4282.pdf>
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4758.html>
__cpp_lib_observer_ptr
__cpp_lib_experimental_observer_ptr
A reference implementation is available.
LUL_VIS_xxx
These describe different levels of symbol visibility. By default, all
symbols are hidden. LUL_VIS_[ALWAYS_]INLINE functions are always hidden in
the symbol table, regardless of whether or not the affected function is
actually inlined.
SEEME Conceivably, these may need to be subdivided further, as we might be
lacking sufficient granularity. One factor that could necessitate
subdivision is module support, and the form it takes, which could require
differentation between types and templates in their visibility handling.
LUL_VIS_HIDDEN
// Do not export the variable/function/template/type. This is the
// default, and does not generally need to be explicitly applied.
LUL_VIS_EXTERN
// Declare a constant/variable/function that is defined elsewhere.
// This is specifically useful for headers that refer to library
// binaries, as opposed to the same headers when they are used to
// build the libraries; macros can be used to flip the meaning
// depending on the usage case (see below).
LUL_VIS_DEFINE
// Define a constant/variable/function.
LUL_VIS_ONLY
// Decribe a constant/function that is completely contained in the
// header and does not require a symbol to use.
LUL_VIS_TYPE_EXTERN
// Declare a type/template instantiation that is defined
// elsewhere. In the template case, this is for explicit extern
// template declarations, as opposed to explicit instantiations.
LUL_VIS_TYPE_DEFINE
// Define a type/template. In the template case, this is intended
// for use with an explicit instantiation, which is useful when
// other declarations of the template are extern in order to avoid
// generating multiple copies of the same template instantiation
// only to have most of them discarded during linking.
LUL_VIS_TYPE_ONLY
// Decribe a type/template that is completely contained in the
// header and does not require a symbol to use. Templates
// declarations should always have this decoration.
LUL_VIS_EXCEPTION_EXTERN
LUL_VIS_EXCEPTION_DEFINE
// Usage is the same as for LUL_VIS_TYPE, except there is no “ONLY”
// variant.
// APIME We have this because clang does, though it’s not clear
// why we’d have to differentiate exception classes from other
// classes. Assume Howard knows what he’s doing.
LUL_VIS_INLINE
LUL_VIS_ALWAYS_INLINE
// Declare and define an inline function.
Note that LUL_VIS_EXTERN and LUL_VIS_DEFINE must be used in conjunction with
each other, e.g., in a header file included at build time, LUL_VIS_DEFINE
could establish public visibility for functions in a library which are then
accessed through a header with the same functions declared using
LUL_VIS_EXTERN. For convenience, this may even be the same header, but with
a wrapper macro to select LUL_VIS_DEFINE when building the library, and
LUL_VIS_EXTERN when linking to it.
LUL_CLASS_xxx
These macros describe class decorators whose details are implementation-
specific.
LUL_CLASS_FORCE_EBCO
// Force the use of the Empty Base (Class) Optimization. The
// decorator should precede the class name in its declaration.
// Note that the decorator is used specifically to indicate that
// the bases of a given class are empty, not that a given class is
// an Empty Base Class; this means it must be applied by the end
// user in a large number of practical use cases. Also note that
// the decorator must be applied in the most direct descendant to
// have effect. For example:
//
// struct Empty1 { };
// struct Empty2 { };
// struct Derived1 : Empty1, Empty2 { };
// struct LUL_CLASS_FORCE_EBCO Derived2 : Derived 1 { };
//
// In this example, neither Derived1 -nor- Derived2 will
// necessarily benefit from the EBCO; we can’t guarantee the
// behavior. However, if Derived1 -also- has the
// LUL_CLASS_FORCE_EBCO applied, then any compiler that supports
// the EBCO will apply it to both Derived1 -and- Derived2.
//
// SEEME This is really only necessary when using multiple
// inheritance and targeting MSVS; at least VS2015 Update 3 is
// required (note that Update 2, which actually introduced the
// feature, had a bug which caused it to violate the Standard).
// APIME How aggravating is it that you can’t decorate the empty
// base class itself instead of having to force a weird
// requirement on derived classes? Sadly, we’re at the mercy of
// the built-in compiler decorators, here.
LUL_FUNC_xxx
These macros describe function calling conventions whose details are
implementation-specific.
LUL_FUNC_CALL_C(LUL_func_name_)
// C calling convention; default
LUL_FUNC_CALL_STD(LUL_func_name_)
// Std calling convention
LUL_FUNC_CALLBACK_C(LUL_func_name_)
// C-style function pointer
LUL_FUNC_CALLBACK_STD(LUL_func_name_)
// Std-style function pointer
LUL_BUILTIN_xxx
These are wrappers for intrinsic functions that may not be available on
every platform. Where a given function is not available, it may be
emulated, or simply replaced with a no-op.
LUL_BUILTIN_likely(LUL_expr_)
// branch prediction hinting that something is most likely true;
// LUL_expr_ must resolve to a boolean
// FIXME C++20 this is now an attribute
LUL_BUILTIN_unlikely(LUL_expr_)
// branch prediction hinting that something is most likely false;
// LUL_expr_ must resolve to a boolean
// FIXME C++20 this is now an attribute
------------------------------------------------------------------------------*/
#pragma once
// std
#if defined (_MSC_VER) && defined (_WIN32)
// We guard inclusion of system headers when using MSVS due to its
// noisiness at high warning levels.
#pragma warning (push, 0)
#endif
#if __has_include (<version>)
#include <version>
// Once this header is universally available, it will take the place
// of <ciso646> abuse, providing the same functionality as well as
// (eventually) acting as a clearinghouse for SD-6 macros related to
// library features.
// SEEME This must not be lulVersion.hpp, as that header depends on
// this one.
#else
#include <ciso646>
// In C++, this is a do-nothing header we include just for the side
// effects: the Standard Library implementation will be configured
// and many assorted compiler-dependent feature detection macros will
// be defined.
#endif
#if defined (_MSC_VER) && defined (_WIN32)
#pragma warning (pop)
#endif
// lul
#include <Lucena-Utilities/lulConfig.hpp>
#include <Lucena-Utilities/details/lulPlatformSetup.hpp>
#include <Lucena-Utilities/details/lulCompilerSetup.hpp>
#include <Lucena-Utilities/details/lulLibrarySetup.hpp>
| 43.351931 | 80 | 0.780344 | [
"vector"
] |
0c5a43a6fa94b69ede9964ebaa5c96cbb5560e55 | 950 | cpp | C++ | src/action/ActionGroup.cpp | kevinkraft/RTS_3 | c75c3652650bd0a9610058d414ad562b9b5325c1 | [
"MIT"
] | 1 | 2020-05-17T09:02:27.000Z | 2020-05-17T09:02:27.000Z | src/action/ActionGroup.cpp | kevinkraft/RTS_3 | c75c3652650bd0a9610058d414ad562b9b5325c1 | [
"MIT"
] | null | null | null | src/action/ActionGroup.cpp | kevinkraft/RTS_3 | c75c3652650bd0a9610058d414ad562b9b5325c1 | [
"MIT"
] | null | null | null | #include "ActionGroup.h"
#include "Action.h"
#include <vector>
#include <algorithm>
ActionGroup::ActionGroup()
{}
ActionGroup::~ActionGroup()
{
for(std::vector<Action*>::iterator it = mActions.begin(); it != mActions.end(); ++it)
{
delete (*it);
}
}
void ActionGroup::appendAction(Action* act)
{
std::cout << "ActionGroup::appendAction INFO: About to add action to the action list" << std::endl;
mActions.push_back(act);
}
void ActionGroup::clearAddAction(Action* act)
{
mActions.clear();
mActions.push_back(act);
}
Action * ActionGroup::getAction(int element)
{
if (getSize() == 0)
{
return nullptr;
}
else
{
return mActions.at(element);
}
}
void ActionGroup::prependAction(Action* act)
{
mActions.insert(mActions.begin() + 0, act);
}
void ActionGroup::removeAction(Action* act)
{
mActions.erase(std::remove(mActions.begin(), mActions.end(), act), mActions.end());
delete act;
}
| 18.269231 | 101 | 0.661053 | [
"vector"
] |
0c615ea6e8305ca4e9e1f7492e170f89ea36f8a8 | 1,018 | cpp | C++ | 2nd/174_dungeon_game.cpp | buptlxb/leetcode | b641419de040801c4f54618d7ee26edcf10ee53c | [
"BSD-3-Clause"
] | null | null | null | 2nd/174_dungeon_game.cpp | buptlxb/leetcode | b641419de040801c4f54618d7ee26edcf10ee53c | [
"BSD-3-Clause"
] | null | null | null | 2nd/174_dungeon_game.cpp | buptlxb/leetcode | b641419de040801c4f54618d7ee26edcf10ee53c | [
"BSD-3-Clause"
] | null | null | null | #include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
class Solution {
public:
typedef vector<vector<int> >::size_type sz_t;
int calculateMinimumHP(vector<vector<int> >& dungeon) {
if (dungeon.empty())
return 0;
vector<vector<int> > dp(dungeon.size(), vector<int>(dungeon.front().size(), 1));
dp.back().back() = max(1, 1-dungeon.back().back());
for (sz_t i = dp.size()-1; i > 0; --i) {
dp[i-1].back() = max(1, dp[i].back()-dungeon[i-1].back());
}
for (sz_t i = dp.back().size()-1; i > 0; --i) {
dp.back()[i-1] = max(1, dp.back()[i]-dungeon.back()[i-1]);
}
for (sz_t i = dp.size()-1; i > 0; --i) {
for (sz_t j = dp[i].size()-1; j > 0; --j) {
dp[i-1][j-1] = min(max(1, dp[i][j-1]-dungeon[i-1][j-1]), max(1, dp[i-1][j]-dungeon[i-1][j-1]));
}
}
return dp.front().front();
}
};
int main(void)
{
return 0;
}
| 29.085714 | 111 | 0.490177 | [
"vector"
] |
0c66b2791c94e630d0cb9cec119fd41bea19fb80 | 4,586 | cpp | C++ | libs/ml/benchmark/metrics/metrics.cpp | chr15murray/ledger | 85be05221f19598de8c6c58652139a1f2d9e362f | [
"Apache-2.0"
] | 96 | 2018-08-23T16:49:05.000Z | 2021-11-25T00:47:16.000Z | libs/ml/benchmark/metrics/metrics.cpp | chr15murray/ledger | 85be05221f19598de8c6c58652139a1f2d9e362f | [
"Apache-2.0"
] | 1,011 | 2018-08-17T12:25:21.000Z | 2021-11-18T09:30:19.000Z | libs/ml/benchmark/metrics/metrics.cpp | chr15murray/ledger | 85be05221f19598de8c6c58652139a1f2d9e362f | [
"Apache-2.0"
] | 65 | 2018-08-20T20:05:40.000Z | 2022-02-26T23:54:35.000Z | //------------------------------------------------------------------------------
//
// Copyright 2018-2020 Fetch.AI 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.
//
//------------------------------------------------------------------------------
#include "math/tensor/tensor.hpp"
#include "ml/ops/metrics/categorical_accuracy.hpp"
#include "vectorise/fixed_point/fixed_point.hpp"
#include "benchmark/benchmark.h"
#include <memory>
#include <string>
template <class T, int I, int B>
void BM_CategoricalAccuracy(benchmark::State &state)
{
using TensorType = typename fetch::math::Tensor<T>;
auto test_results = TensorType({I, B});
auto ground_truth = TensorType({I, B});
auto output = TensorType({I, B});
// Fill tensors with random values
test_results.FillUniformRandom();
ground_truth.FillUniformRandom();
std::vector<std::shared_ptr<fetch::math::Tensor<T> const>> inputs;
inputs.emplace_back(std::make_shared<TensorType>(test_results));
inputs.emplace_back(std::make_shared<TensorType>(ground_truth));
fetch::ml::ops::CategoricalAccuracy<TensorType> ca;
for (auto _ : state)
{
ca.Forward(inputs, output);
}
}
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, float, 2, 2)->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, float, 10, 10)->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, float, 100, 100)->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, float, 1000, 1000)->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, float, 2000, 2000)->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, double, 2, 2)->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, double, 10, 10)->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, double, 100, 100)->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, double, 1000, 1000)->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, double, 2000, 2000)->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<16, 16>, 2, 2)
->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<16, 16>, 10, 10)
->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<16, 16>, 100, 100)
->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<16, 16>, 1000, 1000)
->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<16, 16>, 2000, 2000)
->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<32, 32>, 2, 2)
->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<32, 32>, 10, 10)
->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<32, 32>, 100, 100)
->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<32, 32>, 1000, 1000)
->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<32, 32>, 2000, 2000)
->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<64, 64>, 2, 2)
->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<64, 64>, 10, 10)
->Unit(benchmark::kMicrosecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<64, 64>, 100, 100)
->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<64, 64>, 1000, 1000)
->Unit(benchmark::kMillisecond);
BENCHMARK_TEMPLATE(BM_CategoricalAccuracy, fetch::fixed_point::FixedPoint<64, 64>, 2000, 2000)
->Unit(benchmark::kMillisecond);
BENCHMARK_MAIN();
| 46.795918 | 94 | 0.73986 | [
"vector"
] |
0c6de0b6590bfe8eb6c0c5c4c0078445cc63acee | 4,356 | cpp | C++ | Netcode/Graphics/DX12/DX12Common.cpp | tyekx/netcode | c46fef1eeb33ad029d0c262d39309dfa83f76c4d | [
"MIT"
] | null | null | null | Netcode/Graphics/DX12/DX12Common.cpp | tyekx/netcode | c46fef1eeb33ad029d0c262d39309dfa83f76c4d | [
"MIT"
] | null | null | null | Netcode/Graphics/DX12/DX12Common.cpp | tyekx/netcode | c46fef1eeb33ad029d0c262d39309dfa83f76c4d | [
"MIT"
] | null | null | null | #include "DX12Common.h"
#include "DX12Includes.h"
#include <Netcode/Utility.h>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <cstdarg>
#include <string>
#include <comdef.h>
namespace Netcode::Graphics::DX12 {
void DebugPrintBlob(com_ptr<ID3DBlob> blob) {
if(blob != nullptr) {
OutputDebugString(reinterpret_cast<const char *>(blob->GetBufferPointer()));
} else {
OutputDebugString("Blob was NULL");
}
}
std::wstring RootSigDebugName(const std::wstring & filename)
{
std::wostringstream woss;
woss << L"RS(";
size_t indexOf = filename.find_last_of(L'\\');
if(indexOf == std::wstring::npos) {
indexOf = filename.find_last_of(L'/');
}
if(indexOf == std::wstring::npos) {
woss << filename << L')';
} else {
woss << filename.substr(indexOf + 1) << L')';
}
return woss.str();
}
std::wstring IndexedDebugName(const char * prefix, uint32_t idx)
{
std::wostringstream woss;
woss << prefix << L'(' << idx << L')';
return woss.str();
}
void DebugDestruction(IUnknown * pUnknown)
{
ID3DDestructionNotifier * notifier = nullptr;
DX_API("Failed to query notifier interface")
pUnknown->QueryInterface(¬ifier);
notifier->RegisterDestructionCallback(&DebugDestructionCallback, pUnknown, nullptr);
notifier->Release();
}
const char * RootSignatureVersionToString(D3D_ROOT_SIGNATURE_VERSION version)
{
switch(version) {
case D3D_ROOT_SIGNATURE_VERSION_1_0: return "Root Signature Version 1.0";
case D3D_ROOT_SIGNATURE_VERSION_1_1: return "Root Signature Version 1.1";
default: return "Unknown Root Signature Version";
}
}
const char * ShaderModelToString(D3D_SHADER_MODEL shaderModel) {
switch(shaderModel) {
case D3D_SHADER_MODEL_5_1: return "Shader Model 5.1";
case D3D_SHADER_MODEL_6_0: return "Shader Model 6.0";
case D3D_SHADER_MODEL_6_1: return "Shader Model 6.1";
case D3D_SHADER_MODEL_6_2: return "Shader Model 6.2";
case D3D_SHADER_MODEL_6_3: return "Shader Model 6.3";
case D3D_SHADER_MODEL_6_4: return "Shader Model 6.4";
default: return "Unknown shader model";
}
}
const char * FeatureLevelToString(D3D_FEATURE_LEVEL ftlvl) {
switch(ftlvl) {
case D3D_FEATURE_LEVEL_9_1: return "Feature level 9.1";
case D3D_FEATURE_LEVEL_9_2: return "Feature level 9.2";
case D3D_FEATURE_LEVEL_9_3: return "Feature level 9.3";
case D3D_FEATURE_LEVEL_10_0: return "Feature level 10.0";
case D3D_FEATURE_LEVEL_10_1: return "Feature level 10.1";
case D3D_FEATURE_LEVEL_11_0: return "Feature level 11.0";
case D3D_FEATURE_LEVEL_11_1: return "Feature level 11.1";
case D3D_FEATURE_LEVEL_12_0: return "Feature level 12.0";
case D3D_FEATURE_LEVEL_12_1: return "Feature level 12.1";
default: return "Unknown feature level";
}
}
const char * CommandListTypeToString(D3D12_COMMAND_LIST_TYPE type) {
switch(type) {
case D3D12_COMMAND_LIST_TYPE_DIRECT: return "Direct Command List";
case D3D12_COMMAND_LIST_TYPE_BUNDLE: return "Bundle Command List";
case D3D12_COMMAND_LIST_TYPE_COMPUTE: return "Compute Command List";
case D3D12_COMMAND_LIST_TYPE_COPY: return "Copy Command List";
case D3D12_COMMAND_LIST_TYPE_VIDEO_DECODE: return "Video Decode Command List";
case D3D12_COMMAND_LIST_TYPE_VIDEO_PROCESS: return "Video Process Command List";
default: return "Unknown Command List";
}
}
const char * GetBlobDataAsString(com_ptr<ID3DBlob> blob)
{
if(blob != nullptr) {
return static_cast<const char *>(blob->GetBufferPointer());
} else {
return "Blob was null";
}
}
void DebugDestructionCallback(void * pData)
{
static int x = 0;
Log::Debug("Destruction#{0}: {1}", x++, pData);
}
}
namespace Netcode::Detail{
HResultTester::HResultTester(const char * msg, const char * file, int line, ...) :
message{ msg }, file{ file }, line{ line } {
va_list l;
va_start(l, line);
va_copy(args, l);
va_end(l);
}
void HResultTester::operator<<(HRESULT hr) {
if(FAILED(hr)) {
std::ostringstream oss;
oss << file << "(" << line << "): " << message;
std::string buffer;
buffer.resize(1024);
vsprintf_s(&(buffer.at(0)), 1024, oss.str().c_str(), args);
va_end(args);
Log::Error(buffer.c_str());
_com_error err(hr);
Log::Info(err.ErrorMessage());
if(IsDebuggerPresent()) {
DebugBreak();
}
exit(-1);
}
va_end(args);
}
}
| 27.396226 | 86 | 0.706382 | [
"model"
] |
0c762b5855b0498ba7e6de22e790edbb41c4c133 | 13,100 | cpp | C++ | src/mame/drivers/hexion.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | 26 | 2015-03-31T06:25:51.000Z | 2021-12-14T09:29:04.000Z | src/mame/drivers/hexion.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | null | null | null | src/mame/drivers/hexion.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | 10 | 2015-03-27T05:45:51.000Z | 2022-02-04T06:57:36.000Z | // license:BSD-3-Clause
// copyright-holders:Nicola Salmoria
/***************************************************************************
Hexion (GX122) (c) 1992 Konami
driver by Nicola Salmoria
Notes:
- The board has a 052591, which is used for protection in Thunder Cross and
S.P.Y. In this game, however, the only thing it seems to do is clear the
screen.
This is the program for the 052591:
00: 5f 80 01 e0 08
01: df 80 00 e0 0c
02: df 90 02 e0 0c
03: df a0 03 e0 0c
04: df b0 0f e0 0c
05: df c0 ff bf 0c
06: 5c 02 00 33 0c
07: 5f 80 04 80 0c
08: 5c 0e 00 2b 0c
09: df 70 00 cb 08
0a: 5f 80 00 80 0c
0b: 5c 04 00 2b 0c
0c: df 60 00 cb 08
0d: 5c 0c 1f e9 0c
0e: 4c 0c 2d e9 08
0f: 5f 80 03 80 0c
10: 5c 04 00 2b 0c
11: 5f 00 00 cb 00
12: 5f 80 02 a0 0c
13: df d0 00 c0 04
14: 01 3a 00 f3 0a
15: 5c 08 00 b3 0c
16: 5c 0e 00 13 0c
17: 5f 80 00 a0 0c
18: 5c 00 00 13 0c
19: 5c 08 00 b3 0c
1a: 5c 00 00 13 0c
1b: 84 5a 00 b3 0c
1c: 48 0a 5b d1 0c
1d: 5f 80 00 e0 08
1e: 5f 00 1e fd 0c
1f: 5f 80 01 a0 0c
20: df 20 00 cb 08
21: 5c 08 00 b3 0c
22: 5f 80 03 00 0c
23: 5c 08 00 b3 0c
24: 5f 80 00 80 0c
25: 5c 00 00 33 0c
26: 5c 08 00 93 0c
27: 9f 91 ff cf 0e
28: 5c 84 00 20 0c
29: 84 00 00 b3 0c
2a: 49 10 69 d1 0c
2b: 5f 80 00 e0 08
2c: 5f 00 2c fd 0c
2d: 5f 80 01 a0 0c
2e: df 20 00 cb 08
2f: 5c 08 00 b3 0c
30: 5f 80 03 00 0c
31: 5c 00 00 b3 0c
32: 5f 80 01 00 0c
33: 5c 08 00 b3 0c
34: 5f 80 00 80 0c
35: 5c 00 00 33 0c
36: 5c 08 00 93 0c
37: 9f 91 ff cf 0e
38: 5c 84 00 20 0c
39: 84 00 00 b3 0c
3a: 49 10 79 d1 0c
3b: 5f 80 00 e0 08
3c: 5f 00 3c fd 0c
3d: ff ff ff ff ff
3e: ff ff ff ff ff
3f: ff ff ff ff ff
***************************************************************************/
#include "emu.h"
#include "includes/hexion.h"
#include "includes/konamipt.h"
#include "cpu/z80/z80.h"
#include "machine/watchdog.h"
#include "sound/okim6295.h"
#include "sound/k051649.h"
#include "speaker.h"
void hexion_state::coincntr_w(uint8_t data)
{
//logerror("%04x: coincntr_w %02x\n",m_maincpu->pc(),data);
/* bits 0/1 = coin counters */
machine().bookkeeping().coin_counter_w(0,data & 0x01);
machine().bookkeeping().coin_counter_w(1,data & 0x02);
/* bit 5 = flip screen */
flip_screen_set(data & 0x20);
/* other bit unknown */
if ((data & 0xdc) != 0x10) popmessage("coincntr %02x",data);
}
WRITE_LINE_MEMBER(hexion_state::irq_ack_w)
{
m_maincpu->set_input_line(0, CLEAR_LINE);
}
WRITE_LINE_MEMBER(hexion_state::nmi_ack_w)
{
m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
}
void hexion_state::ccu_int_time_w(uint8_t data)
{
logerror("ccu_int_time rewritten with value of %02x\n", data);
m_ccu_int_time = data;
}
void hexion_state::hexion_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0x9fff).bankr("bank1");
map(0xa000, 0xbfff).ram();
map(0xc000, 0xdffe).rw(FUNC(hexion_state::bankedram_r), FUNC(hexion_state::bankedram_w));
map(0xdfff, 0xdfff).w(FUNC(hexion_state::bankctrl_w));
map(0xe000, 0xe000).noprw();
map(0xe800, 0xe8ff).m("k051649", FUNC(k051649_device::scc_map));
map(0xf000, 0xf00f).rw(m_k053252, FUNC(k053252_device::read), FUNC(k053252_device::write));
map(0xf200, 0xf200).w("oki", FUNC(okim6295_device::write));
map(0xf400, 0xf400).portr("DSW1");
map(0xf401, 0xf401).portr("DSW2");
map(0xf402, 0xf402).portr("P1");
map(0xf403, 0xf403).portr("P2");
map(0xf440, 0xf440).portr("DSW3");
map(0xf441, 0xf441).portr("SYSTEM");
map(0xf480, 0xf480).w(FUNC(hexion_state::bankswitch_w));
map(0xf4c0, 0xf4c0).w(FUNC(hexion_state::coincntr_w));
map(0xf500, 0xf500).w(FUNC(hexion_state::gfxrom_select_w));
map(0xf540, 0xf540).r("watchdog", FUNC(watchdog_timer_device::reset_r));
}
void hexion_state::hexionb_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0x9fff).bankr("bank1");
map(0xa000, 0xbfff).ram();
map(0xc000, 0xdffe).rw(FUNC(hexion_state::bankedram_r), FUNC(hexion_state::bankedram_w));
map(0xdfff, 0xdfff).w(FUNC(hexion_state::bankctrl_w));
map(0xe000, 0xe000).noprw();
map(0xe800, 0xe87f).noprw(); // all the code to use the k051649 is still present
map(0xe880, 0xe889).noprw(); // but the bootleg has an additional M6295 @ 0xf5c0 instead
map(0xe88a, 0xe88e).noprw();
map(0xe88f, 0xe88f).noprw();
map(0xe8e0, 0xe8ff).noprw();
map(0xf000, 0xf00f).rw(m_k053252, FUNC(k053252_device::read), FUNC(k053252_device::write));
map(0xf200, 0xf200).w("oki", FUNC(okim6295_device::write));
map(0xf400, 0xf400).portr("DSW1");
map(0xf401, 0xf401).portr("DSW2");
map(0xf402, 0xf402).portr("P1");
map(0xf403, 0xf403).portr("P2");
map(0xf440, 0xf440).portr("DSW3");
map(0xf441, 0xf441).portr("SYSTEM");
map(0xf480, 0xf480).w(FUNC(hexion_state::bankswitch_w));
map(0xf4c0, 0xf4c0).w(FUNC(hexion_state::coincntr_w));
map(0xf500, 0xf500).w(FUNC(hexion_state::gfxrom_select_w));
map(0xf540, 0xf540).r("watchdog", FUNC(watchdog_timer_device::reset_r));
map(0xf5c0, 0xf5c0).w("oki2", FUNC(okim6295_device::write));
}
static INPUT_PORTS_START( hexion )
PORT_START("DSW1")
KONAMI_COINAGE_LOC(DEF_STR( Free_Play ), DEF_STR( Free_Play ), SW1)
PORT_START("DSW2")
PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_DIPNAME( 0x70, 0x40, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:5,6,7")
PORT_DIPSETTING( 0x70, DEF_STR( Easiest ) ) // "1"
PORT_DIPSETTING( 0x60, DEF_STR( Very_Easy) ) // "2"
PORT_DIPSETTING( 0x50, DEF_STR( Easy ) ) // "3"
PORT_DIPSETTING( 0x40, DEF_STR( Medium ) ) // "4"
PORT_DIPSETTING( 0x30, DEF_STR( Medium_Hard ) ) // "5"
PORT_DIPSETTING( 0x20, DEF_STR( Hard ) ) // "6"
PORT_DIPSETTING( 0x10, DEF_STR( Very_Hard ) ) // "7"
PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) // "8"
PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:8")
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START("DSW3")
PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW3:1")
PORT_DIPSETTING( 0x01, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_BIT( 0xfa, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_SERVICE_DIPLOC( 0x04, IP_ACTIVE_LOW, "SW3:3" )
PORT_START("P1")
KONAMI8_B12_START(1)
PORT_START("P2")
KONAMI8_B12_START(2)
PORT_START("SYSTEM")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_CUSTOM ) /* 052591? game waits for it to be 0 */
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
INPUT_PORTS_END
static const gfx_layout charlayout =
{
8,8,
RGN_FRAC(1,2),
4,
{ 0, 1, 2, 3 },
{ RGN_FRAC(1,2)+0*4, RGN_FRAC(1,2)+1*4, 0*4, 1*4, RGN_FRAC(1,2)+2*4, RGN_FRAC(1,2)+3*4, 2*4, 3*4 },
{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
16*8
};
static GFXDECODE_START( gfx_hexion )
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 16 )
GFXDECODE_END
TIMER_DEVICE_CALLBACK_MEMBER(hexion_state::scanline)
{
int scanline = param;
// z80 /IRQ is connected to the IRQ1(vblank) pin of k053252 CCU
if(scanline == 256)
m_maincpu->set_input_line(0, ASSERT_LINE);
// z80 /NMI is connected to the IRQ2 pin of k053252 CCU
// the following code is emulating INT_TIME of the k053252, this code will go away
// when the new konami branch is merged.
m_ccu_int_time_count--;
if (m_ccu_int_time_count <= 0)
{
m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
m_ccu_int_time_count = m_ccu_int_time;
}
}
void hexion_state::hexion(machine_config &config)
{
/* basic machine hardware */
Z80(config, m_maincpu, XTAL(24'000'000)/4); /* Z80B 6 MHz @ 17F, xtal verified, divider not verified */
m_maincpu->set_addrmap(AS_PROGRAM, &hexion_state::hexion_map);
TIMER(config, "scantimer").configure_scanline(FUNC(hexion_state::scanline), "screen", 0, 1);
WATCHDOG_TIMER(config, "watchdog");
K053252(config, m_k053252, XTAL(24'000'000)/2); /* K053252, X0-010(?) @8D, xtal verified, divider not verified */
m_k053252->int1_ack().set(FUNC(hexion_state::irq_ack_w));
m_k053252->int2_ack().set(FUNC(hexion_state::nmi_ack_w));
m_k053252->int_time().set(FUNC(hexion_state::ccu_int_time_w));
/* video hardware */
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh_hz(60);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
screen.set_size(64*8, 36*8);
screen.set_visarea(0*8, 64*8-1, 0*8, 32*8-1);
screen.set_screen_update(FUNC(hexion_state::screen_update));
screen.set_palette(m_palette);
GFXDECODE(config, m_gfxdecode, m_palette, gfx_hexion);
PALETTE(config, "palette", palette_device::RGB_444_PROMS, "proms", 256);
/* sound hardware */
SPEAKER(config, "mono").front_center();
/* MSM6295GS @ 5E, clock frequency & pin 7 not verified */
OKIM6295(config, "oki", 1056000, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "mono", 0.5);
/* KONAMI 051649 // 2212P003 // JAPAN 8910EAJ @ 1D, xtal verified, divider not verified */
K051649(config, "k051649", XTAL(24'000'000)/16).add_route(ALL_OUTPUTS, "mono", 0.5);
}
void hexion_state::hexionb(machine_config &config)
{
hexion(config);
m_maincpu->set_addrmap(AS_PROGRAM, &hexion_state::hexionb_map);
config.device_remove("k051649");
// clock frequency & pin 7 not verified; this clock and pin 7 being low makes the pitch match the non-bootleg version, so is probably correct
OKIM6295(config, "oki2", 1056000, okim6295_device::PIN7_LOW).add_route(ALL_OUTPUTS, "mono", 0.5);
}
/***************************************************************************
Game driver(s)
***************************************************************************/
ROM_START( hexion )
ROM_REGION( 0x34800, "maincpu", 0 ) /* ROMs + space for additional RAM */
ROM_LOAD( "122__j_a__b01.16f", 0x00000, 0x20000, CRC(eabc6dd1) SHA1(e74c1f1f2fcf8973f0741a2d544f25c8639448bf) ) /* "122 // J A // B01" @16F (27c010?) */
ROM_RELOAD( 0x10000, 0x20000 ) /* banked at 8000-9fff */
ROM_REGION( 0x80000, "gfx1", 0 ) /* addressable by the main CPU */
ROM_LOAD( "122a07.1h", 0x00000, 0x40000, CRC(22ae55e3) SHA1(41bdc990f69416b639542e2186a3610c16389063) ) /* Later pcbs have mask roms labeled: "KONAMI // 055066 // 122A07 // 233505" @1H (maybe mismarked 2H on pcb?) */
ROM_LOAD( "122a06.1g", 0x40000, 0x40000, CRC(438f4388) SHA1(9e23805c9642a237daeaf106187d1e1e0692434d) ) /* Later pcbs have mask roms labeled: "KONAMI // 055065 // 122A06 // 233506" @1G */
ROM_REGION( 0x40000, "oki", 0 ) /* OKIM6295 samples */
ROM_LOAD( "122a05.2f", 0x0000, 0x40000, CRC(bcc831bf) SHA1(c3382065dd0069a4dc0bde2d9931ec85b0bffc73) ) /* Later pcbs have mask roms labeled: "KONAMI // 055064 // 122A05 // 233507" @2F (maybe 2G? marking isn't visible in the picture I have) */
ROM_REGION( 0x0300, "proms", 0 )
ROM_LOAD( "122a04.10b", 0x0000, 0x0100, CRC(506eb8c6) SHA1(3bff7cf286942d8bdbc3998245c3de20981fbecb) ) // AMD27S21 == 82S129
ROM_LOAD( "122a03.11b", 0x0100, 0x0100, CRC(590c4f64) SHA1(db4b34f8c5fdfea034a94d65873f6fb842f123e9) ) // AMD27S21 == 82S129
ROM_LOAD( "122a02.13b", 0x0200, 0x0100, CRC(5734305c) SHA1(c72e59acf79a4db1a5a9d827eef899c0675336f2) ) // AMD27S21 == 82S129
// there are also two PALs of unknown type on the pcb:
//054843 @12F
//054844 @12H(12I?)
ROM_END
ROM_START( hexionb )
ROM_REGION( 0x34800, "maincpu", 0 ) /* ROMs + space for additional RAM */
ROM_LOAD( "hexionb.u2", 0x00000, 0x20000, CRC(93edc5d4) SHA1(d14c5be85a67eebddda9103bdf19de8c3c05d3af) )
ROM_RELOAD( 0x10000, 0x20000 ) /* banked at 8000-9fff */
ROM_REGION( 0x80000, "gfx1", 0 ) /* addressable by the main CPU */
ROM_LOAD( "hexionb.u30", 0x00000, 0x40000, CRC(22ae55e3) SHA1(41bdc990f69416b639542e2186a3610c16389063) ) // == 122a07.1h
ROM_LOAD( "hexionb.u29", 0x40000, 0x40000, CRC(438f4388) SHA1(9e23805c9642a237daeaf106187d1e1e0692434d) ) // == 122a06.1g
ROM_REGION( 0x40000, "oki", 0 ) /* OKIM6295 samples */
ROM_LOAD( "hexionb.u16", 0x0000, 0x40000, CRC(bcc831bf) SHA1(c3382065dd0069a4dc0bde2d9931ec85b0bffc73) ) // == 122a05.2f
ROM_REGION( 0x40000, "oki2", 0 ) /* OKIM6295 samples */
ROM_LOAD( "hexionb.u18", 0x0000, 0x40000, CRC(c179d315) SHA1(b39d5ec8a90b7ae06763191b8324f32fe1d0ca9b) )
ROM_REGION( 0x0300, "proms", 0 )
ROM_LOAD( "82s129.u36", 0x0000, 0x0100, CRC(506eb8c6) SHA1(3bff7cf286942d8bdbc3998245c3de20981fbecb) )
ROM_LOAD( "82s129.u37", 0x0100, 0x0100, CRC(590c4f64) SHA1(db4b34f8c5fdfea034a94d65873f6fb842f123e9) )
ROM_LOAD( "82s129.u38", 0x0200, 0x0100, CRC(5734305c) SHA1(c72e59acf79a4db1a5a9d827eef899c0675336f2) )
// there are also two PALs on the bootleg:
//PAL20L10 @U12
//PAL20L10 @U31
ROM_END
GAME( 1992, hexion, 0, hexion, hexion, hexion_state, empty_init, ROT0, "Konami", "Hexion (Japan ver JAB)", 0 )
GAME( 1992, hexionb, hexion, hexionb, hexion, hexion_state, empty_init, ROT0, "bootleg (Impeuropex Corp.)", "Hexion (Asia ver AAA, bootleg)", 0 ) // we're missing an original Asia AAA
| 36.797753 | 245 | 0.68771 | [
"3d"
] |
0c8a1b740f2fcd57b73a86d5459c0126d1b65766 | 3,821 | cpp | C++ | src/RiboseMobilizer.cpp | MadCatX/molmodel | 5abde979e1780dcc61a4b05affcba6e116250585 | [
"MIT"
] | null | null | null | src/RiboseMobilizer.cpp | MadCatX/molmodel | 5abde979e1780dcc61a4b05affcba6e116250585 | [
"MIT"
] | 1 | 2020-12-09T16:45:16.000Z | 2020-12-09T16:56:52.000Z | src/RiboseMobilizer.cpp | MadCatX/molmodel | 5abde979e1780dcc61a4b05affcba6e116250585 | [
"MIT"
] | 4 | 2020-06-23T18:24:37.000Z | 2021-04-29T14:44:25.000Z | /* -------------------------------------------------------------------------- *
* SimTK Core: SimTK Simbody(tm) *
* -------------------------------------------------------------------------- *
* This is part of the SimTK Core biosimulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Christopher Bruns *
* Contributors: Ajay Seth *
* *
* 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, CONTRIBUTORS 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 "molmodel/internal/RiboseMobilizer.h"
#include <cmath>
namespace SimTK {
/* static */ std::vector< const Function* > PseudorotationMobilizer::createFunctions(Angle amplitude, Angle phase)
{
std::vector< const Function* > functions;
functions.push_back(new ZeroFunction ); // x rotation
functions.push_back(new ZeroFunction ); // y rotation
// Z-rotation is the only degree of freedom for this mobilizer
functions.push_back(new SinusoidFunction(amplitude, phase) ); // z rotation
functions.push_back(new ZeroFunction ); // x translation
functions.push_back(new ZeroFunction ); // y translation
functions.push_back(new ZeroFunction ); // z translation
return functions;
}
/* static */ std::vector< std::vector<int> > PseudorotationMobilizer::createCoordIndices()
{
std::vector<int> oneCoordinateVec;
oneCoordinateVec.push_back(0); // first and only generalized coordinate index
std::vector< std::vector<int> > coordIndices;
// All six functions take the one generalized coordinate
coordIndices.push_back(std::vector<int>()); // 1, empty
coordIndices.push_back(std::vector<int>()); // 2, empty
coordIndices.push_back(oneCoordinateVec); // 3, one coordinate, zero
coordIndices.push_back(std::vector<int>()); // 4, empty
coordIndices.push_back(std::vector<int>()); // 5, empty
coordIndices.push_back(std::vector<int>()); // 6, empty
return coordIndices;
}
} // namespace SimTK
| 53.816901 | 115 | 0.582047 | [
"vector"
] |
0c925d1661d6374cabdb00f1ac43331a7e8db77f | 9,915 | cpp | C++ | src/vendors/OceanOptics/protocols/obp/exchanges/OBPTransaction.cpp | ska/SeaBreeze | 09aac3e764867825f51f75c519a025a863d03590 | [
"MIT"
] | null | null | null | src/vendors/OceanOptics/protocols/obp/exchanges/OBPTransaction.cpp | ska/SeaBreeze | 09aac3e764867825f51f75c519a025a863d03590 | [
"MIT"
] | null | null | null | src/vendors/OceanOptics/protocols/obp/exchanges/OBPTransaction.cpp | ska/SeaBreeze | 09aac3e764867825f51f75c519a025a863d03590 | [
"MIT"
] | 1 | 2020-07-03T08:36:47.000Z | 2020-07-03T08:36:47.000Z | /***************************************************//**
* @file OBPTransaction.cpp
* @date March 2011
* @author Ocean Optics, Inc.
*
* All messages in the Ocean Binary Protocol begin with
* a standard 64-byte header. It is always safe to read
* 64 bytes for the start of a new transfer from a device
* that supports this protocol, which works nicely with
* the USB minimum packet size.
*
* This class simplifies the task of performing transactions
* with the device, where a command is always followed
* by a response.
*
* LICENSE:
*
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*******************************************************/
#include "common/globals.h"
#include "vendors/OceanOptics/protocols/obp/exchanges/OBPTransaction.h"
using namespace seabreeze;
using namespace seabreeze::oceanBinaryProtocol;
using namespace std;
#ifdef _WINDOWS
#pragma warning (disable: 4101) // unreferenced local variable
#endif
#define MINIMUM_TRANSFER_SIZE 64
OBPTransaction::OBPTransaction() {
this->hints = new vector<ProtocolHint *>;
}
OBPTransaction::~OBPTransaction() {
vector<ProtocolHint *>::iterator iter;
for(iter = this->hints->begin(); iter != this->hints->end(); iter++) {
delete *iter;
}
delete this->hints;
}
const vector<ProtocolHint *> &OBPTransaction::getHints() {
return *(this->hints);
}
vector<byte> *OBPTransaction::queryDevice(TransferHelper *helper,
unsigned int messageType,
vector<byte> &data) throw (ProtocolException) {
int flag = 0;
vector<byte> *bytes = NULL;
vector<byte> *fullVector = NULL;
OBPMessage *message = new OBPMessage();
OBPMessage *response = NULL;
message->setMessageType(messageType);
/* Need a copy of the input data that can be given to the message. */
/* Note: copy will be deleted by message when appropriate. */
message->setData(new vector<byte>(data));
try {
bytes = message->toByteStream();
flag = helper->send(*bytes, (unsigned) bytes->size());
if(((unsigned int)flag) != bytes->size()) {
/* FIXME: retry, throw exception, something here */
}
} catch (BusException &be) {
if(NULL != bytes) {
delete bytes;
}
delete message;
string error("Failed to write to bus.");
/* FIXME: previous exception should probably be bundled up into the new exception */
/* FIXME: there is probably a more descriptive type for this than ProtocolException */
throw ProtocolException(error);
}
delete message;
delete bytes;
bytes = NULL;
try {
/* Read the 64-byte OBP header. This may indicate that more data
* must be absorbed afterwards.
*/
bytes = new vector<byte>(64);
flag = helper->receive(*bytes, (unsigned) bytes->size());
if(((unsigned int)flag) != bytes->size()) {
/* FIXME: retry, throw exception, something here */
}
/* Parse out the header and see if there is an extended payload. */
try {
response = OBPMessage::parseHeaderFromByteStream(bytes);
} catch (IllegalArgumentException &iae) {
response = NULL;
}
if(NULL == response || true == response->isNackFlagSet()
|| response->getMessageType() != messageType) {
if(NULL != bytes) {
delete bytes;
}
if(NULL != response) {
delete response;
}
/* There may be a legitimate reason to not return a message
* (e.g. tried to read an unprogrammed value). Just return
* NULL here instead of throwing an exception and let the
* caller figure it out.
*/
return NULL;
}
unsigned int bytesToRead = response->getBytesRemaining() - 20; /* omit footer and checksum */
if(bytesToRead > 0) {
fullVector = new vector<byte>(bytesToRead + bytes->size());
/* Safely stl::copy() the header into a full-sized block and
* delete the existing buffer
*/
vector<byte>::iterator iter = copy(bytes->begin(), bytes->end(), fullVector->begin());
delete bytes;
bytes = NULL;
/* TransferHelper expects a vector, so create a new one for it */
vector<byte> *remainder = new vector<byte>(bytesToRead);
flag = helper->receive(*remainder, (unsigned) remainder->size());
if(((unsigned int)flag) != bytesToRead) {
/* FIXME: retry, throw exception, something here */
}
copy(remainder->begin(), remainder->end(), iter);
delete remainder;
} else {
fullVector = bytes;
bytes = NULL; /* To prevent double deletion */
}
/* Delete and recreate response using the full message */
delete response;
try {
response = OBPMessage::parseByteStream(fullVector);
} catch (IllegalArgumentException &iae) {
response = NULL;
}
delete fullVector;
fullVector = NULL;
} catch (BusException &be) {
if(NULL != bytes) {
delete bytes;
}
if(NULL != fullVector) {
delete fullVector;
}
string error("Failed to read from bus.");
/* FIXME: previous exception should probably be bundled up into the new exception */
/* FIXME: there is probably a more descriptive type for this than ProtocolException */
throw ProtocolException(error);
}
if(NULL == response) {
/* This could happen if the footer or checksum failed for
* some reason, but that would be very unusual. This can only happen
* if the header was already verified, but there was some error in the
* rest of the payload.
*/
string error("Failed to parse extended message");
throw ProtocolException(error);
}
/* Make a copy of the response buffer so response can be deleted */
bytes = new vector<byte>(*response->getData());
delete response;
return bytes;
}
bool OBPTransaction::sendCommandToDevice(TransferHelper *helper,
unsigned int messageType,
vector<byte> &data) throw (ProtocolException) {
bool retval = false;
int flag = 0;
vector<byte> *bytes = NULL;
OBPMessage *message = new OBPMessage();
OBPMessage *response = NULL;
message->setMessageType(messageType);
message->setAckRequestedFlag();
/* Need a copy of the input data that can be given to the message. */
/* Note: copy will be deleted by message when appropriate. */
message->setData(new vector<byte>(data));
try {
bytes = message->toByteStream();
flag = helper->send(*bytes, (unsigned) bytes->size());
if(((unsigned int)flag) != bytes->size()) {
/* FIXME: retry, throw exception, something here */
}
} catch (BusException &be) {
if(NULL != bytes) {
delete bytes;
}
delete message;
string error("Failed to write to bus.");
/* FIXME: previous exception should probably be bundled up into the new exception */
/* FIXME: there is probably a more descriptive type for this than ProtocolException */
throw ProtocolException(error);
}
delete message;
delete bytes;
bytes = NULL;
try {
/* Read the 64-byte OBP header. */
bytes = new vector<byte>(64);
flag = helper->receive(*bytes, (unsigned) bytes->size());
if(((unsigned int)flag) != bytes->size()) {
/* FIXME: retry, throw exception, something here */
}
/* Parse out the header. */
try {
response = OBPMessage::parseHeaderFromByteStream(bytes);
} catch (IllegalArgumentException &iae) {
response = NULL;
}
} catch (BusException &be) {
if(NULL != bytes) {
delete bytes;
}
string error("Failed to read from bus.");
/* FIXME: previous exception should probably be bundled up into the new exception */
/* FIXME: there is probably a more descriptive type for this than ProtocolException */
throw ProtocolException(error);
}
delete bytes;
if(NULL == response || true == response->isNackFlagSet()
|| response->getMessageType() != messageType) {
retval = false;
} else if(true == response->isAckFlagSet()) {
retval = true;
} else {
delete response;
string error("Illegal device response");
throw ProtocolException(error);
}
delete response;
return retval;
}
| 36.054545 | 101 | 0.607161 | [
"vector"
] |
0c95a0ba46c91a489e4124a0f715ab78ee947c48 | 1,806 | cpp | C++ | leetcode.com/Weekly Contest 215/4/better.cpp | sky-bro/AC | 29bfa3f13994612887e18065fa6e854b9a29633d | [
"MIT"
] | 1 | 2020-08-20T11:02:49.000Z | 2020-08-20T11:02:49.000Z | leetcode.com/Weekly Contest 215/4/better.cpp | sky-bro/AC | 29bfa3f13994612887e18065fa6e854b9a29633d | [
"MIT"
] | null | null | null | leetcode.com/Weekly Contest 215/4/better.cpp | sky-bro/AC | 29bfa3f13994612887e18065fa6e854b9a29633d | [
"MIT"
] | 1 | 2022-01-01T23:23:13.000Z | 2022-01-01T23:23:13.000Z | // ref:
// https://leetcode.com/problems/maximize-grid-happiness/discuss/936081/C%2B%2B-5D-DP
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int dp[25][7][7][64][64] = {};
class Solution {
public:
int nCost(int m, int n, int i, int j, int mask_in, int mask_ex, int d) {
int diff = 0, up = (1 << (n - 1));
if (j > 0 && (mask_in & 1)) diff += d - 30;
if (i > 0 && (mask_in & up)) diff += d - 30;
if (j > 0 && (mask_ex & 1)) diff += d + 20;
if (i > 0 && (mask_ex & up)) diff += d + 20;
return diff;
}
int dfs(int m, int n, int p, int in, int ex, int mask_in, int mask_ex) {
int i = p / n, j = p % n;
if (i >= m) return 0;
if (dp[p][in][ex][mask_in][mask_ex])
return dp[p][in][ex][mask_in][mask_ex] - 1;
int n_mask_in = (mask_in << 1) & 63, n_mask_ex = (mask_ex << 1) & 63;
int res = dfs(m, n, p + 1, in, ex, n_mask_in, n_mask_ex); // space
if (in > 0) { // intro
int diff = 120 + nCost(m, n, i, j, mask_in, mask_ex, -30);
res = max(res,
diff + dfs(m, n, p + 1, in - 1, ex, n_mask_in + 1, n_mask_ex));
}
if (ex > 0) { // extro
int diff = 40 + nCost(m, n, i, j, mask_in, mask_ex, 20);
res = max(res,
diff + dfs(m, n, p + 1, in, ex - 1, n_mask_in, n_mask_ex + 1));
}
dp[p][in][ex][mask_in][mask_ex] = res + 1;
return res;
}
int getMaxGridHappiness(int m, int n, int introvertsCount,
int extrovertsCount) {
return dfs(m, n, 0, introvertsCount, extrovertsCount, 0, 0);
}
};
int main(int argc, char const* argv[]) {
Solution s;
int m = 3, n = 1, i = 2, e = 1;
m = 3, n = 4, i = 6, e = 5;
cout << s.getMaxGridHappiness(m, n, i, e) << endl;
return 0;
}
| 34.075472 | 85 | 0.512182 | [
"vector"
] |
0c9a961954572e86f59d954de04ecf8b3ae36036 | 660 | cpp | C++ | example/ordinary_least_squares_cpp/main.cpp | NewYaroslav/xalgorithms | ffb9abc6107bed496382b053f333c40fab61a700 | [
"MIT"
] | null | null | null | example/ordinary_least_squares_cpp/main.cpp | NewYaroslav/xalgorithms | ffb9abc6107bed496382b053f333c40fab61a700 | [
"MIT"
] | null | null | null | example/ordinary_least_squares_cpp/main.cpp | NewYaroslav/xalgorithms | ffb9abc6107bed496382b053f333c40fab61a700 | [
"MIT"
] | null | null | null | #include <iostream>
#include "ordinary_least_squares.hpp"
using namespace std;
struct point2D {
double x;
double y;
point2D(double xIn, double yIn) {
x = xIn;
y = yIn;
}
};
int main()
{
cout << "Hello world!" << endl;
std::vector<point2D> vPoint;
const int NUM_POINT = 10;
for(int i = 0; i < NUM_POINT; ++i) {
vPoint.push_back(point2D((double)i, 8*(double)i - 3 + ((rand()%100)-50)*0.05));
}
std::vector<double> vCoeff;
xaCalcOls(vPoint, vCoeff, XA_PARABOLA);
for(size_t i = 0; i < vCoeff.size(); ++i) {
cout << "a[" << i << "] = " << vCoeff[i] << endl;
}
return 0;
}
| 21.290323 | 87 | 0.543939 | [
"vector"
] |
0ca5d30aa0ed1624bca39fa18dcc7fc32bc743f8 | 2,061 | cpp | C++ | libs/sge_engine/src/sge_engine/GameObject.cpp | Alekssasho/sge_source | 2db4ae08f7b3434d32dd9767fe1136234cb70b83 | [
"MIT"
] | null | null | null | libs/sge_engine/src/sge_engine/GameObject.cpp | Alekssasho/sge_source | 2db4ae08f7b3434d32dd9767fe1136234cb70b83 | [
"MIT"
] | null | null | null | libs/sge_engine/src/sge_engine/GameObject.cpp | Alekssasho/sge_source | 2db4ae08f7b3434d32dd9767fe1136234cb70b83 | [
"MIT"
] | null | null | null | #include "sge_engine/TypeRegister.h"
#include "sge_utils/utils/strings.h"
#include "Actor.h"
namespace sge {
//--------------------------------------------------------------------
// struct Object
//--------------------------------------------------------------------
// clang-format off
DefineTypeId(GameObject, 20'03'01'0011);
DefineTypeId(std::vector<ObjectId>, 20'03'07'0012);
ReflBlock()
{
ReflAddType(ObjectId)
ReflMember(ObjectId, id);
ReflAddType(std::vector<ObjectId>);
ReflAddType(GameObject)
ReflMember(GameObject, m_id)
.addMemberFlag(MFF_PrefabDontCopy)
.addMemberFlag(MFF_NonEditable) // CAUTION: the id is actually saveable, but it is handeled diferently!
ReflMember(GameObject, m_displayName)
.addMemberFlag(MFF_PrefabDontCopy)
;
}
// clang-format on
bool GameObject::isActor() const {
return dynamic_cast<const Actor*>(this) != nullptr;
}
Actor* GameObject::getActor() {
return dynamic_cast<Actor*>(this);
}
const Actor* GameObject::getActor() const {
return dynamic_cast<const Actor*>(this);
}
void GameObject::composeDebugDisplayName(std::string& result) const {
string_format(result, "%s[id=%d]", m_displayName.c_str(), m_id.id);
}
void GameObject::onPlayStateChanged(bool const isStartingToPlay) {
for (auto itr : m_traits) {
if_checked(itr.value()) { itr.value()->onPlayStateChanged(isStartingToPlay); }
}
}
void GameObject::registerTrait(Trait& trait) {
Trait* const pTrait = &trait;
TypeId const family = pTrait->getFamily();
// There shouldn't be a trait with the same family registered.
if_checked(m_traits.find_element(family) == nullptr) {
m_traits[family] = pTrait;
pTrait->onRegister(this);
}
}
//--------------------------------------------------------------------
// Trait
//--------------------------------------------------------------------
Actor* Trait::getActor() {
Actor* actor = dynamic_cast<Actor*>(getObject());
return actor;
}
const Actor* Trait::getActor() const {
const Actor* actor = dynamic_cast<const Actor*>(getObject());
return actor;
}
} // namespace sge | 26.088608 | 106 | 0.630762 | [
"object",
"vector"
] |
0ca91323d18664162c87a0a9496e6b0acda7a4f3 | 2,093 | cpp | C++ | src/lib/materials/dielectric.cpp | Manu343726/raytracer | eb868034ea5c62c49b54608c6ad7815c24aaedd5 | [
"MIT"
] | 4 | 2019-06-12T11:25:59.000Z | 2021-05-23T13:35:05.000Z | src/lib/materials/dielectric.cpp | Manu343726/raytracer | eb868034ea5c62c49b54608c6ad7815c24aaedd5 | [
"MIT"
] | null | null | null | src/lib/materials/dielectric.cpp | Manu343726/raytracer | eb868034ea5c62c49b54608c6ad7815c24aaedd5 | [
"MIT"
] | 1 | 2019-11-03T04:00:18.000Z | 2019-11-03T04:00:18.000Z | #include <raytracer/debug/profile.hpp>
#include <raytracer/hitable.hpp>
#include <raytracer/materials/dielectric.hpp>
#include <raytracer/math.hpp>
#include <fmt/format.h>
#include <fmt/ostream.h>
#include <spdlog/spdlog.h>
using namespace rt;
using namespace rt::materials;
float schlick(const float cosine, const float refraction_index)
{
ZoneScoped;
float r0 = (1.0f - refraction_index) / (1.0f + refraction_index);
r0 = r0 * r0;
return r0 + (1.0f - r0) * std::pow(1.0f - cosine, 5.0f);
}
dielectric::dielectric(
const float refraction_index, const vector& albedo, const vector& emissive)
: _refraction_index{refraction_index}, _albedo{albedo}, _emissive{emissive}
{
}
vector dielectric::emitted() const
{
return _emissive;
}
bool dielectric::scatter(
const rt::ray& in,
const rt::hit_record& hit,
rt::vector& attenuation,
rt::ray& scattered) const
{
ZoneScoped;
attenuation = _albedo;
float cosine;
vector outward_normal;
float index;
const float dot = dot_product(in.direction(), hit.normal);
if(dot > 0.0f)
{
outward_normal = -hit.normal;
index = _refraction_index;
cosine = _refraction_index * dot;
}
else
{
outward_normal = hit.normal;
index = 1.0f / _refraction_index;
cosine = -dot;
}
const auto refracted = refract(in.direction(), outward_normal, index);
float reflected_ray_probability;
if(refracted)
{
reflected_ray_probability = schlick(cosine, _refraction_index);
}
else
{
reflected_ray_probability = 1.0f;
}
if(rt::random() < reflected_ray_probability)
{
scattered = rt::ray(hit.point, reflect(in.direction(), hit.normal));
}
else
{
scattered = rt::ray(hit.point, refracted.value());
}
return true;
}
std::string dielectric::to_string() const
{
return fmt::format(
"rt::materials::dielectric{{refraction_index: {}}}", _refraction_index);
}
| 23 | 80 | 0.626374 | [
"vector"
] |
0caad49ac537e969ac3137a18e63074ab5cbbbb9 | 553 | hpp | C++ | src/format-slip39.hpp | maaku/bc-seedtool-cli | e7cf7555b8d775954c2a8e5bf1f5963fa2f42dde | [
"BSD-2-Clause-Patent"
] | null | null | null | src/format-slip39.hpp | maaku/bc-seedtool-cli | e7cf7555b8d775954c2a8e5bf1f5963fa2f42dde | [
"BSD-2-Clause-Patent"
] | null | null | null | src/format-slip39.hpp | maaku/bc-seedtool-cli | e7cf7555b8d775954c2a8e5bf1f5963fa2f42dde | [
"BSD-2-Clause-Patent"
] | null | null | null | //
// format-slip39.hpp
//
// Copyright © 2020 by Blockchain Commons, LLC
// Licensed under the "BSD-2-Clause Plus Patent License"
//
#pragma once
#include <bc-slip39/bc-slip39.h>
#include <vector>
#include "format.hpp"
#include "utils.hpp"
class FormatSLIP39 : public Format {
public:
FormatSLIP39();
virtual void process_input(Params* p) override;
virtual void process_output(Params* p) override;
static bool is_seed_length_valid(size_t seed_len);
size_t groups_threshold;
std::vector<group_descriptor> groups;
};
| 19.75 | 57 | 0.712477 | [
"vector"
] |
0cab4696802e1900e349ce87851cba0c30d0fec4 | 8,825 | cpp | C++ | src_dualcontouring/DCGridHermiteData.cpp | hushanming/UrbanReconstruction | 8b058349fd860ea9029623a92d705dd93a4e4878 | [
"MIT"
] | 94 | 2017-07-20T05:32:07.000Z | 2022-03-02T03:38:54.000Z | src_dualcontouring/DCGridHermiteData.cpp | GucciPrada/UrbanReconstruction | 8b058349fd860ea9029623a92d705dd93a4e4878 | [
"MIT"
] | 3 | 2017-09-12T00:07:05.000Z | 2020-03-08T21:12:36.000Z | src_dualcontouring/DCGridHermiteData.cpp | GucciPrada/UrbanReconstruction | 8b058349fd860ea9029623a92d705dd93a4e4878 | [
"MIT"
] | 38 | 2017-07-25T06:00:52.000Z | 2022-03-19T10:01:06.000Z | #include "StdAfx.h"
#include "DCGrid.h"
//////////////////////////////////////////////////////////////////////////
// HermiteData functions
//////////////////////////////////////////////////////////////////////////
void CDCGrid::ComputeHermiteData_XY()
{
for ( int i = 0; i < m_nHDSideNumber; i++ ) {
for ( int j = 0; j < m_nHDSideNumber; j++ ) {
ComputeHermiteData_XY( i, j );
}
}
}
void CDCGrid::ComputeHermiteData_XY( int i, int j )
{
// segment points in its four adjacent cells
CVector3DPointer_Vector points;
std::vector< int > points_idx;
// surrounded by (i,j) (i+1,j) (i,j+1) (i+1,j+1)
for ( int ii = 0; ii <= 1; ii++ ) {
for ( int jj = 0; jj <= 1; jj++ ) {
if ( IIsValid( ii + i ) && JIsValid( jj + j ) ) {
Grid_Index & grid_index = m_vecIndex[ Index( ii + i, jj + j ) ];
for ( int k = 0; k < ( int )grid_index.size(); k++ ) {
int idx = grid_index[ k ];
points_idx.push_back( idx );
points.push_back( &( m_pPointCloud->m_vecPoint[ idx ] ) );
}
}
}
}
std::vector< int > points_cluster;
DistanceSegmentationEx( points, points_cluster, m_dbSegmentationDistance * m_dbSegmentationDistance, m_dbSegmentationZ );
// estimate the height of each cluster
int c = CompressCluster( points_cluster );
std::vector< double > cluster_height( c, 0.0 );
std::vector< int > cluster_number( c, 0 );
for ( int ci = 0; ci < ( int )points_cluster.size(); ci++ ) {
cluster_height[ points_cluster[ ci ] ] += points[ ci ]->pVec[ 2 ];
cluster_number[ points_cluster[ ci ] ] ++;
}
for ( int k = 0; k < c; k++ ) {
cluster_height[ k ] /= ( double )( cluster_number[ k ] );
}
// find the highest cluster covering each adjacent cell
int covering_cluster[ 2 ][ 2 ] = { { -1, -1 }, { -1, -1 } };
double covering_height[ 2 ][ 2 ] = { { -1e300, -1e300 }, { -1e300, -1e300 } };
int ci = 0;
for ( int ii = 0; ii <= 1; ii++ ) {
for ( int jj = 0; jj <= 1; jj++ ) {
if ( IIsValid( ii + i ) && JIsValid( jj + j ) ) {
Grid_Index & grid_index = m_vecIndex[ Index( ii + i, jj + j ) ];
for ( int k = 0; k < ( int )grid_index.size(); k++ ) {
if ( cluster_number[ points_cluster[ ci ] ] >= m_nAcceptNumber && cluster_height[ points_cluster[ ci ] ] > covering_height[ ii ][ jj ] ) {
covering_height[ ii ][ jj ] = cluster_height[ points_cluster[ ci ] ];
covering_cluster[ ii ][ jj ] = points_cluster[ ci ];
}
ci++;
}
}
}
}
// find the lowest cluster covering the grid point
double point_covering_height = 1e300;
int point_covering_cluster = -1;
for ( int ii = 0; ii <= 1; ii++ ) {
for ( int jj = 0; jj <= 1; jj++ ) {
if ( covering_height[ ii ][ jj ] < point_covering_height ) {
point_covering_height = covering_height[ ii ][ jj ];
point_covering_cluster = covering_cluster[ ii ][ jj ];
}
}
}
// finally, compute x-y hermite data
HermiteData & hd = m_vecHermiteDataXY[ HDIndex( i, j ) ];
hd.v = CVector3D( i, j, 0 ) * m_dbGridLength + m_pPointCloud->m_cBoundingBox.m_vMin;
hd.n = CVector3D( 0.0, 0.0, 1.0 );
if ( point_covering_cluster == -1 ) {
// if the covering cluster is a ground
hd.v[ 2 ] = m_pPointCloud->m_dbGroundZ;
} else {
std::vector< DistanceSorting > sorting_result;
SortDistance2D( points, hd.v, points_cluster, point_covering_cluster, sorting_result );
hd.n = CVector3D( 0.0, 0.0, 0.0 );
hd.v[ 2 ] = 0.0;
for ( int k = 0; k < m_nAcceptNumber; k++ ) {
hd.v[ 2 ] += m_pPointCloud->m_vecPoint[ points_idx[ sorting_result[ k ].index ] ][ 2 ];
hd.n += m_pPointCloud->m_vecNormal[ points_idx[ sorting_result[ k ].index ] ];
}
hd.v[ 2 ] /= ( double )m_nAcceptNumber;
hd.n.normalize();
}
}
void CDCGrid::ComputeHermiteData_Z()
{
// first dir along Y
for ( int i = 0; i < m_nHDSideNumber; i++ ) {
for ( int j = 0; j < m_nHDSideNumber - 1; j++ ) {
ComputeHermiteData_Z( i, j, 0 );
}
}
// second dir along X
for ( int i = 0; i < m_nHDSideNumber - 1; i++ ) {
for ( int j = 0; j < m_nHDSideNumber; j++ ) {
ComputeHermiteData_Z( i, j, 1 );
}
}
}
void CDCGrid::ComputeHermiteData_Z( int i, int j, int dir )
{
HermiteData & hd = m_vecHermiteDataZ[ HDIndex( i, j ) * 2 + dir ];
CVector3D v[ 2 ] = {
m_vecHermiteDataXY[ HDIndex( i, j ) ].v,
m_vecHermiteDataXY[ HDIndex( i + dir, j + 1 - dir ) ].v
};
CVector3DPointer_Vector points;
points.push_back( & v[ 0 ] );
points.push_back( & v[ 1 ] );
if ( IIsValid( i + dir ) && JIsValid( j + 1 - dir ) ) {
Grid_Index & grid_index_0 = m_vecIndex[ Index( i + dir, j + 1 - dir ) ];
for ( int k = 0; k < ( int )grid_index_0.size(); k++ )
points.push_back( & m_pPointCloud->m_vecPoint[ grid_index_0[ k ] ] );
}
if ( IIsValid( i + 1 ) && JIsValid( j + 1 ) ) {
Grid_Index & grid_index_1 = m_vecIndex[ Index( i + 1, j + 1 ) ];
for ( int k = 0; k < ( int )grid_index_1.size(); k++ )
points.push_back( & m_pPointCloud->m_vecPoint[ grid_index_1[ k ] ] );
}
ComputeHermiteData_Z( hd, v, points );
}
void CDCGrid::ComputeHermiteData_Z( HermiteData & hd, CVector3D v[ 2 ], CVector3DPointer_Vector & points )
{
// Parameters:
// points is used for segmentation, and v is used for calculating
// note that points[0..1] == &v[0..1]
std::vector< int > points_cluster;
DistanceSegmentationEx( points, points_cluster, m_dbSegmentationDistance * m_dbSegmentationDistance, m_dbSegmentationZ );
if ( ( HermiteDataXY_IsGround( v[ 0 ] ) && HermiteDataXY_IsGround( v[ 1 ] ) ) || points_cluster[ 0 ] == points_cluster[ 1 ] ) {
// they are in the same cluster
// do nothing
} else {
// otherwise...
int higher_v_index = -1;
if ( HermiteDataXY_IsGround( v[ 0 ] ) ) {
higher_v_index = 1;
} else if ( HermiteDataXY_IsGround( v[ 1 ] ) ) {
higher_v_index = 0;
} else if ( v[ 0 ][ 2 ] > v[ 1 ][ 2 ] ) {
higher_v_index = 0;
} else {
higher_v_index = 1;
}
int higher_cluster = points_cluster[ higher_v_index ];
CVector3D & lower_v = v[ 1 - higher_v_index ];
std::vector< DistanceSorting > sorting_result;
SortDistance2D( points, lower_v, points_cluster, higher_cluster, sorting_result );
// now apply 2D support vector machine
CVector3D v_key;
CVector3D v_dir;
// first check if sorting_result[0] is the only active set
bool pass = true;
v_key = * points[ sorting_result[ 0 ].index ];
for ( int i = 1; i < ( int )sorting_result.size(); i++ ) {
CVector3D & v = * points[ sorting_result[ i ].index ];
if ( ( lower_v - v_key ).XY() * ( v - v_key ).XY() > 0 ) {
pass = false;
break;
}
}
if ( pass ) {
CVector3D v_norm = lower_v - v_key;
v_dir = CVector3D( v_norm[ 1 ], - v_norm[ 0 ], 0.0 );
} else {
// check active set {i, j}
double best_dis = 0.0;
CVector3D v_key_temp;
CVector3D v_dir_temp;
for ( int i = 0; i < ( int )sorting_result.size(); i++ ) {
v_key_temp = * points[ sorting_result[ i ].index ];
for ( int j = i + 1; j < ( int )sorting_result.size(); j++ ) {
v_dir_temp = * points[ sorting_result[ j ].index ] - v_key_temp;
CVector3D v_norm_temp = CVector3D( v_dir_temp[ 1 ], - v_dir_temp[ 0 ], 0.0 );
pass = true;
for ( int k = 0; k < ( int )sorting_result.size(); k++ ) {
CVector3D & v = * points[ sorting_result[ k ].index ];
if ( k != i && k != j && ( ( lower_v - v_key_temp ) * v_norm_temp ) * ( ( v - v_key_temp ) * v_norm_temp ) > 0.0 ) {
pass = false;
break;
}
}
if ( pass && fabs( ( lower_v - v_key_temp ) * v_norm_temp ) > best_dis ) {
v_key = v_key_temp;
v_dir = v_dir_temp;
best_dis = fabs( ( lower_v - v_key_temp ) * v_norm_temp );
}
}
}
if ( best_dis == 0.0 ) {
v_key = * points[ sorting_result[ 0 ].index ];
v_dir = * points[ sorting_result[ 1 ].index ] - v_key;
}
}
ComputeHermiteData_Z_Key( hd, v, v_key, v_dir );
}
}
void CDCGrid::ComputeHermiteData_Z_Ill( HermiteData & hd, CVector3D v[ 2 ] )
{
hd.v = ( v[ 0 ] + v[ 1 ] ) * 0.5;
if ( v[ 0 ][ 2 ] > v[ 1 ][ 2 ] ) {
hd.n = v[ 1 ] - v[ 0 ];
} else {
hd.n = v[ 0 ] - v[ 1 ];
}
hd.n[ 2 ] = 0.0;
hd.n.normalize();
}
void CDCGrid::ComputeHermiteData_Z_Key( HermiteData & hd, CVector3D v[ 2 ], CVector3D & v_key, CVector3D & v_dir )
{
double temp = ( v_dir.XY() ^ ( v[ 0 ] - v[ 1 ] ).XY() )[ 2 ];
if ( abs( temp ) / ( v[ 0 ] - v[ 1 ] ).XY().length() < 1e-6 ) {
ComputeHermiteData_Z_Ill( hd, v );
} else {
double a = ( ( ( v[ 0 ] - v_key ).XY() ^ ( v[ 1 ] - v_key ).XY() )[ 2 ] ) / temp;
hd.v = v_key - a * v_dir;
if ( ( v[ 0 ] - hd.v ) * ( v[ 0 ] - v[ 1 ] ).XY() < 0.0 )
hd.v = v[ 0 ];
if ( ( v[ 1 ] - hd.v ) * ( v[ 1 ] - v[ 0 ] ).XY() < 0.0 )
hd.v = v[ 1 ];
hd.v[ 2 ] = ( v[ 0 ][ 2 ] + v[ 1 ][ 2 ] ) * 0.5;
hd.n = CVector3D( v_dir[ 1 ], - v_dir[ 0 ], 0.0 );
hd.n.normalize();
if ( hd.n * ( v[ 0 ] - v[ 1 ] ) * ( v[ 0 ][ 2 ] - v[ 1 ][ 2 ] ) > 0.0 )
hd.n *= -1.0;
}
}
| 32.444853 | 143 | 0.571558 | [
"vector"
] |
0cae7ed8b31d11a58e11b2a66391c37a5365b148 | 3,612 | cpp | C++ | tests/libace/Class.cpp | xguerin/ace | ad6e1bc4cb4f10d6cf5b782f623ec0eef13e000b | [
"MIT"
] | 5 | 2016-06-14T17:56:47.000Z | 2022-02-10T19:54:25.000Z | tests/libace/Class.cpp | xguerin/ace | ad6e1bc4cb4f10d6cf5b782f623ec0eef13e000b | [
"MIT"
] | 42 | 2016-06-21T20:48:22.000Z | 2021-03-23T15:20:51.000Z | tests/libace/Class.cpp | xguerin/ace | ad6e1bc4cb4f10d6cf5b782f623ec0eef13e000b | [
"MIT"
] | 1 | 2016-10-02T02:58:49.000Z | 2016-10-02T02:58:49.000Z | /**
* Copyright (c) 2016 Xavier R. Guerin
*
* 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 "Common.h"
#include <ace/engine/Master.h>
#include <ace/model/Model.h>
#include <ace/tree/Value.h>
#include <vector>
class Class : public ::testing::Test
{
public:
static void SetUpTestCase()
{
MASTER.reset();
ace::fs::Path incPath =
ace::fs::Directory().path() / ace::fs::Path("class/");
MASTER.addModelDirectory(incPath);
incPath = ace::fs::Directory().path() / ace::fs::Path("includes/");
MASTER.addModelDirectory(incPath);
}
protected:
static const char* prgnam;
};
const char* Class::prgnam = "tests";
TEST_F(Class, Fail_BadDefault)
{
WRITE_HEADER;
auto res = ace::model::Model::load("00_BadDefault.json");
ASSERT_EQ(res.get(), nullptr);
}
TEST_F(Class, Fail_InvalidModel)
{
WRITE_HEADER;
auto res = ace::model::Model::load("00_InvalidModel.json");
ASSERT_EQ(res.get(), nullptr);
}
TEST_F(Class, Fail_MissingModel)
{
WRITE_HEADER;
auto res = ace::model::Model::load("00_MissingModel.json");
ASSERT_EQ(res.get(), nullptr);
}
TEST_F(Class, Pass_Ok)
{
WRITE_HEADER;
auto res = ace::model::Model::load("01_Ok.json");
ASSERT_NE(res.get(), nullptr);
}
TEST_F(Class, Pass_Ok_All)
{
WRITE_HEADER;
auto res = ace::model::Model::load("01_Ok.json");
auto svr = res->validate("class/01_Ok.lua", 1, const_cast<char**>(&prgnam));
ASSERT_NE(svr.get(), nullptr);
}
TEST_F(Class, Pass_Defaulted_All)
{
WRITE_HEADER;
auto res = ace::model::Model::load("02_Ok.json");
auto svr = res->validate("class/02_Ok.lua", 1, const_cast<char**>(&prgnam));
ASSERT_NE(svr.get(), nullptr);
std::vector<ace::tree::Value::Ref> values;
auto path0 = ace::tree::Path::parse("$.var0.var0");
ASSERT_TRUE(svr->has(path0));
svr->get(path0, values);
ASSERT_EQ(values.size(), 1);
ASSERT_EQ(values[0]->type(), ace::tree::Value::Type::Float);
auto const& val0 = dynamic_cast<ace::tree::Primitive const&>(*values[0]);
ASSERT_EQ(val0.value<double>(), -1);
values.clear();
auto path1 = ace::tree::Path::parse("$.var1.var0");
ASSERT_TRUE(svr->has(path1));
svr->get(path1, values);
ASSERT_EQ(values.size(), 1);
ASSERT_EQ(values[0]->type(), ace::tree::Value::Type::Float);
auto const& val1 = dynamic_cast<ace::tree::Primitive const&>(*values[0]);
ASSERT_EQ(val1.value<double>(), -1);
}
TEST_F(Class, Fail_BadArity_All)
{
WRITE_HEADER;
auto res = ace::model::Model::load("03_BadArity.json");
auto svr = res->validate("class/03_Bad.json", 1, const_cast<char**>(&prgnam));
ASSERT_EQ(svr.get(), nullptr);
}
| 31.408696 | 80 | 0.697398 | [
"vector",
"model"
] |
0caedb1cc171b7edfb831216229f8eb71010459a | 9,528 | cc | C++ | src/bigint/div-burnikel.cc | EXHades/v8 | 5fe0aa3bc79c0a9d3ad546b79211f07105f09585 | [
"BSD-3-Clause"
] | 20,995 | 2015-01-01T05:12:40.000Z | 2022-03-31T21:39:18.000Z | src/bigint/div-burnikel.cc | Andrea-MariaDB-2/v8 | a0f0ebd7a876e8cb2210115adbfcffe900e99540 | [
"BSD-3-Clause"
] | 333 | 2020-07-15T17:06:05.000Z | 2021-03-15T12:13:09.000Z | src/bigint/div-burnikel.cc | Andrea-MariaDB-2/v8 | a0f0ebd7a876e8cb2210115adbfcffe900e99540 | [
"BSD-3-Clause"
] | 4,523 | 2015-01-01T15:12:34.000Z | 2022-03-28T06:23:41.000Z | // Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Burnikel-Ziegler division.
// Reference: "Fast Recursive Division" by Christoph Burnikel and Joachim
// Ziegler, found at http://cr.yp.to/bib/1998/burnikel.ps
#include <string.h>
#include "src/bigint/bigint-internal.h"
#include "src/bigint/digit-arithmetic.h"
#include "src/bigint/div-helpers.h"
#include "src/bigint/util.h"
#include "src/bigint/vector-arithmetic.h"
namespace v8 {
namespace bigint {
namespace {
// Compares [a_high, A] with B.
// Returns:
// - a value < 0 if [a_high, A] < B
// - 0 if [a_high, A] == B
// - a value > 0 if [a_high, A] > B.
int SpecialCompare(digit_t a_high, Digits A, Digits B) {
B.Normalize();
int a_len;
if (a_high == 0) {
A.Normalize();
a_len = A.len();
} else {
a_len = A.len() + 1;
}
int diff = a_len - B.len();
if (diff != 0) return diff;
int i = a_len - 1;
if (a_high != 0) {
if (a_high > B[i]) return 1;
if (a_high < B[i]) return -1;
i--;
}
while (i >= 0 && A[i] == B[i]) i--;
if (i < 0) return 0;
return A[i] > B[i] ? 1 : -1;
}
void SetOnes(RWDigits X) {
memset(X.digits(), 0xFF, X.len() * sizeof(digit_t));
}
// Since the Burnikel-Ziegler method is inherently recursive, we put
// non-changing data into a container object.
class BZ {
public:
BZ(ProcessorImpl* proc, int scratch_space)
: proc_(proc),
scratch_mem_(scratch_space >= kBurnikelThreshold ? scratch_space : 0) {}
void DivideBasecase(RWDigits Q, RWDigits R, Digits A, Digits B);
void D3n2n(RWDigits Q, RWDigits R, Digits A1A2, Digits A3, Digits B);
void D2n1n(RWDigits Q, RWDigits R, Digits A, Digits B);
private:
ProcessorImpl* proc_;
Storage scratch_mem_;
};
void BZ::DivideBasecase(RWDigits Q, RWDigits R, Digits A, Digits B) {
A.Normalize();
B.Normalize();
DCHECK(B.len() > 0); // NOLINT(readability/check)
int cmp = Compare(A, B);
if (cmp <= 0) {
Q.Clear();
if (cmp == 0) {
// If A == B, then Q=1, R=0.
R.Clear();
Q[0] = 1;
} else {
// If A < B, then Q=0, R=A.
PutAt(R, A, R.len());
}
return;
}
if (B.len() == 1) {
return proc_->DivideSingle(Q, R.digits(), A, B[0]);
}
return proc_->DivideSchoolbook(Q, R, A, B);
}
// Algorithm 2 from the paper. Variable names same as there.
// Returns Q(uotient) and R(emainder) for A/B, with B having two thirds
// the size of A = [A1, A2, A3].
void BZ::D3n2n(RWDigits Q, RWDigits R, Digits A1A2, Digits A3, Digits B) {
DCHECK((B.len() & 1) == 0); // NOLINT(readability/check)
int n = B.len() / 2;
DCHECK(A1A2.len() == 2 * n);
// Actual condition is stricter than length: A < B * 2^(kDigitBits * n)
DCHECK(Compare(A1A2, B) < 0); // NOLINT(readability/check)
DCHECK(A3.len() == n);
DCHECK(Q.len() == n);
DCHECK(R.len() == 2 * n);
// 1. Split A into three parts A = [A1, A2, A3] with Ai < 2^(kDigitBits * n).
Digits A1(A1A2, n, n);
// 2. Split B into two parts B = [B1, B2] with Bi < 2^(kDigitBits * n).
Digits B1(B, n, n);
Digits B2(B, 0, n);
// 3. Distinguish the cases A1 < B1 or A1 >= B1.
RWDigits Qhat = Q;
RWDigits R1(R, n, n);
digit_t r1_high = 0;
if (Compare(A1, B1) < 0) {
// 3a. If A1 < B1, compute Qhat = floor([A1, A2] / B1) with remainder R1
// using algorithm D2n1n.
D2n1n(Qhat, R1, A1A2, B1);
if (proc_->should_terminate()) return;
} else {
// 3b. If A1 >= B1, set Qhat = 2^(kDigitBits * n) - 1 and set
// R1 = [A1, A2] - [B1, 0] + [0, B1]
SetOnes(Qhat);
// Step 1: compute A1 - B1, which can't underflow because of the comparison
// guarding this else-branch, and always has a one-digit result because
// of this function's preconditions.
RWDigits temp = R1;
Subtract(temp, A1, B1);
temp.Normalize();
DCHECK(temp.len() <= 1); // NOLINT(readability/check)
if (temp.len() > 0) r1_high = temp[0];
// Step 2: compute A2 + B1.
Digits A2(A1A2, 0, n);
r1_high += AddAndReturnCarry(R1, A2, B1);
}
// 4. Compute D = Qhat * B2 using (Karatsuba) multiplication.
RWDigits D(scratch_mem_.get(), 2 * n);
proc_->Multiply(D, Qhat, B2);
if (proc_->should_terminate()) return;
// 5. Compute Rhat = R1*2^(kDigitBits * n) + A3 - D = [R1, A3] - D.
PutAt(R, A3, n);
// 6. As long as Rhat < 0, repeat:
while (SpecialCompare(r1_high, R, D) < 0) {
// 6a. Rhat = Rhat + B
r1_high += AddAndReturnCarry(R, R, B);
// 6b. Qhat = Qhat - 1
Subtract(Qhat, 1);
}
// 5. Compute Rhat = R1*2^(kDigitBits * n) + A3 - D = [R1, A3] - D.
digit_t borrow = SubtractAndReturnBorrow(R, R, D);
DCHECK(borrow == r1_high);
DCHECK(Compare(R, B) < 0); // NOLINT(readability/check)
(void)borrow;
// 7. Return R = Rhat, Q = Qhat.
}
// Algorithm 1 from the paper. Variable names same as there.
// Returns Q(uotient) and (R)emainder for A/B, with A twice the size of B.
void BZ::D2n1n(RWDigits Q, RWDigits R, Digits A, Digits B) {
int n = B.len();
DCHECK(A.len() <= 2 * n);
// A < B * 2^(kDigitsBits * n)
DCHECK(Compare(Digits(A, n, n), B) < 0); // NOLINT(readability/check)
DCHECK(Q.len() == n);
DCHECK(R.len() == n);
// 1. If n is odd or smaller than some convenient constant, compute Q and R
// by school division and return.
if ((n & 1) == 1 || n < kBurnikelThreshold) {
return DivideBasecase(Q, R, A, B);
}
// 2. Split A into four parts A = [A1, ..., A4] with
// Ai < 2^(kDigitBits * n / 2). Split B into two parts [B2, B1] with
// Bi < 2^(kDigitBits * n / 2).
Digits A1A2(A, n, n);
Digits A3(A, n / 2, n / 2);
Digits A4(A, 0, n / 2);
// 3. Compute the high part Q1 of floor(A/B) as
// Q1 = floor([A1, A2, A3] / [B1, B2]) with remainder R1 = [R11, R12],
// using algorithm D3n2n.
RWDigits Q1(Q, n / 2, n / 2);
ScratchDigits R1(n);
D3n2n(Q1, R1, A1A2, A3, B);
if (proc_->should_terminate()) return;
// 4. Compute the low part Q2 of floor(A/B) as
// Q2 = floor([R11, R12, A4] / [B1, B2]) with remainder R, using
// algorithm D3n2n.
RWDigits Q2(Q, 0, n / 2);
D3n2n(Q2, R, R1, A4, B);
// 5. Return Q = [Q1, Q2] and R.
}
} // namespace
// Algorithm 3 from the paper. Variables names same as there.
// Returns Q(uotient) and R(emainder) for A/B (no size restrictions).
// R is optional, Q is not.
void ProcessorImpl::DivideBurnikelZiegler(RWDigits Q, RWDigits R, Digits A,
Digits B) {
DCHECK(A.len() >= B.len());
DCHECK(R.len() == 0 || R.len() >= B.len());
DCHECK(Q.len() > A.len() - B.len());
int r = A.len();
int s = B.len();
// The requirements are:
// - n >= s, n as small as possible.
// - m must be a power of two.
// 1. Set m = min {2^k | 2^k * kBurnikelThreshold > s}.
int m = 1 << BitLength(s / kBurnikelThreshold);
// 2. Set j = roundup(s/m) and n = j * m.
int j = DIV_CEIL(s, m);
int n = j * m;
// 3. Set sigma = max{tao | 2^tao * B < 2^(kDigitBits * n)}.
int sigma = CountLeadingZeros(B[s - 1]);
int digit_shift = n - s;
// 4. Set B = B * 2^sigma to normalize B. Shift A by the same amount.
ScratchDigits B_shifted(n);
LeftShift(B_shifted + digit_shift, B, sigma);
for (int i = 0; i < digit_shift; i++) B_shifted[i] = 0;
B = B_shifted;
// We need an extra digit if A's top digit does not have enough space for
// the left-shift by {sigma}. Additionally, the top bit of A must be 0
// (see "-1" in step 5 below), which combined with B being normalized (i.e.
// B's top bit is 1) ensures the preconditions of the helper functions.
int extra_digit = CountLeadingZeros(A[r - 1]) < (sigma + 1) ? 1 : 0;
r = A.len() + digit_shift + extra_digit;
ScratchDigits A_shifted(r);
LeftShift(A_shifted + digit_shift, A, sigma);
for (int i = 0; i < digit_shift; i++) A_shifted[i] = 0;
A = A_shifted;
// 5. Set t = min{t >= 2 | A < 2^(kDigitBits * t * n - 1)}.
int t = std::max(DIV_CEIL(r, n), 2);
// 6. Split A conceptually into t blocks.
// 7. Set Z_(t-2) = [A_(t-1), A_(t-2)].
int z_len = n * 2;
ScratchDigits Z(z_len);
PutAt(Z, A + n * (t - 2), z_len);
// 8. For i from t-2 downto 0 do:
BZ bz(this, n);
ScratchDigits Ri(n);
{
// First iteration unrolled and specialized.
// We might not have n digits at the top of Q, so use temporary storage
// for Qi...
ScratchDigits Qi(n);
bz.D2n1n(Qi, Ri, Z, B);
if (should_terminate()) return;
// ...but there *will* be enough space for any non-zero result digits!
Qi.Normalize();
RWDigits target = Q + n * (t - 2);
DCHECK(Qi.len() <= target.len());
PutAt(target, Qi, target.len());
}
// Now loop over any remaining iterations.
for (int i = t - 3; i >= 0; i--) {
// 8b. If i > 0, set Z_(i-1) = [Ri, A_(i-1)].
// (De-duped with unrolled first iteration, hence reading A_(i).)
PutAt(Z + n, Ri, n);
PutAt(Z, A + n * i, n);
// 8a. Using algorithm D2n1n compute Qi, Ri such that Zi = B*Qi + Ri.
RWDigits Qi(Q, i * n, n);
bz.D2n1n(Qi, Ri, Z, B);
if (should_terminate()) return;
}
// 9. Return Q = [Q_(t-2), ..., Q_0] and R = R_0 * 2^(-sigma).
#if DEBUG
for (int i = 0; i < digit_shift; i++) {
DCHECK(Ri[i] == 0); // NOLINT(readability/check)
}
#endif
if (R.len() != 0) {
Digits Ri_part(Ri, digit_shift, Ri.len());
Ri_part.Normalize();
DCHECK(Ri_part.len() <= R.len());
RightShift(R, Ri_part, sigma);
}
}
} // namespace bigint
} // namespace v8
| 34.028571 | 80 | 0.589001 | [
"object",
"vector"
] |
0cb4a52b3d1c2b4bfbf822f7b58ab03babff57ed | 4,355 | hpp | C++ | src/cppmat/fix_regular_vector.hpp | tdegeus/cppmatrix | a6738a2c8be4c6e83b499b54bd874a3d3ee05000 | [
"MIT"
] | 6 | 2017-05-05T15:44:36.000Z | 2019-01-19T09:58:47.000Z | src/cppmat/fix_regular_vector.hpp | tdegeus/cppmatrix | a6738a2c8be4c6e83b499b54bd874a3d3ee05000 | [
"MIT"
] | 32 | 2017-08-31T08:04:09.000Z | 2019-10-21T15:42:01.000Z | src/cppmat/fix_regular_vector.hpp | tdegeus/cppmatrix | a6738a2c8be4c6e83b499b54bd874a3d3ee05000 | [
"MIT"
] | 2 | 2018-08-03T09:08:32.000Z | 2022-01-25T07:38:25.000Z | /* =================================================================================================
(c - MIT) T.W.J. de Geus (Tom) | tom@geus.me | www.geus.me | github.com/tdegeus/cppmat
================================================================================================= */
#ifndef CPPMAT_FIX_REGULAR_VECTOR_HPP
#define CPPMAT_FIX_REGULAR_VECTOR_HPP
// -------------------------------------------------------------------------------------------------
#include "cppmat.h"
// -------------------------------------------------------------------------------------------------
namespace cppmat {
namespace tiny {
// =================================================================================================
// constructors
// =================================================================================================
template<typename X, size_t N>
inline
vector<X,N>::vector() : cppmat::tiny::array<X,1,N>()
{
}
// =================================================================================================
// constructors: copy from parent (with different type)
// =================================================================================================
template<typename X, size_t N>
template<typename U, typename V>
inline
vector<X,N>::vector(const cppmat::tiny::array<U,1,N> &A) : cppmat::tiny::array<X,1,N>(A)
{
}
// =================================================================================================
// constructors: copy from other class
// =================================================================================================
template<typename X, size_t N>
template<typename U, typename V>
inline
vector<X,N>::vector(const std::vector<U> &A) : cppmat::tiny::array<X,1,N>::Copy(A)
{
}
// =================================================================================================
// constructor: copy from {...}
// =================================================================================================
template<typename X, size_t N>
inline
vector<X,N>::vector(const std::initializer_list<X> &A) : cppmat::tiny::array<X,1,N>(A)
{
}
// =================================================================================================
// constructors: copy from dynamic size
// =================================================================================================
template<typename X, size_t N>
inline
vector<X,N>::vector(const cppmat::vector<X> &A) : cppmat::tiny::array<X,1,N>(A)
{
}
// =================================================================================================
// constructors: copy from view
// =================================================================================================
template<typename X, size_t N>
inline
vector<X,N>::vector(const cppmat::view::vector<X,N> &A) : cppmat::tiny::array<X,1,N>(A)
{
}
// =================================================================================================
// finite difference
// =================================================================================================
template<typename X, size_t N>
inline
vector<X,N> vector<X,N>::diff() const
{
vector<X,N> out;
std::adjacent_difference(this->begin(), this->end(), out.begin());
return out;
}
// =================================================================================================
// STL-like behaviour
// =================================================================================================
template<typename X, size_t N>
inline
void vector<X,N>::reserve(size_t n)
{
Assert( n == N );
}
// -------------------------------------------------------------------------------------------------
template<typename X, size_t N>
inline
void vector<X,N>::push_back(const X &value)
{
Assert( mIstore < N );
this->mData[mIstore] = value;
mIstore++;
}
// -------------------------------------------------------------------------------------------------
template<typename X, size_t N>
inline
void vector<X,N>::clear()
{
mIstore = 0;
for ( size_t i = 0 ; i < N ; ++i ) this->mData[i] = static_cast<X>(0);
}
// =================================================================================================
}} // namespace ...
// -------------------------------------------------------------------------------------------------
#endif
| 31.330935 | 100 | 0.297589 | [
"vector"
] |
0cb7d488c7ee730720a20d413591eda0b6b55031 | 1,386 | cc | C++ | solutions/hackerrank/projecteuler/euler011.cc | zwliew/ctci | 871f4fc957be96c6d0749d205549b7b35dc53d9e | [
"MIT"
] | 4 | 2020-11-07T14:38:02.000Z | 2022-01-03T19:02:36.000Z | solutions/hackerrank/projecteuler/euler011.cc | zwliew/ctci | 871f4fc957be96c6d0749d205549b7b35dc53d9e | [
"MIT"
] | 1 | 2019-04-17T06:55:14.000Z | 2019-04-17T06:55:14.000Z | solutions/hackerrank/projecteuler/euler011.cc | zwliew/ctci | 871f4fc957be96c6d0749d205549b7b35dc53d9e | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<vector<int>> grid(20, vector<int>(20));
for (int i = 0; i < 20; ++i) {
for (int j = 0; j < 20; ++j) {
cin >> grid[i][j];
}
}
int best = 0;
for (int i = 0; i < 20; ++i) {
int endi = i + 4;
for (int j = 0; j < 20; ++j) {
int endj = j + 4;
int startj = j - 3;
int prod = 1;
if (endj <= 20) {
prod = 1;
for (int k = j; k < endj; ++k) {
prod *= grid[i][k];
}
best = max(best, prod);
}
if (endi <= 20) {
prod = 1;
for (int k = i; k < endi; ++k) {
prod *= grid[k][j];
}
best = max(best, prod);
}
if (endi <= 20 && endj <= 20) {
prod = 1;
for (int k = 0; k < 4; ++k) {
prod *= grid[i + k][j + k];
}
best = max(best, prod);
}
if (endi <= 20 && startj >= 0) {
prod = 1;
for (int k = 0; k < 4; ++k) {
prod *= grid[i + k][j - k];
}
best = max(best, prod);
}
}
}
cout << best;
}
| 25.2 | 50 | 0.289322 | [
"vector"
] |
0cbb462da7f8c854f5902807010aa3e246e2ed4b | 705 | cpp | C++ | src/model/GatewayStatus.cpp | tacr-iotcloud/server | c46fd292843acf25b3f03d927e6ed32bd9d05732 | [
"BSD-3-Clause"
] | 1 | 2020-09-30T06:41:47.000Z | 2020-09-30T06:41:47.000Z | src/model/GatewayStatus.cpp | tacr-iotcloud/server | c46fd292843acf25b3f03d927e6ed32bd9d05732 | [
"BSD-3-Clause"
] | null | null | null | src/model/GatewayStatus.cpp | tacr-iotcloud/server | c46fd292843acf25b3f03d927e6ed32bd9d05732 | [
"BSD-3-Clause"
] | null | null | null | #include "model/GatewayStatus.h"
using namespace std;
using namespace Poco;
using namespace Poco::Net;
using namespace BeeeOn;
void GatewayStatus::setLastChanged(const Nullable<DateTime> &at)
{
m_lastChanged = at;
}
Nullable<DateTime> GatewayStatus::lastChanged() const
{
return m_lastChanged;
}
void GatewayStatus::setVersion(const string &version)
{
m_version = version;
}
string GatewayStatus::version() const
{
return m_version;
}
void GatewayStatus::setIPAddress(const string &ipAddress)
{
setIPAddress(IPAddress(ipAddress));
}
void GatewayStatus::setIPAddress(const IPAddress &ipAddress)
{
m_ipAddress = ipAddress;
}
IPAddress GatewayStatus::ipAddress() const
{
return m_ipAddress;
}
| 16.785714 | 64 | 0.774468 | [
"model"
] |
0cbf3387dc9083fb5029ca626ea91a24c96ca258 | 6,145 | cpp | C++ | Server/relatko-ba-graph-52fc092b557e/test/impl/02creating_deleting_graph.cpp | RadoslavSmarzik/graph-editor | 7441f4768269131e5e9636819f1bf27ae9d6013d | [
"MIT"
] | null | null | null | Server/relatko-ba-graph-52fc092b557e/test/impl/02creating_deleting_graph.cpp | RadoslavSmarzik/graph-editor | 7441f4768269131e5e9636819f1bf27ae9d6013d | [
"MIT"
] | null | null | null | Server/relatko-ba-graph-52fc092b557e/test/impl/02creating_deleting_graph.cpp | RadoslavSmarzik/graph-editor | 7441f4768269131e5e9636819f1bf27ae9d6013d | [
"MIT"
] | null | null | null | #include "gtest/gtest.h"
#include "implementation.h"
using namespace ba_graph;
class CreatingDeletingGraphFixture : public ::testing::Test {
protected:
Vertex v1, v2;
Edge e1, e2;
void TearDown() override {
}
void SetUp() override {
v1 = createV();
v2 = createV();
e1 = createE(v1, v2);
e2 = createE(v1, v1);
}
};
TEST_F(CreatingDeletingGraphFixture, 00_you_cannot_mess_up_factories) {
Factory f1;
Factory f2;
Graph G1(createG());
Graph G2(createG(f1));
ASSERT_DEATH(addV(G2), ".*");
ASSERT_DEATH(addV(G1,f1), ".*");
ASSERT_DEATH(addV(G2,f2), ".*");
ASSERT_FALSE(check(G1, f1));
ASSERT_TRUE(check(G1));
ASSERT_TRUE(check(G2, f1));
ASSERT_FALSE(check(G2, f2));
ASSERT_FALSE(check(G2));
}
TEST_F(CreatingDeletingGraphFixture, 01_order_size_degree) {
//We can add vertices and edges into G,
//if we add a vertex without supplementing one, factory creates a new one for us
Graph G(createG());
addV(G, v1);
addV(G, v2);
addV(G);
addE(G, v1, v2);
//Graph G now.contains three vertices and one edge
ASSERT_EQ(G.order(),3);
ASSERT_EQ(G.size(),1);
//v1 is of degree 1, v2 is of degree 2
//note that degree.contains nothing to do with a Vertex, it is property of Rotation
ASSERT_EQ(G.find(RP::RP(v1))->degree(),1);
ASSERT_EQ(G.find(RP::RP(v2))->degree(),1);
}
TEST_F(CreatingDeletingGraphFixture, 0x_add_loop) {
Graph G(createG());
addV(G, Num(1));
auto [it1, it2]=addE(G, G[1], G[1], G[1].end(), G[1].end());
assert(it1+1==it2);
assert(it1->h1()==it2->h2());
}
TEST_F(CreatingDeletingGraphFixture, 02_other_features) {
Graph G2(createG());
//The suggested way to organize vertices is using Numbers -> intetegers representing the vertex within the graph
addV(G2, v1, 1);
addV(G2, v2, 2);
Vertex v3=addV(G2, 3).v();
Number number=addV(G2).n();
//number of the new vertex is unique
ASSERT_TRUE(number!=1 && number!=2 && number!=3);
addE(G2, Location(1, 2));
addE(G2, Location(2, 3));
addE(G2, Location(1, 2));
addE(G2, e1); //this is also an edge between 1 (v1) and 2 (v2)
addE(G2, Location(3, number));
//Graph G2 now.contains and edges
ASSERT_TRUE(G2.order()==4);
ASSERT_TRUE(G2.size()==5);
//Numbers are the faster way to find get to the Rotation object (e.g. to get vertex degree)
ASSERT_TRUE(G2[1].degree()==3);
ASSERT_TRUE(G2[2].degree()==4);
ASSERT_TRUE(G2[3].degree()==2);
ASSERT_TRUE(G2[number].degree()==1);
auto res21=addE(G2,G2[1],G2[2],G2[1].begin()+3,G2[2].begin());
auto res22=addE(G2,G2[2],G2[2],G2[2].begin()+3,G2[2].begin()+1);
ASSERT_TRUE(G2[1].degree()==4);
ASSERT_TRUE(G2[2].degree()==7);
ASSERT_TRUE(res21.first==G2[1].begin()+3);
ASSERT_TRUE(res21.second==G2[2].begin());
ASSERT_TRUE(res22.first==G2[2].begin()+4);
ASSERT_TRUE(res22.second==G2[2].begin()+1);
ASSERT_TRUE((G2[2].begin()+4)->n2()==2);
ASSERT_TRUE((G2[2].begin()+1)->n2()==2);
deleteE(G2,Location(1,2,3));
deleteE(G2,Location(2,2));
//We can create a seccond graph
Graph H(createG());
addMultipleV(H, {v1, v2, v3}, 1);
addE(H, Location(1, 2));
addE(H, Loc(2, 3));
addE(H, e1);
addE(H, Loc(3, 3));
//now even when the vertices 1 of G and H are equal
ASSERT_TRUE(G2[1].v()==H[1].v());
//if we delete a vertex from F it does not affect H
deleteV(G2,1);
ASSERT_TRUE(G2.order()==3);
ASSERT_TRUE(G2.size()==2);
ASSERT_TRUE(G2[2].degree()==1);
ASSERT_TRUE(G2[3].degree()==2);
ASSERT_TRUE(G2[number].degree()==1);
ASSERT_TRUE(H.order()==3);
ASSERT_TRUE(H.size()==4);
//we can create many vertices at once
{
Graph H2(createG());
int res=addMultipleV(H2, 5).to_int();
addE(H2, Location(res, res+4));
ASSERT_TRUE(H2[res].degree()==1);
}
{
Graph H2(createG());
addMultipleV(H2, 5, 2);
addE(H2, Location(2, 6));
ASSERT_TRUE(H2[6].degree()==1);
int res=addMultipleV(H2, 5).to_int();
ASSERT_TRUE(res>6);
addE(H2, Location(res, res+4));
ASSERT_TRUE(H2[res].degree()==1);
}
{
Graph H2(createG());
Vertex v1=createV();
Vertex v2=createV();
addMultipleV(H2, {v1,v2}, {1, 2});
addMultipleV(H2, {3,4,5});
addMultipleV(H2, {createV(), createV()});
addMultipleE(H2, Locs({{3,3},{5,2}})); //Locations
addMultipleE(H2, {{v1,v2}, {v1,v1}}); //pairs of vertices
addMultipleE(H2, {createE(v1,v2),createE(v2,v2)}); //Locations
ASSERT_TRUE(H2.order()==7);
ASSERT_TRUE(H2.size()==6);
for(auto it=H2.begin();it!=H2.end();) {
if (it->isolated())
it=deleteV(H2,it);
else
it++;
}
ASSERT_TRUE(H2.order()==4);
ASSERT_TRUE(H2.size()==6);
addMultipleE(H2, Locs({{3,3},{3,1}, {5,3}})); //Directions
ASSERT_TRUE(H2.order()==4);
ASSERT_TRUE(H2.size()==9);
for(auto it=H2[3].begin();it!=H2[3].end();) {
if (it->is_loop())
it=deleteE(H2,it);
else
it++;
}
ASSERT_TRUE(H2.order()==4);
ASSERT_TRUE(H2.size()==7);
}
// To create and modify Vertices, Edges and Graphs a Factory is used. If you use ordinary
// function cV(), cE() then Factory static_factory is used. If we want to use more than
// one Factory we can make and use our own.
Factory myFactory;
Vertex w1=createV(myFactory);
Vertex w2=createV(myFactory);
Edge f1=createE(w1, w2, myFactory);
Edge f2=createE(w1, w1, myFactory);
{
Graph G(createG(myFactory));
addV(G, w1, myFactory);
addV(G, w2, myFactory);
addE(G, f1, myFactory);
addE(G, f2, myFactory);
deleteV(G,w1, myFactory);
ASSERT_TRUE(G.order()==1);
ASSERT_TRUE(G.size()==0);
addE(G, *(G.find(w2)),*(G.find(w2)), myFactory);
ASSERT_TRUE(G.size()==1);
}
}
| 29.68599 | 116 | 0.574776 | [
"object"
] |
0cd0b4f66215858d9198fa4df6ae4b7a2186eb2b | 28,632 | cpp | C++ | Sources/MouCaGraphicEngine/source/Engine3DXMLLoaderCommand.cpp | Rominitch/MouCaLab | d8c24de479b1bc11509df8456e0071d394fbeab9 | [
"Unlicense"
] | null | null | null | Sources/MouCaGraphicEngine/source/Engine3DXMLLoaderCommand.cpp | Rominitch/MouCaLab | d8c24de479b1bc11509df8456e0071d394fbeab9 | [
"Unlicense"
] | null | null | null | Sources/MouCaGraphicEngine/source/Engine3DXMLLoaderCommand.cpp | Rominitch/MouCaLab | d8c24de479b1bc11509df8456e0071d394fbeab9 | [
"Unlicense"
] | null | null | null | #include "Dependencies.h"
#include "MouCaGraphicEngine/include/Engine3DXMLLoader.h"
#include "MouCaGraphicEngine/include/Engine3DXMLHelper.h"
#include <LibVulkan/include/VKContextDevice.h>
#include <LibVulkan/include/VKCommand.h>
#include <LibVulkan/include/VKCommandBufferSurface.h>
#include <LibVulkan/include/VKDescriptorSet.h>
#include <LibVulkan/include/VKFrameBuffer.h>
#include <LibVulkan/include/VKGraphicsPipeline.h>
#include <LibVulkan/include/VKRayTracingPipeline.h>
#include <LibVulkan/include/VKSwapChain.h>
#include "MouCaGraphicEngine/include/VulkanEnum.h"
namespace MouCaGraphic
{
void Engine3DXMLLoader::loadCommandPools(ContextLoading& context, Vulkan::ContextDeviceWPtr deviceWeak)
{
MOUCA_PRE_CONDITION(!deviceWeak.expired()); //DEV Issue: Bad device !
// Search CommandBuffer
auto result = context._parser.getNode(u8"CommandPools");
if (result->getNbElements() > 0)
{
MOUCA_ASSERT(result->getNbElements() == 1); //DEV Issue: please clean xml ?
auto device = deviceWeak.lock();
auto aPush = context._parser.autoPushNode(*result->getNode(0));
// Parsing all images
auto allCommandPools = context._parser.getNode(u8"CommandPool");
for (size_t idPool = 0; idPool < allCommandPools->getNbElements(); ++idPool)
{
auto poolNode = allCommandPools->getNode(idPool);
// Mandatory attribute
bool existing;
const uint32_t id = LoaderHelper::getIdentifiant(poolNode, u8"CommandPool", _commandPools, context, existing);
if (existing)
{
continue;
}
int idQueue = 0;
if (poolNode->hasAttribute(u8"families"))
{
Core::String families;
poolNode->getAttribute(u8"families", families);
if (families == u8"graphic")
{
idQueue = device->getDevice().getQueueFamilyGraphicId();
}
else if (families == u8"compute")
{
idQueue = device->getDevice().getQueueFamilyComputeId();
}
else if (families == u8"transfer")
{
idQueue = device->getDevice().getQueueFamilyTransferId();
}
else
{
MOUCA_THROW_ERROR_2(u8"Engine3D", u8"UnknownFamiliesError", context.getFileName(), families);
}
}
else if (poolNode->hasAttribute(u8"queueId"))
{
poolNode->getAttribute(u8"queueId", idQueue);
}
VkCommandPoolCreateFlags flags = 0;
if (poolNode->hasAttribute(u8"flags"))
{
flags = LoaderHelper::readValue(poolNode, u8"flags", poolCreateFlags, true, context);
}
// Build
auto pool = std::make_shared<Vulkan::CommandPool>();
pool->initialize(device->getDevice(), idQueue, flags);
// Register
device->insertCommandPool(pool);
_commandPools[id] = pool;
}
}
}
void Engine3DXMLLoader::loadCommandsGroup(ContextLoading& context, Vulkan::ContextDeviceWPtr deviceWeak)
{
MOUCA_PRE_CONDITION(!deviceWeak.expired()); //DEV Issue: Bad device !
// Search CommandBuffer
auto result = context._parser.getNode(u8"CommandsGroups");
if (result->getNbElements() > 0)
{
MOUCA_ASSERT(result->getNbElements() == 1); //DEV Issue: please clean xml ?
auto device = deviceWeak.lock();
auto aPush = context._parser.autoPushNode(*result->getNode(0));
// Parsing all images
auto allCommandsGroup = context._parser.getNode(u8"CommandsGroup");
for (size_t idGroup = 0; idGroup < allCommandsGroup->getNbElements(); ++idGroup)
{
auto groupNode = allCommandsGroup->getNode(idGroup);
bool existing;
const uint32_t id = LoaderHelper::getIdentifiant(groupNode, u8"CommandsGroup", _commandsGroup, context, existing);
if (existing)
{
continue;
}
// Load commands
auto allCommands = std::make_unique<Vulkan::Commands>();
{
// Enter to node each time to parse properly
auto aPushC = context._parser.autoPushNode(*groupNode);
// Build command for specific framebuffer
loadCommands(context, deviceWeak, VkExtent2D(), *allCommands);
}
// Register
_commandsGroup[id] = std::move(allCommands);
}
}
}
void Engine3DXMLLoader::loadCommandBuffers(ContextLoading& context, Vulkan::ContextDeviceWPtr deviceWeak)
{
MOUCA_PRE_CONDITION(!deviceWeak.expired()); //DEV Issue: Bad device !
// Search CommandBuffer
auto result = context._parser.getNode(u8"CommandBuffers");
if (result->getNbElements() > 0)
{
MOUCA_ASSERT(result->getNbElements() == 1); //DEV Issue: please clean xml ?
auto device = deviceWeak.lock();
auto aPush = context._parser.autoPushNode(*result->getNode(0));
// Parsing all images
auto allCommandBuffers = context._parser.getNode(u8"CommandBuffer");
for (size_t idCommandBuffer = 0; idCommandBuffer < allCommandBuffers->getNbElements(); ++idCommandBuffer)
{
auto commandBufferNode = allCommandBuffers->getNode(idCommandBuffer);
const uint32_t poolId = LoaderHelper::getLinkedIdentifiant(commandBufferNode, u8"commandPoolId", _commandPools, context);
const VkCommandBufferLevel level = LoaderHelper::readValue(commandBufferNode, u8"level", commandBufferLevels, false, context);
VkCommandBufferUsageFlags usage = 0;
if (commandBufferNode->hasAttribute(u8"usage"))
{
usage = LoaderHelper::readValue(commandBufferNode, u8"usage", commandBufferUsages, true, context);
}
// Special command buffer for surface
if (commandBufferNode->hasAttribute("surfaceId"))
{
const uint32_t surfaceId = LoaderHelper::getLinkedIdentifiant(commandBufferNode, u8"surfaceId", _surfaces, context);
auto surface = _surfaces[surfaceId].lock();
MOUCA_ASSERT(surface->getSwapChain().getImages().size() == surface->getFrameBuffer().size());
// Load commands
Vulkan::Commands allCommands;
{
// Enter to node each time to parse properly
auto aPushC = context._parser.autoPushNode(*commandBufferNode);
// Build command for specific framebuffer
loadCommands(context, deviceWeak, surface->getFormat().getConfiguration()._extent, allCommands);
}
// Create command buffer for surface
surface->createCommandBuffer(std::move(allCommands), _commandPools[poolId].lock(), level, usage);
}
else
{
bool existing;
const uint32_t id = LoaderHelper::getIdentifiant(commandBufferNode, u8"CommandBuffer", _commandBuffers, context, existing);
if (existing)
{
continue;
}
// Enter to node each time to parse properly
auto aPushC = context._parser.autoPushNode(*commandBufferNode);
// Build command
Vulkan::Commands allCommands;
loadCommands(context, deviceWeak, VkExtent2D(), allCommands);
// Build new CommandBuffer
auto commandBuffer = std::make_shared<Vulkan::CommandBuffer>();
commandBuffer->initialize(device->getDevice(), _commandPools[poolId].lock(), level, usage);
commandBuffer->registerCommands(std::move(allCommands));
deviceWeak.lock()->insertCommandBuffer(commandBuffer);
_commandBuffers[id] = commandBuffer;
}
}
}
}
void Engine3DXMLLoader::loadCommands(ContextLoading& context, Vulkan::ContextDeviceWPtr deviceWeak, const VkExtent2D& resolution, std::vector<Vulkan::CommandUPtr>& commands, const Core::String& nodeName)
{
// Parsing all commands
auto allCommands = context._parser.getNode(nodeName);
for (size_t idCommand = 0; idCommand < allCommands->getNbElements(); ++idCommand)
{
auto commandNode = allCommands->getNode(idCommand);
Core::String type;
commandNode->getAttribute(u8"type", type);
// Build command
Vulkan::CommandUPtr command;
if(type == u8"viewport")
{
// Build default viewport
VkViewport viewport
{
0.0f, 0.0f,
static_cast<float>(resolution.width), static_cast<float>(resolution.height),
0.0f, 1.0f
};
if(commandNode->hasAttribute(u8"x")) { commandNode->getAttribute(u8"x", viewport.x); }
if(commandNode->hasAttribute(u8"y")) { commandNode->getAttribute(u8"y", viewport.y); }
if(commandNode->hasAttribute(u8"width")) { LoaderHelper::readAttribute(commandNode, u8"width", viewport.width, context); }
if(commandNode->hasAttribute(u8"height")) { LoaderHelper::readAttribute(commandNode, u8"height", viewport.height, context); }
if(commandNode->hasAttribute(u8"minDepth")) { commandNode->getAttribute(u8"minDepth", viewport.minDepth); }
if(commandNode->hasAttribute(u8"maxDepth")) { commandNode->getAttribute(u8"maxDepth", viewport.maxDepth); }
MOUCA_ASSERT(viewport.width != 0 && viewport.height != 0);
// Build command
command = std::make_unique<Vulkan::CommandViewport>(viewport);
}
else if(type == u8"scissor")
{
// Build default rect
VkRect2D rect{ {0, 0}, resolution };
if(commandNode->hasAttribute(u8"x")) { commandNode->getAttribute(u8"x", rect.offset.x); }
if(commandNode->hasAttribute(u8"y")) { commandNode->getAttribute(u8"y", rect.offset.y); }
if(commandNode->hasAttribute(u8"width")) { LoaderHelper::readAttribute(commandNode, u8"width", rect.extent.width, context); }
if(commandNode->hasAttribute(u8"height")) { LoaderHelper::readAttribute(commandNode, u8"height", rect.extent.height, context); }
MOUCA_ASSERT(rect.extent.width > 0 && rect.extent.height > 0);
// Build command
command = std::make_unique<Vulkan::CommandScissor>(rect);
}
else if(type == u8"beginRenderPass")
{
const uint32_t renderPassId = LoaderHelper::getLinkedIdentifiant(commandNode, u8"renderPassId", _renderPasses, context);
// Get specified frameBuffer or use transmit (only for swapchain)
VkRect2D renderArea{ {0,0}, resolution };
std::vector<Vulkan::FrameBufferWPtr> frameBuffers;
if (commandNode->hasAttribute(u8"frameBufferId"))
{
const uint32_t idF = LoaderHelper::getLinkedIdentifiant(commandNode, u8"frameBufferId", _frameBuffers, context);
frameBuffers.emplace_back(_frameBuffers[idF]);
// Use by default framebuffer extent
renderArea.extent = _frameBuffers[idF].lock()->getResolution();
}
else if (commandNode->hasAttribute(u8"surfaceId"))
{
const uint32_t idS = LoaderHelper::getLinkedIdentifiant(commandNode, u8"surfaceId", _surfaces, context);
const auto& fbs = _surfaces[idS].lock()->getFrameBuffer();
frameBuffers.resize(fbs.size());
std::copy(fbs.cbegin(), fbs.cend(), frameBuffers.begin());
}
MOUCA_ASSERT(renderArea.extent.width > 0 && renderArea.extent.height > 0);
if(commandNode->hasAttribute(u8"x")) { commandNode->getAttribute(u8"x", renderArea.offset.x); }
if(commandNode->hasAttribute(u8"y")) { commandNode->getAttribute(u8"y", renderArea.offset.y); }
if(commandNode->hasAttribute(u8"width")) { commandNode->getAttribute(u8"width", renderArea.extent.width); }
if(commandNode->hasAttribute(u8"height")) { commandNode->getAttribute(u8"height", renderArea.extent.height); }
const auto subpassContent = LoaderHelper::readValue(commandNode, u8"subpassContent", subpassContents, false, context);
// Read clear
auto aPushC = context._parser.autoPushNode(*commandNode);
auto allCleanValue = context._parser.getNode(u8"CleanValue");
std::vector<VkClearValue> clearColors(allCleanValue->getNbElements());
auto itClean = clearColors.begin();
for(size_t idCleanValue = 0; idCleanValue < allCleanValue->getNbElements(); ++idCleanValue)
{
auto cleanValueNode = allCleanValue->getNode(idCleanValue);
bool isColor = cleanValueNode->hasAttribute(u8"type") || cleanValueNode->hasAttribute(u8"colorR") || cleanValueNode->hasAttribute(u8"colorG") || cleanValueNode->hasAttribute(u8"colorB") || cleanValueNode->hasAttribute(u8"colorA");
bool isDS = cleanValueNode->hasAttribute(u8"depth") || cleanValueNode->hasAttribute(u8"stencil");
// Check validity
if(!(isColor ^ isDS))
{
MOUCA_THROW_ERROR_1(u8"Engine3D", u8"XMLCleanValueMixError", context.getFileName());
}
if(isColor)
{
Core::String dataType;
cleanValueNode->getAttribute(u8"type", dataType);
if(dataType==u8"float")
{
cleanValueNode->getAttribute(u8"colorR", itClean->color.float32[0]);
cleanValueNode->getAttribute(u8"colorG", itClean->color.float32[1]);
cleanValueNode->getAttribute(u8"colorB", itClean->color.float32[2]);
cleanValueNode->getAttribute(u8"colorA", itClean->color.float32[3]);
}
else if(dataType==u8"int")
{
cleanValueNode->getAttribute(u8"colorR", itClean->color.int32[0]);
cleanValueNode->getAttribute(u8"colorG", itClean->color.int32[1]);
cleanValueNode->getAttribute(u8"colorB", itClean->color.int32[2]);
cleanValueNode->getAttribute(u8"colorA", itClean->color.int32[3]);
}
else if(dataType==u8"uint")
{
cleanValueNode->getAttribute(u8"colorR", itClean->color.uint32[0]);
cleanValueNode->getAttribute(u8"colorG", itClean->color.uint32[1]);
cleanValueNode->getAttribute(u8"colorB", itClean->color.uint32[2]);
cleanValueNode->getAttribute(u8"colorA", itClean->color.uint32[3]);
}
else
{
MOUCA_THROW_ERROR_2(u8"Engine3D", u8"XMLCleanValueTypeError", context.getFileName(), dataType);
}
}
else
{
cleanValueNode->getAttribute(u8"depth", itClean->depthStencil.depth);
cleanValueNode->getAttribute(u8"stencil", itClean->depthStencil.stencil);
}
++itClean;
}
// Build command
if (frameBuffers.size() > 1)
{
command = std::make_unique<Vulkan::CommandBeginRenderPassSurface>(*_renderPasses[renderPassId].lock(), std::move(frameBuffers), renderArea, std::move(clearColors), subpassContent);
}
else
{
command = std::make_unique<Vulkan::CommandBeginRenderPass>(*_renderPasses[renderPassId].lock(), frameBuffers.front(), renderArea, std::move(clearColors), subpassContent);
}
}
else if(type == u8"endRenderPass")
{
// Build command
command = std::make_unique<Vulkan::CommandEndRenderPass>();
}
else if(type == u8"bindPipeline")
{
const auto bindPoint = LoaderHelper::readValue(commandNode, u8"bindPoint", bindPoints, false, context);
if(commandNode->hasAttribute(u8"graphicsPipelineId"))
{
const uint32_t pipelineId = LoaderHelper::getLinkedIdentifiant(commandNode, u8"graphicsPipelineId", _graphicsPipelines, context);
command = std::make_unique<Vulkan::CommandBindPipeline>(_graphicsPipelines[pipelineId], bindPoint);
}
else if (commandNode->hasAttribute(u8"rayTracingPipelineId"))
{
const uint32_t pipelineId = LoaderHelper::getLinkedIdentifiant(commandNode, u8"rayTracingPipelineId", _rayTracingPipelines, context);
command = std::make_unique<Vulkan::CommandBindPipeline>(_rayTracingPipelines[pipelineId], bindPoint);
}
else
{
MOUCA_THROW_ERROR_2(u8"Engine3D", u8"XMLUnknownBindPipelineError", context.getFileName(), type);
}
}
else if (type == u8"draw")
{
uint32_t vertexCount;
uint32_t instanceCount;
uint32_t firstVertex;
uint32_t firstInstance;
commandNode->getAttribute(u8"vertexCount", vertexCount);
commandNode->getAttribute(u8"instanceCount", instanceCount);
commandNode->getAttribute(u8"firstVertex", firstVertex);
commandNode->getAttribute(u8"firstInstance", firstInstance);
command = std::make_unique<Vulkan::CommandDraw>(vertexCount, instanceCount, firstVertex, firstInstance);
}
else if (type == u8"bindVertexBuffers")
{
uint32_t firstBinding;
uint32_t bindingCount;
commandNode->getAttribute(u8"firstBinding", firstBinding);
commandNode->getAttribute(u8"bindingCount", bindingCount);
// Read clear
auto aPushB = context._parser.autoPushNode(*commandNode);
auto allBuffers = context._parser.getNode(u8"Buffer");
std::vector<Vulkan::BufferWPtr> buffers;
buffers.reserve(allBuffers->getNbElements());
std::vector<VkDeviceSize> offsets;
offsets.reserve(allBuffers->getNbElements());
for (size_t idBuffer = 0; idBuffer < allBuffers->getNbElements(); ++idBuffer)
{
auto bufferNode = allBuffers->getNode(idBuffer);
const uint32_t idB = LoaderHelper::getLinkedIdentifiant(bufferNode, u8"bufferId", _buffers, context);
VkDeviceSize offset;
bufferNode->getAttribute(u8"offset", offset);
buffers.emplace_back(_buffers[idB]);
offsets.emplace_back(offset);
}
command = std::make_unique<Vulkan::CommandBindVertexBuffer>(firstBinding, bindingCount, std::move(buffers), std::move(offsets));
}
else if (type == u8"bindIndexBuffers")
{
const uint32_t idB = LoaderHelper::getLinkedIdentifiant(commandNode, u8"bufferId", _buffers, context);
VkDeviceSize offset;
commandNode->getAttribute(u8"offset", offset);
VkIndexType indexType = LoaderHelper::readValue(commandNode, u8"indexType", indexTypes, false, context);
command = std::make_unique<Vulkan::CommandBindIndexBuffer>(_buffers[idB], offset, indexType);
}
else if (type == u8"drawIndexed")
{
uint32_t indexCount;
if (commandNode->hasAttribute(u8"bufferId"))
{
uint32_t idB = LoaderHelper::getLinkedIdentifiant(commandNode, u8"bufferId", _cpuBuffers, context);
indexCount = static_cast<uint32_t>(_cpuBuffers[idB].lock()->getNbElements() * 3);
}
else
{
commandNode->getAttribute(u8"indexCount", indexCount);
}
uint32_t instanceCount;
commandNode->getAttribute(u8"instanceCount", instanceCount);
uint32_t firstIndex;
commandNode->getAttribute(u8"firstIndex", firstIndex);
int32_t vertexOffset;
commandNode->getAttribute(u8"vertexOffset", vertexOffset);
uint32_t firstInstance;
commandNode->getAttribute(u8"firstInstance", firstInstance);
command = std::make_unique<Vulkan::CommandDrawIndexed>(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
}
else if (type == u8"bindDescriptorSets")
{
const uint32_t idP = LoaderHelper::getLinkedIdentifiant(commandNode, u8"pipelineLayoutId", _pipelineLayouts, context);
const auto bindPoint = LoaderHelper::readValue(commandNode, u8"bindPoint", bindPoints, false, context);
uint32_t firstSet;
commandNode->getAttribute(u8"firstSet", firstSet);
const uint32_t idS = LoaderHelper::getLinkedIdentifiant(commandNode, u8"descriptorSetId", _descriptorSets, context);
auto aPushB = context._parser.autoPushNode(*commandNode);
// Read Dynamic Offset
auto allDynamicOffsets = context._parser.getNode(u8"DynamicOffset");
std::vector<uint32_t> dynamicOffsets;
dynamicOffsets.reserve(allDynamicOffsets->getNbElements());
for (size_t idDynamicOffset = 0; idDynamicOffset < allDynamicOffsets->getNbElements(); ++idDynamicOffset)
{
auto dynamicOffsetNode = allDynamicOffsets->getNode(idDynamicOffset);
uint32_t offset;
dynamicOffsetNode->getAttribute(u8"offset", offset);
dynamicOffsets.emplace_back(offset);
}
command = std::make_unique<Vulkan::CommandBindDescriptorSets>(*_pipelineLayouts[idP].lock(), bindPoint, firstSet, _descriptorSets[idS].lock()->getDescriptorSets(), std::move(dynamicOffsets));
}
else if (type == u8"pipelineBarrier")
{
const auto srcStage = LoaderHelper::readValue(commandNode, u8"srcStage", pipelineStageFlags, true, context);
const auto dstStage = LoaderHelper::readValue(commandNode, u8"dstStage", pipelineStageFlags, true, context);
const auto dependency = LoaderHelper::readValue(commandNode, u8"dependencyFlags", dependencyFlags, true, context);
auto aPushP = context._parser.autoPushNode(*commandNode);
// Read image memories
auto allImageMemories = context._parser.getNode(u8"ImageBarrier");
Vulkan::CommandPipelineBarrier::ImageMemoryBarriers imageBarriers;
imageBarriers.reserve(allImageMemories->getNbElements());
for (size_t idImageMemory = 0; idImageMemory < allImageMemories->getNbElements(); ++idImageMemory)
{
auto imageMemoryNode = allImageMemories->getNode(idImageMemory);
const uint32_t idI = LoaderHelper::getLinkedIdentifiant(imageMemoryNode, u8"imageId", _images, context);
VkImageMemoryBarrier barrier
{
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
nullptr,
LoaderHelper::readValue(imageMemoryNode, u8"srcAccessMask", accessFlags, true, context),
LoaderHelper::readValue(imageMemoryNode, u8"dstAccessMask", accessFlags, true, context),
LoaderHelper::readValue(imageMemoryNode, u8"oldLayout", imageLayouts, false, context),
LoaderHelper::readValue(imageMemoryNode, u8"newLayout", imageLayouts, false, context),
0, 0,
_images[idI].lock()->getImage(),
{ LoaderHelper::readValue(imageMemoryNode, u8"aspectMask", aspectFlags, true, context)},
};
imageMemoryNode->getAttribute(u8"srcQueueFamilyIndex", barrier.srcQueueFamilyIndex);
imageMemoryNode->getAttribute(u8"dstQueueFamilyIndex", barrier.dstQueueFamilyIndex);
imageMemoryNode->getAttribute(u8"baseMipLevel", barrier.subresourceRange.baseMipLevel);
imageMemoryNode->getAttribute(u8"levelCount", barrier.subresourceRange.levelCount);
imageMemoryNode->getAttribute(u8"baseArrayLayer", barrier.subresourceRange.baseArrayLayer);
imageMemoryNode->getAttribute(u8"layerCount", barrier.subresourceRange.layerCount);
imageBarriers.emplace_back(barrier);
}
Vulkan::CommandPipelineBarrier::MemoryBarriers memoryBarriers;
Vulkan::CommandPipelineBarrier::BufferMemoryBarriers bufferMemoryBarriers;
command = std::make_unique<Vulkan::CommandPipelineBarrier>(srcStage, dstStage, dependency, std::move(memoryBarriers), std::move(bufferMemoryBarriers), std::move(imageBarriers));
}
else if (type == u8"pushConstants")
{
const uint32_t idL = LoaderHelper::getLinkedIdentifiant(commandNode, u8"pipelineLayoutId", _pipelineLayouts, context);
const VkShaderStageFlags stage = LoaderHelper::readValue(commandNode, u8"stage", shaderStages, true, context);
const uint32_t idB = LoaderHelper::getLinkedIdentifiant(commandNode, u8"external", _cpuBuffers, context);
const auto& buffer = _cpuBuffers[idB].lock();
command = std::make_unique<Vulkan::CommandPushConstants>(*_pipelineLayouts[idL].lock(), stage, static_cast<uint32_t>(buffer->getByteSize()), buffer->getData());
}
else if (type == u8"container")
{
bool existing;
const uint32_t id = LoaderHelper::getIdentifiant(commandNode, nodeName, _commandLinks, context, existing);
if (existing)
{
continue;
}
command = std::make_unique<Vulkan::CommandContainer>();
_commandLinks[id] = command.get(); // Keep pointer (badly because can be delete -> shared/weak ?)
}
else if (type == u8"switch")
{
bool existing;
const uint32_t id = LoaderHelper::getIdentifiant(commandNode, nodeName, _commandLinks, context, existing);
if (existing)
{
continue;
}
auto commandSwitch = std::make_unique<Vulkan::CommandSwitch>();
_commandLinks[id] = commandSwitch.get(); // Keep pointer (badly because can be delete -> shared/weak ?)
// Load sub-commands
{
auto aPush = context._parser.autoPushNode(*commandNode);
std::vector<Vulkan::CommandUPtr> subCommands;
loadCommands(context, deviceWeak, resolution, subCommands, Core::String("Sub"+nodeName));
commandSwitch->transfer(std::move(subCommands));
}
command = std::move(commandSwitch);
}
else if (type == u8"traceRays")
{
uint32_t width;
uint32_t height;
uint32_t depth;
LoaderHelper::readAttribute(commandNode, u8"width", width, context);
LoaderHelper::readAttribute(commandNode, u8"height", height, context);
LoaderHelper::readAttribute(commandNode, u8"depth", depth, context);
const uint32_t idT = LoaderHelper::getLinkedIdentifiant(commandNode, u8"tracingRayId", _tracingRays, context);
auto commandTraceRay = std::make_unique<Vulkan::CommandTraceRay>(deviceWeak.lock()->getDevice(), _tracingRays[idT], width, height, depth);
command = std::move(commandTraceRay);
}
else
{
MOUCA_THROW_ERROR_2(u8"Engine3D", u8"XMLUnknownCommandError", context.getFileName(), type);
}
// Transfer to vector
commands.emplace_back(std::move(command));
}
}
} | 48.20202 | 246 | 0.604324 | [
"vector"
] |
7b4a7645c1efe28012f4d7821dbae9d85b7aaf71 | 2,011 | cpp | C++ | src/enemy.cpp | obliviateandsurrender/PacmanKiller | 65740b9e251c59231d447850899052e7e0d76f6c | [
"MIT"
] | null | null | null | src/enemy.cpp | obliviateandsurrender/PacmanKiller | 65740b9e251c59231d447850899052e7e0d76f6c | [
"MIT"
] | null | null | null | src/enemy.cpp | obliviateandsurrender/PacmanKiller | 65740b9e251c59231d447850899052e7e0d76f6c | [
"MIT"
] | null | null | null | #include "enemy.h"
#include "main.h"
#include "math.h"
Enemy::Enemy(float x, float y, float radius, float xspeed, color_t color) {
this->position = glm::vec3(x, y, 0);
this->rotation = 0;
this->radius = radius;
this->color = color;
this->xspeed = xspeed;
const int n = 360;
const int reqd = n * 9;
GLfloat vertex_buffer_data[reqd] = {};
double angle = 0;
const double pi = 4 * atan(1);
double diff = (2 * pi) / (double)n;
int cur = 0;
//GLfloat vertex_buffer_data[12345];
for (int i = 0; i < n; i++)
{
//Origin
vertex_buffer_data[cur++] = 0.0;
vertex_buffer_data[cur++] = 0.0;
vertex_buffer_data[cur++] = 0.0f;
//Point with lower angle
vertex_buffer_data[cur++] = radius * cos(angle);
vertex_buffer_data[cur++] = radius * sin(angle);
vertex_buffer_data[cur++] = 0.0f;
//Point with higher angle
angle += diff;
vertex_buffer_data[cur++] = radius * cos(angle);
vertex_buffer_data[cur++] = radius * sin(angle);
vertex_buffer_data[cur++] = 0.0f;
}
this->object = create3DObject(GL_TRIANGLES, 3 * n, vertex_buffer_data, color, GL_FILL);
}
void Enemy::tick() {
this->position.x += xspeed;
}
void Enemy::set_position(float x, float y) {
this->position = glm::vec3(x, y, 0);
}
void Enemy::draw(glm::mat4 VP) {
Matrices.model = glm::mat4(1.0f);
glm::mat4 translate = glm::translate (this->position); // glTranslatef
glm::mat4 rotate = glm::rotate((float) (this->rotation * M_PI / 180.0f), glm::vec3(0, 0, 1));
rotate = rotate * glm::translate(glm::vec3(0, -0.6, 0));
Matrices.model *= (translate * rotate);
glm::mat4 MVP = VP * Matrices.model;
glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]);
draw3DObject(this->object);
}
bounding_circle_t Enemy::bounding_circle() {
bounding_circle_t enbcircle = {this->position.x, this->position.y, this->radius};
return enbcircle;
}
| 29.144928 | 97 | 0.607658 | [
"object",
"model"
] |
7b4acd353ccd9d5c16b129ee687610a054c513dc | 13,867 | cpp | C++ | module/record/src/record/PlayerRecorder.cpp | Khoronus/StoreData | 067c64cc0e240412fab99759fab5b88083d0dbe0 | [
"MIT"
] | null | null | null | module/record/src/record/PlayerRecorder.cpp | Khoronus/StoreData | 067c64cc0e240412fab99759fab5b88083d0dbe0 | [
"MIT"
] | null | null | null | module/record/src/record/PlayerRecorder.cpp | Khoronus/StoreData | 067c64cc0e240412fab99759fab5b88083d0dbe0 | [
"MIT"
] | null | null | null | /* @file PlayerRecorder.cpp
* @brief Body of the class which performs all the main functions.
*
* @section LICENSE
*
* 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 AUTHOR/AUTHORS 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.
*
* @author Alessandro Moro <alessandromoro.italy@gmail.com>
* @bug No known bugs.
* @version 0.2.0.0
*
*/
#include "record/inc/record/PlayerRecorder.hpp"
namespace storedata
{
// ----------------------------------------------------------------------------
void PlayerRecorder::setup_file(
const std::string &filename,
const std::string &dot_extension,
int max_memory_allocable, int record_framerate) {
std::cout << "PlayerRecorder::setup" << std::endl;
std::cout << "insert FileGeneratorParam" << std::endl;
fgp_.insert(std::make_pair(0, FileGeneratorParams()));
std::cout << "filename: " << filename << std::endl;
fgp_[0].set_filename(filename);
fgp_[0].set_dot_extension(dot_extension);
std::cout << "PlayerRecorder::setup:" << max_memory_allocable << " " <<
record_framerate << std::endl;
fgm_.setup(max_memory_allocable, fgp_, record_framerate);
}
// ----------------------------------------------------------------------------
void PlayerRecorder::setup_video(std::map<int, cv::Mat> &sources,
const std::string &filename,
int max_frames_allocable, int fps, int record_framerate) {
std::cout << "PlayerRecorder::setup_video" << std::endl;
std::cout << "insert VideoGeneratorParam" << std::endl;
for (auto &it : sources) {
//std::cout << "source: " << it.first << " " << it.second.size() <<
// std::endl;
int width = it.second.cols, height = it.second.rows,
framerate = fps;
vgp_.insert(std::make_pair(it.first, VideoGeneratorParams()));
vgp_[it.first].set_filename(filename);
vgp_[it.first].set_width(width);
vgp_[it.first].set_height(height);
vgp_[it.first].set_video_framerate(fps);
}
std::cout << "PlayerRecorder::setup:" << max_frames_allocable << " " <<
fps << std::endl;
vgm_.setup(max_frames_allocable, vgp_, record_framerate);
}
// ----------------------------------------------------------------------------
void PlayerRecorder::setup_metaframe(cv::Mat &meta_frame) {
vgm_.setup_metaframe(meta_frame);
}
// ----------------------------------------------------------------------------
bool PlayerRecorder::record_file(cv::Mat &curr, bool encoded, std::string &msg) {
if (fgm_.under_writing()) return false;
// Container with the buffer data of the encoded image.
std::vector< std::vector< uchar > > v_buffer_;
int codified = 0;
size_t size_img_data = curr.cols * curr.rows * curr.channels();
uchar *data = curr.data;
if (curr.empty()) size_img_data = 0;
// Encode the source image
if (encoded && !curr.empty()) {
codified = 1;
std::vector<int> params(2);
#if CV_MAJOR_VERSION == 4
params[0] = cv::IMWRITE_JPEG_QUALITY;
#else
params[0] = CV_IMWRITE_JPEG_QUALITY;
#endif
params[1] = 100;//CV_IMWRITE_JPEG_QUALITY;
v_buffer_.clear();
v_buffer_.push_back( std::vector<uchar>() );
cv::imencode(".jpg", curr, v_buffer_[ v_buffer_.size() - 1 ], params);
// Image data size
size_img_data = v_buffer_[ v_buffer_.size() - 1 ].size();
data = &v_buffer_[ v_buffer_.size() - 1 ][0];
}
// Add the information to transmit
size_t size_msg_data = msg.size();
std::vector<char> info_to_transmit(size_msg_data);
memcpy(&info_to_transmit[0], &msg[0], size_msg_data);
// Prepare the container for the data to transmit
std::map<int, std::vector<char> > m_data;
// The size of the data header.
int imagedatasize_bytes = sizeof(int) * 4 + sizeof(size_t) * 2; // IT MUST BE SAME LATER
// Cols, Rows, Channels, Data size, Message size
m_data[0] = std::vector<char>(size_img_data + size_msg_data +
imagedatasize_bytes);
// Copy the data
int channels = curr.channels();
size_t byte_header_size = 0;
memcpy(&m_data[0][byte_header_size], &codified, sizeof(int));
byte_header_size += sizeof(int);
memcpy(&m_data[0][byte_header_size], &curr.cols, sizeof(int));
byte_header_size += sizeof(int);
memcpy(&m_data[0][byte_header_size], &curr.rows, sizeof(int));
byte_header_size += sizeof(int);
memcpy(&m_data[0][byte_header_size], &channels, sizeof(int));
byte_header_size += sizeof(int);
memcpy(&m_data[0][byte_header_size], &size_img_data, sizeof(size_t));
byte_header_size += sizeof(size_t);
memcpy(&m_data[0][byte_header_size], &size_msg_data, sizeof(size_t));
byte_header_size += sizeof(size_t);
memcpy(&m_data[0][byte_header_size], data, size_img_data);
byte_header_size += size_img_data;
memcpy(&m_data[0][byte_header_size], &info_to_transmit[0],
size_msg_data);
if (!fgm_.push_data_write_not_guarantee_can_replace(m_data)) { return false; }
return true;
}
// ----------------------------------------------------------------------------
bool PlayerRecorder::record_file(
cv::Mat &curr,
bool encoded,
unsigned char *msg,
size_t msg_size) {
if (fgm_.under_writing()) return false;
// Container with the buffer data of the encoded image.
std::vector< std::vector< uchar > > v_buffer_;
int codified = 0;
size_t size_img_data = curr.cols * curr.rows * curr.channels();
uchar *data = curr.data;
if (curr.empty()) size_img_data = 0;
// Encode the source image
if (encoded && !curr.empty()) {
codified = 1;
std::vector<int> params(2);
#if CV_MAJOR_VERSION == 4
params[0] = cv::IMWRITE_JPEG_QUALITY;
#else
params[0] = CV_IMWRITE_JPEG_QUALITY;
#endif
params[1] = 100;//CV_IMWRITE_JPEG_QUALITY;
v_buffer_.clear();
v_buffer_.push_back(std::vector<uchar>());
cv::imencode(".jpg", curr, v_buffer_[v_buffer_.size() - 1], params);
// Image data size
size_img_data = v_buffer_[v_buffer_.size() - 1].size();
data = &v_buffer_[v_buffer_.size() - 1][0];
}
// Add the information to transmit
size_t size_msg_data = msg_size;
std::vector<char> info_to_transmit(size_msg_data);
memcpy(&info_to_transmit[0], &msg[0], size_msg_data);
// Prepare the container for the data to transmit
std::map<int, std::vector<char> > m_data;
// The size of the data header.
int imagedatasize_bytes = sizeof(int) * 4 + sizeof(size_t) * 2; // IT MUST BE SAME LATER
// Cols, Rows, Channels, Data size, Message size
m_data[0] = std::vector<char>(size_img_data + size_msg_data +
imagedatasize_bytes);
// Copy the data
int channels = curr.channels();
size_t byte_header_size = 0;
memcpy(&m_data[0][byte_header_size], &codified, sizeof(int));
byte_header_size += sizeof(int);
memcpy(&m_data[0][byte_header_size], &curr.cols, sizeof(int));
byte_header_size += sizeof(int);
memcpy(&m_data[0][byte_header_size], &curr.rows, sizeof(int));
byte_header_size += sizeof(int);
memcpy(&m_data[0][byte_header_size], &channels, sizeof(int));
byte_header_size += sizeof(int);
memcpy(&m_data[0][byte_header_size], &size_img_data, sizeof(size_t));
byte_header_size += sizeof(size_t);
memcpy(&m_data[0][byte_header_size], &size_msg_data, sizeof(size_t));
byte_header_size += sizeof(size_t);
memcpy(&m_data[0][byte_header_size], data, size_img_data);
byte_header_size += size_img_data;
memcpy(&m_data[0][byte_header_size], &info_to_transmit[0],
size_msg_data);
if (!fgm_.push_data_write_not_guarantee_can_replace(m_data)) { return false; }
return true;
}
// ----------------------------------------------------------------------------
void PlayerRecorder::record_video(std::map<int, cv::Mat> &sources) {
vgm_.push_data_write_not_guarantee_can_replace(sources);
}
// ----------------------------------------------------------------------------
void PlayerRecorder::read_file(const std::string &filename, int FPS) {
int _FPS = (std::max)(1, FPS);
// Read the data
bool bPlayRecord = true;
std::ifstream file(filename.c_str(),
std::ios::in | std::ios::binary | std::ios::ate);
int size = 0;
char *memblock = nullptr;
std::vector< std::pair<cv::Mat, std::vector<char> > > img_info;
if (file.is_open())
{
size = file.tellg();
memblock = new char[size];
file.seekg(0, std::ios::beg);
file.read(memblock, size);
file.close();
data2data_type(memblock, size, img_info);
delete[] memblock;
}
#if _MSC_VER && !__INTEL_COMPILER && (_MSC_VER > 1600)
for (auto it = img_info.begin(); it != img_info.end(); it++)
#else
for (std::vector< std::pair<cv::Mat, std::vector<char> > >::const_iterator it = img_info.begin(); it != img_info.end(); it++)
#endif
{
// show the image
if (!it->first.empty()) cv::imshow("record", it->first);
// show the text result
char msg[2048];
for (int i = 0; i < it->second.size(); i++)
msg[i] = it->second[i];
msg[it->second.size()] = '\0';
std::cout << "msg[" << it->second.size() << "]: " << msg << std::endl;
//// specialized
//memcpy(msg, &(it->second[0]), 384);
//msg[384] = '\0';
//std::cout << "msg[" << it->second.size() << "]: " << msg << std::endl;
//memcpy(msg, &(it->second[384]), it->second.size() - 384);
//msg[it->second.size() - 384] = '\0';
//std::cout << "msg[" << it->second.size() << "]: " << msg << std::endl;
cv::waitKey(1000 / _FPS);
}
}
// ----------------------------------------------------------------------------
void PlayerRecorder::unpack(
const std::string &filename, int FPS,
const std::string &path, unsigned int &index_start) {
int _FPS = (std::max)(1, FPS);
// Read the data
bool bPlayRecord = true;
std::ifstream file(filename.c_str(),
std::ios::in | std::ios::binary | std::ios::ate);
int size = 0;
char *memblock = nullptr;
std::vector< std::pair<cv::Mat, std::vector<char> > > img_info;
if (file.is_open())
{
size = file.tellg();
memblock = new char[size];
file.seekg(0, std::ios::beg);
file.read(memblock, size);
file.close();
data2data_type(memblock, size, img_info);
delete[] memblock;
}
// save the data from this index
unsigned int index_start_internal = index_start;
#if _MSC_VER && !__INTEL_COMPILER && (_MSC_VER > 1600)
for (auto it = img_info.begin(); it != img_info.end(); it++)
#else
for (std::vector< std::pair<cv::Mat, std::vector<char> > >::const_iterator it = img_info.begin(); it != img_info.end(); it++)
#endif
{
// show the image
if (!it->first.empty()) {
cv::imshow("record", it->first);
cv::imwrite(path + "\\" + std::to_string(index_start_internal) + ".jpg", it->first);
}
// show the text result
char msg[2048];
for (int i = 0; i < it->second.size(); i++)
msg[i] = it->second[i];
msg[it->second.size()] = '\0';
std::cout << "msg[" << it->second.size() << "]: " << msg << std::endl;
// save the message
std::ofstream fout(path + "\\" + std::to_string(index_start_internal) + ".txt", std::ios::binary);
fout.write(&it->second[0], it->second.size());
fout.flush();
//// specialized
//memcpy(msg, &(it->second[0]), 384);
//msg[384] = '\0';
//std::cout << "msg[" << it->second.size() << "]: " << msg << std::endl;
//memcpy(msg, &(it->second[384]), it->second.size() - 384);
//msg[it->second.size() - 384] = '\0';
//std::cout << "msg[" << it->second.size() << "]: " << msg << std::endl;
cv::waitKey(1000 / _FPS);
// increment the counter
++index_start_internal;
}
}
// ----------------------------------------------------------------------------
void PlayerRecorder::data2data_type(char *data, int maxsize,
std::vector< std::pair<cv::Mat, std::vector<char> > > &out)
{
const int sizeofinfo = sizeof(int) * 4 + sizeof(size_t) * 2; // Expected
// information about the size
// of the image
int pos = 0;
while (pos < maxsize) {
std::cout << "read: " << pos << " " << maxsize << std::endl;
// Get the image size
char imginfo[sizeofinfo];
if (pos + sizeofinfo < maxsize) {
memcpy(imginfo, &data[pos], sizeofinfo);
}
int codified = 0, cols = 0, rows = 0, channels = 0;
size_t imgsize = 0, msgsize = 0;
size_t byte_header_size = 0;
memcpy(&codified, &imginfo[byte_header_size], sizeof(int));
memcpy(&cols, &imginfo[byte_header_size], sizeof(int));
memcpy(&rows, &imginfo[byte_header_size], sizeof(int));
memcpy(&channels, &imginfo[byte_header_size], sizeof(int));
memcpy(&imgsize, &imginfo[byte_header_size], sizeof(size_t));
memcpy(&msgsize, &imginfo[byte_header_size], sizeof(size_t));
if (pos + sizeofinfo + imgsize + msgsize < maxsize)
{
cv::Mat m;
if (codified == 0) {
int ch = channels == 3 ? CV_8UC3 : CV_8U;
m = cv::Mat::zeros(rows, cols, ch);
memcpy(m.data, &data[pos + sizeofinfo], imgsize);
} else if (codified == 1) {
std::vector< uchar > data_tmp(imgsize);
memcpy(&data_tmp[0], &data[pos + sizeofinfo], imgsize);
int flags = channels == 3 ? 1 : 0;
m = cv::imdecode(data_tmp, flags);
}
std::vector< uchar > msg_tmp(msgsize);
memcpy(&msg_tmp[0], &data[pos + sizeofinfo + imgsize], msgsize);
std::vector<char> v(msgsize);
for (int i = 0; i < msgsize; i++)
v[i] = msg_tmp[i];
out.push_back(std::make_pair(m, v));
}
pos += sizeofinfo + imgsize + msgsize;
}
}
// ----------------------------------------------------------------------------
void PlayerRecorder::set_callback_createfile(
cbk_fname_changed callback_createfile) {
vgm_.set_callback_createfile(callback_createfile);
fgm_.set_callback_createfile(callback_createfile);
}
} // namespace storedata | 37.579946 | 126 | 0.634528 | [
"vector"
] |
7b4f7dbb516d67b87799747883d8846d657279db | 69,544 | cxx | C++ | main/chart2/source/view/axes/VCartesianAxis.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 679 | 2015-01-06T06:34:58.000Z | 2022-03-30T01:06:03.000Z | main/chart2/source/view/axes/VCartesianAxis.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 102 | 2017-11-07T08:51:31.000Z | 2022-03-17T12:13:49.000Z | main/chart2/source/view/axes/VCartesianAxis.cxx | Grosskopf/openoffice | 93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7 | [
"Apache-2.0"
] | 331 | 2015-01-06T11:40:55.000Z | 2022-03-14T04:07:51.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.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
#include <basegfx/numeric/ftools.hxx>
#include "VCartesianAxis.hxx"
#include "PlottingPositionHelper.hxx"
#include "ShapeFactory.hxx"
#include "CommonConverters.hxx"
#include "macros.hxx"
#include "ViewDefines.hxx"
#include "PropertyMapper.hxx"
#include "NumberFormatterWrapper.hxx"
#include "LabelPositionHelper.hxx"
#include "TrueGuard.hxx"
#include "BaseGFXHelper.hxx"
#include "AxisHelper.hxx"
#include "Tickmarks_Equidistant.hxx"
#include <rtl/math.hxx>
#include <tools/color.hxx>
#include <tools/debug.hxx>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
#include <editeng/unoprnms.hxx>
#include <svx/unoshape.hxx>
#include <svx/unoshtxt.hxx>
#include <algorithm>
#include <memory>
//.............................................................................
namespace chart
{
//.............................................................................
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
using namespace ::rtl::math;
using ::com::sun::star::uno::Reference;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
VCartesianAxis::VCartesianAxis( const AxisProperties& rAxisProperties
, const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier
, sal_Int32 nDimensionIndex, sal_Int32 nDimensionCount
, PlottingPositionHelper* pPosHelper )//takes ownership
: VAxisBase( nDimensionIndex, nDimensionCount, rAxisProperties, xNumberFormatsSupplier )
{
if( pPosHelper )
m_pPosHelper = pPosHelper;
else
m_pPosHelper = new PlottingPositionHelper();
}
VCartesianAxis::~VCartesianAxis()
{
delete m_pPosHelper;
m_pPosHelper = NULL;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Reference< drawing::XShape > createSingleLabel(
const Reference< lang::XMultiServiceFactory>& xShapeFactory
, const Reference< drawing::XShapes >& xTarget
, const awt::Point& rAnchorScreenPosition2D
, const rtl::OUString& rLabel
, const AxisLabelProperties& rAxisLabelProperties
, const AxisProperties& rAxisProperties
, const tNameSequence& rPropNames
, const tAnySequence& rPropValues
)
{
if( rLabel.isEmpty() )
return 0;
// #i78696# use mathematically correct rotation now
const double fRotationAnglePi(rAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0));
uno::Any aATransformation = ShapeFactory::makeTransformation( rAnchorScreenPosition2D, fRotationAnglePi );
rtl::OUString aLabel = ShapeFactory::getStackedString( rLabel, rAxisLabelProperties.bStackCharacters );
Reference< drawing::XShape > xShape2DText = ShapeFactory(xShapeFactory)
.createText( xTarget, aLabel, rPropNames, rPropValues, aATransformation );
//correctPositionForRotation
LabelPositionHelper::correctPositionForRotation( xShape2DText
, rAxisProperties.m_aLabelAlignment, rAxisLabelProperties.fRotationAngleDegree, rAxisProperties.m_bComplexCategories );
return xShape2DText;
}
bool lcl_doesShapeOverlapWithTickmark( const Reference< drawing::XShape >& xShape
, double fRotationAngleDegree
, const basegfx::B2DVector& rTickScreenPosition
, bool bIsHorizontalAxis, bool bIsVerticalAxis )
{
if(!xShape.is())
return false;
::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(xShape->getPosition(),ShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree ));
if( bIsVerticalAxis )
{
return ( (rTickScreenPosition.getY() >= aShapeRect.getMinY())
&& (rTickScreenPosition.getY() <= aShapeRect.getMaxY()) );
}
if( bIsHorizontalAxis )
{
return ( (rTickScreenPosition.getX() >= aShapeRect.getMinX())
&& (rTickScreenPosition.getX() <= aShapeRect.getMaxX()) );
}
basegfx::B2IVector aPosition(
static_cast<sal_Int32>( rTickScreenPosition.getX() )
, static_cast<sal_Int32>( rTickScreenPosition.getY() ) );
return aShapeRect.isInside(aPosition);
}
bool doesOverlap( const Reference< drawing::XShape >& xShape1
, const Reference< drawing::XShape >& xShape2
, double fRotationAngleDegree )
{
if( !xShape1.is() || !xShape2.is() )
return false;
::basegfx::B2IRectangle aRect1( BaseGFXHelper::makeRectangle(xShape1->getPosition(),ShapeFactory::getSizeAfterRotation( xShape1, fRotationAngleDegree )));
::basegfx::B2IRectangle aRect2( BaseGFXHelper::makeRectangle(xShape2->getPosition(),ShapeFactory::getSizeAfterRotation( xShape2, fRotationAngleDegree )));
return aRect1.overlaps(aRect2);
}
void removeShapesAtWrongRhythm( TickIter& rIter
, sal_Int32 nCorrectRhythm
, sal_Int32 nMaxTickToCheck
, const Reference< drawing::XShapes >& xTarget )
{
sal_Int32 nTick = 0;
for( TickInfo* pTickInfo = rIter.firstInfo()
; pTickInfo && nTick <= nMaxTickToCheck
; pTickInfo = rIter.nextInfo(), nTick++ )
{
//remove labels which does not fit into the rhythm
if( nTick%nCorrectRhythm != 0)
{
if(pTickInfo->xTextShape.is())
{
xTarget->remove(pTickInfo->xTextShape);
pTickInfo->xTextShape = NULL;
}
}
}
}
class LabelIterator : public TickIter
{
//this Iterator iterates over existing text labels
//if the labels are staggered and bInnerLine is true
//we iterate only through the labels which are lying more inside the diagram
//if the labels are staggered and bInnerLine is false
//we iterate only through the labels which are lying more outside the diagram
//if the labels are not staggered
//we iterate through all labels
public:
LabelIterator( ::std::vector< TickInfo >& rTickInfoVector
, const AxisLabelStaggering eAxisLabelStaggering
, bool bInnerLine );
virtual TickInfo* firstInfo();
virtual TickInfo* nextInfo();
private: //methods
LabelIterator();
private: //member
PureTickIter m_aPureTickIter;
const AxisLabelStaggering m_eAxisLabelStaggering;
bool m_bInnerLine;
};
LabelIterator::LabelIterator( ::std::vector< TickInfo >& rTickInfoVector
, const AxisLabelStaggering eAxisLabelStaggering
, bool bInnerLine )
: m_aPureTickIter( rTickInfoVector )
, m_eAxisLabelStaggering(eAxisLabelStaggering)
, m_bInnerLine(bInnerLine)
{
}
TickInfo* LabelIterator::firstInfo()
{
TickInfo* pTickInfo = m_aPureTickIter.firstInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() )
pTickInfo = m_aPureTickIter.nextInfo();
if(!pTickInfo)
return NULL;
if( (STAGGER_EVEN==m_eAxisLabelStaggering && m_bInnerLine)
||
(STAGGER_ODD==m_eAxisLabelStaggering && !m_bInnerLine)
)
{
//skip first label
do
pTickInfo = m_aPureTickIter.nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
}
if(!pTickInfo)
return NULL;
return pTickInfo;
}
TickInfo* LabelIterator::nextInfo()
{
TickInfo* pTickInfo = NULL;
//get next label
do
pTickInfo = m_aPureTickIter.nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
if( STAGGER_EVEN==m_eAxisLabelStaggering
|| STAGGER_ODD==m_eAxisLabelStaggering )
{
//skip one label
do
pTickInfo = m_aPureTickIter.nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
}
return pTickInfo;
}
B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTickToText, double fRotationAngleDegree )
{
//calculates the height or width of a line of labels
//thus a following line of labels can be shifted for that distance
B2DVector aRet(0,0);
sal_Int32 nDistanceTickToText = static_cast<sal_Int32>( rDistanceTickToText.getLength() );
if( nDistanceTickToText==0.0)
return aRet;
B2DVector aStaggerDirection(rDistanceTickToText);
aStaggerDirection.normalize();
sal_Int32 nDistance=0;
Reference< drawing::XShape > xShape2DText(NULL);
for( TickInfo* pTickInfo = rIter.firstInfo()
; pTickInfo
; pTickInfo = rIter.nextInfo() )
{
xShape2DText = pTickInfo->xTextShape;
if( xShape2DText.is() )
{
awt::Size aSize = ShapeFactory::getSizeAfterRotation( xShape2DText, fRotationAngleDegree );
if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY()))
nDistance = ::std::max(nDistance,aSize.Width);
else
nDistance = ::std::max(nDistance,aSize.Height);
}
}
aRet = aStaggerDirection*nDistance;
//add extra distance for vertical distance
if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY()))
aRet += rDistanceTickToText;
return aRet;
}
void lcl_shiftLables( TickIter& rIter, const B2DVector& rStaggerDistance )
{
if(rStaggerDistance.getLength()==0.0)
return;
Reference< drawing::XShape > xShape2DText(NULL);
for( TickInfo* pTickInfo = rIter.firstInfo()
; pTickInfo
; pTickInfo = rIter.nextInfo() )
{
xShape2DText = pTickInfo->xTextShape;
if( xShape2DText.is() )
{
awt::Point aPos = xShape2DText->getPosition();
aPos.X += static_cast<sal_Int32>(rStaggerDistance.getX());
aPos.Y += static_cast<sal_Int32>(rStaggerDistance.getY());
xShape2DText->setPosition( aPos );
}
}
}
bool lcl_hasWordBreak( const Reference< drawing::XShape >& rxShape )
{
if ( rxShape.is() )
{
SvxShape* pShape = SvxShape::getImplementation( rxShape );
SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( pShape );
if ( pShapeText )
{
SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() );
if ( pTextEditSource )
{
pTextEditSource->UpdateOutliner();
SvxTextForwarder* pTextForwarder = pTextEditSource->GetTextForwarder();
if ( pTextForwarder )
{
sal_uInt16 nParaCount = pTextForwarder->GetParagraphCount();
for ( sal_uInt16 nPara = 0; nPara < nParaCount; ++nPara )
{
sal_uInt16 nLineCount = pTextForwarder->GetLineCount( nPara );
for ( sal_uInt16 nLine = 0; nLine < nLineCount; ++nLine )
{
sal_uInt16 nLineStart = 0;
sal_uInt16 nLineEnd = 0;
pTextForwarder->GetLineBoundaries( nLineStart, nLineEnd, nPara, nLine );
sal_uInt16 nWordStart = 0;
sal_uInt16 nWordEnd = 0;
if ( pTextForwarder->GetWordIndices( nPara, nLineStart, nWordStart, nWordEnd ) &&
( nWordStart != nLineStart ) )
{
return true;
}
}
}
}
}
}
}
return false;
}
class MaxLabelTickIter : public TickIter
{
//iterate over first two and last two labels and the longest label
public:
MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector
, sal_Int32 nLongestLabelIndex );
virtual ~MaxLabelTickIter();
virtual TickInfo* firstInfo();
virtual TickInfo* nextInfo();
private:
::std::vector< TickInfo >& m_rTickInfoVector;
::std::vector< sal_Int32 > m_aValidIndices;
sal_Int32 m_nCurrentIndex;
};
MaxLabelTickIter::MaxLabelTickIter( ::std::vector< TickInfo >& rTickInfoVector
, sal_Int32 nLongestLabelIndex )
: m_rTickInfoVector(rTickInfoVector)
, m_nCurrentIndex(0)
{
sal_Int32 nMaxIndex = m_rTickInfoVector.size()-1;
if( nLongestLabelIndex<0 || nLongestLabelIndex>=nMaxIndex-1 )
nLongestLabelIndex = 0;
if( nMaxIndex>=0 )
m_aValidIndices.push_back(0);
if( nMaxIndex>=1 )
m_aValidIndices.push_back(1);
if( nLongestLabelIndex>1 )
m_aValidIndices.push_back(nLongestLabelIndex);
if( nMaxIndex > 2 )
m_aValidIndices.push_back(nMaxIndex-1);
if( nMaxIndex > 1 )
m_aValidIndices.push_back(nMaxIndex);
}
MaxLabelTickIter::~MaxLabelTickIter()
{
}
TickInfo* MaxLabelTickIter::firstInfo()
{
m_nCurrentIndex = 0;
if( m_nCurrentIndex < static_cast<sal_Int32>(m_aValidIndices.size()) )
return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]];
return 0;
}
TickInfo* MaxLabelTickIter::nextInfo()
{
m_nCurrentIndex++;
if( m_nCurrentIndex>=0 && m_nCurrentIndex<static_cast<sal_Int32>(m_aValidIndices.size()) )
return &m_rTickInfoVector[m_aValidIndices[m_nCurrentIndex]];
return 0;
}
bool VCartesianAxis::isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
, bool bIsHorizontalAxis )
{
if( m_aTextLabels.getLength() > 100 )
return false;
if( !rAxisLabelProperties.bLineBreakAllowed )
return false;
if( rAxisLabelProperties.bStackCharacters )
return false;
//no break for value axis
if( !m_bUseTextLabels )
return false;
if( !::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) )
return false;
//break only for horizontal axis
return bIsHorizontalAxis;
}
bool VCartesianAxis::isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
, bool bIsHorizontalAxis, bool bIsVerticalAxis )
{
if( rAxisLabelProperties.eStaggering != STAGGER_AUTO )
return false;
if( rAxisLabelProperties.bOverlapAllowed )
return false;
if( rAxisLabelProperties.bLineBreakAllowed ) //auto line break or auto staggering, doing both automatisms they may conflict...
return false;
if( !::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) )
return false;
//automatic staggering only for horizontal axis with horizontal text
//or vertical axis with vertical text
if( bIsHorizontalAxis )
return !rAxisLabelProperties.bStackCharacters;
if( bIsVerticalAxis )
return rAxisLabelProperties.bStackCharacters;
return false;
}
struct ComplexCategoryPlacement
{
rtl::OUString Text;
sal_Int32 Count;
double TickValue;
ComplexCategoryPlacement( const rtl::OUString& rText, sal_Int32 nCount, double fTickValue )
: Text(rText), Count(nCount), TickValue(fTickValue)
{}
};
void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition )
{
//no minor tickmarks will be generated!
//order is: inner labels first , outer labels last (that is different to all other TickIter cases)
if(!bShiftedPosition)
{
rAllTickInfos.clear();
sal_Int32 nLevel=0;
sal_Int32 nLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
for( ; nLevel<nLevelCount; nLevel++ )
{
::std::vector< TickInfo > aTickInfoVector;
std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) );
sal_Int32 nCatIndex = 0;
std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin());
std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end());
for(;aIt!=aEnd;++aIt)
{
TickInfo aTickInfo(0);
ComplexCategory aCat(*aIt);
sal_Int32 nCount = aCat.Count;
if( nCatIndex + 1.0 + nCount >= m_aScale.Maximum )
{
nCount = static_cast<sal_Int32>(m_aScale.Maximum - 1.0 - nCatIndex);
if( nCount <= 0 )
nCount = 1;
}
aTickInfo.fScaledTickValue = nCatIndex + 1.0 + nCount/2.0;
aTickInfo.nFactorForLimitedTextWidth = nCount;
aTickInfo.aText = aCat.Text;
aTickInfoVector.push_back(aTickInfo);
nCatIndex += nCount;
if( nCatIndex + 1.0 >= m_aScale.Maximum )
break;
}
rAllTickInfos.push_back(aTickInfoVector);
}
}
else //bShiftedPosition==false
{
rAllTickInfos.clear();
sal_Int32 nLevel=0;
sal_Int32 nLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
for( ; nLevel<nLevelCount; nLevel++ )
{
::std::vector< TickInfo > aTickInfoVector;
std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) );
sal_Int32 nCatIndex = 0;
std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin());
std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end());
for(;aIt!=aEnd;++aIt)
{
TickInfo aTickInfo(0);
ComplexCategory aCat(*aIt);
aTickInfo.fScaledTickValue = nCatIndex + 1.0;
aTickInfoVector.push_back(aTickInfo);
nCatIndex += aCat.Count;
if( nCatIndex + 1.0 > m_aScale.Maximum )
break;
}
//fill up with single ticks until maximum scale
while( nCatIndex + 1.0 < m_aScale.Maximum )
{
TickInfo aTickInfo(0);
aTickInfo.fScaledTickValue = nCatIndex + 1.0;
aTickInfoVector.push_back(aTickInfo);
nCatIndex ++;
if( nLevel>0 )
break;
}
//add an additional tick at the end
{
TickInfo aTickInfo(0);
aTickInfo.fScaledTickValue = m_aScale.Maximum;
aTickInfoVector.push_back(aTickInfo);
}
rAllTickInfos.push_back(aTickInfoVector);
}
}
}
void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos )
{
if( isComplexCategoryAxis() )
createAllTickInfosFromComplexCategories( rAllTickInfos, false );
else
VAxisBase::createAllTickInfos(rAllTickInfos);
}
::std::auto_ptr< TickIter > VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel )
{
if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) )
return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) );
return ::std::auto_ptr< TickIter >();
}
::std::auto_ptr< TickIter > VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel )
{
if( isComplexCategoryAxis() || isDateAxis() )
{
return createLabelTickIterator( nTextLevel ); //mmmm maybe todo: create less than all texts here
}
else
{
if(nTextLevel==0)
{
if( !m_aAllTickInfos.empty() )
{
sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0;
return ::std::auto_ptr< TickIter >( new MaxLabelTickIter( m_aAllTickInfos[0], nLongestLabelIndex ) );
}
}
}
return ::std::auto_ptr< TickIter >();
}
sal_Int32 VCartesianAxis::getTextLevelCount() const
{
sal_Int32 nTextLevelCount = 1;
if( isComplexCategoryAxis() )
nTextLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
return nTextLevelCount;
}
bool VCartesianAxis::createTextShapes(
const Reference< drawing::XShapes >& xTarget
, TickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
, TickFactory_2D* pTickFactory
, sal_Int32 nScreenDistanceBetweenTicks )
{
//returns true if the text shapes have been created successfully
//otherwise false - in this case the AxisLabelProperties have changed
//and contain new instructions for the next try for text shape creation
Reference< XScaling > xInverseScaling( NULL );
if( m_aScale.Scaling.is() )
xInverseScaling = m_aScale.Scaling->getInverseScaling();
FixedNumberFormatter aFixedNumberFormatter(
m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey );
const bool bIsHorizontalAxis = pTickFactory->isHorizontalAxis();
const bool bIsVerticalAxis = pTickFactory->isVerticalAxis();
bool bIsStaggered = rAxisLabelProperties.getIsStaggered();
B2DVector aTextToTickDistance( pTickFactory->getDistanceAxisTickToText( m_aAxisProperties, true ) );
sal_Int32 nLimitedSpaceForText = -1;
if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis ) )
{
nLimitedSpaceForText = nScreenDistanceBetweenTicks;
if( bIsStaggered )
nLimitedSpaceForText *= 2;
if( nLimitedSpaceForText > 0 )
{ //reduce space for a small amount to have a visible distance between the labels:
sal_Int32 nReduce = (nLimitedSpaceForText*5)/100;
if(!nReduce)
nReduce = 1;
nLimitedSpaceForText -= nReduce;
}
}
std::vector< ComplexCategoryPlacement > aComplexCategoryPlacements;
uno::Sequence< rtl::OUString >* pCategories = 0;
if( m_bUseTextLabels && !m_aAxisProperties.m_bComplexCategories )
pCategories = &m_aTextLabels;
TickInfo* pPreviousVisibleTickInfo = NULL;
TickInfo* pPREPreviousVisibleTickInfo = NULL;
TickInfo* pLastVisibleNeighbourTickInfo = NULL;
//------------------------------------------------
//prepare properties for multipropertyset-interface of shape
tNameSequence aPropNames;
tAnySequence aPropValues;
bool bLimitedHeight = fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY());
Reference< beans::XPropertySet > xProps( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY );
PropertyMapper::getTextLabelMultiPropertyLists( xProps, aPropNames, aPropValues, false
, nLimitedSpaceForText, bLimitedHeight );
LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps
, m_aAxisLabelProperties.m_aFontReferenceSize );
LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.m_aLabelAlignment );
uno::Any* pColorAny = PropertyMapper::getValuePointer(aPropValues,aPropNames,C2U("CharColor"));
sal_Int32 nColor = Color( COL_AUTO ).GetColor();
if(pColorAny)
*pColorAny >>= nColor;
uno::Any* pLimitedSpaceAny = PropertyMapper::getValuePointerForLimitedSpace(aPropValues,aPropNames,bLimitedHeight);
//------------------------------------------------
sal_Int32 nTick = 0;
for( TickInfo* pTickInfo = rTickIter.firstInfo()
; pTickInfo
; pTickInfo = rTickIter.nextInfo(), nTick++ )
{
pLastVisibleNeighbourTickInfo = bIsStaggered ?
pPREPreviousVisibleTickInfo : pPreviousVisibleTickInfo;
//don't create labels which does not fit into the rhythm
if( nTick%rAxisLabelProperties.nRhythm != 0)
continue;
//don't create labels for invisible ticks
if( !pTickInfo->bPaintIt )
continue;
//if NO OVERLAP -> don't create labels where the tick overlaps
//with the text of the last neighbour tickmark
if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed )
{
if( lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
, pTickInfo->aTickScreenPosition
, bIsHorizontalAxis, bIsVerticalAxis ) )
{
bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true;
if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) )
{
bIsStaggered = true;
rAxisLabelProperties.eStaggering = STAGGER_EVEN;
pLastVisibleNeighbourTickInfo = pPREPreviousVisibleTickInfo;
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
, pTickInfo->aTickScreenPosition
, bIsHorizontalAxis, bIsVerticalAxis ) )
bOverlapAlsoAfterSwitchingOnAutoStaggering = false;
}
if( bOverlapAlsoAfterSwitchingOnAutoStaggering )
{
if( rAxisLabelProperties.bRhythmIsFix )
continue;
rAxisLabelProperties.nRhythm++;
removeShapesAtWrongRhythm( rTickIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
return false;
}
}
}
//xxxxx pTickInfo->updateUnscaledValue( xInverseScaling );
bool bHasExtraColor=false;
sal_Int32 nExtraColor=0;
rtl::OUString aLabel;
if(pCategories)
{
sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->getUnscaledTickValue()) - 1; //first category (index 0) matches with real number 1.0
if( nIndex>=0 && nIndex<pCategories->getLength() )
aLabel = (*pCategories)[nIndex];
}
else if( m_aAxisProperties.m_bComplexCategories )
{
aLabel = pTickInfo->aText;
}
else
aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->getUnscaledTickValue(), nExtraColor, bHasExtraColor );
if(pColorAny)
*pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor);
if(pLimitedSpaceAny)
*pLimitedSpaceAny = uno::makeAny(sal_Int32(nLimitedSpaceForText*pTickInfo->nFactorForLimitedTextWidth));
B2DVector aTickScreenPos2D( pTickInfo->aTickScreenPosition );
aTickScreenPos2D += aTextToTickDistance;
awt::Point aAnchorScreenPosition2D(
static_cast<sal_Int32>(aTickScreenPos2D.getX())
,static_cast<sal_Int32>(aTickScreenPos2D.getY()));
//create single label
if(!pTickInfo->xTextShape.is())
pTickInfo->xTextShape = createSingleLabel( m_xShapeFactory, xTarget
, aAnchorScreenPosition2D, aLabel
, rAxisLabelProperties, m_aAxisProperties
, aPropNames, aPropValues );
if(!pTickInfo->xTextShape.is())
continue;
recordMaximumTextSize( pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree );
//better rotate if single words are broken apart
if( nLimitedSpaceForText>0 && !rAxisLabelProperties.bOverlapAllowed
&& ::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 )
&& m_aAxisProperties.m_bComplexCategories
&& lcl_hasWordBreak( pTickInfo->xTextShape ) )
{
rAxisLabelProperties.fRotationAngleDegree = 90;
rAxisLabelProperties.bLineBreakAllowed = false;
m_aAxisLabelProperties.fRotationAngleDegree = rAxisLabelProperties.fRotationAngleDegree;
removeTextShapesFromTicks();
return false;
}
//if NO OVERLAP -> remove overlapping shapes
if( pLastVisibleNeighbourTickInfo && !rAxisLabelProperties.bOverlapAllowed )
{
if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, rAxisLabelProperties.fRotationAngleDegree ) )
{
bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true;
if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) )
{
bIsStaggered = true;
rAxisLabelProperties.eStaggering = STAGGER_EVEN;
pLastVisibleNeighbourTickInfo = pPREPreviousVisibleTickInfo;
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
, pTickInfo->aTickScreenPosition
, bIsHorizontalAxis, bIsVerticalAxis ) )
bOverlapAlsoAfterSwitchingOnAutoStaggering = false;
}
if( bOverlapAlsoAfterSwitchingOnAutoStaggering )
{
if( rAxisLabelProperties.bRhythmIsFix )
{
xTarget->remove(pTickInfo->xTextShape);
pTickInfo->xTextShape = NULL;
continue;
}
rAxisLabelProperties.nRhythm++;
removeShapesAtWrongRhythm( rTickIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
return false;
}
}
}
pPREPreviousVisibleTickInfo = pPreviousVisibleTickInfo;
pPreviousVisibleTickInfo = pTickInfo;
}
return true;
}
drawing::PointSequenceSequence lcl_makePointSequence( B2DVector& rStart, B2DVector& rEnd )
{
drawing::PointSequenceSequence aPoints(1);
aPoints[0].realloc(2);
aPoints[0][0].X = static_cast<sal_Int32>(rStart.getX());
aPoints[0][0].Y = static_cast<sal_Int32>(rStart.getY());
aPoints[0][1].X = static_cast<sal_Int32>(rEnd.getX());
aPoints[0][1].Y = static_cast<sal_Int32>(rEnd.getY());
return aPoints;
}
double VCartesianAxis::getLogicValueWhereMainLineCrossesOtherAxis() const
{
double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
double fCrossesOtherAxis;
if(m_aAxisProperties.m_pfMainLinePositionAtOtherAxis)
fCrossesOtherAxis = *m_aAxisProperties.m_pfMainLinePositionAtOtherAxis;
else
{
if( ::com::sun::star::chart::ChartAxisPosition_END == m_aAxisProperties.m_eCrossoverType )
fCrossesOtherAxis = fMax;
else
fCrossesOtherAxis = fMin;
}
return fCrossesOtherAxis;
}
double VCartesianAxis::getLogicValueWhereLabelLineCrossesOtherAxis() const
{
double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
double fCrossesOtherAxis;
if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == m_aAxisProperties.m_eLabelPos )
fCrossesOtherAxis = fMin;
else if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END == m_aAxisProperties.m_eLabelPos )
fCrossesOtherAxis = fMax;
else
fCrossesOtherAxis = getLogicValueWhereMainLineCrossesOtherAxis();
return fCrossesOtherAxis;
}
bool VCartesianAxis::getLogicValueWhereExtraLineCrossesOtherAxis( double& fCrossesOtherAxis ) const
{
if( !m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis )
return false;
double fMin = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMinY();
double fMax = (m_nDimensionIndex==1) ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMaxY();
if( *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis <= fMin
|| *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis >= fMax )
return false;
fCrossesOtherAxis = *m_aAxisProperties.m_pfExrtaLinePositionAtOtherAxis;
return true;
}
B2DVector VCartesianAxis::getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const
{
B2DVector aRet(0,0);
if( m_pPosHelper )
{
drawing::Position3D aScenePos = m_pPosHelper->transformLogicToScene( fLogicX, fLogicY, fLogicZ, true );
if(3==m_nDimension)
{
if( m_xLogicTarget.is() && m_pPosHelper && m_pShapeFactory )
{
tPropertyNameMap aDummyPropertyNameMap;
Reference< drawing::XShape > xShape3DAnchor = m_pShapeFactory->createCube( m_xLogicTarget
, aScenePos,drawing::Direction3D(1,1,1), 0, 0, aDummyPropertyNameMap);
awt::Point a2DPos = xShape3DAnchor->getPosition(); //get 2D position from xShape3DAnchor
m_xLogicTarget->remove(xShape3DAnchor);
aRet.setX( a2DPos.X );
aRet.setY( a2DPos.Y );
}
else
{
DBG_ERROR("cannot calculate scrren position in VCartesianAxis::getScreenPosition");
}
}
else
{
aRet.setX( aScenePos.PositionX );
aRet.setY( aScenePos.PositionY );
}
}
return aRet;
}
VCartesianAxis::ScreenPosAndLogicPos VCartesianAxis::getScreenPosAndLogicPos( double fLogicX_, double fLogicY_, double fLogicZ_ ) const
{
ScreenPosAndLogicPos aRet;
aRet.fLogicX = fLogicX_;
aRet.fLogicY = fLogicY_;
aRet.fLogicZ = fLogicZ_;
aRet.aScreenPos = getScreenPosition( fLogicX_, fLogicY_, fLogicZ_ );
return aRet;
}
typedef ::std::vector< VCartesianAxis::ScreenPosAndLogicPos > tScreenPosAndLogicPosList;
struct lcl_LessXPos : ::std::binary_function< VCartesianAxis::ScreenPosAndLogicPos, VCartesianAxis::ScreenPosAndLogicPos, bool >
{
inline bool operator() ( const VCartesianAxis::ScreenPosAndLogicPos& rPos1, const VCartesianAxis::ScreenPosAndLogicPos& rPos2 )
{
return ( rPos1.aScreenPos.getX() < rPos2.aScreenPos.getX() );
}
};
struct lcl_GreaterYPos : ::std::binary_function< VCartesianAxis::ScreenPosAndLogicPos, VCartesianAxis::ScreenPosAndLogicPos, bool >
{
inline bool operator() ( const VCartesianAxis::ScreenPosAndLogicPos& rPos1, const VCartesianAxis::ScreenPosAndLogicPos& rPos2 )
{
return ( rPos1.aScreenPos.getY() > rPos2.aScreenPos.getY() );
}
};
void VCartesianAxis::get2DAxisMainLine( B2DVector& rStart, B2DVector& rEnd, double fCrossesOtherAxis )
{
//m_aAxisProperties might get updated and changed here because
// the label alignmant and inner direction sign depends exactly of the choice of the axis line position which is made here in this method
double fMinX = m_pPosHelper->getLogicMinX();
double fMinY = m_pPosHelper->getLogicMinY();
double fMinZ = m_pPosHelper->getLogicMinZ();
double fMaxX = m_pPosHelper->getLogicMaxX();
double fMaxY = m_pPosHelper->getLogicMaxY();
double fMaxZ = m_pPosHelper->getLogicMaxZ();
double fXStart = fMinX;
double fYStart = fMinY;
double fZStart = fMinZ;
double fXEnd = fXStart;
double fYEnd = fYStart;
double fZEnd = fZStart;
double fXOnXPlane = fMinX;
double fXOther = fMaxX;
int nDifferentValue = !m_pPosHelper->isMathematicalOrientationX() ? -1 : 1;
if( !m_pPosHelper->isSwapXAndY() )
nDifferentValue *= (CuboidPlanePosition_Left != m_eLeftWallPos) ? -1 : 1;
else
nDifferentValue *= (CuboidPlanePosition_Bottom != m_eBottomPos) ? -1 : 1;
if( nDifferentValue<0 )
{
fXOnXPlane = fMaxX;
fXOther = fMinX;
}
double fYOnYPlane = fMinY;
double fYOther = fMaxY;
nDifferentValue = !m_pPosHelper->isMathematicalOrientationY() ? -1 : 1;
if( !m_pPosHelper->isSwapXAndY() )
nDifferentValue *= (CuboidPlanePosition_Bottom != m_eBottomPos) ? -1 : 1;
else
nDifferentValue *= (CuboidPlanePosition_Left != m_eLeftWallPos) ? -1 : 1;
if( nDifferentValue<0 )
{
fYOnYPlane = fMaxY;
fYOther = fMinY;
}
double fZOnZPlane = fMaxZ;
double fZOther = fMinZ;
nDifferentValue = !m_pPosHelper->isMathematicalOrientationZ() ? -1 : 1;
nDifferentValue *= (CuboidPlanePosition_Back != m_eBackWallPos) ? -1 : 1;
if( nDifferentValue<0 )
{
fZOnZPlane = fMinZ;
fZOther = fMaxZ;
}
if( 0==m_nDimensionIndex ) //x-axis
{
if( fCrossesOtherAxis < fMinY )
fCrossesOtherAxis = fMinY;
else if( fCrossesOtherAxis > fMaxY )
fCrossesOtherAxis = fMaxY;
fYStart = fYEnd = fCrossesOtherAxis;
fXEnd=m_pPosHelper->getLogicMaxX();
if(3==m_nDimension)
{
if( AxisHelper::isAxisPositioningEnabled() )
{
if( ::rtl::math::approxEqual( fYOther, fYStart) )
fZStart = fZEnd = fZOnZPlane;
else
fZStart = fZEnd = fZOther;
}
else
{
rStart = getScreenPosition( fXStart, fYStart, fZStart );
rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd );
double fDeltaX = rEnd.getX() - rStart.getX();
double fDeltaY = rEnd.getY() - rStart.getY();
//only those points are candidates which are lying on exactly one wall as these are outer edges
tScreenPosAndLogicPosList aPosList;
aPosList.push_back( getScreenPosAndLogicPos( fMinX, fYOnYPlane, fZOther ) );
aPosList.push_back( getScreenPosAndLogicPos( fMinX, fYOther, fZOnZPlane ) );
if( fabs(fDeltaY) > fabs(fDeltaX) )
{
m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
//choose most left positions
::std::sort( aPosList.begin(), aPosList.end(), lcl_LessXPos() );
m_aAxisProperties.m_fLabelDirectionSign = fDeltaY<0 ? -1 : 1;
}
else
{
m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
//choose most bottom positions
::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() );
m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
}
ScreenPosAndLogicPos aBestPos( aPosList[0] );
fYStart = fYEnd = aBestPos.fLogicY;
fZStart = fZEnd = aBestPos.fLogicZ;
if( !m_pPosHelper->isMathematicalOrientationX() )
m_aAxisProperties.m_fLabelDirectionSign *= -1;
}
}//end 3D x axis
}
else if( 1==m_nDimensionIndex ) //y-axis
{
if( fCrossesOtherAxis < fMinX )
fCrossesOtherAxis = fMinX;
else if( fCrossesOtherAxis > fMaxX )
fCrossesOtherAxis = fMaxX;
fXStart = fXEnd = fCrossesOtherAxis;
fYEnd=m_pPosHelper->getLogicMaxY();
if(3==m_nDimension)
{
if( AxisHelper::isAxisPositioningEnabled() )
{
if( ::rtl::math::approxEqual( fXOther, fXStart) )
fZStart = fZEnd = fZOnZPlane;
else
fZStart = fZEnd = fZOther;
}
else
{
rStart = getScreenPosition( fXStart, fYStart, fZStart );
rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd );
double fDeltaX = rEnd.getX() - rStart.getX();
double fDeltaY = rEnd.getY() - rStart.getY();
//only those points are candidates which are lying on exactly one wall as these are outer edges
tScreenPosAndLogicPosList aPosList;
aPosList.push_back( getScreenPosAndLogicPos( fXOnXPlane, fMinY, fZOther ) );
aPosList.push_back( getScreenPosAndLogicPos( fXOther, fMinY, fZOnZPlane ) );
if( fabs(fDeltaY) > fabs(fDeltaX) )
{
m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
//choose most left positions
::std::sort( aPosList.begin(), aPosList.end(), lcl_LessXPos() );
m_aAxisProperties.m_fLabelDirectionSign = fDeltaY<0 ? -1 : 1;
}
else
{
m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
//choose most bottom positions
::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() );
m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
}
ScreenPosAndLogicPos aBestPos( aPosList[0] );
fXStart = fXEnd = aBestPos.fLogicX;
fZStart = fZEnd = aBestPos.fLogicZ;
if( !m_pPosHelper->isMathematicalOrientationY() )
m_aAxisProperties.m_fLabelDirectionSign *= -1;
}
}//end 3D y axis
}
else //z-axis
{
fZEnd = m_pPosHelper->getLogicMaxZ();
if( AxisHelper::isAxisPositioningEnabled() )
{
if( !m_aAxisProperties.m_bSwapXAndY )
{
if( fCrossesOtherAxis < fMinY )
fCrossesOtherAxis = fMinY;
else if( fCrossesOtherAxis > fMaxY )
fCrossesOtherAxis = fMaxY;
fYStart = fYEnd = fCrossesOtherAxis;
if( ::rtl::math::approxEqual( fYOther, fYStart) )
fXStart = fXEnd = fXOnXPlane;
else
fXStart = fXEnd = fXOther;
}
else
{
if( fCrossesOtherAxis < fMinX )
fCrossesOtherAxis = fMinX;
else if( fCrossesOtherAxis > fMaxX )
fCrossesOtherAxis = fMaxX;
fXStart = fXEnd = fCrossesOtherAxis;
if( ::rtl::math::approxEqual( fXOther, fXStart) )
fYStart = fYEnd = fYOnYPlane;
else
fYStart = fYEnd = fYOther;
}
}
else
{
if( !m_pPosHelper->isSwapXAndY() )
{
fXStart = fXEnd = m_pPosHelper->isMathematicalOrientationX() ? m_pPosHelper->getLogicMaxX() : m_pPosHelper->getLogicMinX();
fYStart = fYEnd = m_pPosHelper->isMathematicalOrientationY() ? m_pPosHelper->getLogicMinY() : m_pPosHelper->getLogicMaxY();
}
else
{
fXStart = fXEnd = m_pPosHelper->isMathematicalOrientationX() ? m_pPosHelper->getLogicMinX() : m_pPosHelper->getLogicMaxX();
fYStart = fYEnd = m_pPosHelper->isMathematicalOrientationY() ? m_pPosHelper->getLogicMaxY() : m_pPosHelper->getLogicMinY();
}
if(3==m_nDimension)
{
rStart = getScreenPosition( fXStart, fYStart, fZStart );
rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd );
double fDeltaX = rEnd.getX() - rStart.getX();
//only those points are candidates which are lying on exactly one wall as these are outer edges
tScreenPosAndLogicPosList aPosList;
aPosList.push_back( getScreenPosAndLogicPos( fXOther, fYOnYPlane, fMinZ ) );
aPosList.push_back( getScreenPosAndLogicPos( fXOnXPlane, fYOther, fMinZ ) );
::std::sort( aPosList.begin(), aPosList.end(), lcl_GreaterYPos() );
ScreenPosAndLogicPos aBestPos( aPosList[0] );
ScreenPosAndLogicPos aNotSoGoodPos( aPosList[1] );
//choose most bottom positions
if( !::rtl::math::approxEqual( fDeltaX, 0.0 ) ) // prefere left-right algnments
{
if( aBestPos.aScreenPos.getX() > aNotSoGoodPos.aScreenPos.getX() )
m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_RIGHT;
else
m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_LEFT;
}
else
{
if( aBestPos.aScreenPos.getY() > aNotSoGoodPos.aScreenPos.getY() )
m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_BOTTOM;
else
m_aAxisProperties.m_aLabelAlignment = LABEL_ALIGN_TOP;
}
m_aAxisProperties.m_fLabelDirectionSign = fDeltaX<0 ? -1 : 1;
if( !m_pPosHelper->isMathematicalOrientationZ() )
m_aAxisProperties.m_fLabelDirectionSign *= -1;
fXStart = fXEnd = aBestPos.fLogicX;
fYStart = fYEnd = aBestPos.fLogicY;
}
}//end 3D z axis
}
rStart = getScreenPosition( fXStart, fYStart, fZStart );
rEnd = getScreenPosition( fXEnd, fYEnd, fZEnd );
if(3==m_nDimension && !AxisHelper::isAxisPositioningEnabled() )
m_aAxisProperties.m_fInnerDirectionSign = m_aAxisProperties.m_fLabelDirectionSign;//to behave like before
if(3==m_nDimension && AxisHelper::isAxisPositioningEnabled() )
{
double fDeltaX = rEnd.getX() - rStart.getX();
double fDeltaY = rEnd.getY() - rStart.getY();
if( 2==m_nDimensionIndex )
{
if( m_eLeftWallPos != CuboidPlanePosition_Left )
{
m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
}
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
if( ( fDeltaY<0 && m_aScale.Orientation == AxisOrientation_REVERSE ) ||
( fDeltaY>0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) )
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
}
else if( fabs(fDeltaY) > fabs(fDeltaX) )
{
if( m_eBackWallPos != CuboidPlanePosition_Back )
{
m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
}
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
if( ( fDeltaY<0 && m_aScale.Orientation == AxisOrientation_REVERSE ) ||
( fDeltaY>0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) )
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_RIGHT ) ?
LABEL_ALIGN_LEFT : LABEL_ALIGN_RIGHT;
}
else
{
if( m_eBackWallPos != CuboidPlanePosition_Back )
{
m_aAxisProperties.m_fLabelDirectionSign *= -1.0;
m_aAxisProperties.m_fInnerDirectionSign *= -1.0;
}
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_fLabelDirectionSign<0 ) ?
LABEL_ALIGN_TOP : LABEL_ALIGN_BOTTOM;
if( ( fDeltaX>0 && m_aScale.Orientation == AxisOrientation_REVERSE ) ||
( fDeltaX<0 && m_aScale.Orientation == AxisOrientation_MATHEMATICAL ) )
m_aAxisProperties.m_aLabelAlignment =
( m_aAxisProperties.m_aLabelAlignment==LABEL_ALIGN_TOP ) ?
LABEL_ALIGN_BOTTOM : LABEL_ALIGN_TOP;
}
}
}
TickFactory* VCartesianAxis::createTickFactory()
{
return createTickFactory2D();
}
TickFactory_2D* VCartesianAxis::createTickFactory2D()
{
B2DVector aStart, aEnd;
this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() );
B2DVector aLabelLineStart, aLabelLineEnd;
this->get2DAxisMainLine( aLabelLineStart, aLabelLineEnd, this->getLogicValueWhereLabelLineCrossesOtherAxis() );
return new TickFactory_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart );
}
void lcl_hideIdenticalScreenValues( TickIter& rTickIter )
{
TickInfo* pPreviousTickInfo = rTickIter.firstInfo();
if(!pPreviousTickInfo)
return;
pPreviousTickInfo->bPaintIt = true;
for( TickInfo* pTickInfo = rTickIter.nextInfo(); pTickInfo; pTickInfo = rTickIter.nextInfo())
{
pTickInfo->bPaintIt =
( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getX())
!= static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getX()) )
||
( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getY())
!= static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getY()) );
pPreviousTickInfo = pTickInfo;
}
}
//'hide' tickmarks with identical screen values in aAllTickInfos
void VCartesianAxis::hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const
{
if( isComplexCategoryAxis() || isDateAxis() )
{
sal_Int32 nCount = rTickInfos.size();
for( sal_Int32 nN=0; nN<nCount; nN++ )
{
PureTickIter aTickIter( rTickInfos[nN] );
lcl_hideIdenticalScreenValues( aTickIter );
}
}
else
{
EquidistantTickIter aTickIter( rTickInfos, m_aIncrement, 0, -1 );
lcl_hideIdenticalScreenValues( aTickIter );
}
}
sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount()
{
sal_Int32 nRet = 10;
if( m_nMaximumTextWidthSoFar==0 && m_nMaximumTextHeightSoFar==0 )
return nRet;
B2DVector aStart, aEnd;
this->get2DAxisMainLine( aStart, aEnd, this->getLogicValueWhereMainLineCrossesOtherAxis() );
sal_Int32 nMaxHeight = static_cast<sal_Int32>(fabs(aEnd.getY()-aStart.getY()));
sal_Int32 nMaxWidth = static_cast<sal_Int32>(fabs(aEnd.getX()-aStart.getX()));
sal_Int32 nTotalAvailable = nMaxHeight;
sal_Int32 nSingleNeeded = m_nMaximumTextHeightSoFar;
//for horizontal axis:
if( (m_nDimensionIndex == 0 && !m_aAxisProperties.m_bSwapXAndY)
|| (m_nDimensionIndex == 1 && m_aAxisProperties.m_bSwapXAndY) )
{
nTotalAvailable = nMaxWidth;
nSingleNeeded = m_nMaximumTextWidthSoFar;
}
if( nSingleNeeded>0 )
nRet = nTotalAvailable/nSingleNeeded;
return nRet;
}
void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties, TickFactory_2D* pTickFactory2D )
{
if( !pTickFactory2D )
return;
if( isComplexCategoryAxis() )
{
sal_Int32 nTextLevelCount = getTextLevelCount();
B2DVector aCummulatedLabelsDistance(0,0);
for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
if(apTickIter.get())
{
double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree;
if( nTextLevel>0 )
{
lcl_shiftLables( *apTickIter.get(), aCummulatedLabelsDistance );
fRotationAngleDegree = 0.0;
}
aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get()
, pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties )
, fRotationAngleDegree );
}
}
}
else if( rAxisLabelProperties.getIsStaggered() )
{
if( !m_aAllTickInfos.empty() )
{
LabelIterator aInnerIter( m_aAllTickInfos[0], rAxisLabelProperties.eStaggering, true );
LabelIterator aOuterIter( m_aAllTickInfos[0], rAxisLabelProperties.eStaggering, false );
lcl_shiftLables( aOuterIter
, lcl_getLabelsDistance( aInnerIter
, pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties ), 0.0 ) );
}
}
}
void VCartesianAxis::createLabels()
{
if( !prepareShapeCreation() )
return;
//-----------------------------------------
//create labels
if( m_aAxisProperties.m_bDisplayLabels )
{
std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
//-----------------------------------------
//get the transformed screen values for all tickmarks in aAllTickInfos
pTickFactory2D->updateScreenValues( m_aAllTickInfos );
//-----------------------------------------
//'hide' tickmarks with identical screen values in aAllTickInfos
hideIdenticalScreenValues( m_aAllTickInfos );
removeTextShapesFromTicks();
//create tick mark text shapes
sal_Int32 nTextLevelCount = getTextLevelCount();
sal_Int32 nScreenDistanceBetweenTicks = -1;
for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
if(apTickIter.get())
{
if(nTextLevel==0)
{
nScreenDistanceBetweenTicks = TickFactory_2D::getTickScreenDistance( *apTickIter.get() );
if( nTextLevelCount>1 )
nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half
}
AxisLabelProperties aComplexProps(m_aAxisLabelProperties);
if( m_aAxisProperties.m_bComplexCategories )
{
if( nTextLevel==0 )
{
aComplexProps.bLineBreakAllowed = true;
aComplexProps.bOverlapAllowed = !::rtl::math::approxEqual( aComplexProps.fRotationAngleDegree, 0.0 );
}
else
{
aComplexProps.bOverlapAllowed = true;
aComplexProps.bRhythmIsFix = true;
aComplexProps.nRhythm = 1;
aComplexProps.fRotationAngleDegree = 0.0;
}
}
AxisLabelProperties& rAxisLabelProperties = m_aAxisProperties.m_bComplexCategories ? aComplexProps : m_aAxisLabelProperties;
while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickFactory2D, nScreenDistanceBetweenTicks ) )
{
};
}
}
doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D );
}
}
void VCartesianAxis::createMaximumLabels()
{
TrueGuard aRecordMaximumTextSize(m_bRecordMaximumTextSize);
if( !prepareShapeCreation() )
return;
//-----------------------------------------
//create labels
if( m_aAxisProperties.m_bDisplayLabels )
{
std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
//-----------------------------------------
//get the transformed screen values for all tickmarks in aAllTickInfos
pTickFactory2D->updateScreenValues( m_aAllTickInfos );
//create tick mark text shapes
//@todo: iterate through all tick depth which should be labeled
AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickFactory2D->isHorizontalAxis(), pTickFactory2D->isVerticalAxis() ) )
aAxisLabelProperties.eStaggering = STAGGER_EVEN;
aAxisLabelProperties.bOverlapAllowed = true;
aAxisLabelProperties.bLineBreakAllowed = false;
sal_Int32 nTextLevelCount = getTextLevelCount();
for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
::std::auto_ptr< TickIter > apTickIter = createMaximumLabelTickIterator( nTextLevel );
if(apTickIter.get())
{
while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickFactory2D, -1 ) )
{
};
}
}
doStaggeringOfLabels( aAxisLabelProperties, pTickFactory2D );
}
}
void VCartesianAxis::updatePositions()
{
//-----------------------------------------
//update positions of labels
if( m_aAxisProperties.m_bDisplayLabels )
{
std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
//-----------------------------------------
//update positions of all existing text shapes
pTickFactory2D->updateScreenValues( m_aAllTickInfos );
::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin();
const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end();
for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd; aDepthIter++, nDepth++ )
{
::std::vector< TickInfo >::iterator aTickIter = aDepthIter->begin();
const ::std::vector< TickInfo >::const_iterator aTickEnd = aDepthIter->end();
for( ; aTickIter != aTickEnd; aTickIter++ )
{
TickInfo& rTickInfo = (*aTickIter);
Reference< drawing::XShape > xShape2DText( rTickInfo.xTextShape );
if( xShape2DText.is() )
{
B2DVector aTextToTickDistance( pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, true ) );
B2DVector aTickScreenPos2D( rTickInfo.aTickScreenPosition );
aTickScreenPos2D += aTextToTickDistance;
awt::Point aAnchorScreenPosition2D(
static_cast<sal_Int32>(aTickScreenPos2D.getX())
,static_cast<sal_Int32>(aTickScreenPos2D.getY()));
double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree;
if( nDepth>0 )
fRotationAngleDegree = 0.0;
// #i78696# use mathematically correct rotation now
const double fRotationAnglePi(fRotationAngleDegree * (F_PI / -180.0));
uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi);
//set new position
uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY );
if( xProp.is() )
{
try
{
xProp->setPropertyValue( C2U( "Transformation" ), aATransformation );
}
catch( uno::Exception& e )
{
ASSERT_EXCEPTION( e );
}
}
//correctPositionForRotation
LabelPositionHelper::correctPositionForRotation( xShape2DText
, m_aAxisProperties.m_aLabelAlignment, fRotationAngleDegree, m_aAxisProperties.m_bComplexCategories );
}
}
}
doStaggeringOfLabels( m_aAxisLabelProperties, pTickFactory2D );
}
}
void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickFactory_2D& rTickFactory2D, bool bOnlyAtLabels )
{
sal_Int32 nPointCount = rTickInfos.size();
drawing::PointSequenceSequence aPoints(2*nPointCount);
::std::vector< TickInfo >::const_iterator aTickIter = rTickInfos.begin();
const ::std::vector< TickInfo >::const_iterator aTickEnd = rTickInfos.end();
sal_Int32 nN = 0;
for( ; aTickIter != aTickEnd; aTickIter++ )
{
if( !(*aTickIter).bPaintIt )
continue;
bool bTicksAtLabels = ( m_aAxisProperties.m_eTickmarkPos != ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS );
double fInnerDirectionSign = m_aAxisProperties.m_fInnerDirectionSign;
if( bTicksAtLabels && m_aAxisProperties.m_eLabelPos == ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END )
fInnerDirectionSign *= -1.0;
bTicksAtLabels = bTicksAtLabels || bOnlyAtLabels;
//add ticks at labels:
rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
, fInnerDirectionSign , rTickmarkProperties, bTicksAtLabels );
//add ticks at axis (without lables):
if( !bOnlyAtLabels && m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
rTickFactory2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
, m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels );
}
aPoints.realloc(nN);
m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints
, &rTickmarkProperties.aLineProperties );
}
void VCartesianAxis::createShapes()
{
if( !prepareShapeCreation() )
return;
std::auto_ptr< TickFactory_2D > apTickFactory2D( this->createTickFactory2D() );
TickFactory_2D* pTickFactory2D = apTickFactory2D.get();
if( !pTickFactory2D )
return;
//-----------------------------------------
//create line shapes
if(2==m_nDimension)
{
//-----------------------------------------
//create extra long ticks to separate complex categories (create them only there where the labels are)
if( isComplexCategoryAxis() )
{
::std::vector< ::std::vector< TickInfo > > aComplexTickInfos;
createAllTickInfosFromComplexCategories( aComplexTickInfos, true );
pTickFactory2D->updateScreenValues( aComplexTickInfos );
hideIdenticalScreenValues( aComplexTickInfos );
::std::vector<TickmarkProperties> aTickmarkPropertiesList;
static bool bIncludeSpaceBetweenTickAndText = false;
sal_Int32 nOffset = static_cast<sal_Int32>(pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false, bIncludeSpaceBetweenTickAndText ).getLength());
sal_Int32 nTextLevelCount = getTextLevelCount();
for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
if( apTickIter.get() )
{
double fRotationAngleDegree = m_aAxisLabelProperties.fRotationAngleDegree;
if( nTextLevel>0 )
fRotationAngleDegree = 0.0;
B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickFactory2D->getDistanceAxisTickToText( m_aAxisProperties, false ), fRotationAngleDegree ) );
sal_Int32 nCurrentLength = static_cast<sal_Int32>(aLabelsDistance.getLength());
aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) );
nOffset += nCurrentLength;
}
}
sal_Int32 nTickmarkPropertiesCount = aTickmarkPropertiesList.size();
::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = aComplexTickInfos.begin();
const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = aComplexTickInfos.end();
for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ )
{
if(nDepth==0 && !m_aAxisProperties.m_nMajorTickmarks)
continue;
createTickMarkLineShapes( *aDepthIter, aTickmarkPropertiesList[nDepth], *pTickFactory2D, true /*bOnlyAtLabels*/ );
}
}
//-----------------------------------------
//create normal ticks for major and minor intervals
{
::std::vector< ::std::vector< TickInfo > > aUnshiftedTickInfos;
if( m_aScale.ShiftedCategoryPosition )// if ShiftedCategoryPosition==true the tickmarks in m_aAllTickInfos are shifted
{
pTickFactory2D->getAllTicks( aUnshiftedTickInfos );
pTickFactory2D->updateScreenValues( aUnshiftedTickInfos );
hideIdenticalScreenValues( aUnshiftedTickInfos );
}
::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aScale.ShiftedCategoryPosition ? aUnshiftedTickInfos : m_aAllTickInfos;
::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin();
const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end();
if(aDepthIter == aDepthEnd)//no tickmarks at all
return;
sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size();
for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ )
createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickFactory2D, false /*bOnlyAtLabels*/ );
}
//-----------------------------------------
//create axis main lines
//it serves also as the handle shape for the axis selection
{
drawing::PointSequenceSequence aPoints(1);
apTickFactory2D->createPointSequenceForAxisMainLine( aPoints );
Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
m_xGroupShape_Shapes, aPoints
, &m_aAxisProperties.m_aLineProperties );
//because of this name this line will be used for marking the axis
m_pShapeFactory->setShapeName( xShape, C2U("MarkHandles") );
}
//-----------------------------------------
//create an additional line at NULL
if( !AxisHelper::isAxisPositioningEnabled() )
{
double fExtraLineCrossesOtherAxis;
if( getLogicValueWhereExtraLineCrossesOtherAxis(fExtraLineCrossesOtherAxis) )
{
B2DVector aStart, aEnd;
this->get2DAxisMainLine( aStart, aEnd, fExtraLineCrossesOtherAxis );
drawing::PointSequenceSequence aPoints( lcl_makePointSequence(aStart,aEnd) );
Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties );
}
}
}
//createLabels();
}
//.............................................................................
} //namespace chart
//.............................................................................
| 41.668065 | 185 | 0.611627 | [
"shape",
"vector",
"3d"
] |
7b589dff689dc8d2b32858d5dc290345b499cb5c | 2,083 | cpp | C++ | codes/HDU/hdu3065.cpp | JeraKrs/ACM | edcd61ec6764b8cd804bf1538dfde53d0ff572b5 | [
"Apache-2.0"
] | null | null | null | codes/HDU/hdu3065.cpp | JeraKrs/ACM | edcd61ec6764b8cd804bf1538dfde53d0ff572b5 | [
"Apache-2.0"
] | null | null | null | codes/HDU/hdu3065.cpp | JeraKrs/ACM | edcd61ec6764b8cd804bf1538dfde53d0ff572b5 | [
"Apache-2.0"
] | null | null | null | #include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 50005;
const int sigma_size = 256;
struct Aho_Corasick {
int sz, g[maxn][sigma_size];
int tag[maxn], fail[maxn], last[maxn];
int cnt[1005];
void init();
int idx(char ch);
void insert(char* str, int k);
void getFail();
void match(char* str);
void put(int u);
}A;
int N;
char s[1005][55], str[2000005];
int main () {
while (scanf("%d", &N) == 1) {
A.init();
for (int i = 1; i <= N; i++) {
scanf("%s", s[i]);
A.insert(s[i], i);
}
A.getFail();
scanf("%s", str);
A.match(str);
for (int i = 1; i <= N; i++)
if (A.cnt[i])
printf("%s: %d\n", s[i], A.cnt[i]);
}
return 0;
}
void Aho_Corasick::init() {
sz = 1;
tag[0] = 0;
memset(g[0], 0, sizeof(g[0]));
}
int Aho_Corasick::idx(char ch) {
return ch;
}
void Aho_Corasick::put(int u) {
cnt[tag[u]]++;
if (last[u])
put(last[u]);
}
void Aho_Corasick::insert(char* str, int k) {
int u = 0, n = strlen(str);
for (int i = 0; i < n; i++) {
int v = idx(str[i]);
if (g[u][v] == 0) {
tag[sz] = 0;
memset(g[sz], 0, sizeof(g[sz]));
g[u][v] = sz++;
}
u = g[u][v];
}
tag[u] = k;
}
void Aho_Corasick::match(char* str) {
memset(cnt, 0, sizeof(cnt));
int n = strlen(str), u = 0;
for (int i = 0; i < n; i++) {
int v = idx(str[i]);
while (u && g[u][v] == 0)
u = fail[u];
u = g[u][v];
if (tag[u])
put(u);
else if (last[u])
put(last[u]);
}
}
void Aho_Corasick::getFail() {
queue<int> que;
for (int i = 0; i < sigma_size; i++) {
int u = g[0][i];
if (u) {
fail[u] = last[u] = 0;
que.push(u);
}
}
while (!que.empty()) {
int r = que.front();
que.pop();
for (int i = 0; i < sigma_size; i++) {
int u = g[r][i];
if (u == 0) {
g[r][i] = g[fail[r]][i];
continue;
}
que.push(u);
int v = fail[r];
while (v && g[v][i] == 0)
v = fail[v];
fail[u] = g[v][i];
last[u] = tag[fail[u]] ? fail[u] : last[fail[u]];
}
}
}
| 15.900763 | 52 | 0.506961 | [
"vector"
] |
7b5da6e840236876c2bd123bd754a70b8f055cf7 | 5,010 | hpp | C++ | PSME/application/tests/rest/model/handler/mocks.hpp | opencomputeproject/HWMgmt-DeviceMgr-PSME | 2a00188aab6f4bef3776987f0842ef8a8ea972ac | [
"Apache-2.0"
] | 5 | 2021-10-07T15:36:37.000Z | 2022-03-01T07:21:49.000Z | PSME/application/tests/rest/model/handler/mocks.hpp | opencomputeproject/HWMgmt-DeviceMgr-PSME | 2a00188aab6f4bef3776987f0842ef8a8ea972ac | [
"Apache-2.0"
] | null | null | null | PSME/application/tests/rest/model/handler/mocks.hpp | opencomputeproject/HWMgmt-DeviceMgr-PSME | 2a00188aab6f4bef3776987f0842ef8a8ea972ac | [
"Apache-2.0"
] | 1 | 2022-03-01T07:21:51.000Z | 2022-03-01T07:21:51.000Z | /*!
* @copyright
* Copyright (c) 2015-2017 Intel Corporation
*
* @copyright
* 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
*
* @copyright
* http://www.apache.org/licenses/LICENSE-2.0
*
* @copyright
* 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 mocks.hpp
* @brief Mocks of objects utilized by GenericHandler object.
* Mocks must proceed inclusion of generic_handler.hpp
* */
#pragma once
#include "psme/rest/eventing/event.hpp"
#include "psme/core/agent/agent_unreachable.hpp"
#include "agent-framework/module/requests/common/get_managers_collection.hpp"
#include "agent-framework/module/requests/common/get_tasks_collection.hpp"
#include "agent-framework/module/requests/common/get_collection.hpp"
#include <jsonrpccpp/client/connectors/httpclient.h>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <assert.h>
#define PSME_CORE_AGENT_JSON_AGENT_HPP
#define PSME_AGENT_MANAGER_HPP
namespace agent_framework {
namespace model {
namespace requests {
class GetManagersCollection;
}
}
}
namespace psme {
namespace core {
namespace agent {
struct JsonAgent {
template<typename Response, typename Request>
Response execute(const Request &req) {
m_requests.push_back(req.get_uuid());
assert(m_responses.size() > m_rsp_idx);
Json::Value rr;
auto response_s = m_responses[m_rsp_idx++];
if (response_s == "[JsonRpcException]") {
throw psme::core::agent::AgentUnreachable(get_gami_id());
}
std::stringstream ss(response_s);
ss >> rr;
return Response::from_json(rr);
}
template<typename Response>
Response execute(const agent_framework::model::requests::GetManagersCollection&) {
m_requests.push_back("GetManagersCollection");
assert(m_responses.size() > m_rsp_idx);
Json::Value rr;
std::stringstream ss(m_responses[m_rsp_idx++]);
ss >> rr;
return Response::from_json(rr);
}
template<typename Response>
Response execute(const agent_framework::model::requests::GetTasksCollection&) {
m_requests.push_back("GetManagersCollection");
assert(m_responses.size() > m_rsp_idx);
Json::Value rr;
std::stringstream ss(m_responses[m_rsp_idx++]);
ss >> rr;
return Response::from_json(rr);
}
template<typename Response>
Response execute(
const agent_framework::model::requests::GetCollection& req) {
m_requests.push_back(req.get_uuid());
m_collections.push_back(
std::make_pair(req.get_name(), req.get_uuid()));
assert(m_responses.size() > m_rsp_idx);
Json::Value rr;
std::stringstream ss(m_responses[m_rsp_idx++]);
ss >> rr;
return Response::from_json(rr);
}
const std::string get_gami_id() const { return "gami_id"; }
void clear() {
m_requests.clear();
m_rsp_idx = 0;
m_responses.clear();
m_collections.clear();
}
std::vector<std::pair<std::string, std::string>> m_collections{};
std::vector<std::string> m_requests{};
std::vector<std::string> m_responses{};
size_t m_rsp_idx{0};
};
typedef std::shared_ptr<JsonAgent> JsonAgentSPtr;
struct AgentManager {
static AgentManager &get_instance() {
static AgentManager am;
return am;
}
JsonAgentSPtr get_agent(const std::string& /*gami_id*/) {
if(!m_agent) {
m_agent = std::make_shared<JsonAgent>();
}
return m_agent;
}
void remove_agent(const std::string & /*gami_id*/) {
if(m_agent) {
m_agent.reset();
}
}
JsonAgentSPtr m_agent { new JsonAgent() };
};
}
}
namespace rest {
namespace eventing {
namespace manager {
/*!
* SubscriptionManager mock implementation
*/
class SubscriptionManager {
public:
/*!
* @brief Returns instance of singleton
*/
static SubscriptionManager* get_instance() {
static SubscriptionManager m;
return &m;
}
/*!
* @brief Notifies subscribers according to event
*
* @param event Event
*/
void notify(const psme::rest::eventing::Event& event) {
m_events.emplace_back(event);
}
void notify(const psme::rest::eventing::EventVec& events) {
m_events.reserve(m_events.size() + events.size());
m_events.insert(m_events.end(), events.begin(), events.end());
}
void clear() {
m_events.clear();
}
psme::rest::eventing::EventVec m_events {};
};
}
}
}
}
| 25.05 | 86 | 0.658882 | [
"object",
"vector",
"model"
] |
7b628e39cebd20d709698428dfe1fe6ed33050e5 | 2,133 | cpp | C++ | partialmodel_hrt/test_multires_octree.cpp | irvingvasquez/vpl | 1a6e88353395ca0e43a0c4d0d6b38f7c7e2925f7 | [
"BSD-3-Clause"
] | 12 | 2017-05-11T13:07:20.000Z | 2021-11-22T15:48:10.000Z | partialmodel_hrt/test_multires_octree.cpp | irvingvasquez/vpl | 1a6e88353395ca0e43a0c4d0d6b38f7c7e2925f7 | [
"BSD-3-Clause"
] | 1 | 2017-11-19T21:29:51.000Z | 2017-11-19T21:29:51.000Z | partialmodel_hrt/test_multires_octree.cpp | irvingvasquez/vpl | 1a6e88353395ca0e43a0c4d0d6b38f7c7e2925f7 | [
"BSD-3-Clause"
] | 5 | 2017-05-11T07:57:01.000Z | 2021-11-22T16:44:37.000Z | #include <iostream>
#include <string>
//#include <stdio.h>
#include <octomap/octomap.h>
#include <octomap/math/Utils.h>
#include "coctreevpl.h"
using namespace std;
using namespace octomap;
int main(int argc, char **argv) {
//##############################################################
COctreeVPL tree (0.02);
point3d origin (0.01f, 0.01f, 0.02f);
point3d point_on_surface (1.01f, 0.01f, 0.01f);
std::cout << "generating spherical scan at " << origin << " ..." << std::endl;
Pointcloud cloud;
for (int i=-50; i<51; i++) {
for (int j=-50; j<51; j++) {
point3d rotated = point_on_surface;
rotated.rotate_IP(0, DEG2RAD(i*0.5), DEG2RAD(j*0.5));
cloud.push_back(rotated);
}
}
// insert in global coordinates:
tree.insertScan(cloud, origin);
// insert free space;
point3d p1(-1,-1,-1);
//point3d p1()
KeyRay rr1;
std::vector<point3d> v1;
KeyRay rr2;
std::vector<point3d> v2;
tree.computeRay(origin, point_on_surface, v1);
tree.setResolution(tree.getResolution()*4);
tree.computeRay(origin,point_on_surface, v2);
std::cout << "v1 size: " << v1.size() << std::endl;
std::cout << "v2 size: " << v2.size() << std::endl;
point3d fin;
tree.expand();
switch( tree.castRayVPLHierarchical(origin, point_on_surface, fin, false, -1.0, tree.getTreeDepth()-2)){
case VXL_OCCUPIED:
std::cout << "occupied" << std::endl;
break;
case VXL_UNKNOWN:
std::cout << "Unknown" << std::endl;
break;
case VXL_OCCUPIED_TOUCHED:
std::cout << "occupied touched" << std::endl;
break;
}
switch( tree.castRayVPLHierarchical(origin, point_on_surface, fin, false, -1.0, tree.getTreeDepth()-2)){
case VXL_OCCUPIED:
std::cout << "occupied" << std::endl;
break;
case VXL_UNKNOWN:
std::cout << "Unknown" << std::endl;
break;
case VXL_OCCUPIED_TOUCHED:
std::cout << "occupied touched" << std::endl;
break;
}
std::cout << "writing to spherical_scan.bt..." << std::endl;
tree.writeBinary("spherical_scan.bt");
return 0;
}
| 23.966292 | 108 | 0.591655 | [
"vector"
] |
7b6516f4d9d2b6bba28d7aa57befbc5ffb4d9519 | 409 | hpp | C++ | leetcode/2157/graph.hpp | mkmark/leetcode | 638a9d37fb3223107d2852ce493d831996a7649e | [
"MIT"
] | null | null | null | leetcode/2157/graph.hpp | mkmark/leetcode | 638a9d37fb3223107d2852ce493d831996a7649e | [
"MIT"
] | null | null | null | leetcode/2157/graph.hpp | mkmark/leetcode | 638a9d37fb3223107d2852ce493d831996a7649e | [
"MIT"
] | null | null | null | /*
author: mark@mkmark.net
*/
#include <bits/stdc++.h>
using namespace std;
class graph {
int n;
vector<vector<int>> adj;
vector<int> grp;
vector<int> grp_size;
vector<int> value;
void dfs(int v, vector<int>& grp, int gid);
public:
graph(int n);
graph(int n, vector<int>& val);
int grp_cnt;
int max_grp_size();
void add_edge(int i, int j);
void group();
};
| 17.041667 | 47 | 0.601467 | [
"vector"
] |
7b6552265ba2100c650b2e37a6a4621bf625259f | 1,458 | hpp | C++ | src/SegmentTree.hpp | rajyan/library | abad203321e34b87a248e02f5ae84a0899f6c4fd | [
"MIT"
] | null | null | null | src/SegmentTree.hpp | rajyan/library | abad203321e34b87a248e02f5ae84a0899f6c4fd | [
"MIT"
] | 8 | 2019-08-18T18:23:37.000Z | 2021-01-21T00:20:00.000Z | src/SegmentTree.hpp | rajyan/library | abad203321e34b87a248e02f5ae84a0899f6c4fd | [
"MIT"
] | null | null | null | #pragma once
#include <cassert>
#include <vector>
#include "Monoid.hpp"
#include "clz.hpp"
using namespace std;
template<class M>
class SegmentTree {
using T = typename M::type;
using vt = typename M::vt;
public:
explicit SegmentTree(const int &n_)
: n(n_), lg(64 - clz(n)), sz(1 << lg),
d(2 * sz, m.identity()) {
}
explicit SegmentTree(const vector<T> &v)
: n((int)v.size()), lg(64 - clz(n)), sz(1 << lg),
d(2 * sz, m.identity()) {
for (int i = 0; i < n; i++) d[sz + i] = v[i];
for (int i = sz - 1; i >= 0; i--) update(i);
}
void set(int k, const vt &x) {
assert(0 <= k && k < n);
k += sz, d[k] = x;
for (int i = 1; i <= lg; i++) update(k >> i);
}
void add(const int &k, const vt &x) { set(k, m.op(d[k + sz], x)); }
[[nodiscard]] vt sum(int l, int r) const {
assert(l <= r);
vt sml = m.identity(), smr = m.identity();
l += sz, r += sz;
while (l < r) {
if (l & 1) sml = m.op(sml, d[l++]);
if (r & 1) smr = m.op(d[--r], smr);
l >>= 1;
r >>= 1;
}
return m.op(sml, smr);
}
[[nodiscard]] vt operator[](const int &k) const {
assert(0 <= k && k < n);
return d[k + sz];
}
private:
M m;
int n, lg, sz;
vector<vt> d;
void update(const int &k) { d[k] = m.op(d[2 * k], d[2 * k + 1]); }
};
| 25.137931 | 71 | 0.440329 | [
"vector"
] |
7b65fc13c672babcfe0f69e3e081bc6761b08624 | 23,300 | cpp | C++ | Code/Tools/FBuild/FBuildCore/Protocol/Server.cpp | qq573011406/FASTBuild_UnrealEngine | 29c49672f82173a903cb32f0e4656e2fd07ebef2 | [
"MIT"
] | 30 | 2020-07-15T06:16:55.000Z | 2022-02-10T21:37:52.000Z | Code/Tools/FBuild/FBuildCore/Protocol/Server.cpp | qq573011406/FASTBuild_UnrealEngine | 29c49672f82173a903cb32f0e4656e2fd07ebef2 | [
"MIT"
] | 1 | 2020-10-19T22:12:03.000Z | 2020-10-19T22:12:03.000Z | Code/Tools/FBuild/FBuildCore/Protocol/Server.cpp | qq573011406/FASTBuild_UnrealEngine | 29c49672f82173a903cb32f0e4656e2fd07ebef2 | [
"MIT"
] | 12 | 2020-09-16T17:39:34.000Z | 2021-08-17T11:32:37.000Z | // Server.cpp
//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include "Server.h"
#include "Protocol.h"
#include "Tools/FBuild/FBuildCore/FLog.h"
#include "Tools/FBuild/FBuildCore/Helpers/ToolManifest.h"
#include "Tools/FBuild/FBuildCore/WorkerPool/Job.h"
#include "Tools/FBuild/FBuildCore/WorkerPool/JobQueueRemote.h"
#include "Tools/FBuild/FBuildCore/WorkerPool/WorkerThreadRemote.h"
#include "Core/Env/Env.h"
#include "Core/FileIO/ConstMemoryStream.h"
#include "Core/FileIO/MemoryStream.h"
#include "Core/Process/Atomic.h"
#include "Core/Profile/Profile.h"
#include "Core/Strings/AStackString.h"
// Defines
//------------------------------------------------------------------------------
#if defined( __OSX__ ) || defined( __LINUX__ )
// Touch files every 4 hours
#define SERVER_TOOLCHAIN_TIMESTAMP_REFRESH_INTERVAL_SECS (60.0f * 60.0f * 4.0f)
#endif
// CONSTRUCTOR
//------------------------------------------------------------------------------
Server::Server( uint32_t numThreadsInJobQueue )
: m_ShouldExit( false )
, m_ClientList( 32, true )
{
m_JobQueueRemote = FNEW( JobQueueRemote( numThreadsInJobQueue ? numThreadsInJobQueue : Env::GetNumProcessors() ) );
m_Thread = Thread::CreateThread( ThreadFuncStatic,
"Server",
( 64 * KILOBYTE ),
this );
ASSERT( m_Thread );
}
// DESTRUCTOR
//------------------------------------------------------------------------------
Server::~Server()
{
AtomicStoreRelaxed( &m_ShouldExit, true );
JobQueueRemote::Get().WakeMainThread();
Thread::WaitForThread( m_Thread );
ShutdownAllConnections();
Thread::CloseHandle( m_Thread );
FDELETE m_JobQueueRemote;
const ToolManifest * const * end = m_Tools.End();
for ( ToolManifest ** it = m_Tools.Begin(); it != end; ++it )
{
FDELETE *it;
}
}
// GetHostForJob
//------------------------------------------------------------------------------
/*static*/ void Server::GetHostForJob( const Job * job, AString & hostName )
{
const ClientState * cs = (const ClientState *)job->GetUserData();
if ( cs )
{
hostName = cs->m_HostName;
}
else
{
hostName.Clear();
}
}
// IsSynchingTool
//------------------------------------------------------------------------------
bool Server::IsSynchingTool( AString & statusStr ) const
{
MutexHolder manifestMH( m_ToolManifestsMutex ); // ensure we don't make redundant requests
const ToolManifest * const * end = m_Tools.End();
ToolManifest ** it = m_Tools.Begin();
while ( it != end )
{
if ( ( *it )->IsSynchronized() == false )
{
uint32_t synchDone;
uint32_t synchTotal;
bool synching = ( *it )->GetSynchronizationStatus( synchDone, synchTotal );
if ( synching )
{
statusStr.Format( "Synchronizing Compiler %2.1f / %2.1f MiB\n",
(double)( (float)synchDone / (float)MEGABYTE ),
(double)( (float)synchTotal / (float)MEGABYTE ) );
return true;
}
}
++it;
}
return false; // no toolchain is currently synching
}
// OnConnected
//------------------------------------------------------------------------------
/*virtual*/ void Server::OnConnected( const ConnectionInfo * connection )
{
ClientState * cs = FNEW( ClientState( connection ) );
connection->SetUserData( cs );
MutexHolder mh( m_ClientListMutex );
m_ClientList.Append( cs );
}
//------------------------------------------------------------------------------
/*virtual*/ void Server::OnDisconnected( const ConnectionInfo * connection )
{
ASSERT( connection );
ClientState * cs = (ClientState *)connection->GetUserData();
ASSERT( cs );
// Unhook any jobs which are queued or in progress for this client
// - deletes the queued jobs
// - unhooks the UserData for in-progress jobs so the result is discarded on completion
JobQueueRemote & jqr = JobQueueRemote::Get();
jqr.CancelJobsWithUserData( cs );
// check if any tool chain was being sync'd from this Client
Array< ToolManifest * > cancelledManifests( 0, true );
{
MutexHolder manifestMH( m_ToolManifestsMutex );
const ToolManifest * const * end = m_Tools.End();
ToolManifest ** it = m_Tools.Begin();
while ( it != end )
{
// if synchronizing from connection that was just disconnected...
ToolManifest * tm = *it;
if ( ( tm->IsSynchronized() == false ) &&
( tm->GetUserData() == connection ) )
{
// ...flag any expected files as not synching
tm->CancelSynchronizingFiles();
tm->SetUserData( nullptr );
cancelledManifests.Append( tm );
}
++it;
}
}
// free the serverstate structure
MutexHolder mh( m_ClientListMutex );
ClientState ** iter = m_ClientList.Find( cs );
ASSERT( iter );
m_ClientList.Erase( iter );
// because we cancelled manifest syncrhonization, we need to check if other
// connections are waiting for the same manifest
{
ClientState ** it = m_ClientList.Begin();
const ClientState * const * end = m_ClientList.End();
for ( ; it != end; ++it )
{
ClientState * otherCS = *it;
MutexHolder mh2( otherCS->m_Mutex );
const Job * const * jEnd = otherCS->m_WaitingJobs.End();
for ( Job ** jIt = otherCS->m_WaitingJobs.Begin(); jIt != jEnd; ++jIt )
{
Job * j = *jIt;
ToolManifest * jMan = j->GetToolManifest();
if ( cancelledManifests.Find( jMan ) )
{
RequestMissingFiles( otherCS->m_Connection, jMan );
}
}
}
}
// This is usually null here, but might need to be freed if
// we had the connection drop between message and payload
FREE( (void *)( cs->m_CurrentMessage ) );
// delete any jobs where we were waiting on Tool synchronization
const Job * const * end = cs->m_WaitingJobs.End();
for ( Job ** it=cs->m_WaitingJobs.Begin(); it!=end; ++it )
{
delete *it;
}
FDELETE cs;
}
// OnReceive
//------------------------------------------------------------------------------
/*virtual*/ void Server::OnReceive( const ConnectionInfo * connection, void * data, uint32_t size, bool & keepMemory )
{
keepMemory = true; // we'll take care of freeing the memory
ClientState * cs = (ClientState *)connection->GetUserData();
ASSERT( cs );
// are we expecting a msg, or the payload for a msg?
void * payload = nullptr;
size_t payloadSize = 0;
if ( cs->m_CurrentMessage == nullptr )
{
// message
cs->m_CurrentMessage = static_cast< const Protocol::IMessage * >( data );
if ( cs->m_CurrentMessage->HasPayload() )
{
return;
}
}
else
{
// payload
ASSERT( cs->m_CurrentMessage->HasPayload() );
payload = data;
payloadSize = size;
}
// determine message type
const Protocol::IMessage * imsg = cs->m_CurrentMessage;
Protocol::MessageType messageType = imsg->GetType();
PROTOCOL_DEBUG( "Client -> Server : %u (%s)\n", messageType, GetProtocolMessageDebugName( messageType ) );
switch ( messageType )
{
case Protocol::MSG_CONNECTION:
{
const Protocol::MsgConnection * msg = static_cast< const Protocol::MsgConnection * >( imsg );
Process( connection, msg );
break;
}
case Protocol::MSG_STATUS:
{
const Protocol::MsgStatus * msg = static_cast< const Protocol::MsgStatus * >( imsg );
Process( connection, msg );
break;
}
case Protocol::MSG_NO_JOB_AVAILABLE:
{
const Protocol::MsgNoJobAvailable * msg = static_cast< const Protocol::MsgNoJobAvailable * >( imsg );
Process( connection, msg );
break;
}
case Protocol::MSG_JOB:
{
const Protocol::MsgJob * msg = static_cast< const Protocol::MsgJob * >( imsg );
Process( connection, msg, payload, payloadSize );
break;
}
case Protocol::MSG_MANIFEST:
{
const Protocol::MsgManifest * msg = static_cast< const Protocol::MsgManifest * >( imsg );
Process( connection, msg, payload, payloadSize );
break;
}
case Protocol::MSG_FILE:
{
const Protocol::MsgFile * msg = static_cast< const Protocol::MsgFile * >( imsg );
Process( connection, msg, payload, payloadSize );
break;
}
default:
{
// unknown message type
ASSERT( false ); // this indicates a protocol bug
Disconnect( connection );
break;
}
}
// free everything
FREE( (void *)( cs->m_CurrentMessage ) );
FREE( payload );
cs->m_CurrentMessage = nullptr;
}
// Process( MsgConnection )
//------------------------------------------------------------------------------
void Server::Process( const ConnectionInfo * connection, const Protocol::MsgConnection * msg )
{
// check for valid/supported protocol version
if ( msg->GetProtocolVersion() != Protocol::PROTOCOL_VERSION )
{
AStackString<> remoteAddr;
TCPConnectionPool::GetAddressAsString( connection->GetRemoteAddress(), remoteAddr );
FLOG_WARN( "Disconnecting '%s' due to bad protocol version\n", remoteAddr.Get() );
Disconnect( connection );
return;
}
// Check for matching platform
if (msg->GetPlatform() != Env::GetPlatform())
{
AStackString<> remoteAddr;
TCPConnectionPool::GetAddressAsString( connection->GetRemoteAddress(), remoteAddr );
FLOG_WARN( "Disconnecting '%s' (%s) due to mismatched platform\n", remoteAddr.Get(), msg->GetHostName() );
Disconnect( connection );
return;
}
// take note of initial status of client
ClientState * cs = (ClientState *)connection->GetUserData();
MutexHolder mh( cs->m_Mutex );
cs->m_NumJobsAvailable = msg->GetNumJobsAvailable();
cs->m_HostName = msg->GetHostName();
}
// Process( MsgStatus )
//------------------------------------------------------------------------------
void Server::Process( const ConnectionInfo * connection, const Protocol::MsgStatus * msg )
{
// take note of latest status of client
ClientState * cs = (ClientState *)connection->GetUserData();
MutexHolder mh( cs->m_Mutex );
cs->m_NumJobsAvailable = msg->GetNumJobsAvailable();
// Wake main thread to request jobs
JobQueueRemote::Get().WakeMainThread();
}
// Process( MsgNoJobAvailable )
//------------------------------------------------------------------------------
void Server::Process( const ConnectionInfo * connection, const Protocol::MsgNoJobAvailable * )
{
// We requested a job, but the client didn't have any left
ClientState * cs = (ClientState *)connection->GetUserData();
MutexHolder mh( cs->m_Mutex );
ASSERT( cs->m_NumJobsRequested > 0 );
cs->m_NumJobsRequested--;
}
// Process( MsgJob )
//------------------------------------------------------------------------------
void Server::Process( const ConnectionInfo * connection, const Protocol::MsgJob * msg, const void * payload, size_t payloadSize )
{
ClientState * cs = (ClientState *)connection->GetUserData();
MutexHolder mh( cs->m_Mutex );
ASSERT( cs->m_NumJobsRequested > 0 );
cs->m_NumJobsRequested--;
cs->m_NumJobsActive++;
// deserialize job
ConstMemoryStream ms( payload, payloadSize );
Job * job = FNEW( Job( ms ) );
job->SetUserData( cs );
//
const uint64_t toolId = msg->GetToolId();
ASSERT( toolId );
MutexHolder manifestMH( m_ToolManifestsMutex ); // ensure we don't make redundant requests
ToolManifest ** found = m_Tools.FindDeref( toolId );
ToolManifest * manifest = found ? *found : nullptr;
if ( manifest )
{
job->SetToolManifest( manifest );
if ( manifest->IsSynchronized() )
{
// we have all the files - we can do the job
JobQueueRemote::Get().QueueJob( job );
return;
}
// missing some files - request them
RequestMissingFiles( connection, manifest );
}
else
{
// first time seeing this tool
// create manifest object
manifest = FNEW( ToolManifest( toolId ) );
job->SetToolManifest( manifest );
m_Tools.Append( manifest );
// request manifest of tool chain
Protocol::MsgRequestManifest reqMsg( toolId );
reqMsg.Send( connection );
}
// can't start job yet - put it on hold
cs->m_WaitingJobs.Append( job );
}
// Process( MsgManifest )
//------------------------------------------------------------------------------
void Server::Process( const ConnectionInfo * connection, const Protocol::MsgManifest * msg, const void * payload, size_t payloadSize )
{
ToolManifest * manifest = nullptr;
const uint64_t toolId = msg->GetToolId();
ConstMemoryStream ms( payload, payloadSize );
{
MutexHolder manifestMH( m_ToolManifestsMutex ); // ensure we don't make redundant requests
// fill out the received manifest
ToolManifest ** found = m_Tools.FindDeref( toolId );
ASSERT( found );
manifest = *found;
manifest->DeserializeFromRemote( ms );
}
// manifest has checked local files, from previous sessions an may
// be synchronized
if ( manifest->IsSynchronized() )
{
CheckWaitingJobs( manifest );
return;
}
RequestMissingFiles( connection, manifest );
}
// Process( MsgFile )
//------------------------------------------------------------------------------
void Server::Process( const ConnectionInfo * connection, const Protocol::MsgFile * msg, const void * payload, size_t payloadSize )
{
const uint64_t toolId = msg->GetToolId();
const uint32_t fileId = msg->GetFileId();
// Update the Manifest
ToolManifest * manifest = nullptr;
{
MutexHolder manifestMH( m_ToolManifestsMutex );
// fill out the received manifest
ToolManifest ** found = m_Tools.FindDeref( toolId );
ASSERT( found );
manifest = *found;
ASSERT( manifest->GetUserData() == connection ); (void)connection;
if ( manifest->ReceiveFileData( fileId, payload, payloadSize ) == false )
{
// something went wrong storing the file
FLOG_WARN( "Failed to store fileId %u for manifest 0x%" PRIx64 "\n", fileId, toolId );
Disconnect( connection );
return;
}
if ( manifest->IsSynchronized() == false )
{
// wait for more files
return;
}
manifest->SetUserData( nullptr );
}
// ToolChain is now synchronized
// Allow any jobs that were waiting on it to start
CheckWaitingJobs( manifest );
}
// CheckWaitingJobs
//------------------------------------------------------------------------------
void Server::CheckWaitingJobs( const ToolManifest * manifest )
{
// queue for start any jobs that may now be ready
#ifdef ASSERTS_ENABLED
bool atLeastOneJobStarted = false;
#endif
MutexHolder mhC( m_ClientListMutex );
const ClientState * const * end = m_ClientList.End();
for ( ClientState ** it = m_ClientList.Begin(); it!=end; ++it )
{
// For each connected client...
ClientState * cs = *it;
MutexHolder mh2( cs->m_Mutex );
// .. check all jobs waiting for ToolManifests
int32_t numJobs = (int32_t)cs->m_WaitingJobs.GetSize();
for ( int32_t i=( numJobs -1 ); i >= 0; --i )
{
Job * job = cs->m_WaitingJobs[ (size_t)i ];
ToolManifest * manifestForThisJob = job->GetToolManifest();
ASSERT( manifestForThisJob );
if ( manifestForThisJob == manifest )
{
cs->m_WaitingJobs.EraseIndex( (size_t)i );
JobQueueRemote::Get().QueueJob( job );
PROTOCOL_DEBUG( "Server: Job %x can now be started\n", job );
#ifdef ASSERTS_ENABLED
atLeastOneJobStarted = true;
#endif
}
}
}
// We should only have called this function when a ToolChain sync was complete
// so at least 1 job should have been waiting for it
ASSERT( atLeastOneJobStarted );
}
// ThreadFuncStatic
//------------------------------------------------------------------------------
/*static*/ uint32_t Server::ThreadFuncStatic( void * param )
{
PROFILE_SET_THREAD_NAME( "ServerThread" )
Server * s = (Server *)param;
s->ThreadFunc();
return 0;
}
// ThreadFunc
//------------------------------------------------------------------------------
void Server::ThreadFunc()
{
while ( AtomicLoadRelaxed( &m_ShouldExit ) == false )
{
FinalizeCompletedJobs();
FindNeedyClients();
TouchToolchains();
JobQueueRemote::Get().MainThreadWait( 100 );
}
}
// FindNeedyClients
//------------------------------------------------------------------------------
void Server::FindNeedyClients()
{
if ( AtomicLoadRelaxed( &m_ShouldExit ) )
{
return;
}
PROFILE_FUNCTION
MutexHolder mh( m_ClientListMutex );
// determine job availability
int availableJobs = (int)WorkerThreadRemote::GetNumCPUsToUse();
if ( availableJobs == 0 )
{
return;
}
++availableJobs; // over request to parallelize building/network transfers
ClientState ** iter = m_ClientList.Begin();
const ClientState * const * end = m_ClientList.End();
for ( ; iter != end; ++iter )
{
ClientState * cs = *iter;
MutexHolder mh2( cs->m_Mutex );
// any jobs requested or in progress reduce the available count
int32_t reservedJobs = (int32_t)( cs->m_NumJobsRequested + cs->m_NumJobsActive );
availableJobs -= reservedJobs;
if ( availableJobs <= 0 )
{
return;
}
}
// we have some jobs available
// sort clients to find neediest first
m_ClientList.SortDeref();
Protocol::MsgRequestJob msg;
while ( availableJobs > 0 )
{
bool anyJobsRequested = false;
iter = m_ClientList.Begin();
for ( ; iter != end; ++iter )
{
ClientState * cs = *iter;
MutexHolder mh2( cs->m_Mutex );
size_t reservedJobs = cs->m_NumJobsRequested;
if ( reservedJobs >= cs->m_NumJobsAvailable )
{
continue; // we've maxed out the requests to this worker
}
// request job from this client
msg.Send( cs->m_Connection );
cs->m_NumJobsRequested++;
availableJobs--;
anyJobsRequested = true;
}
// if we did a pass and couldn't request any more jobs, then bail out
if ( anyJobsRequested == false )
{
break;
}
}
}
// FinalizeCompletedJobs
//------------------------------------------------------------------------------
void Server::FinalizeCompletedJobs()
{
PROFILE_FUNCTION
JobQueueRemote & jcr = JobQueueRemote::Get();
while ( Job * job = jcr.GetCompletedJob() )
{
// get associated connection
ClientState * cs = (ClientState *)job->GetUserData();
MutexHolder mh( m_ClientListMutex );
bool connectionStillActive = ( m_ClientList.Find( cs ) != nullptr );
if ( connectionStillActive )
{
Node::State result = job->GetNode()->GetState();
ASSERT( ( result == Node::UP_TO_DATE ) || ( result == Node::FAILED ) );
MemoryStream ms;
ms.Write( job->GetJobId() );
ms.Write( job->GetNode()->GetName() );
ms.Write( result == Node::UP_TO_DATE );
ms.Write( job->GetSystemErrorCount() > 0 );
ms.Write( job->GetMessages() );
ms.Write( job->GetNode()->GetLastBuildTime() );
ms.Write( job->IsDataCompressed() );
// write the data - build result for success, or output+errors for failure
ms.Write( (uint32_t)job->GetDataSize() );
ms.WriteBuffer( job->GetData(), job->GetDataSize() );
MutexHolder mh2( cs->m_Mutex );
ASSERT( cs->m_NumJobsActive );
cs->m_NumJobsActive--;
Protocol::MsgJobResult msg;
msg.Send( cs->m_Connection, ms );
}
else
{
// we might get here without finding the connection
// (if the connection was lost before we completed)
}
FDELETE job;
}
}
// TouchToolchains
//------------------------------------------------------------------------------
void Server::TouchToolchains()
{
#if defined( __OSX__ ) || defined( __LINUX__)
if ( m_TouchToolchainTimer.GetElapsed() < SERVER_TOOLCHAIN_TIMESTAMP_REFRESH_INTERVAL_SECS )
{
return;
}
m_TouchToolchainTimer.Start();
MutexHolder manifestMH( m_ToolManifestsMutex );
for ( const ToolManifest * toolManifest : m_Tools )
{
toolManifest->TouchFiles();
}
#else
// TODO:C we could update Windows timestamps too
#endif
}
// RequestMissingFiles
//------------------------------------------------------------------------------
void Server::RequestMissingFiles( const ConnectionInfo * connection, ToolManifest * manifest ) const
{
MutexHolder manifestMH( m_ToolManifestsMutex );
const Array< ToolManifestFile > & files = manifest->GetFiles();
const size_t numFiles = files.GetSize();
for ( size_t i=0; i<numFiles; ++i )
{
const ToolManifestFile & f = files[ i ];
if ( f.GetSyncState() == ToolManifestFile::NOT_SYNCHRONIZED )
{
// request this file
Protocol::MsgRequestFile reqFileMsg( manifest->GetToolId(), (uint32_t)i );
reqFileMsg.Send( connection );
// prevent it being requested again
manifest->MarkFileAsSynchronizing( i );
// either this is the first file being synchronized, or we
// are synchronizing multiple files from the same connection
// (it should not be possible to have files requested from different connections)
ASSERT( ( manifest->GetUserData() == nullptr ) || ( manifest->GetUserData() == connection ) );
manifest->SetUserData( (void *)connection );
}
}
}
//------------------------------------------------------------------------------
| 32.678822 | 134 | 0.548197 | [
"object"
] |
7b6d7bfe44c07d86b06631f09c662b4da2426e26 | 5,788 | hpp | C++ | DemoApps/Vulkan/Triangle/source/Triangle.hpp | alexvonduar/gtec-demo-framework | 6f8a7e429d0e15242ba64eb4cb41bfc2dd7dc749 | [
"MIT",
"BSD-3-Clause"
] | null | null | null | DemoApps/Vulkan/Triangle/source/Triangle.hpp | alexvonduar/gtec-demo-framework | 6f8a7e429d0e15242ba64eb4cb41bfc2dd7dc749 | [
"MIT",
"BSD-3-Clause"
] | null | null | null | DemoApps/Vulkan/Triangle/source/Triangle.hpp | alexvonduar/gtec-demo-framework | 6f8a7e429d0e15242ba64eb4cb41bfc2dd7dc749 | [
"MIT",
"BSD-3-Clause"
] | null | null | null | #ifndef VULKAN_TRIANGLE_TRIANGLE_HPP
#define VULKAN_TRIANGLE_TRIANGLE_HPP
/****************************************************************************************************************************************************
* Copyright 2021 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the NXP. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************************************************************************************/
#include <FslDemoApp/Vulkan/Basic/DemoAppVulkanBasic.hpp>
#include <RapidVulkan/Buffer.hpp>
#include <RapidVulkan/DescriptorPool.hpp>
#include <RapidVulkan/DescriptorSetLayout.hpp>
#include <RapidVulkan/GraphicsPipeline.hpp>
#include <RapidVulkan/Memory.hpp>
#include <RapidVulkan/PipelineLayout.hpp>
#include <RapidVulkan/ShaderModule.hpp>
// GLM Headers for standard math operations
#include <glm/glm.hpp>
#include <utility>
namespace Fsl
{
struct BufferAndMemory
{
RapidVulkan::Memory Memory; // Handle to the device memory for this buffer
RapidVulkan::Buffer Buffer; // Handle to the Vulkan buffer object that the memory is bound to
};
struct VertexBuffer
{
BufferAndMemory Content;
VkVertexInputBindingDescription InputBinding{};
std::vector<VkVertexInputAttributeDescription> InputAttributes{};
};
class Triangle final : public VulkanBasic::DemoAppVulkanBasic
{
struct CameraInfo
{
glm::vec3 Rotation{};
float Zoom{0};
};
// Vertex buffer and attributes
// Index buffer
struct IndexBuffer
{
BufferAndMemory Content;
uint32_t Count{0};
};
struct Mesh
{
VertexBuffer Vertices;
IndexBuffer Indices;
};
// For simplicity we use the same uniform block layout as in the shader:
//
// layout(set = 0, binding = 0) uniform UBO
// {
// mat4 projectionMatrix;
// mat4 modelMatrix;
// mat4 viewMatrix;
// } ubo;
//
// This way we can just memcopy the ubo data to the ubo
// Note: You should use data types that align with the GPU in order to avoid manual padding (vec4, mat4)
struct UboVS
{
glm::mat4 ProjectionMatrix{};
glm::mat4 ModelMatrix{};
glm::mat4 ViewMatrix{};
};
// Uniform block object
struct UniformDataVS
{
RapidVulkan::Memory Memory;
RapidVulkan::Buffer Buffer;
VkDescriptorBufferInfo Descriptor{};
};
struct Resources
{
// PrepareVertices
Mesh TriangleMesh;
UniformDataVS UniformData;
// SetupDescriptorSetLayout
RapidVulkan::DescriptorSetLayout DescriptorSetLayout;
RapidVulkan::PipelineLayout PipelineLayout;
RapidVulkan::ShaderModule VertShaderModule;
RapidVulkan::ShaderModule FragShaderModule;
// SetupDescriptorPool
RapidVulkan::DescriptorPool DescriptorPool;
// SetupDescriptorSet
// We use the native type here since this is managed by a pool
VkDescriptorSet DescriptorSet{VK_NULL_HANDLE};
};
struct DependentResources
{
RapidVulkan::RenderPass MainRenderPass;
RapidVulkan::GraphicsPipeline Pipeline;
};
CameraInfo m_cameraInfo;
Resources m_resources;
DependentResources m_dependentResources;
UboVS m_uboVS;
public:
explicit Triangle(const DemoAppConfig& config);
protected:
void Update(const DemoTime& demoTime) final;
void VulkanDraw(const DemoTime& demoTime, RapidVulkan::CommandBuffers& rCmdBuffers, const VulkanBasic::DrawContext& drawContext) final;
void DrawTriangle(VkCommandBuffer hCmdBuffer, const uint32_t cmdBufferIndex);
VkRenderPass OnBuildResources(const VulkanBasic::BuildResourcesContext& context) final;
void OnFreeResources() final;
private:
static Mesh PrepareVertices(const Vulkan::VUDevice& device, Vulkan::VUDeviceQueueRecord& rDeviceQueue, const VkCommandPool cmdPool,
const bool useStagingBuffers);
static UniformDataVS PrepareUniformBuffers(const Vulkan::VUDevice& device, const CameraInfo& cameraInfo, const float aspectRatio);
static UboVS UpdateUniformBuffers(const Vulkan::VUDevice& device, const CameraInfo& cameraInfo, const float aspectRatio,
UniformDataVS& rUniformData);
};
}
#endif
| 34.86747 | 150 | 0.683138 | [
"mesh",
"object",
"vector"
] |
7b6f3804fd53ec4bb0ff0cd6e31f6fc9144ac607 | 13,789 | cpp | C++ | Intermediate/Build/Win64/UE4Editor/Inc/Pacman/PacmanPlayer.gen.cpp | A-Yu-cn/ue4_demo_pacman | 60aa91d23e770199be7d12b5db4cced0a2154f52 | [
"MIT"
] | null | null | null | Intermediate/Build/Win64/UE4Editor/Inc/Pacman/PacmanPlayer.gen.cpp | A-Yu-cn/ue4_demo_pacman | 60aa91d23e770199be7d12b5db4cced0a2154f52 | [
"MIT"
] | null | null | null | Intermediate/Build/Win64/UE4Editor/Inc/Pacman/PacmanPlayer.gen.cpp | A-Yu-cn/ue4_demo_pacman | 60aa91d23e770199be7d12b5db4cced0a2154f52 | [
"MIT"
] | null | null | null | // Copyright Epic Games, Inc. All Rights Reserved.
/*===========================================================================
Generated code exported from UnrealHeaderTool.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "UObject/GeneratedCppIncludes.h"
#include "Pacman/PacmanPlayer.h"
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable : 4883)
#endif
PRAGMA_DISABLE_DEPRECATION_WARNINGS
void EmptyLinkFunctionForGeneratedCodePacmanPlayer() {}
// Cross Module References
PACMAN_API UClass* Z_Construct_UClass_APacmanPlayer_NoRegister();
PACMAN_API UClass* Z_Construct_UClass_APacmanPlayer();
ENGINE_API UClass* Z_Construct_UClass_ACharacter();
UPackage* Z_Construct_UPackage__Script_Pacman();
ENGINE_API UClass* Z_Construct_UClass_UPrimitiveComponent_NoRegister();
ENGINE_API UClass* Z_Construct_UClass_AActor_NoRegister();
ENGINE_API UScriptStruct* Z_Construct_UScriptStruct_FHitResult();
ENGINE_API UClass* Z_Construct_UClass_UStaticMeshComponent_NoRegister();
// End Cross Module References
DEFINE_FUNCTION(APacmanPlayer::execOnPacmanBeginOverlay)
{
P_GET_OBJECT(UPrimitiveComponent,Z_Param_OverlappedComponent);
P_GET_OBJECT(AActor,Z_Param_OtherActor);
P_GET_OBJECT(UPrimitiveComponent,Z_Param_OtherComp);
P_GET_PROPERTY(FIntProperty,Z_Param_OtherBodyIndex);
P_GET_UBOOL(Z_Param_bFromSweep);
P_GET_STRUCT_REF(FHitResult,Z_Param_Out_SweepResult);
P_FINISH;
P_NATIVE_BEGIN;
P_THIS->OnPacmanBeginOverlay(Z_Param_OverlappedComponent,Z_Param_OtherActor,Z_Param_OtherComp,Z_Param_OtherBodyIndex,Z_Param_bFromSweep,Z_Param_Out_SweepResult);
P_NATIVE_END;
}
void APacmanPlayer::StaticRegisterNativesAPacmanPlayer()
{
UClass* Class = APacmanPlayer::StaticClass();
static const FNameNativePtrPair Funcs[] = {
{ "OnPacmanBeginOverlay", &APacmanPlayer::execOnPacmanBeginOverlay },
};
FNativeFunctionRegistrar::RegisterFunctions(Class, Funcs, UE_ARRAY_COUNT(Funcs));
}
struct Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics
{
struct PacmanPlayer_eventOnPacmanBeginOverlay_Parms
{
UPrimitiveComponent* OverlappedComponent;
AActor* OtherActor;
UPrimitiveComponent* OtherComp;
int32 OtherBodyIndex;
bool bFromSweep;
FHitResult SweepResult;
};
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_OverlappedComponent_MetaData[];
#endif
static const UE4CodeGen_Private::FObjectPropertyParams NewProp_OverlappedComponent;
static const UE4CodeGen_Private::FObjectPropertyParams NewProp_OtherActor;
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_OtherComp_MetaData[];
#endif
static const UE4CodeGen_Private::FObjectPropertyParams NewProp_OtherComp;
static const UE4CodeGen_Private::FIntPropertyParams NewProp_OtherBodyIndex;
static void NewProp_bFromSweep_SetBit(void* Obj);
static const UE4CodeGen_Private::FBoolPropertyParams NewProp_bFromSweep;
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_SweepResult_MetaData[];
#endif
static const UE4CodeGen_Private::FStructPropertyParams NewProp_SweepResult;
static const UE4CodeGen_Private::FPropertyParamsBase* const PropPointers[];
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam Function_MetaDataParams[];
#endif
static const UE4CodeGen_Private::FFunctionParams FuncParams;
};
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OverlappedComponent_MetaData[] = {
{ "EditInline", "true" },
};
#endif
const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OverlappedComponent = { "OverlappedComponent", nullptr, (EPropertyFlags)0x0010000000080080, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(PacmanPlayer_eventOnPacmanBeginOverlay_Parms, OverlappedComponent), Z_Construct_UClass_UPrimitiveComponent_NoRegister, METADATA_PARAMS(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OverlappedComponent_MetaData, UE_ARRAY_COUNT(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OverlappedComponent_MetaData)) };
const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherActor = { "OtherActor", nullptr, (EPropertyFlags)0x0010000000000080, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(PacmanPlayer_eventOnPacmanBeginOverlay_Parms, OtherActor), Z_Construct_UClass_AActor_NoRegister, METADATA_PARAMS(nullptr, 0) };
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherComp_MetaData[] = {
{ "EditInline", "true" },
};
#endif
const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherComp = { "OtherComp", nullptr, (EPropertyFlags)0x0010000000080080, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(PacmanPlayer_eventOnPacmanBeginOverlay_Parms, OtherComp), Z_Construct_UClass_UPrimitiveComponent_NoRegister, METADATA_PARAMS(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherComp_MetaData, UE_ARRAY_COUNT(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherComp_MetaData)) };
const UE4CodeGen_Private::FIntPropertyParams Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherBodyIndex = { "OtherBodyIndex", nullptr, (EPropertyFlags)0x0010000000000080, UE4CodeGen_Private::EPropertyGenFlags::Int, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(PacmanPlayer_eventOnPacmanBeginOverlay_Parms, OtherBodyIndex), METADATA_PARAMS(nullptr, 0) };
void Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_bFromSweep_SetBit(void* Obj)
{
((PacmanPlayer_eventOnPacmanBeginOverlay_Parms*)Obj)->bFromSweep = 1;
}
const UE4CodeGen_Private::FBoolPropertyParams Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_bFromSweep = { "bFromSweep", nullptr, (EPropertyFlags)0x0010000000000080, UE4CodeGen_Private::EPropertyGenFlags::Bool | UE4CodeGen_Private::EPropertyGenFlags::NativeBool, RF_Public|RF_Transient|RF_MarkAsNative, 1, sizeof(bool), sizeof(PacmanPlayer_eventOnPacmanBeginOverlay_Parms), &Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_bFromSweep_SetBit, METADATA_PARAMS(nullptr, 0) };
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_SweepResult_MetaData[] = {
{ "NativeConst", "" },
};
#endif
const UE4CodeGen_Private::FStructPropertyParams Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_SweepResult = { "SweepResult", nullptr, (EPropertyFlags)0x0010008008000182, UE4CodeGen_Private::EPropertyGenFlags::Struct, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(PacmanPlayer_eventOnPacmanBeginOverlay_Parms, SweepResult), Z_Construct_UScriptStruct_FHitResult, METADATA_PARAMS(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_SweepResult_MetaData, UE_ARRAY_COUNT(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_SweepResult_MetaData)) };
const UE4CodeGen_Private::FPropertyParamsBase* const Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::PropPointers[] = {
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OverlappedComponent,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherActor,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherComp,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_OtherBodyIndex,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_bFromSweep,
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::NewProp_SweepResult,
};
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::Function_MetaDataParams[] = {
{ "ModuleRelativePath", "PacmanPlayer.h" },
};
#endif
const UE4CodeGen_Private::FFunctionParams Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::FuncParams = { (UObject*(*)())Z_Construct_UClass_APacmanPlayer, nullptr, "OnPacmanBeginOverlay", nullptr, nullptr, sizeof(PacmanPlayer_eventOnPacmanBeginOverlay_Parms), Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::PropPointers, UE_ARRAY_COUNT(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::PropPointers), RF_Public|RF_Transient|RF_MarkAsNative, (EFunctionFlags)0x00420401, 0, 0, METADATA_PARAMS(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::Function_MetaDataParams, UE_ARRAY_COUNT(Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::Function_MetaDataParams)) };
UFunction* Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay()
{
static UFunction* ReturnFunction = nullptr;
if (!ReturnFunction)
{
UE4CodeGen_Private::ConstructUFunction(ReturnFunction, Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay_Statics::FuncParams);
}
return ReturnFunction;
}
UClass* Z_Construct_UClass_APacmanPlayer_NoRegister()
{
return APacmanPlayer::StaticClass();
}
struct Z_Construct_UClass_APacmanPlayer_Statics
{
static UObject* (*const DependentSingletons[])();
static const FClassFunctionLinkInfo FuncInfo[];
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam Class_MetaDataParams[];
#endif
#if WITH_METADATA
static const UE4CodeGen_Private::FMetaDataPairParam NewProp_PacmanDisplayMesh_MetaData[];
#endif
static const UE4CodeGen_Private::FObjectPropertyParams NewProp_PacmanDisplayMesh;
static const UE4CodeGen_Private::FPropertyParamsBase* const PropPointers[];
static const FCppClassTypeInfoStatic StaticCppClassTypeInfo;
static const UE4CodeGen_Private::FClassParams ClassParams;
};
UObject* (*const Z_Construct_UClass_APacmanPlayer_Statics::DependentSingletons[])() = {
(UObject* (*)())Z_Construct_UClass_ACharacter,
(UObject* (*)())Z_Construct_UPackage__Script_Pacman,
};
const FClassFunctionLinkInfo Z_Construct_UClass_APacmanPlayer_Statics::FuncInfo[] = {
{ &Z_Construct_UFunction_APacmanPlayer_OnPacmanBeginOverlay, "OnPacmanBeginOverlay" }, // 2791550176
};
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_APacmanPlayer_Statics::Class_MetaDataParams[] = {
{ "HideCategories", "Navigation" },
{ "IncludePath", "PacmanPlayer.h" },
{ "ModuleRelativePath", "PacmanPlayer.h" },
};
#endif
#if WITH_METADATA
const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_APacmanPlayer_Statics::NewProp_PacmanDisplayMesh_MetaData[] = {
{ "Category", "PacmanPlayer" },
{ "EditInline", "true" },
{ "ModuleRelativePath", "PacmanPlayer.h" },
};
#endif
const UE4CodeGen_Private::FObjectPropertyParams Z_Construct_UClass_APacmanPlayer_Statics::NewProp_PacmanDisplayMesh = { "PacmanDisplayMesh", nullptr, (EPropertyFlags)0x00100000000a000d, UE4CodeGen_Private::EPropertyGenFlags::Object, RF_Public|RF_Transient|RF_MarkAsNative, 1, STRUCT_OFFSET(APacmanPlayer, PacmanDisplayMesh), Z_Construct_UClass_UStaticMeshComponent_NoRegister, METADATA_PARAMS(Z_Construct_UClass_APacmanPlayer_Statics::NewProp_PacmanDisplayMesh_MetaData, UE_ARRAY_COUNT(Z_Construct_UClass_APacmanPlayer_Statics::NewProp_PacmanDisplayMesh_MetaData)) };
const UE4CodeGen_Private::FPropertyParamsBase* const Z_Construct_UClass_APacmanPlayer_Statics::PropPointers[] = {
(const UE4CodeGen_Private::FPropertyParamsBase*)&Z_Construct_UClass_APacmanPlayer_Statics::NewProp_PacmanDisplayMesh,
};
const FCppClassTypeInfoStatic Z_Construct_UClass_APacmanPlayer_Statics::StaticCppClassTypeInfo = {
TCppClassTypeTraits<APacmanPlayer>::IsAbstract,
};
const UE4CodeGen_Private::FClassParams Z_Construct_UClass_APacmanPlayer_Statics::ClassParams = {
&APacmanPlayer::StaticClass,
"Game",
&StaticCppClassTypeInfo,
DependentSingletons,
FuncInfo,
Z_Construct_UClass_APacmanPlayer_Statics::PropPointers,
nullptr,
UE_ARRAY_COUNT(DependentSingletons),
UE_ARRAY_COUNT(FuncInfo),
UE_ARRAY_COUNT(Z_Construct_UClass_APacmanPlayer_Statics::PropPointers),
0,
0x009000A4u,
METADATA_PARAMS(Z_Construct_UClass_APacmanPlayer_Statics::Class_MetaDataParams, UE_ARRAY_COUNT(Z_Construct_UClass_APacmanPlayer_Statics::Class_MetaDataParams))
};
UClass* Z_Construct_UClass_APacmanPlayer()
{
static UClass* OuterClass = nullptr;
if (!OuterClass)
{
UE4CodeGen_Private::ConstructUClass(OuterClass, Z_Construct_UClass_APacmanPlayer_Statics::ClassParams);
}
return OuterClass;
}
IMPLEMENT_CLASS(APacmanPlayer, 2221740549);
template<> PACMAN_API UClass* StaticClass<APacmanPlayer>()
{
return APacmanPlayer::StaticClass();
}
static FCompiledInDefer Z_CompiledInDefer_UClass_APacmanPlayer(Z_Construct_UClass_APacmanPlayer, &APacmanPlayer::StaticClass, TEXT("/Script/Pacman"), TEXT("APacmanPlayer"), false, nullptr, nullptr, nullptr);
DEFINE_VTABLE_PTR_HELPER_CTOR(APacmanPlayer);
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#ifdef _MSC_VER
#pragma warning (pop)
#endif
| 65.976077 | 744 | 0.848647 | [
"object"
] |
7b75dbc8cbde254cf6b02ead073b2a2907685dc3 | 453 | hpp | C++ | cleContextManager.hpp | StRigaud/swig-sandbox | 27d3cb111201f333f2ba7d3be7b4cac2f9265244 | [
"Apache-2.0"
] | null | null | null | cleContextManager.hpp | StRigaud/swig-sandbox | 27d3cb111201f333f2ba7d3be7b4cac2f9265244 | [
"Apache-2.0"
] | null | null | null | cleContextManager.hpp | StRigaud/swig-sandbox | 27d3cb111201f333f2ba7d3be7b4cac2f9265244 | [
"Apache-2.0"
] | null | null | null | #ifndef __cleContextManager_h
#define __cleContextManager_h
#include "clic.hpp"
#include <vector>
namespace clic
{
class ContextManager
{
private:
cl::Context m_Context;
public:
ContextManager() =default;
ContextManager(cl::Device);
ContextManager(std::vector<cl::Device>);
~ContextManager();
cl::Context GetContext();
std::vector<cl::Device> GetDevices();
};
} // namespace clic
#endif // __cleContextManager_h | 15.1 | 44 | 0.699779 | [
"vector"
] |
7b76f20031ab0deed7b42baee4013dade2774591 | 17,028 | cpp | C++ | src/sort.cpp | waderly/ardb | 9f2460cf747dc2c238eda065b7a1f9371399fa7b | [
"BSD-3-Clause"
] | 1 | 2015-11-05T18:35:53.000Z | 2015-11-05T18:35:53.000Z | src/sort.cpp | waderly/ardb | 9f2460cf747dc2c238eda065b7a1f9371399fa7b | [
"BSD-3-Clause"
] | null | null | null | src/sort.cpp | waderly/ardb | 9f2460cf747dc2c238eda065b7a1f9371399fa7b | [
"BSD-3-Clause"
] | null | null | null | /*
*Copyright (c) 2013-2013, yinqiwen <yinqiwen@gmail.com>
*All rights reserved.
*
*Redistribution and use in source and binary forms, with or without
*modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Redis 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.
*/
#include "db.hpp"
#include "ardb_server.hpp"
#include <algorithm>
#include <vector>
#include <fnmatch.h>
namespace ardb
{
int ArdbServer::Sort(ArdbConnContext& ctx, RedisCommandFrame& cmd)
{
ValueDataArray vs;
std::string key = cmd.GetArguments()[0];
cmd.GetMutableArguments().pop_front();
int ret = m_db->Sort(ctx.currentDB, key, cmd.GetArguments(), vs);
if (ret < 0)
{
fill_error_reply(ctx.reply, "Invalid SORT command or invalid state for SORT.");
}
else
{
fill_array_reply(ctx.reply, vs);
}
cmd.GetMutableArguments().push_front(key);
return 0;
}
struct SortValue
{
ValueData* value;
ValueData cmp;
double score;
SortValue(ValueData* v) :
value(v), score(0)
{
}
int Compare(const SortValue& other) const
{
if (cmp.type == EMPTY_VALUE && other.cmp.type == EMPTY_VALUE)
{
return value->Compare(*other.value);
}
return cmp.Compare(other.cmp);
}
};
template<typename T>
static bool greater_value(const T& v1, const T& v2)
{
return v1.Compare(v2) > 0;
}
template<typename T>
static bool less_value(const T& v1, const T& v2)
{
return v1.Compare(v2) < 0;
}
static int parse_sort_options(SortOptions& options, const StringArray& args)
{
for (uint32 i = 0; i < args.size(); i++)
{
if (!strcasecmp(args[i].c_str(), "asc"))
{
options.is_desc = false;
}
else if (!strcasecmp(args[i].c_str(), "desc"))
{
options.is_desc = true;
}
else if (!strcasecmp(args[i].c_str(), "alpha"))
{
options.with_alpha = true;
}
else if (!strcasecmp(args[i].c_str(), "limit") && i < args.size() - 2)
{
options.with_limit = true;
if (!string_toint32(args[i + 1], options.limit_offset)
|| !string_toint32(args[i + 2], options.limit_count))
{
return -1;
}
i += 2;
}
else if (!strcasecmp(args[i].c_str(), "aggregate") && i < args.size() - 1)
{
if (!strcasecmp(args[i + 1].c_str(), "sum"))
{
options.aggregate = AGGREGATE_SUM;
}
else if (!strcasecmp(args[i + 1].c_str(), "max"))
{
options.aggregate = AGGREGATE_MAX;
}
else if (!strcasecmp(args[i + 1].c_str(), "min"))
{
options.aggregate = AGGREGATE_MIN;
}
else if (!strcasecmp(args[i + 1].c_str(), "count"))
{
options.aggregate = AGGREGATE_COUNT;
}
else if (!strcasecmp(args[i + 1].c_str(), "avg"))
{
options.aggregate = AGGREGATE_AVG;
}
else
{
return -1;
}
i++;
}
else if (!strcasecmp(args[i].c_str(), "store") && i < args.size() - 1)
{
options.store_dst = args[i + 1].c_str();
i++;
}
else if (!strcasecmp(args[i].c_str(), "by") && i < args.size() - 1)
{
options.by = args[i + 1].c_str();
if (!strcasecmp(options.by, "nosort"))
{
options.by = NULL;
options.nosort = true;
}
i++;
}
else if (!strcasecmp(args[i].c_str(), "get") && i < args.size() - 1)
{
options.get_patterns.push_back(args[i + 1].c_str());
i++;
}
else
{
DEBUG_LOG("Invalid sort option:%s", args[i].c_str());
return -1;
}
}
return 0;
}
int Ardb::MatchValueByPattern(const DBID& db, const Slice& key_pattern, const Slice& value_pattern,
ValueData& subst, ValueData& value)
{
if (0 != GetValueByPattern(db, key_pattern, subst, value))
{
return -1;
}
std::string str;
value.ToString(str);
std::string vpattern(value_pattern.data(), value_pattern.size());
return fnmatch(vpattern.c_str(), str.c_str(), 0) == 0 ? 0 : -1;
}
int Ardb::GetValueByPattern(const DBID& db, const Slice& pattern, ValueData& subst, ValueData& value)
{
const char *p, *f;
const char* spat;
/* If the pattern is "#" return the substitution object itself in order
* to implement the "SORT ... GET #" feature. */
spat = pattern.data();
if (spat[0] == '#' && spat[1] == '\0')
{
value = subst;
return 0;
}
/* If we can't find '*' in the pattern we return NULL as to GET a
* fixed key does not make sense. */
p = strchr(spat, '*');
if (!p)
{
return -1;
}
std::string vstr;
subst.ToString(vstr);
f = strstr(spat, "->");
if (NULL != f && (uint32) (f - spat) == (pattern.size() - 2))
{
f = NULL;
}
std::string keystr(pattern.data(), pattern.size());
string_replace(keystr, "*", vstr);
if (f == NULL)
{
/*
* keystr = "len(...)"
*/
if (keystr.find("len(") == 0 && keystr.rfind(")") == keystr.size() - 1)
{
keystr = keystr.substr(4, keystr.size() - 5);
int keytype = Type(db, keystr);
int len = -1;
switch (keytype)
{
case SET_META:
{
len = SCard(db, keystr);
break;
}
case LIST_META:
{
len = LLen(db, keystr);
break;
}
case ZSET_META:
{
len = ZCard(db, keystr);
break;
}
default:
{
return -1;
}
}
value.SetIntValue(len);
return 0;
}
value.type = BYTES_VALUE;
return Get(db, keystr, value.bytes_value);
}
else
{
size_t pos = keystr.find("->");
std::string field = keystr.substr(pos + 2);
keystr = keystr.substr(0, pos);
value.type = BYTES_VALUE;
return HGet(db, keystr, field, &value.bytes_value);
}
}
int Ardb::Sort(const DBID& db, const Slice& key, const StringArray& args, ValueDataArray& values)
{
values.clear();
SortOptions options;
if (parse_sort_options(options, args) < 0)
{
DEBUG_LOG("Failed to parse sort options.");
return ERR_INVALID_ARGS;
}
int type = Type(db, key);
ValueDataArray sortvals;
switch (type)
{
case LIST_META:
{
LRange(db, key, 0, -1, sortvals);
break;
}
case SET_META:
{
SMembers(db, key, sortvals);
break;
}
case ZSET_META:
{
ZSetQueryOptions tmp;
ZRange(db, key, 0, -1, sortvals, tmp);
if (NULL == options.by)
{
options.nosort = true;
}
break;
}
default:
{
return ERR_INVALID_TYPE;
}
}
if (sortvals.empty())
{
return 0;
}
if (options.with_limit)
{
if (options.limit_offset < 0)
{
options.limit_offset = 0;
}
if ((uint32) options.limit_offset > sortvals.size())
{
values.clear();
return 0;
}
if (options.limit_count < 0)
{
options.limit_count = sortvals.size();
}
}
std::vector<SortValue> sortvec;
if (!options.nosort)
{
if (NULL != options.by)
{
sortvec.reserve(sortvals.size());
}
for (uint32 i = 0; i < sortvals.size(); i++)
{
if (NULL != options.by)
{
sortvec.push_back(SortValue(&sortvals[i]));
if (GetValueByPattern(db, options.by, sortvals[i], sortvec[i].cmp) < 0)
{
DEBUG_LOG("Failed to get value by pattern:%s", options.by);
sortvec[i].cmp.Clear();
continue;
}
}
if (options.with_alpha)
{
if (NULL != options.by)
{
sortvec[i].cmp.ToBytes();
}
else
{
sortvals[i].ToBytes();
}
}
else
{
if (NULL != options.by)
{
sortvec[i].cmp.ToNumber();
}
else
{
sortvals[i].ToNumber();
}
}
}
if (NULL != options.by)
{
if (!options.is_desc)
{
std::sort(sortvec.begin(), sortvec.end(), less_value<SortValue>);
}
else
{
std::sort(sortvec.begin(), sortvec.end(), greater_value<SortValue>);
}
}
else
{
if (!options.is_desc)
{
std::sort(sortvals.begin(), sortvals.end(), less_value<ValueData>);
}
else
{
std::sort(sortvals.begin(), sortvals.end(), greater_value<ValueData>);
}
}
}
if (!options.with_limit)
{
options.limit_offset = 0;
options.limit_count = sortvals.size();
}
uint32 count = 0;
for (uint32 i = options.limit_offset; i < sortvals.size() && count < (uint32) options.limit_count; i++, count++)
{
ValueData* patternObj = NULL;
if (NULL != options.by)
{
patternObj = sortvec[i].value;
}
else
{
patternObj = &(sortvals[i]);
}
if (options.get_patterns.empty())
{
values.push_back(*patternObj);
}
else
{
for (uint32 j = 0; j < options.get_patterns.size(); j++)
{
ValueData vo;
if (GetValueByPattern(db, options.get_patterns[j], *patternObj, vo) < 0)
{
DEBUG_LOG("Failed to get value by pattern for:%s", options.get_patterns[j]);
vo.Clear();
}
vo.ToNumber();
values.push_back(vo);
}
}
}
uint32 step = options.get_patterns.empty() ? 1 : options.get_patterns.size();
switch (options.aggregate)
{
case AGGREGATE_SUM:
case AGGREGATE_AVG:
{
ValueDataArray result;
result.resize(step);
for (uint32 i = 0; i < result.size(); i++)
{
for (uint32 j = i; j < values.size(); j += step)
{
result[i] += values[j];
}
}
if (options.aggregate == AGGREGATE_AVG)
{
size_t count = values.size() / step;
for (uint32 i = 0; i < result.size(); i++)
{
result[i] /= count;
}
}
values.assign(result.begin(), result.end());
break;
}
case AGGREGATE_MAX:
case AGGREGATE_MIN:
{
ValueDataArray result;
result.resize(step);
for (uint32 i = 0; i < result.size(); i++)
{
for (uint32 j = i; j < values.size(); j += step)
{
if (result[i].type == EMPTY_VALUE)
{
result[i] = values[j];
}
else
{
if (options.aggregate == AGGREGATE_MIN)
{
if (values[j] < result[i])
{
result[i] = values[j];
}
}
else
{
if (values[j] > result[i])
{
result[i] = values[j];
}
}
}
}
}
values.assign(result.begin(), result.end());
break;
}
case AGGREGATE_COUNT:
{
size_t size = values.size() / step;
values.clear();
values.push_back(ValueData((int64) size));
break;
}
default:
{
break;
}
}
if (options.store_dst != NULL && !values.empty())
{
BatchWriteGuard guard(GetEngine());
LClear(db, options.store_dst);
ValueDataArray::iterator it = values.begin();
int64 score = 0;
while (it != values.end())
{
if (it->type != EMPTY_VALUE)
{
ListKeyObject lk(options.store_dst, score, db);
SetKeyValueObject(lk, *it);
score++;
}
it++;
}
ListMetaValue meta;
meta.min_score.SetIntValue(0);
meta.max_score.SetIntValue(score - 1);
meta.size = score;
SetMeta(db, options.store_dst, meta);
}
return 0;
}
}
| 32.25 | 120 | 0.41649 | [
"object",
"vector"
] |
7b82ab50ceca5bc87408d0842186b6b6c167765a | 3,713 | cpp | C++ | Source/Renderer/SeaRenderable.cpp | hipiPan/effects | d9003f71e6fb485d054fb198cfdf5b944e2e158f | [
"MIT"
] | 2 | 2019-10-14T14:48:29.000Z | 2019-10-14T15:45:25.000Z | Source/Renderer/SeaRenderable.cpp | hipiPan/effects | d9003f71e6fb485d054fb198cfdf5b944e2e158f | [
"MIT"
] | null | null | null | Source/Renderer/SeaRenderable.cpp | hipiPan/effects | d9003f71e6fb485d054fb198cfdf5b944e2e158f | [
"MIT"
] | null | null | null | #include "Renderer/SeaRenderable.h"
#include "Renderer/Renderer.h"
#include "Resources/Mesh.h"
#include "Resources/Material.h"
#include "Scene/Components/CSea.h"
#include "Core/Utility/FileUtility.h"
EFFECTS_NAMESPACE_BEGIN
SeaRenderable::SeaRenderable(CSea* csea){
mCSea = csea;
mType = RenderableType::SEA;
std::string vs, fs;
GfxProgramDesc programDesc;
readFileData("./BuiltinResources/Shaders/Sea/SeaOctave.vert", vs);
readFileData("./BuiltinResources/Shaders/Sea/SeaOctave.frag", fs);
programDesc.vertSource = vs;
programDesc.fragSource = fs;
programDesc.define = "";
mSeaOctave = createGfxProgram(programDesc);
readFileData("./BuiltinResources/Shaders/Sea/SeaNormal.vert", vs);
readFileData("./BuiltinResources/Shaders/Sea/SeaNormal.frag", fs);
programDesc.vertSource = vs;
programDesc.fragSource = fs;
programDesc.define = "";
mSeaNormal = createGfxProgram(programDesc);
}
SeaRenderable::~SeaRenderable() {
destroyGfxFramebuffer(mProcessFB);
destroyGfxTexture(mHeightMap);
destroyGfxSampler(mSampler);
destroyGfxProgram(mSeaOctave);
destroyGfxProgram(mSeaNormal);
}
void SeaRenderable::initialize() {
}
void SeaRenderable::setMesh(std::shared_ptr<Mesh> mesh) {
mMesh = mesh;
}
void SeaRenderable::setMaterial(std::shared_ptr<Material> material) {
mMaterial = material;
}
void SeaRenderable::setTransform(const glm::mat4 &mat) {
mWorldMatrix = mat;
}
std::shared_ptr<Mesh> SeaRenderable::getMesh() {
return mMesh;
}
std::shared_ptr<Material> SeaRenderable::getMaterial() {
return mMaterial;
}
glm::mat4 SeaRenderable::getTransform() {
return mWorldMatrix;
}
void SeaRenderable::updateSeaMap() {
if (mShouldReset) {
GfxSamplerDesc samplerDesc;
mSampler = createGfxSampler(samplerDesc);
GfxTextureDesc texDesc;
texDesc.width = mCSea->mSeaX;
texDesc.height = mCSea->mSeaY;
texDesc.depth = 1;
texDesc.arraySize = 1;
texDesc.format = GL_RGB;
texDesc.internalFormat = GL_RGB16F;
texDesc.componentType = GL_FLOAT;
mHeightMap = createGfxTexture(texDesc);
writeGfxTextureData(mHeightMap, nullptr);
setGfxTextureSampler(mHeightMap, mSampler);
texDesc.format = GL_RGB;
texDesc.internalFormat = GL_RGB16F;
mNormalMap = createGfxTexture(texDesc);
writeGfxTextureData(mNormalMap, nullptr);
setGfxTextureSampler(mNormalMap, mSampler);
GfxFramebufferDesc fbDesc;
mProcessFB = createGfxFramebuffer();
mShouldReset = false;
}
attachGfxFramebufferTexture(mProcessFB, 0, mHeightMap);
glViewport(0, 0, mCSea->mSeaX, mCSea->mSeaY);
bindGfxFramebuffer(mProcessFB);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setGfxProgramFloat(mSeaOctave, "u_seaTime", mCSea->mSeaTime * 10.0);
bindGfxProgram(mSeaOctave);
Renderer::instance().getQuadMesh()->draw(GL_TRIANGLES);
unbindGfxProgram(mSeaOctave);
unbindGfxFramebuffer(mProcessFB);
attachGfxFramebufferTexture(mProcessFB, 0, mNormalMap);
glViewport(0, 0, mCSea->mSeaX, mCSea->mSeaY);
bindGfxFramebuffer(mProcessFB);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
setGfxProgramFloat2(mSeaNormal, "u_texelSize", glm::value_ptr(glm::vec2(1.0 / mCSea->mSeaX, 1.0 / mCSea->mSeaY)));
setGfxProgramSampler(mSeaNormal, "u_heightMap", mHeightMap);
bindGfxProgram(mSeaNormal);
Renderer::instance().getQuadMesh()->draw(GL_TRIANGLES);
unbindGfxProgram(mSeaNormal);
unbindGfxFramebuffer(mProcessFB);
}
EFFECTS_NAMESPACE_END
| 31.735043 | 118 | 0.712901 | [
"mesh"
] |
7b873346e43692a27eb887933f14d1df42e7a9c2 | 1,430 | cpp | C++ | examples/signal/connection.cpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | examples/signal/connection.cpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | examples/signal/connection.cpp | pmiddend/fcppt | 9f437acbb10258e6df6982a550213a05815eb2be | [
"BSL-1.0"
] | null | null | null | // Copyright Carl Philipp Reh 2009 - 2018.
// 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)
//! [signal_connection]
#include <fcppt/container/make.hpp>
#include <fcppt/signal/auto_connection.hpp>
#include <fcppt/signal/auto_connection_container.hpp>
#include <fcppt/signal/object.hpp>
#include <fcppt/config/external_begin.hpp>
#include <utility>
#include <fcppt/config/external_end.hpp>
namespace
{
void
function1()
{
}
void
function2()
{
}
void
function3()
{
}
}
namespace
{
void
take_connection(
fcppt::signal::auto_connection
)
{
// do something with connection
}
}
int
main()
{
typedef fcppt::signal::object<
void ()
> void_signal;
void_signal signal;
// use fcppt::container::make to pass a container of connections
fcppt::signal::auto_connection_container const connections(
fcppt::container::make<
fcppt::signal::auto_connection_container
>(
signal.connect(
void_signal::function{
::function1
}
),
signal.connect(
void_signal::function{
::function2
}
)
)
);
// or you can take the auto_connection and process it somehow
fcppt::signal::auto_connection connection4(
signal.connect(
void_signal::function{
::function3
}
)
);
::take_connection(
std::move(
connection4
)
);
}
//! [signal_connection]
| 15.376344 | 65 | 0.692308 | [
"object"
] |
7b966d71891d9395fa2830c94623bd76f0ee9b1b | 2,035 | hh | C++ | hackt_docker/hackt/src/Object/inst/pint_instance.hh | broken-wheel/hacktist | 36e832ae7dd38b27bca9be7d0889d06054dc2806 | [
"MIT"
] | null | null | null | hackt_docker/hackt/src/Object/inst/pint_instance.hh | broken-wheel/hacktist | 36e832ae7dd38b27bca9be7d0889d06054dc2806 | [
"MIT"
] | null | null | null | hackt_docker/hackt/src/Object/inst/pint_instance.hh | broken-wheel/hacktist | 36e832ae7dd38b27bca9be7d0889d06054dc2806 | [
"MIT"
] | null | null | null | /**
\file "Object/inst/pint_instance.hh"
$Id: pint_instance.hh,v 1.3 2006/10/18 01:19:39 fang Exp $
*/
#ifndef __HAC_OBJECT_INST_PINT_INSTANCE_H__
#define __HAC_OBJECT_INST_PINT_INSTANCE_H__
#include <cassert>
#include <iosfwd>
#include "Object/expr/types.hh"
#include "util/boolean_types.hh"
namespace HAC {
namespace entity {
struct pint_tag;
using std::ostream;
using util::good_bool;
//=============================================================================
/**
Run-time instance of integer parameter.
TODO: add a 'relaxed' poison bit to trace origin of value,
to avoid polluting strict template parameters with relaxed ones.
*/
struct pint_instance {
public:
typedef pint_value_type value_type;
public:
/**
The unroll-time value of this pint parameter.
*/
value_type value;
/**
Whether or not this instance was truly instantiated,
Safeguards against extraneous instances in arrays.
*/
bool instantiated : 1;
/**
Whether or not value has been initialized exactly
once to a value.
*/
bool valid : 1;
public:
pint_instance() : value(-1), instantiated(false), valid(false) { }
explicit
pint_instance(const bool b) :
value(-1), instantiated(b), valid(false) { }
explicit
pint_instance(const value_type v) :
value(v), instantiated(true), valid(true) { }
// default copy constructor
// default destructor
/**
\return false on error, true on success.
*/
good_bool
operator = (const value_type i) {
assert(instantiated);
if (valid)
// error: already initialized
// or allow multiple assignments with the same value?
return good_bool(false);
else {
value = i;
valid = true;
return good_bool(true);
}
}
}; // end struct pint_instance
bool
operator == (const pint_instance& p, const pint_instance& q);
ostream&
operator << (ostream& o, const pint_instance& p);
//=============================================================================
} // end namespace entity
} // end namespace HAC
#endif // __HAC_OBJECT_INST_PINT_INSTANCE_H__
| 23.125 | 79 | 0.657002 | [
"object"
] |
7ba891d970ee6da977ec6dd592175960dca3ded5 | 3,014 | cpp | C++ | Equity/Transaction.cpp | jambolo/Equity | e9f142aec8c5292406b32633fd714c26cf7fd6cd | [
"MIT"
] | null | null | null | Equity/Transaction.cpp | jambolo/Equity | e9f142aec8c5292406b32633fd714c26cf7fd6cd | [
"MIT"
] | null | null | null | Equity/Transaction.cpp | jambolo/Equity | e9f142aec8c5292406b32633fd714c26cf7fd6cd | [
"MIT"
] | null | null | null | #include "Transaction.h"
#include "equity/Script.h"
#include "p2p/Serialize.h"
#include "utility/Endian.h"
#include "utility/Utility.h"
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace Equity;
Equity::Transaction::Input::Input(json const & json)
: txid(json["txid"])
, outputIndex(json["outputIndex"])
, script(Utility::fromHex(json["script"].get<std::string>()))
, sequence(json["sequence"])
{
}
Transaction::Input::Input(uint8_t const * & in, size_t & size)
{
txid = Txid(in, size);
outputIndex = P2p::deserialize<uint32_t>(in, size);
script = P2p::VarArray<uint8_t>(in, size).value();
sequence = P2p::deserialize<uint32_t>(in, size);
}
void Transaction::Input::serialize(std::vector<uint8_t> & out) const
{
P2p::serialize(txid, out);
P2p::serialize(outputIndex, out);
P2p::VarArray<uint8_t>(script).serialize(out);
P2p::serialize(sequence, out);
}
json Transaction::Input::toJson() const
{
return json::object(
{
{ "txid", txid.toJson() },
{ "outputIndex", outputIndex },
{ "script", Script(script).toJson() },
{ "sequence", sequence }
});
}
Transaction::Output::Output(uint8_t const * & in, size_t & size)
{
value = P2p::deserialize<uint64_t>(in, size);
script = P2p::VarArray<uint8_t>(in, size).value();
}
void Transaction::Output::serialize(std::vector<uint8_t> & out) const
{
P2p::serialize(value, out);
P2p::serialize(P2p::VarArray<uint8_t>(script), out);
}
json Transaction::Output::toJson() const
{
return json::object(
{
{ "value", (double)value },
{ "script", Script(script).toJson() }
});
}
Transaction::Transaction(int version, InputList const & inputs, OutputList const & outputs, uint32_t lockTime)
: version_(version)
, inputs_(inputs)
, outputs_(outputs)
, lockTime_(lockTime)
, valid_(true)
{
}
Transaction::Transaction(uint8_t const * & in, size_t & size)
: valid_(false)
{
version_ = Utility::Endian::little(P2p::deserialize<uint32_t>(in, size));
// Only version 1 is valid now.
if (version_ != 1)
throw P2p::DeserializationError();
inputs_ = P2p::VarArray<Input>(in, size).value();
outputs_ = P2p::VarArray<Output>(in, size).value();
lockTime_ = Utility::Endian::little(P2p::deserialize<uint32_t>(in, size));
valid_ = true;
}
Transaction::Transaction(std::string const & json)
: valid_(false)
{
}
void Transaction::serialize(std::vector<uint8_t> & out) const
{
P2p::serialize(Utility::Endian::little(version_), out);
P2p::serialize(P2p::VarArray<Input>(inputs_), out);
P2p::serialize(P2p::VarArray<Output>(outputs_), out);
P2p::serialize(Utility::Endian::little(lockTime_), out);
}
json Transaction::toJson() const
{
return json::object(
{
{ "version", version_ },
{ "inputs", P2p::toJson(inputs_) },
{ "outputs", P2p::toJson(outputs_) },
{ "locktime", lockTime_ }
});
}
| 25.982759 | 110 | 0.637359 | [
"object",
"vector"
] |
7baadec925628b43ae9c97c7801fdeb7dfc9ce19 | 900 | cpp | C++ | Strings/String simulation/longest_common_prefix.cpp | srjhnd/InterviewBit-Solutions | 578c9cb4096fb832f68f44fc43bbe69c228e4c9e | [
"MIT"
] | null | null | null | Strings/String simulation/longest_common_prefix.cpp | srjhnd/InterviewBit-Solutions | 578c9cb4096fb832f68f44fc43bbe69c228e4c9e | [
"MIT"
] | null | null | null | Strings/String simulation/longest_common_prefix.cpp | srjhnd/InterviewBit-Solutions | 578c9cb4096fb832f68f44fc43bbe69c228e4c9e | [
"MIT"
] | null | null | null | /*
Problem:
Longest Common Prefix:
Given the array of strings A,
you need to find the longest string S which is the prefix of ALL the strings
in the array.
Longest common prefix for a pair of strings S1 and S2 is the longest string
S which is the prefix of both S1 and S2.
For Example, longest common prefix of "abcdefgh" and "abcefgh" is "abc".
*/
/*
Solution:
Time: O(N)
Space: O(1)
*/
void compareAndStore(string &ret, string &str) {
if (ret.length() > str.length()) {
swap(ret, str);
}
int len = 0;
while (len < ret.length()) {
if (ret[len] == str[len])
len++;
else
break;
}
ret = str.substr(0, len);
}
string Solution::longestCommonPrefix(vector<string> &A) {
if (A.size() <= 0)
return "";
string ret = A[0];
for (int i = 1; i < A.size(); i++) {
compareAndStore(ret, A[i]);
}
return ret;
}
| 20 | 80 | 0.593333 | [
"vector"
] |
7baf5e647938277e8dbc86cf6ca3583fc001232c | 4,520 | cpp | C++ | draw_blocks.cpp | Charptr0/Sorting-Algorithm-Visualizer | 0c20de884792da9acfa9000007aee2c18dee557f | [
"Apache-2.0"
] | null | null | null | draw_blocks.cpp | Charptr0/Sorting-Algorithm-Visualizer | 0c20de884792da9acfa9000007aee2c18dee557f | [
"Apache-2.0"
] | null | null | null | draw_blocks.cpp | Charptr0/Sorting-Algorithm-Visualizer | 0c20de884792da9acfa9000007aee2c18dee557f | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <SFML/Graphics.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/System/Time.hpp>
#include <ctime>
#include <vector>
#include <stdlib.h>
#include "constants.cpp"
#include "Text_Manager/text.cpp"
using std::vector;
sf::Clock GlobalClock;
int Number_of_comparsions = 0;
Text ComparsionText(std::to_string(Number_of_comparsions) + "Comparsions", 0, 0, TEXT_SIZE);
Text AuthorText("Made by Charptr0 (github.com/Charptr0)", 0, 25, TEXT_SIZE);
Text ElaspedTimeText("Elasped Time: 0s", 0, 50, TEXT_SIZE);
Text CurrentAlgorithmText("", 0, 75, TEXT_SIZE);
void grabEvents(sf::RenderWindow &screen)
{
//SFML event boiler code
sf::Event event;
while (screen.pollEvent(event))
{
if (event.type == sf::Event::Closed)
screen.close();
}
//SFML event boiler code
}
//generate a random number
vector<int> numberGenerator(size_t amount, size_t upperBound = 100)
{
srand(time(NULL));
vector<int>randomNums;
for(size_t i = 0; i < amount; i++)
{
int rand_num = rand() % (upperBound + 1);
rand_num++;
randomNums.push_back(rand_num);
}
return randomNums;
}
//draw the rectangle blocks to the screen
void drawToScreen(vector<int>&nums, sf::RenderWindow &screen)
{
screen.clear(sf::Color::Black); //clear the screen and set the background to black
float offset_x = 0.f;
float rectLength = (RESOLUTION_X/(float)nums.size()); //calculate the length of the rectangle
for(int i = 0; i < nums.size(); i++)
{
grabEvents(screen);
float rectHeight = nums[i] * SIZE_AMPLIFIER; //calculate the height of the rectangle
sf::RectangleShape block;
block.setFillColor(sf::Color::White); //set the rectangle color to white
block.setOutlineColor(sf::Color::Black);
block.setOutlineThickness(1.f);
block.setPosition(sf::Vector2f(offset_x, RESOLUTION_Y-rectHeight)); //set the position
block.setSize(sf::Vector2f(rectLength, rectHeight));
screen.draw(block); //draw the block to the screen
offset_x += rectLength; //increase the x value so it is ready for the next rectangle
}
//display text
//==========================================================================================
screen.draw(ComparsionText.getText());
screen.draw(AuthorText.getText());
sf::Time elaspedTime = GlobalClock.getElapsedTime();
ElaspedTimeText.updateText("Elasped Time: " + std::to_string(elaspedTime.asSeconds()) + "s");
screen.draw(ElaspedTimeText.getText());
screen.draw(CurrentAlgorithmText.getText());
screen.display();
//==========================================================================================
}
//color the rectangle green when the algo is done
void colorBlocksGreen(const vector<int>&nums, sf::RenderWindow &screen, int index = 0)
{
if(index == nums.size()) {return;} //base case: once it has cycle thru the whole array, terminate the function
screen.clear();
//same code from drawToScreen()
float offset_x = 0.f;
float rectLength = (RESOLUTION_X/(float)nums.size());
//same code from drawToScreen()
for(int i = 0; i < nums.size(); i++)
{
grabEvents(screen);
//same code from drawToScreen()
float rectHeight = nums[i] * SIZE_AMPLIFIER;
sf::RectangleShape block;
//same code from drawToScreen()
//color each block green in ascending order
if(i <= index) {block.setFillColor(sf::Color::Green);} //color the blocks green that is before the index var
else {block.setFillColor(sf::Color::White);} //any block that is after the index var, color it white
//same code from drawToScreen()
block.setOutlineColor(sf::Color::Black);
block.setOutlineThickness(1.f);
block.setPosition(sf::Vector2f(offset_x, RESOLUTION_Y-rectHeight));
block.setSize(sf::Vector2f(rectLength, rectHeight));
screen.draw(block);
offset_x += rectLength;
//same code from drawToScreen()
}
screen.draw(ComparsionText.getText());
screen.draw(AuthorText.getText());
sf::Time elaspedTime = GlobalClock.getElapsedTime();
ElaspedTimeText.updateText("Elasped Time: " + std::to_string(elaspedTime.asSeconds()) + "s");
screen.draw(ElaspedTimeText.getText());
screen.draw(CurrentAlgorithmText.getText());
screen.display();
colorBlocksGreen(nums, screen, ++index); //recursion, increment the index by 1
}
| 31.388889 | 116 | 0.64115 | [
"vector"
] |
7bb000cee40a6c13fdde751acc4941acfd8e84ed | 577 | cxx | C++ | Algorithms/Search/minimum-loss.cxx | will-crawford/HackerRank | 74965480ee6a51603eb320e5982b0943fdaf1302 | [
"MIT"
] | null | null | null | Algorithms/Search/minimum-loss.cxx | will-crawford/HackerRank | 74965480ee6a51603eb320e5982b0943fdaf1302 | [
"MIT"
] | null | null | null | Algorithms/Search/minimum-loss.cxx | will-crawford/HackerRank | 74965480ee6a51603eb320e5982b0943fdaf1302 | [
"MIT"
] | null | null | null | #include <cmath>
#include <cstdio>
#include <limits>
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;
const int64_t MaxLoss = numeric_limits<int64_t>::max();
int main() {
int n; cin >> n;
set<int64_t> prior; int64_t pi, loss, best = MaxLoss;
cin >> pi; prior.insert(pi);
while (--n > 0) {
cin >> pi;
auto i = prior.upper_bound(pi);
if ( i != prior.end() && ( loss = *i - pi ) < best )
best = loss;
prior.insert( i, pi );
}
cout << best << endl;
return 0;
}
| 22.192308 | 60 | 0.558059 | [
"vector"
] |
7bb92706b006e492813417bdc496cb872f13c4d9 | 16,584 | cpp | C++ | sqlines-studio3/src/mainwindowpresenter.cpp | 1newstar/sqlines | 7887a10d00f0d92aea34001c9f2b3bcc872d39f6 | [
"Apache-2.0"
] | 299 | 2016-03-19T14:50:39.000Z | 2022-03-25T05:43:52.000Z | sqlines-studio3/src/mainwindowpresenter.cpp | ChrisYuan/sqlines | f82176f154a158105f655d71fb7934dd0ee1c82f | [
"Apache-2.0"
] | 47 | 2016-11-30T23:52:59.000Z | 2021-05-17T10:04:45.000Z | sqlines-studio3/src/mainwindowpresenter.cpp | ChrisYuan/sqlines | f82176f154a158105f655d71fb7934dd0ee1c82f | [
"Apache-2.0"
] | 149 | 2016-03-15T15:06:06.000Z | 2022-03-16T14:38:45.000Z | /**
* Copyright (c) 2021 SQLines
*
* 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 <algorithm>
#include <QDesktopServices>
#include <QUrl>
#include "mainwindowpresenter.hpp"
#include "coreprocess.hpp"
using namespace presenter;
MainWindowPresenter::MainWindowPresenter(const model::Settings& settings,
model::Converter& converter,
view::IMainWindow& mainWindow) noexcept
: settings(settings), converter(converter), mainWindow(mainWindow)
{
openNewTab();
this->converter.updateTabTitle(0, this->mainWindow.currentTabTitle());
this->converter.updateSourceMode(0, this->mainWindow.currentSourceMode());
this->converter.updateTargetMode(0, this->mainWindow.currentTargetMode());
auto view = dynamic_cast<QObject*>(&this->mainWindow);
connect(view, SIGNAL(tabTitleChanged(int,QString)),
this, SLOT(tabTitleChanged(int,QString)));
connect(view, SIGNAL(sourceDataChanged(int,QString)),
this, SLOT(sourceDataChanged(int,QString)));
connect(view, SIGNAL(targetDataChanged(int,QString)),
this, SLOT(targetDataChanged(int,QString)));
connect(view, SIGNAL(sourceModeChanged(int,QString)),
this, SLOT(sourceModeChanged(int,QString)));
connect(view, SIGNAL(targetModeChanged(int,QString)),
this, SLOT(targetModeChanged(int,QString)));
connect(view, SIGNAL(fileOpened(int,QString,QString)),
this, SLOT(fileOpened(int,QString,QString)));
connect(view, SIGNAL(focusChanged(int,view::IMainWindow::FieldInFocus)),
this, SLOT(focusChanged(int,view::IMainWindow::FieldInFocus)));
connect(view, SIGNAL(convertPressed(int)),
this, SLOT(convert(int)));
connect(view, SIGNAL(openNewTabPressed()),
this, SLOT(openNewTab()));
connect(view, SIGNAL(closeTabPressed(int)),
this, SLOT(closeTab(int)));
connect(view, SIGNAL(tabChanged(int)),
this, SLOT(tabChanged(int)));
connect(view, SIGNAL(tabMoved(int,int)),
this, SLOT(tabMoved(int,int)));
connect(view, SIGNAL(openFilePressed(int)),
this, SLOT(openFile(int)));
connect(view, SIGNAL(saveFilePressed(int)),
this, SLOT(saveFile(int)));
connect(view, SIGNAL(saveFileAsPressed(int)),
this, SLOT(saveFileAs(int)));
connect(view, SIGNAL(openAboutPressed()),
this, SIGNAL(openAboutPressed()));
connect(view, SIGNAL(openConvertUtilityPressed()),
this, SIGNAL(openConvertUtilityPressed()));
connect(view, SIGNAL(openSettingsPressed()),
this, SIGNAL(openSettingsPressed()));
connect(view, SIGNAL(openOnlineHelpPressed()),
this, SLOT(openOnlineHelp()));
connect(view, SIGNAL(openContactUsPressed()),
this, SLOT(openContactUs()));
connect(view, SIGNAL(openSitePressed()),
this, SLOT(openSite()));
connect(view, SIGNAL(openSourceCodePressed()),
this, SLOT(openSourceCode()));
}
void MainWindowPresenter::conversionStarted(int tabIndex) noexcept
{
this->mainWindow.showConversionStart(tabIndex);
}
void MainWindowPresenter::conversionEnded(int tabIndex) noexcept
{
this->mainWindow.showConversionEnd(tabIndex);
}
void MainWindowPresenter::conversionCrashed(int tabIndex,
const std::exception_ptr& exception) noexcept
{
try {
std::rethrow_exception(exception);
} catch (const model::Converter::fileCreationError& error) {
QString errorMsg = "Unable to create ";
if (error.fileType() == model::Converter::fileCreationError::FileType::Source) {
errorMsg += "source file.";
} else if (error.fileType() == model::Converter::fileCreationError::FileType::Target) {
errorMsg += "target file.";
} else if (error.fileType() == model::Converter::fileCreationError::FileType::Log) {
errorMsg += "log file.";
}
errorMsg += "\nPath: " + error.filePath();
errorMsg += "\n\n" + QString(error.what()) + ".";
this->mainWindow.showConversionError(tabIndex, errorMsg);
} catch (const model::Converter::fileOpenError& error) {
QString errorMsg = "Unable to open ";
if (error.fileType() == model::Converter::fileOpenError::FileType::Source) {
errorMsg += "source file.";
} else if (error.fileType() == model::Converter::fileOpenError::FileType::Target) {
errorMsg += "target file.";
} else if (error.fileType() == model::Converter::fileOpenError::FileType::Log) {
errorMsg += "log file.";
}
errorMsg += "\nPath: " + error.filePath();
errorMsg += "\n\n" + QString(error.what()) + ".";
this->mainWindow.showConversionError(tabIndex, errorMsg);
} catch (const model::CoreProcess::processError& error) {
QString errorMsg = "Error type: " + error.errorType();
errorMsg += "\nExit code: " + QString::number(error.exitCode());
errorMsg += "\nLog: " + error.log() + ".";
this->mainWindow.showConversionError(tabIndex, errorMsg);
} catch (const model::CoreProcess::noProcess&) {
QString errorMsg = "No SQLines process.\nReinstall the application.";
this->mainWindow.showConversionError(tabIndex, errorMsg);
} catch (const model::Converter::noConfigFile&) {
QString errorMsg = "No config file.\nReinstall the application.";
this->mainWindow.showConversionError(tabIndex, errorMsg);
} catch (const model::Converter::noConversionData&) {
QString errorMsg = "No conversion data.\n"
"Open the file or enter the text manually.";
this->mainWindow.showConversionError(tabIndex, errorMsg);
} catch (...) {
this->mainWindow.showConversionError(tabIndex, "Unknown error.");
}
}
void MainWindowPresenter::remodeled() noexcept
{
this->mainWindow.reset();
}
void MainWindowPresenter::tabAdded() noexcept
{
bool lineNumberEnabled = this->settings["ui.input-field.number-area"].toInt();
bool highlighterEnabled = this->settings["ui.input-field.highlighter"].toInt();
bool wrappingEnabled = this->settings["ui.input-field.wrapping"].toInt();
this->mainWindow.openNewTab(lineNumberEnabled,
highlighterEnabled,
wrappingEnabled);
}
void MainWindowPresenter::tabTitleUpdated(int tabIndex,
const QString& tabTitle) noexcept
{
this->mainWindow.showTabTitle(tabIndex, tabTitle);
}
void MainWindowPresenter::sourceModeUpdated(int, const QString& sourceMode) noexcept
{
this->mainWindow.showSourceMode(sourceMode);
}
void MainWindowPresenter::targetModeUpdated(int, const QString& targetMode) noexcept
{
this->mainWindow.showTargetMode(targetMode);
}
void MainWindowPresenter::sourceDataUpdated(int tabIndex,
const QString& sourceData) noexcept
{
this->mainWindow.showSourceData(tabIndex, sourceData);
}
void MainWindowPresenter::targetDataUpdated(int tabIndex,
const QString& targetData) noexcept
{
this->mainWindow.showTargetData(tabIndex, targetData);
}
void MainWindowPresenter::sourceFilePathUpdated(int tabIndex,
const QString& filePath) noexcept
{
if (this->mainWindow.currentTabIndex() == tabIndex) {
this->mainWindow.showFilePath(filePath);
}
}
void MainWindowPresenter::targetFilePathUpdated(int tabIndex,
const QString& filePath) noexcept
{
if (this->mainWindow.currentTabIndex() == tabIndex) {
this->mainWindow.showFilePath(filePath);
}
}
void MainWindowPresenter::tabTitleChanged(int tabIndex,
const QString& tabTitle) noexcept
{
this->converter.updateTabTitle(tabIndex, tabTitle);
}
void MainWindowPresenter::sourceModeChanged(int tabIndex,
const QString& currentMode) noexcept
{
this->converter.updateSourceMode(tabIndex, currentMode);
}
void MainWindowPresenter::targetModeChanged(int tabIndex,
const QString& currentMode) noexcept
{
this->converter.updateTargetMode(tabIndex, currentMode);
}
void MainWindowPresenter::sourceDataChanged(int tabIndex,
const QString& data) noexcept
{
this->converter.updateSourceData(tabIndex, data);
}
void MainWindowPresenter::targetDataChanged(int tabIndex,
const QString& data) noexcept
{
this->converter.updateTargetData(tabIndex, data);
}
void MainWindowPresenter::fileOpened(int tabIndex,
const QString& sourceData,
const QString& filePath) noexcept
{
this->converter.updateSourceData(tabIndex, sourceData);
this->converter.updateSourceFilePath(tabIndex, filePath);
this->mainWindow.showFilePath(filePath);
}
void MainWindowPresenter::focusChanged(int tabIndex,
view::IMainWindow::FieldInFocus inFocus) noexcept
{
// Show the source file path of the current input field
if (inFocus == view::IMainWindow::FieldInFocus::SourceField) {
const QString& sourcePath = this->converter.sourceFilePath(tabIndex);
this->mainWindow.showFilePath(sourcePath);
} else if (inFocus == view::IMainWindow::FieldInFocus::TargetField) {
const QString& targetPath = this->converter.targetFilePath(tabIndex);
this->mainWindow.showFilePath(targetPath);
}
}
void MainWindowPresenter::convert(int tabIndex) noexcept
{
const QString& sourceFilePath = this->converter.sourceFilePath(tabIndex);
if (!sourceFilePath.isEmpty()) {
saveFile(tabIndex);
}
this->converter.convert(tabIndex);
}
void MainWindowPresenter::openNewTab() noexcept
{
bool lineNumberEnabled = this->settings["ui.input-field.number-area"].toInt();
bool highlighterEnabled = this->settings["ui.input-field.highlighter"].toInt();
bool wrappingEnabled = this->settings["ui.input-field.wrapping"].toInt();
this->converter.addNewTab();
this->mainWindow.openNewTab(lineNumberEnabled,
highlighterEnabled,
wrappingEnabled);
this->converter.updateTabTitle(this->mainWindow.currentTabIndex(),
this->mainWindow.currentTabTitle());
this->converter.updateSourceMode(this->mainWindow.currentTabIndex(),
this->mainWindow.currentSourceMode());
this->converter.updateTargetMode(this->mainWindow.currentTabIndex(),
this->mainWindow.currentTargetMode());
}
void MainWindowPresenter::closeTab(int tabIndex) noexcept
{
if (this->converter.tabsNumber() == 1) {
return;
}
this->converter.deleteTab(tabIndex);
this->mainWindow.closeTab(tabIndex);
}
void MainWindowPresenter::tabChanged(int currTabIndex) noexcept
{
// Show selected modes in current tab
const QString& sourceMode = this->converter.sourceMode(currTabIndex);
const QString& targetMode = this->converter.targetMode(currTabIndex);
this->mainWindow.showSourceMode(sourceMode);
this->mainWindow.showTargetMode(targetMode);
// Show the source file path of the current input field
view::IMainWindow::FieldInFocus inFocus = this->mainWindow.inFocus();
if (inFocus == view::IMainWindow::FieldInFocus::SourceField) {
const QString& sourcePath = this->converter.sourceFilePath(currTabIndex);
this->mainWindow.showFilePath(sourcePath);
} else if (inFocus == view::IMainWindow::FieldInFocus::TargetField) {
const QString& targetPath = this->converter.targetFilePath(currTabIndex);
this->mainWindow.showFilePath(targetPath);
}
}
void MainWindowPresenter::tabMoved(int from, int to) noexcept
{
this->converter.moveTab(from, to);
}
void MainWindowPresenter::openFile(int tabIndex) noexcept
{
QString currDir = this->settings["general.dirs.curr-dir"];
QString path = this->mainWindow.chooseFileToOpen(currDir);
if (path.isEmpty()) {
return;
}
try {
this->converter.openFile(tabIndex, path);
} catch (model::Converter::filesystemError& error) {
QString errorMsg = "Unable to open source file.";
errorMsg += "\nPath: " + error.filePath();
errorMsg += "\n\n" + QString(error.what()) + ".";
errorMsg += "\nUse the Conversion utility"
"(Tools->Conversion utility) for large files.";
this->mainWindow.showFileOpeningError(errorMsg);
}
}
void MainWindowPresenter::saveFile(int tabIndex) noexcept
{
try {
view::IMainWindow::FieldInFocus workingField = this->mainWindow.inFocus();
if (workingField == view::IMainWindow::FieldInFocus::SourceField) {
const QString& filePath = this->converter.sourceFilePath(tabIndex);
if (!filePath.isEmpty()) {
this->converter.saveSourceFile(tabIndex);
} else {
saveFileAs(tabIndex);
}
} else if (workingField == view::IMainWindow::FieldInFocus::TargetField) {
const QString& filePath = this->converter.targetFilePath(tabIndex);
if (!filePath.isEmpty()) {
this->converter.saveTargetFile(tabIndex);
} else {
saveFileAs(tabIndex);
}
}
} catch (const model::Converter::filesystemError& error) {
QString errorMsg = "Unable to open ";
if (error.fileType() == model::Converter::fileOpenError::FileType::Source) {
errorMsg += "source file.";
} else if (error.fileType() == model::Converter::fileOpenError::FileType::Target) {
errorMsg += "target file.";
}
errorMsg += "\nPath: " + error.filePath();
errorMsg += "\n\n" + QString(error.what()) + ".";
this->mainWindow.showFileOpeningError(errorMsg);
}
}
void MainWindowPresenter::saveFileAs(int tabIndex) noexcept
{
QString currDir = this->settings["general.dirs.curr-dir"];
QString path = this->mainWindow.choseFileToCreate(currDir);
if (path.isEmpty()) {
return;
}
try {
view::IMainWindow::FieldInFocus workingField = this->mainWindow.inFocus();
if (workingField == view::IMainWindow::FieldInFocus::SourceField) {
this->converter.saveSourceFileAs(tabIndex, path);
} else if (workingField == view::IMainWindow::FieldInFocus::TargetField) {
this->converter.saveTargetFileAs(tabIndex, path);
}
} catch (const model::Converter::fileOpenError& error) {
QString errorMsg = "Unable to open ";
if (error.fileType() == model::Converter::fileOpenError::FileType::Source) {
errorMsg += "source file.";
} else if (error.fileType() == model::Converter::fileOpenError::FileType::Target) {
errorMsg += "target file.";
}
errorMsg += "\nPath: " + error.filePath();
errorMsg += "\n\n" + QString(error.what()) + ".";
this->mainWindow.showFileOpeningError(errorMsg);
}
}
void MainWindowPresenter::openOnlineHelp() const noexcept
{
QDesktopServices::openUrl(QUrl("https://www.sqlines.com/support"));
}
void MainWindowPresenter::openContactUs() const noexcept
{
QDesktopServices::openUrl(QUrl("https://www.sqlines.com/contact-us"));
}
void MainWindowPresenter::openSite() const noexcept
{
QDesktopServices::openUrl(QUrl("https://www.sqlines.com"));
}
void MainWindowPresenter::openSourceCode() const noexcept
{
QDesktopServices::openUrl(QUrl("https://github.com/dmtolpeko/sqlines/tree/master/sqlines-studio3"));
}
| 35.896104 | 104 | 0.647311 | [
"model"
] |
7bba4048ca3afa6e6d14a9eb16921cf4e70c04fc | 2,678 | cpp | C++ | src/DrawGL2D.cpp | stnoh/cvgl | ada5e459edf3cb84abaae33a6312eb4b8f2ef883 | [
"MIT"
] | null | null | null | src/DrawGL2D.cpp | stnoh/cvgl | ada5e459edf3cb84abaae33a6312eb4b8f2ef883 | [
"MIT"
] | 1 | 2020-12-07T08:14:32.000Z | 2020-12-07T08:14:32.000Z | src/DrawGL2D.cpp | stnoh/cvgl | ada5e459edf3cb84abaae33a6312eb4b8f2ef883 | [
"MIT"
] | null | null | null | /******************************************************************************
Helper for OpenCV image handling with GL
Author: Seung-Tak Noh (seungtak.noh [at] gmail.com)
******************************************************************************/
#include "cvgl/DrawGL2D.h"
#include <glm/ext.hpp>
namespace cvgl {
///////////////////////////////////////////////////////////////////////////////
// draw cv::Mat in OpenGL viewport
///////////////////////////////////////////////////////////////////////////////
void drawImage(const cv::Mat& img, const double a, const double b)
{
int width = img.cols;
int height = img.rows;
GLenum format = GL_BGR;
int channels = img.channels();
switch (channels) {
case 1: format = GL_LUMINANCE; break;
case 2: format = GL_LUMINANCE_ALPHA; break;
case 3: format = GL_BGR; break;
case 4: format = GL_BGRA; break;
default: fprintf(stderr, "invalid pixel channels.\n"); return;
}
int depth = img.depth();
// check image type
/*
int type = GL_UNSIGNED_BYTE;
switch (depth) {
case CV_8U : type = GL_UNSIGNED_BYTE; break;
case CV_8S : type = GL_BYTE; break;
case CV_16U: type = GL_UNSIGNED_SHORT; break;
case CV_16S: type = GL_SHORT; break;
case CV_32S: type = GL_INT; break;
case CV_32F: type = GL_FLOAT; break;
case CV_64F: type = GL_DOUBLE; break;
default: fprintf(stderr, "invalid pixel depth.\n"); break;
}
//*/
if (1.0 == a && 0.0 == b && depth == CV_8U)
{
// in case of unsigned byte: "direct" drawing
glDrawPixels(width, height, format, GL_UNSIGNED_BYTE, img.data);
}
else
{
// in case of different format
int new_type = CV_MAKETYPE(CV_8U, img.channels());
cv::Mat img_8u(img.cols, img.rows, new_type);
img.convertTo(img_8u, new_type, a, b);
glDrawPixels(width, height, format, GL_UNSIGNED_BYTE, img_8u.data);
}
}
void drawImage(const cv::Mat& img, cv::Rect viewportGL, const double a, const double b)
{
cv::Size imgSize = cv::Size(img.cols, img.rows);
if (0 == imgSize.width || 0 == imgSize.height) return; // fast return
// set view-projection matrices with immediate model
float width = (float)viewportGL.width; float height = (float)viewportGL.height;
glm::mat4 proj = glm::ortho( 0.0f, width, 0.0f, height );
glMatrixMode(GL_PROJECTION); glLoadIdentity(); glLoadMatrixf(glm::value_ptr(proj));
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
// image flipping by renderer setting
glRasterPos2f(0.0f, height - 1.0f); // [CAUTION] FLIPPED
float zoom_x = (float)width / (float)imgSize.width;
float zoom_y = (float)height / (float)imgSize.height;
glPixelZoom(zoom_x, -zoom_y); // [CAUTION] FLIPPED
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
drawImage(img, a, b);
}
}
| 31.880952 | 87 | 0.616131 | [
"model"
] |
7bbaacb7e758338ff4091c6cafacdebcb4d02f84 | 138,205 | cpp | C++ | reference_decoders/HM-4.0/source/Lib/TLibCommon/TComTrQuant.cpp | gabrieldiego/VideoAnalyzer | 34890d408820688dc25d7596547859052c9ce673 | [
"Apache-2.0"
] | null | null | null | reference_decoders/HM-4.0/source/Lib/TLibCommon/TComTrQuant.cpp | gabrieldiego/VideoAnalyzer | 34890d408820688dc25d7596547859052c9ce673 | [
"Apache-2.0"
] | null | null | null | reference_decoders/HM-4.0/source/Lib/TLibCommon/TComTrQuant.cpp | gabrieldiego/VideoAnalyzer | 34890d408820688dc25d7596547859052c9ce673 | [
"Apache-2.0"
] | null | null | null | /* The copyright in this software is being made available under the BSD
* License, included below. This software may be subject to other third party
* and contributor rights, including patent rights, and no such rights are
* granted under this license.
*
* Copyright (c) 2010-2011, ITU/ISO/IEC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
*/
/** \file TComTrQuant.cpp
\brief transform and quantization class
*/
#include <stdlib.h>
#include <math.h>
#include <memory.h>
#include "TComTrQuant.h"
#include "TComPic.h"
#include "ContextTables.h"
//! \ingroup TLibCommon
//! \{
// ====================================================================================================================
// Constants
// ====================================================================================================================
#define RDOQ_CHROMA 1 ///< use of RDOQ in chroma
// ====================================================================================================================
// Tables
// ====================================================================================================================
// RDOQ parameter
#if CAVLC_COEF_LRG_BLK
static const int VLClength[14][128] =
#else
static const int VLClength[13][128] =
#endif
{
{ 1, 2, 3, 4, 5, 6, 7, 9, 9,11,11,11,11,13,13,13,13,13,13,13,13,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19},
{ 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8,10,10,10,10,12,12,12,12,12,12,12,12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18},
{ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9,11,11,11,11,11,11,11,11,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17},
{ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16},
{ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13},
{ 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,43,43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,51,51,52,52,53,53,54,54,55,55,56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63,64,64,65,65},
{ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,22,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,27,27,27,27,28,28,28,28,29,29,29,29,30,30,30,30,31,31,31,31,32,32,32,32,33,33,33,33,34,34,34,34},
{ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19},
{ 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13},
{ 1, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,15},
{ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
{ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}
#if CAVLC_COEF_LRG_BLK
,{ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12}
#endif
};
// ====================================================================================================================
// Qp class member functions
// ====================================================================================================================
QpParam::QpParam()
{
}
// ====================================================================================================================
// TComTrQuant class member functions
// ====================================================================================================================
TComTrQuant::TComTrQuant()
{
m_cQP.clear();
// allocate temporary buffers
m_plTempCoeff = new Int[ MAX_CU_SIZE*MAX_CU_SIZE ];
// allocate bit estimation class (for RDOQ)
m_pcEstBitsSbac = new estBitsSbacStruct;
}
TComTrQuant::~TComTrQuant()
{
// delete temporary buffers
if ( m_plTempCoeff )
{
delete [] m_plTempCoeff;
m_plTempCoeff = NULL;
}
// delete bit estimation class
if ( m_pcEstBitsSbac )
{
delete m_pcEstBitsSbac;
}
}
/// Including Chroma QP Parameter setting
Void TComTrQuant::setQPforQuant( Int iQP, Bool bLowpass, SliceType eSliceType, TextType eTxtType)
{
iQP = max( min( iQP, 51 ), 0 );
if(eTxtType != TEXT_LUMA) //Chroma
{
iQP = g_aucChromaScale[ iQP ];
}
m_cQP.setQpParam( iQP, bLowpass, eSliceType );
}
#if MATRIX_MULT
/** NxN forward transform (2D) using brute force matrix multiplication (3 nested loops)
* \param block pointer to input data (residual)
* \param coeff pointer to output data (transform coefficients)
* \param uiStride stride of input data
* \param uiTrSize transform size (uiTrSize x uiTrSize)
* \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
*/
#if INTRA_DST_TYPE_7
void xTr(Pel *block, Int *coeff, UInt uiStride, UInt uiTrSize, UInt uiMode)
#else
void xTr(Pel *block, Int *coeff, UInt uiStride, UInt uiTrSize)
#endif
{
Int i,j,k,iSum;
Int tmp[32*32];
const short *iT;
UInt uiLog2TrSize = g_aucConvertToBit[ uiTrSize ] + 2;
if (uiTrSize==4)
{
iT = g_aiT4[0];
}
else if (uiTrSize==8)
{
iT = g_aiT8[0];
}
else if (uiTrSize==16)
{
iT = g_aiT16[0];
}
else if (uiTrSize==32)
{
iT = g_aiT32[0];
}
else
{
assert(0);
}
#if FULL_NBIT
int shift_1st = uiLog2TrSize - 1 + g_uiBitDepth - 8; // log2(N) - 1 + g_uiBitDepth - 8
#else
int shift_1st = uiLog2TrSize - 1 + g_uiBitIncrement; // log2(N) - 1 + g_uiBitIncrement
#endif
int add_1st = 1<<(shift_1st-1);
int shift_2nd = uiLog2TrSize + 6;
int add_2nd = 1<<(shift_2nd-1);
/* Horizontal transform */
#if INTRA_DST_TYPE_7
if (uiTrSize==4)
{
if (uiMode != REG_DCT && g_aucDCTDSTMode_Hor[uiMode])
{
iT = g_as_DST_MAT_4[0];
}
}
#endif
for (i=0; i<uiTrSize; i++)
{
for (j=0; j<uiTrSize; j++)
{
iSum = 0;
for (k=0; k<uiTrSize; k++)
{
iSum += iT[i*uiTrSize+k]*block[j*uiStride+k];
}
tmp[i*uiTrSize+j] = (iSum + add_1st)>>shift_1st;
}
}
/* Vertical transform */
#if INTRA_DST_TYPE_7
if (uiTrSize==4)
{
if (uiMode != REG_DCT && g_aucDCTDSTMode_Vert[uiMode])
{
iT = g_as_DST_MAT_4[0];
}
else
{
iT = g_aiT4[0];
}
}
#endif
for (i=0; i<uiTrSize; i++)
{
for (j=0; j<uiTrSize; j++)
{
iSum = 0;
for (k=0; k<uiTrSize; k++)
{
iSum += iT[i*uiTrSize+k]*tmp[j*uiTrSize+k];
}
coeff[i*uiTrSize+j] = (iSum + add_2nd)>>shift_2nd;
}
}
}
/** NxN inverse transform (2D) using brute force matrix multiplication (3 nested loops)
* \param coeff pointer to input data (transform coefficients)
* \param block pointer to output data (residual)
* \param uiStride stride of output data
* \param uiTrSize transform size (uiTrSize x uiTrSize)
* \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
*/
#if INTRA_DST_TYPE_7
void xITr(Int *coeff, Pel *block, UInt uiStride, UInt uiTrSize, UInt uiMode)
#else
void xITr(Int *coeff, Pel *block, UInt uiStride, UInt uiTrSize)
#endif
{
int i,j,k,iSum;
Int tmp[32*32];
const short *iT;
if (uiTrSize==4)
{
iT = g_aiT4[0];
}
else if (uiTrSize==8)
{
iT = g_aiT8[0];
}
else if (uiTrSize==16)
{
iT = g_aiT16[0];
}
else if (uiTrSize==32)
{
iT = g_aiT32[0];
}
else
{
assert(0);
}
int shift_1st = SHIFT_INV_1ST;
int add_1st = 1<<(shift_1st-1);
#if FULL_NBIT
int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
#else
int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
#endif
int add_2nd = 1<<(shift_2nd-1);
#if INTRA_DST_TYPE_7
if (uiTrSize==4)
{
if (uiMode != REG_DCT && g_aucDCTDSTMode_Vert[uiMode] ) // Check for DCT or DST
{
iT = g_as_DST_MAT_4[0];
}
}
#endif
/* Horizontal transform */
for (i=0; i<uiTrSize; i++)
{
for (j=0; j<uiTrSize; j++)
{
iSum = 0;
for (k=0; k<uiTrSize; k++)
{
iSum += iT[k*uiTrSize+i]*coeff[k*uiTrSize+j];
}
tmp[i*uiTrSize+j] = (iSum + add_1st)>>shift_1st;
}
}
#if INTRA_DST_TYPE_7
if (uiTrSize==4)
{
if (uiMode != REG_DCT && g_aucDCTDSTMode_Hor[uiMode] ) // Check for DCT or DST
{
iT = g_as_DST_MAT_4[0];
}
else
{
iT = g_aiT4[0];
}
}
#endif
/* Vertical transform */
for (i=0; i<uiTrSize; i++)
{
for (j=0; j<uiTrSize; j++)
{
iSum = 0;
for (k=0; k<uiTrSize; k++)
{
iSum += iT[k*uiTrSize+j]*tmp[i*uiTrSize+k];
}
block[i*uiStride+j] = (iSum + add_2nd)>>shift_2nd;
}
}
}
#else //MATRIX_MULT
/** 4x4 forward transform implemented using partial butterfly structure (1D)
* \param src input data (residual)
* \param dst output data (transform coefficients)
* \param shift specifies right shift after 1D transform
*/
void partialButterfly4(short src[4][4],short dst[4][4],int shift)
{
int j;
int E[2],O[2];
int add = 1<<(shift-1);
for (j=0; j<4; j++)
{
/* E and O */
E[0] = src[j][0] + src[j][3];
O[0] = src[j][0] - src[j][3];
E[1] = src[j][1] + src[j][2];
O[1] = src[j][1] - src[j][2];
dst[0][j] = (g_aiT4[0][0]*E[0] + g_aiT4[0][1]*E[1] + add)>>shift;
dst[2][j] = (g_aiT4[2][0]*E[0] + g_aiT4[2][1]*E[1] + add)>>shift;
dst[1][j] = (g_aiT4[1][0]*O[0] + g_aiT4[1][1]*O[1] + add)>>shift;
dst[3][j] = (g_aiT4[3][0]*O[0] + g_aiT4[3][1]*O[1] + add)>>shift;
}
}
#if NSQT
void partialButterfly4(short *src,short *dst,int shift, int line)
{
int j;
int E[2],O[2];
int add = 1<<(shift-1);
for (j=0; j<line; j++)
{
/* E and O */
E[0] = src[0] + src[3];
O[0] = src[0] - src[3];
E[1] = src[1] + src[2];
O[1] = src[1] - src[2];
dst[0] = (g_aiT4[0][0]*E[0] + g_aiT4[0][1]*E[1] + add)>>shift;
dst[2*line] = (g_aiT4[2][0]*E[0] + g_aiT4[2][1]*E[1] + add)>>shift;
dst[line] = (g_aiT4[1][0]*O[0] + g_aiT4[1][1]*O[1] + add)>>shift;
dst[3*line] = (g_aiT4[3][0]*O[0] + g_aiT4[3][1]*O[1] + add)>>shift;
src += 4;
dst ++;
}
}
#endif
#if INTRA_DST_TYPE_7
// Fast DST Algorithm. Full matrix multiplication for DST and Fast DST algorithm
// give identical results
void fastForwardDst(short block[4][4],short coeff[4][4],int shift) // input block, output coeff
{
int i, c[4];
int rnd_factor = 1<<(shift-1);
for (i=0; i<4; i++)
{
// Intermediate Variables
c[0] = block[i][0] + block[i][3];
c[1] = block[i][1] + block[i][3];
c[2] = block[i][0] - block[i][1];
c[3] = 74* block[i][2];
coeff[0][i] = ( 29 * c[0] + 55 * c[1] + c[3] + rnd_factor ) >> shift;
coeff[1][i] = ( 74 * (block[i][0]+ block[i][1] - block[i][3]) + rnd_factor ) >> shift;
coeff[2][i] = ( 29 * c[2] + 55 * c[0] - c[3] + rnd_factor ) >> shift;
coeff[3][i] = ( 55 * c[2] - 29 * c[1] + c[3] + rnd_factor ) >> shift;
}
}
void fastInverseDst(short tmp[4][4],short block[4][4],int shift) // input tmp, output block
{
int i, c[4];
int rnd_factor = 1<<(shift-1);
for (i=0; i<4; i++)
{
// Intermediate Variables
c[0] = tmp[0][i] + tmp[2][i];
c[1] = tmp[2][i] + tmp[3][i];
c[2] = tmp[0][i] - tmp[3][i];
c[3] = 74* tmp[1][i];
block[i][0] = ( 29 * c[0] + 55 * c[1] + c[3] + rnd_factor ) >> shift;
block[i][1] = ( 55 * c[2] - 29 * c[1] + c[3] + rnd_factor ) >> shift;
block[i][2] = ( 74 * (tmp[0][i] - tmp[2][i] + tmp[3][i]) + rnd_factor ) >> shift;
block[i][3] = ( 55 * c[0] + 29 * c[2] - c[3] + rnd_factor ) >> shift;
}
}
#endif
/** 4x4 forward transform (2D)
* \param block input data (residual)
* \param coeff output data (transform coefficients)
* \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
*/
#if INTRA_DST_TYPE_7
void xTr4(short block[4][4],short coeff[4][4],UInt uiMode)
#else
void xTr4(short block[4][4],short coeff[4][4])
#endif
{
#if FULL_NBIT
int shift_1st = 1 + g_uiBitDepth - 8; // log2(4) - 1 + g_uiBitDepth - 8
#else
int shift_1st = 1 + g_uiBitIncrement; // log2(4) - 1 + g_uiBitIncrement
#endif
int shift_2nd = 8; // log2(4) + 6
short tmp[4][4];
#if INTRA_DST_TYPE_7
if (uiMode != REG_DCT && g_aucDCTDSTMode_Hor[uiMode])// Check for DCT or DST
{
fastForwardDst(block,tmp,shift_1st); // Forward DST BY FAST ALGORITHM, block input, tmp output
}
else
{
partialButterfly4(block,tmp,shift_1st);
}
#else
partialButterfly4(block,tmp,shift_1st);
#endif
#if INTRA_DST_TYPE_7
if (uiMode != REG_DCT && g_aucDCTDSTMode_Vert[uiMode] ) // Check for DCT or DST
{
fastForwardDst(tmp,coeff,shift_2nd); // Forward DST BY FAST ALGORITHM, tmp input, coeff output
}
else
{
partialButterfly4(tmp,coeff,shift_2nd);
}
#else
partialButterfly4(tmp,coeff,shift_2nd);
#endif
}
/** 4x4 inverse transform implemented using partial butterfly structure (1D)
* \param src input data (transform coefficients)
* \param dst output data (residual)
* \param shift specifies right shift after 1D transform
*/
void partialButterflyInverse4(short src[4][4],short dst[4][4],int shift)
{
int j;
int E[2],O[2];
int add = 1<<(shift-1);
for (j=0; j<4; j++)
{
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
O[0] = g_aiT4[1][0]*src[1][j] + g_aiT4[3][0]*src[3][j];
O[1] = g_aiT4[1][1]*src[1][j] + g_aiT4[3][1]*src[3][j];
E[0] = g_aiT4[0][0]*src[0][j] + g_aiT4[2][0]*src[2][j];
E[1] = g_aiT4[0][1]*src[0][j] + g_aiT4[2][1]*src[2][j];
/* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
dst[j][0] = (E[0] + O[0] + add)>>shift;
dst[j][1] = (E[1] + O[1] + add)>>shift;
dst[j][2] = (E[1] - O[1] + add)>>shift;
dst[j][3] = (E[0] - O[0] + add)>>shift;
}
}
#if NSQT
void partialButterflyInverse4(short *src,short *dst,int shift, int line)
{
int j;
int E[2],O[2];
int add = 1<<(shift-1);
for (j=0; j<line; j++)
{
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
O[0] = g_aiT4[1][0]*src[line] + g_aiT4[3][0]*src[3*line];
O[1] = g_aiT4[1][1]*src[line] + g_aiT4[3][1]*src[3*line];
E[0] = g_aiT4[0][0]*src[0] + g_aiT4[2][0]*src[2*line];
E[1] = g_aiT4[0][1]*src[0] + g_aiT4[2][1]*src[2*line];
/* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
dst[0] = (E[0] + O[0] + add)>>shift;
dst[1] = (E[1] + O[1] + add)>>shift;
dst[2] = (E[1] - O[1] + add)>>shift;
dst[3] = (E[0] - O[0] + add)>>shift;
src ++;
dst += 4;
}
}
#endif
/** 4x4 inverse transform (2D)
* \param coeff input data (transform coefficients)
* \param block output data (residual)
* \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
*/
#if INTRA_DST_TYPE_7
void xITr4(short coeff[4][4],short block[4][4], UInt uiMode)
#else
void xITr4(short coeff[4][4],short block[4][4])
#endif
{
int shift_1st = SHIFT_INV_1ST;
#if FULL_NBIT
int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
#else
int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
#endif
short tmp[4][4];
#if INTRA_DST_TYPE_7
if (uiMode != REG_DCT && g_aucDCTDSTMode_Vert[uiMode] ) // Check for DCT or DST
{
fastInverseDst(coeff,tmp,shift_1st); // Inverse DST by FAST Algorithm, coeff input, tmp output
}
else
{
partialButterflyInverse4(coeff,tmp,shift_1st);
}
#else
partialButterflyInverse4(coeff,tmp,shift_1st);
#endif
#if INTRA_DST_TYPE_7
if (uiMode != REG_DCT && g_aucDCTDSTMode_Hor[uiMode] ) // Check for DCT or DST
{
fastInverseDst(tmp,block,shift_2nd); // Inverse DST by FAST Algorithm, tmp input, coeff output
}
else
{
partialButterflyInverse4(tmp,block,shift_2nd);
}
#else
partialButterflyInverse4(tmp,block,shift_2nd);
#endif
}
/** 8x8 forward transform implemented using partial butterfly structure (1D)
* \param src input data (residual)
* \param dst output data (transform coefficients)
* \param shift specifies right shift after 1D transform
*/
void partialButterfly8(short src[8][8],short dst[8][8],int shift)
{
int j,k;
int E[4],O[4];
int EE[2],EO[2];
int add = 1<<(shift-1);
for (j=0; j<8; j++)
{
/* E and O*/
for (k=0;k<4;k++)
{
E[k] = src[j][k] + src[j][7-k];
O[k] = src[j][k] - src[j][7-k];
}
/* EE and EO */
EE[0] = E[0] + E[3];
EO[0] = E[0] - E[3];
EE[1] = E[1] + E[2];
EO[1] = E[1] - E[2];
dst[0][j] = (g_aiT8[0][0]*EE[0] + g_aiT8[0][1]*EE[1] + add)>>shift;
dst[4][j] = (g_aiT8[4][0]*EE[0] + g_aiT8[4][1]*EE[1] + add)>>shift;
dst[2][j] = (g_aiT8[2][0]*EO[0] + g_aiT8[2][1]*EO[1] + add)>>shift;
dst[6][j] = (g_aiT8[6][0]*EO[0] + g_aiT8[6][1]*EO[1] + add)>>shift;
dst[1][j] = (g_aiT8[1][0]*O[0] + g_aiT8[1][1]*O[1] + g_aiT8[1][2]*O[2] + g_aiT8[1][3]*O[3] + add)>>shift;
dst[3][j] = (g_aiT8[3][0]*O[0] + g_aiT8[3][1]*O[1] + g_aiT8[3][2]*O[2] + g_aiT8[3][3]*O[3] + add)>>shift;
dst[5][j] = (g_aiT8[5][0]*O[0] + g_aiT8[5][1]*O[1] + g_aiT8[5][2]*O[2] + g_aiT8[5][3]*O[3] + add)>>shift;
dst[7][j] = (g_aiT8[7][0]*O[0] + g_aiT8[7][1]*O[1] + g_aiT8[7][2]*O[2] + g_aiT8[7][3]*O[3] + add)>>shift;
}
}
#if NSQT
void partialButterfly8(short *src,short *dst,int shift, int line)
{
int j,k;
int E[4],O[4];
int EE[2],EO[2];
int add = 1<<(shift-1);
for (j=0; j<line; j++)
{
/* E and O*/
for (k=0;k<4;k++)
{
E[k] = src[k] + src[7-k];
O[k] = src[k] - src[7-k];
}
/* EE and EO */
EE[0] = E[0] + E[3];
EO[0] = E[0] - E[3];
EE[1] = E[1] + E[2];
EO[1] = E[1] - E[2];
dst[0] = (g_aiT8[0][0]*EE[0] + g_aiT8[0][1]*EE[1] + add)>>shift;
dst[4*line] = (g_aiT8[4][0]*EE[0] + g_aiT8[4][1]*EE[1] + add)>>shift;
dst[2*line] = (g_aiT8[2][0]*EO[0] + g_aiT8[2][1]*EO[1] + add)>>shift;
dst[6*line] = (g_aiT8[6][0]*EO[0] + g_aiT8[6][1]*EO[1] + add)>>shift;
dst[line] = (g_aiT8[1][0]*O[0] + g_aiT8[1][1]*O[1] + g_aiT8[1][2]*O[2] + g_aiT8[1][3]*O[3] + add)>>shift;
dst[3*line] = (g_aiT8[3][0]*O[0] + g_aiT8[3][1]*O[1] + g_aiT8[3][2]*O[2] + g_aiT8[3][3]*O[3] + add)>>shift;
dst[5*line] = (g_aiT8[5][0]*O[0] + g_aiT8[5][1]*O[1] + g_aiT8[5][2]*O[2] + g_aiT8[5][3]*O[3] + add)>>shift;
dst[7*line] = (g_aiT8[7][0]*O[0] + g_aiT8[7][1]*O[1] + g_aiT8[7][2]*O[2] + g_aiT8[7][3]*O[3] + add)>>shift;
src += 8;
dst ++;
}
}
#endif
/** 8x8 forward transform (2D)
* \param block input data (residual)
* \param coeff output data (transform coefficients)
*/
void xTr8(short block[8][8],short coeff[8][8])
{
#if FULL_NBIT
int shift_1st = 2 + g_uiBitDepth - 8; // log2(8) - 1 + g_uiBitDepth - 8
#else
int shift_1st = 2 + g_uiBitIncrement; // log2(8) - 1 + g_uiBitIncrement
#endif
int shift_2nd = 9; // log2(8) + 6
short tmp[8][8];
partialButterfly8(block,tmp,shift_1st);
partialButterfly8(tmp,coeff,shift_2nd);
}
/** 8x8 inverse transform implemented using partial butterfly structure (1D)
* \param src input data (transform coefficients)
* \param dst output data (residual)
* \param shift specifies right shift after 1D transform
*/
void partialButterflyInverse8(short src[8][8],short dst[8][8],int shift)
{
int j,k;
int E[4],O[4];
int EE[2],EO[2];
int add = 1<<(shift-1);
for (j=0; j<8; j++)
{
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
for (k=0;k<4;k++)
{
O[k] = g_aiT8[ 1][k]*src[ 1][j] + g_aiT8[ 3][k]*src[ 3][j] + g_aiT8[ 5][k]*src[ 5][j] + g_aiT8[ 7][k]*src[ 7][j];
}
EO[0] = g_aiT8[2][0]*src[2][j] + g_aiT8[6][0]*src[6][j];
EO[1] = g_aiT8[2][1]*src[2][j] + g_aiT8[6][1]*src[6][j];
EE[0] = g_aiT8[0][0]*src[0][j] + g_aiT8[4][0]*src[4][j];
EE[1] = g_aiT8[0][1]*src[0][j] + g_aiT8[4][1]*src[4][j];
/* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
E[0] = EE[0] + EO[0];
E[3] = EE[0] - EO[0];
E[1] = EE[1] + EO[1];
E[2] = EE[1] - EO[1];
for (k=0;k<4;k++)
{
dst[j][k] = (E[k] + O[k] + add)>>shift;
dst[j][k+4] = (E[3-k] - O[3-k] + add)>>shift;
}
}
}
#if NSQT
void partialButterflyInverse8(short *src,short *dst,int shift, int line)
{
int j,k;
int E[4],O[4];
int EE[2],EO[2];
int add = 1<<(shift-1);
for (j=0; j<line; j++)
{
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
for (k=0;k<4;k++)
{
O[k] = g_aiT8[ 1][k]*src[line] + g_aiT8[ 3][k]*src[3*line] + g_aiT8[ 5][k]*src[5*line] + g_aiT8[ 7][k]*src[7*line];
}
EO[0] = g_aiT8[2][0]*src[ 2*line ] + g_aiT8[6][0]*src[ 6*line ];
EO[1] = g_aiT8[2][1]*src[ 2*line ] + g_aiT8[6][1]*src[ 6*line ];
EE[0] = g_aiT8[0][0]*src[ 0 ] + g_aiT8[4][0]*src[ 4*line ];
EE[1] = g_aiT8[0][1]*src[ 0 ] + g_aiT8[4][1]*src[ 4*line ];
/* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
E[0] = EE[0] + EO[0];
E[3] = EE[0] - EO[0];
E[1] = EE[1] + EO[1];
E[2] = EE[1] - EO[1];
for (k=0;k<4;k++)
{
dst[ k ] = (E[k] + O[k] + add)>>shift;
dst[ k+4 ] = (E[3-k] - O[3-k] + add)>>shift;
}
src ++;
dst += 8;
}
}
#endif
/** 8x8 inverse transform (2D)
* \param coeff input data (transform coefficients)
* \param block output data (residual)
*/
void xITr8(short coeff[8][8],short block[8][8])
{
int shift_1st = SHIFT_INV_1ST;
#if FULL_NBIT
int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
#else
int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
#endif
short tmp[8][8];
partialButterflyInverse8(coeff,tmp,shift_1st);
partialButterflyInverse8(tmp,block,shift_2nd);
}
/** 16x16 forward transform implemented using partial butterfly structure (1D)
* \param src input data (residual)
* \param dst output data (transform coefficients)
* \param shift specifies right shift after 1D transform
*/
void partialButterfly16(short src[16][16],short dst[16][16],int shift)
{
int j,k;
int E[8],O[8];
int EE[4],EO[4];
int EEE[2],EEO[2];
int add = 1<<(shift-1);
for (j=0; j<16; j++)
{
/* E and O*/
for (k=0;k<8;k++)
{
E[k] = src[j][k] + src[j][15-k];
O[k] = src[j][k] - src[j][15-k];
}
/* EE and EO */
for (k=0;k<4;k++)
{
EE[k] = E[k] + E[7-k];
EO[k] = E[k] - E[7-k];
}
/* EEE and EEO */
EEE[0] = EE[0] + EE[3];
EEO[0] = EE[0] - EE[3];
EEE[1] = EE[1] + EE[2];
EEO[1] = EE[1] - EE[2];
dst[ 0][j] = (g_aiT16[ 0][0]*EEE[0] + g_aiT16[ 0][1]*EEE[1] + add)>>shift;
dst[ 8][j] = (g_aiT16[ 8][0]*EEE[0] + g_aiT16[ 8][1]*EEE[1] + add)>>shift;
dst[ 4][j] = (g_aiT16[ 4][0]*EEO[0] + g_aiT16[ 4][1]*EEO[1] + add)>>shift;
dst[12][j] = (g_aiT16[12][0]*EEO[0] + g_aiT16[12][1]*EEO[1] + add)>>shift;
for (k=2;k<16;k+=4)
{
dst[k][j] = (g_aiT16[k][0]*EO[0] + g_aiT16[k][1]*EO[1] + g_aiT16[k][2]*EO[2] + g_aiT16[k][3]*EO[3] + add)>>shift;
}
for (k=1;k<16;k+=2)
{
dst[k][j] = (g_aiT16[k][0]*O[0] + g_aiT16[k][1]*O[1] + g_aiT16[k][2]*O[2] + g_aiT16[k][3]*O[3] +
g_aiT16[k][4]*O[4] + g_aiT16[k][5]*O[5] + g_aiT16[k][6]*O[6] + g_aiT16[k][7]*O[7] + add)>>shift;
}
}
}
#if NSQT
void partialButterfly16(short *src,short *dst,int shift, int line)
{
int j,k;
int E[8],O[8];
int EE[4],EO[4];
int EEE[2],EEO[2];
int add = 1<<(shift-1);
for (j=0; j<line; j++)
{
/* E and O*/
for (k=0;k<8;k++)
{
E[k] = src[k] + src[15-k];
O[k] = src[k] - src[15-k];
}
/* EE and EO */
for (k=0;k<4;k++)
{
EE[k] = E[k] + E[7-k];
EO[k] = E[k] - E[7-k];
}
/* EEE and EEO */
EEE[0] = EE[0] + EE[3];
EEO[0] = EE[0] - EE[3];
EEE[1] = EE[1] + EE[2];
EEO[1] = EE[1] - EE[2];
dst[ 0 ] = (g_aiT16[ 0][0]*EEE[0] + g_aiT16[ 0][1]*EEE[1] + add)>>shift;
dst[ 8*line ] = (g_aiT16[ 8][0]*EEE[0] + g_aiT16[ 8][1]*EEE[1] + add)>>shift;
dst[ 4*line ] = (g_aiT16[ 4][0]*EEO[0] + g_aiT16[ 4][1]*EEO[1] + add)>>shift;
dst[ 12*line] = (g_aiT16[12][0]*EEO[0] + g_aiT16[12][1]*EEO[1] + add)>>shift;
for (k=2;k<16;k+=4)
{
dst[ k*line ] = (g_aiT16[k][0]*EO[0] + g_aiT16[k][1]*EO[1] + g_aiT16[k][2]*EO[2] + g_aiT16[k][3]*EO[3] + add)>>shift;
}
for (k=1;k<16;k+=2)
{
dst[ k*line ] = (g_aiT16[k][0]*O[0] + g_aiT16[k][1]*O[1] + g_aiT16[k][2]*O[2] + g_aiT16[k][3]*O[3] +
g_aiT16[k][4]*O[4] + g_aiT16[k][5]*O[5] + g_aiT16[k][6]*O[6] + g_aiT16[k][7]*O[7] + add)>>shift;
}
src += 16;
dst ++;
}
}
#endif
/** 16x16 forward transform (2D)
* \param block input data (residual)
* \param coeff output data (transform coefficients)
*/
void xTr16(short block[16][16],short coeff[16][16])
{
#if FULL_NBIT
int shift_1st = 3 + g_uiBitDepth - 8; // log2(16) - 1 + g_uiBitDepth - 8
#else
int shift_1st = 3 + g_uiBitIncrement; // log2(16) - 1 + g_uiBitIncrement
#endif
int shift_2nd = 10; // log2(16) + 6
short tmp[16][16];
partialButterfly16(block,tmp,shift_1st);
partialButterfly16(tmp,coeff,shift_2nd);
}
/** 16x16 inverse transform implemented using partial butterfly structure (1D)
* \param src input data (transform coefficients)
* \param dst output data (residual)
* \param shift specifies right shift after 1D transform
*/
void partialButterflyInverse16(short src[16][16],short dst[16][16],int shift)
{
int j,k;
int E[8],O[8];
int EE[4],EO[4];
int EEE[2],EEO[2];
int add = 1<<(shift-1);
for (j=0; j<16; j++)
{
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
for (k=0;k<8;k++)
{
O[k] = g_aiT16[ 1][k]*src[ 1][j] + g_aiT16[ 3][k]*src[ 3][j] + g_aiT16[ 5][k]*src[ 5][j] + g_aiT16[ 7][k]*src[ 7][j] +
g_aiT16[ 9][k]*src[ 9][j] + g_aiT16[11][k]*src[11][j] + g_aiT16[13][k]*src[13][j] + g_aiT16[15][k]*src[15][j];
}
for (k=0;k<4;k++)
{
EO[k] = g_aiT16[ 2][k]*src[ 2][j] + g_aiT16[ 6][k]*src[ 6][j] + g_aiT16[10][k]*src[10][j] + g_aiT16[14][k]*src[14][j];
}
EEO[0] = g_aiT16[4][0]*src[4][j] + g_aiT16[12][0]*src[12][j];
EEE[0] = g_aiT16[0][0]*src[0][j] + g_aiT16[ 8][0]*src[ 8][j];
EEO[1] = g_aiT16[4][1]*src[4][j] + g_aiT16[12][1]*src[12][j];
EEE[1] = g_aiT16[0][1]*src[0][j] + g_aiT16[ 8][1]*src[ 8][j];
/* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
for (k=0;k<2;k++)
{
EE[k] = EEE[k] + EEO[k];
EE[k+2] = EEE[1-k] - EEO[1-k];
}
for (k=0;k<4;k++)
{
E[k] = EE[k] + EO[k];
E[k+4] = EE[3-k] - EO[3-k];
}
for (k=0;k<8;k++)
{
dst[j][k] = (E[k] + O[k] + add)>>shift;
dst[j][k+8] = (E[7-k] - O[7-k] + add)>>shift;
}
}
}
#if NSQT
void partialButterflyInverse16(short *src,short *dst,int shift, int line)
{
int j,k;
int E[8],O[8];
int EE[4],EO[4];
int EEE[2],EEO[2];
int add = 1<<(shift-1);
for (j=0; j<line; j++)
{
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
for (k=0;k<8;k++)
{
O[k] = g_aiT16[ 1][k]*src[ line] + g_aiT16[ 3][k]*src[ 3*line] + g_aiT16[ 5][k]*src[ 5*line] + g_aiT16[ 7][k]*src[ 7*line] +
g_aiT16[ 9][k]*src[ 9*line] + g_aiT16[11][k]*src[11*line] + g_aiT16[13][k]*src[13*line] + g_aiT16[15][k]*src[15*line];
}
for (k=0;k<4;k++)
{
EO[k] = g_aiT16[ 2][k]*src[ 2*line] + g_aiT16[ 6][k]*src[ 6*line] + g_aiT16[10][k]*src[10*line] + g_aiT16[14][k]*src[14*line];
}
EEO[0] = g_aiT16[4][0]*src[ 4*line ] + g_aiT16[12][0]*src[ 12*line ];
EEE[0] = g_aiT16[0][0]*src[ 0 ] + g_aiT16[ 8][0]*src[ 8*line ];
EEO[1] = g_aiT16[4][1]*src[ 4*line ] + g_aiT16[12][1]*src[ 12*line ];
EEE[1] = g_aiT16[0][1]*src[ 0 ] + g_aiT16[ 8][1]*src[ 8*line ];
/* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
for (k=0;k<2;k++)
{
EE[k] = EEE[k] + EEO[k];
EE[k+2] = EEE[1-k] - EEO[1-k];
}
for (k=0;k<4;k++)
{
E[k] = EE[k] + EO[k];
E[k+4] = EE[3-k] - EO[3-k];
}
for (k=0;k<8;k++)
{
dst[k] = (E[k] + O[k] + add)>>shift;
dst[k+8] = (E[7-k] - O[7-k] + add)>>shift;
}
src ++;
dst += 16;
}
}
#endif
/** 16x16 inverse transform (2D)
* \param coeff input data (transform coefficients)
* \param block output data (residual)
*/
void xITr16(short coeff[16][16],short block[16][16])
{
int shift_1st = SHIFT_INV_1ST;
#if FULL_NBIT
int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
#else
int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
#endif
short tmp[16][16];
partialButterflyInverse16(coeff,tmp,shift_1st);
partialButterflyInverse16(tmp,block,shift_2nd);
}
/** 32x32 forward transform implemented using partial butterfly structure (1D)
* \param src input data (residual)
* \param dst output data (transform coefficients)
* \param shift specifies right shift after 1D transform
*/
void partialButterfly32(short src[32][32],short dst[32][32],int shift)
{
int j,k;
int E[16],O[16];
int EE[8],EO[8];
int EEE[4],EEO[4];
int EEEE[2],EEEO[2];
int add = 1<<(shift-1);
for (j=0; j<32; j++)
{
/* E and O*/
for (k=0;k<16;k++)
{
E[k] = src[j][k] + src[j][31-k];
O[k] = src[j][k] - src[j][31-k];
}
/* EE and EO */
for (k=0;k<8;k++)
{
EE[k] = E[k] + E[15-k];
EO[k] = E[k] - E[15-k];
}
/* EEE and EEO */
for (k=0;k<4;k++)
{
EEE[k] = EE[k] + EE[7-k];
EEO[k] = EE[k] - EE[7-k];
}
/* EEEE and EEEO */
EEEE[0] = EEE[0] + EEE[3];
EEEO[0] = EEE[0] - EEE[3];
EEEE[1] = EEE[1] + EEE[2];
EEEO[1] = EEE[1] - EEE[2];
dst[ 0][j] = (g_aiT32[ 0][0]*EEEE[0] + g_aiT32[ 0][1]*EEEE[1] + add)>>shift;
dst[16][j] = (g_aiT32[16][0]*EEEE[0] + g_aiT32[16][1]*EEEE[1] + add)>>shift;
dst[ 8][j] = (g_aiT32[ 8][0]*EEEO[0] + g_aiT32[ 8][1]*EEEO[1] + add)>>shift;
dst[24][j] = (g_aiT32[24][0]*EEEO[0] + g_aiT32[24][1]*EEEO[1] + add)>>shift;
for (k=4;k<32;k+=8)
{
dst[k][j] = (g_aiT32[k][0]*EEO[0] + g_aiT32[k][1]*EEO[1] + g_aiT32[k][2]*EEO[2] + g_aiT32[k][3]*EEO[3] + add)>>shift;
}
for (k=2;k<32;k+=4)
{
dst[k][j] = (g_aiT32[k][0]*EO[0] + g_aiT32[k][1]*EO[1] + g_aiT32[k][2]*EO[2] + g_aiT32[k][3]*EO[3] +
g_aiT32[k][4]*EO[4] + g_aiT32[k][5]*EO[5] + g_aiT32[k][6]*EO[6] + g_aiT32[k][7]*EO[7] + add)>>shift;
}
for (k=1;k<32;k+=2)
{
dst[k][j] = (g_aiT32[k][ 0]*O[ 0] + g_aiT32[k][ 1]*O[ 1] + g_aiT32[k][ 2]*O[ 2] + g_aiT32[k][ 3]*O[ 3] +
g_aiT32[k][ 4]*O[ 4] + g_aiT32[k][ 5]*O[ 5] + g_aiT32[k][ 6]*O[ 6] + g_aiT32[k][ 7]*O[ 7] +
g_aiT32[k][ 8]*O[ 8] + g_aiT32[k][ 9]*O[ 9] + g_aiT32[k][10]*O[10] + g_aiT32[k][11]*O[11] +
g_aiT32[k][12]*O[12] + g_aiT32[k][13]*O[13] + g_aiT32[k][14]*O[14] + g_aiT32[k][15]*O[15] + add)>>shift;
}
}
}
#if NSQT
void partialButterfly32(short *src,short *dst,int shift, int line)
{
int j,k;
int E[16],O[16];
int EE[8],EO[8];
int EEE[4],EEO[4];
int EEEE[2],EEEO[2];
int add = 1<<(shift-1);
for (j=0; j<line; j++)
{
/* E and O*/
for (k=0;k<16;k++)
{
E[k] = src[k] + src[31-k];
O[k] = src[k] - src[31-k];
}
/* EE and EO */
for (k=0;k<8;k++)
{
EE[k] = E[k] + E[15-k];
EO[k] = E[k] - E[15-k];
}
/* EEE and EEO */
for (k=0;k<4;k++)
{
EEE[k] = EE[k] + EE[7-k];
EEO[k] = EE[k] - EE[7-k];
}
/* EEEE and EEEO */
EEEE[0] = EEE[0] + EEE[3];
EEEO[0] = EEE[0] - EEE[3];
EEEE[1] = EEE[1] + EEE[2];
EEEO[1] = EEE[1] - EEE[2];
dst[ 0 ] = (g_aiT32[ 0][0]*EEEE[0] + g_aiT32[ 0][1]*EEEE[1] + add)>>shift;
dst[ 16*line ] = (g_aiT32[16][0]*EEEE[0] + g_aiT32[16][1]*EEEE[1] + add)>>shift;
dst[ 8*line ] = (g_aiT32[ 8][0]*EEEO[0] + g_aiT32[ 8][1]*EEEO[1] + add)>>shift;
dst[ 24*line ] = (g_aiT32[24][0]*EEEO[0] + g_aiT32[24][1]*EEEO[1] + add)>>shift;
for (k=4;k<32;k+=8)
{
dst[ k*line ] = (g_aiT32[k][0]*EEO[0] + g_aiT32[k][1]*EEO[1] + g_aiT32[k][2]*EEO[2] + g_aiT32[k][3]*EEO[3] + add)>>shift;
}
for (k=2;k<32;k+=4)
{
dst[ k*line ] = (g_aiT32[k][0]*EO[0] + g_aiT32[k][1]*EO[1] + g_aiT32[k][2]*EO[2] + g_aiT32[k][3]*EO[3] +
g_aiT32[k][4]*EO[4] + g_aiT32[k][5]*EO[5] + g_aiT32[k][6]*EO[6] + g_aiT32[k][7]*EO[7] + add)>>shift;
}
for (k=1;k<32;k+=2)
{
dst[ k*line ] = (g_aiT32[k][ 0]*O[ 0] + g_aiT32[k][ 1]*O[ 1] + g_aiT32[k][ 2]*O[ 2] + g_aiT32[k][ 3]*O[ 3] +
g_aiT32[k][ 4]*O[ 4] + g_aiT32[k][ 5]*O[ 5] + g_aiT32[k][ 6]*O[ 6] + g_aiT32[k][ 7]*O[ 7] +
g_aiT32[k][ 8]*O[ 8] + g_aiT32[k][ 9]*O[ 9] + g_aiT32[k][10]*O[10] + g_aiT32[k][11]*O[11] +
g_aiT32[k][12]*O[12] + g_aiT32[k][13]*O[13] + g_aiT32[k][14]*O[14] + g_aiT32[k][15]*O[15] + add)>>shift;
}
src += 32;
dst ++;
}
}
#endif
/** 32x32 forward transform (2D)
* \param block input data (residual)
* \param coeff output data (transform coefficients)
*/
void xTr32(short block[32][32],short coeff[32][32])
{
#if FULL_NBIT
int shift_1st = 4 + g_uiBitDepth - 8; // log2(32) - 1 + g_uiBitDepth - 8
#else
int shift_1st = 4 + g_uiBitIncrement; // log2(32) - 1 + g_uiBitIncrement
#endif
int shift_2nd = 11; // log2(32) + 6
short tmp[32][32];
partialButterfly32(block,tmp,shift_1st);
partialButterfly32(tmp,coeff,shift_2nd);
}
/** 32x32 inverse transform implemented using partial butterfly structure (1D)
* \param src input data (transform coefficients)
* \param dst output data (residual)
* \param shift specifies right shift after 1D transform
*/
void partialButterflyInverse32(short src[32][32],short dst[32][32],int shift)
{
int j,k;
int E[16],O[16];
int EE[8],EO[8];
int EEE[4],EEO[4];
int EEEE[2],EEEO[2];
int add = 1<<(shift-1);
for (j=0; j<32; j++)
{
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
for (k=0;k<16;k++)
{
O[k] = g_aiT32[ 1][k]*src[ 1][j] + g_aiT32[ 3][k]*src[ 3][j] + g_aiT32[ 5][k]*src[ 5][j] + g_aiT32[ 7][k]*src[ 7][j] +
g_aiT32[ 9][k]*src[ 9][j] + g_aiT32[11][k]*src[11][j] + g_aiT32[13][k]*src[13][j] + g_aiT32[15][k]*src[15][j] +
g_aiT32[17][k]*src[17][j] + g_aiT32[19][k]*src[19][j] + g_aiT32[21][k]*src[21][j] + g_aiT32[23][k]*src[23][j] +
g_aiT32[25][k]*src[25][j] + g_aiT32[27][k]*src[27][j] + g_aiT32[29][k]*src[29][j] + g_aiT32[31][k]*src[31][j];
}
for (k=0;k<8;k++)
{
EO[k] = g_aiT32[ 2][k]*src[ 2][j] + g_aiT32[ 6][k]*src[ 6][j] + g_aiT32[10][k]*src[10][j] + g_aiT32[14][k]*src[14][j] +
g_aiT32[18][k]*src[18][j] + g_aiT32[22][k]*src[22][j] + g_aiT32[26][k]*src[26][j] + g_aiT32[30][k]*src[30][j];
}
for (k=0;k<4;k++)
{
EEO[k] = g_aiT32[4][k]*src[4][j] + g_aiT32[12][k]*src[12][j] + g_aiT32[20][k]*src[20][j] + g_aiT32[28][k]*src[28][j];
}
EEEO[0] = g_aiT32[8][0]*src[8][j] + g_aiT32[24][0]*src[24][j];
EEEO[1] = g_aiT32[8][1]*src[8][j] + g_aiT32[24][1]*src[24][j];
EEEE[0] = g_aiT32[0][0]*src[0][j] + g_aiT32[16][0]*src[16][j];
EEEE[1] = g_aiT32[0][1]*src[0][j] + g_aiT32[16][1]*src[16][j];
/* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
EEE[0] = EEEE[0] + EEEO[0];
EEE[3] = EEEE[0] - EEEO[0];
EEE[1] = EEEE[1] + EEEO[1];
EEE[2] = EEEE[1] - EEEO[1];
for (k=0;k<4;k++)
{
EE[k] = EEE[k] + EEO[k];
EE[k+4] = EEE[3-k] - EEO[3-k];
}
for (k=0;k<8;k++)
{
E[k] = EE[k] + EO[k];
E[k+8] = EE[7-k] - EO[7-k];
}
for (k=0;k<16;k++)
{
dst[j][k] = (E[k] + O[k] + add)>>shift;
dst[j][k+16] = (E[15-k] - O[15-k] + add)>>shift;
}
}
}
#if NSQT
void partialButterflyInverse32(short *src,short *dst,int shift, int line)
{
int j,k;
int E[16],O[16];
int EE[8],EO[8];
int EEE[4],EEO[4];
int EEEE[2],EEEO[2];
int add = 1<<(shift-1);
for (j=0; j<line; j++)
{
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
for (k=0;k<16;k++)
{
O[k] = g_aiT32[ 1][k]*src[ line ] + g_aiT32[ 3][k]*src[ 3*line ] + g_aiT32[ 5][k]*src[ 5*line ] + g_aiT32[ 7][k]*src[ 7*line ] +
g_aiT32[ 9][k]*src[ 9*line ] + g_aiT32[11][k]*src[ 11*line ] + g_aiT32[13][k]*src[ 13*line ] + g_aiT32[15][k]*src[ 15*line ] +
g_aiT32[17][k]*src[ 17*line ] + g_aiT32[19][k]*src[ 19*line ] + g_aiT32[21][k]*src[ 21*line ] + g_aiT32[23][k]*src[ 23*line ] +
g_aiT32[25][k]*src[ 25*line ] + g_aiT32[27][k]*src[ 27*line ] + g_aiT32[29][k]*src[ 29*line ] + g_aiT32[31][k]*src[ 31*line ];
}
for (k=0;k<8;k++)
{
EO[k] = g_aiT32[ 2][k]*src[ 2*line ] + g_aiT32[ 6][k]*src[ 6*line ] + g_aiT32[10][k]*src[ 10*line ] + g_aiT32[14][k]*src[ 14*line ] +
g_aiT32[18][k]*src[ 18*line ] + g_aiT32[22][k]*src[ 22*line ] + g_aiT32[26][k]*src[ 26*line ] + g_aiT32[30][k]*src[ 30*line ];
}
for (k=0;k<4;k++)
{
EEO[k] = g_aiT32[4][k]*src[ 4*line ] + g_aiT32[12][k]*src[ 12*line ] + g_aiT32[20][k]*src[ 20*line ] + g_aiT32[28][k]*src[ 28*line ];
}
EEEO[0] = g_aiT32[8][0]*src[ 8*line ] + g_aiT32[24][0]*src[ 24*line ];
EEEO[1] = g_aiT32[8][1]*src[ 8*line ] + g_aiT32[24][1]*src[ 24*line ];
EEEE[0] = g_aiT32[0][0]*src[ 0 ] + g_aiT32[16][0]*src[ 16*line ];
EEEE[1] = g_aiT32[0][1]*src[ 0 ] + g_aiT32[16][1]*src[ 16*line ];
/* Combining even and odd terms at each hierarchy levels to calculate the final spatial domain vector */
EEE[0] = EEEE[0] + EEEO[0];
EEE[3] = EEEE[0] - EEEO[0];
EEE[1] = EEEE[1] + EEEO[1];
EEE[2] = EEEE[1] - EEEO[1];
for (k=0;k<4;k++)
{
EE[k] = EEE[k] + EEO[k];
EE[k+4] = EEE[3-k] - EEO[3-k];
}
for (k=0;k<8;k++)
{
E[k] = EE[k] + EO[k];
E[k+8] = EE[7-k] - EO[7-k];
}
for (k=0;k<16;k++)
{
dst[ k ] = (E[k] + O[k] + add)>>shift;
dst[ k+16 ] = (E[15-k] - O[15-k] + add)>>shift;
}
src ++;
dst += 32;
}
}
#endif
/** 32x32 inverse transform (2D)
* \param coeff input data (transform coefficients)
* \param block output data (residual)
*/
void xITr32(short coeff[32][32],short block[32][32])
{
int shift_1st = SHIFT_INV_1ST;
#if FULL_NBIT
int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
#else
int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
#endif
short tmp[32][32];
partialButterflyInverse32(coeff,tmp,shift_1st);
partialButterflyInverse32(tmp,block,shift_2nd);
}
#if NSQT
/** MxN forward transform (2D)
* \param block input data (residual)
* \param coeff output data (transform coefficients)
* \param iWidth input data (width of transform)
* \param iHeight input data (height of transform)
*/
void xTrMxN(short *block,short *coeff, int iWidth, int iHeight)
{
#if FULL_NBIT
int shift_1st = g_aucConvertToBit[iWidth] + 1 + g_uiBitDepth - 8; // log2(iWidth) - 1 + g_uiBitDepth - 8
#else
int shift_1st = g_aucConvertToBit[iWidth] + 1 + g_uiBitIncrement; // log2(iWidth) - 1 + g_uiBitIncrement
#endif
int shift_2nd = g_aucConvertToBit[iHeight] + 8; // log2(iHeight) + 6
short tmp[ 64 * 64 ];
if( iWidth == 16 && iHeight == 4)
{
partialButterfly16( block, tmp, shift_1st, iHeight );
partialButterfly4( tmp, coeff, shift_2nd, iWidth );
}
else if( iWidth == 32 && iHeight == 8 )
{
partialButterfly32( block, tmp, shift_1st, iHeight );
partialButterfly8( tmp, coeff, shift_2nd, iWidth );
}
}
/** MxN inverse transform (2D)
* \param coeff input data (transform coefficients)
* \param block output data (residual)
* \param iWidth input data (width of transform)
* \param iHeight input data (height of transform)
*/
void xITrMxN(short *coeff,short *block, int iWidth, int iHeight)
{
int shift_1st = SHIFT_INV_1ST;
#if FULL_NBIT
int shift_2nd = SHIFT_INV_2ND - ((short)g_uiBitDepth - 8);
#else
int shift_2nd = SHIFT_INV_2ND - g_uiBitIncrement;
#endif
short tmp[ 64*64];
if( iWidth == 16 && iHeight == 4)
{
partialButterflyInverse4(coeff,tmp,shift_1st,iWidth);
partialButterflyInverse16(tmp,block,shift_2nd,iHeight);
}
else if( iWidth == 32 && iHeight == 8)
{
partialButterflyInverse8(coeff,tmp,shift_1st,iWidth);
partialButterflyInverse32(tmp,block,shift_2nd,iHeight);
}
}
#endif
#endif //MATRIX_MULT
UInt TComTrQuant::xCountVlcBits(UInt uiTableNumber, UInt uiCodeNumber)
{
UInt uiLength = 0;
UInt uiCode = 0;
if ( uiCodeNumber < 128 )
{
uiLength=VLClength[uiTableNumber][uiCodeNumber];
}
else
{
if ( uiTableNumber < 10 )
{
if ( uiTableNumber < 5 )
{
uiCode = uiCodeNumber - (6 * (1 << uiTableNumber)) + (1 << uiTableNumber);
uiLength = ( 6 - uiTableNumber ) + 1 + 2 * xLeadingZeros(uiCode);
}
else if ( uiTableNumber < 8 )
{
uiLength = 1 + (uiTableNumber - 4) + (uiCodeNumber >> (uiTableNumber - 4));
}
else if ( uiTableNumber == 9 )
{
uiLength = 5 + ((uiCodeNumber + 5) >> 4);
}
}
else
{
if ( uiTableNumber == 10 )
{
uiCode = uiCodeNumber + 1;
uiLength = 1 + 2 * xLeadingZeros(uiCode);
}
#if CAVLC_COEF_LRG_BLK
else if (uiTableNumber == 12)
{
uiLength = 7+(uiCodeNumber>>6);
}
else if(uiTableNumber == 13)
{
uiLength = 5+(uiCodeNumber>>4);
}
#endif
}
}
return uiLength;
}
#if CAVLC_COEF_LRG_BLK
#if CAVLC_RDOQ_MOD
#if TBL_RUN_ADAPT
Int TComTrQuant::bitCountRDOQ(Int coeff, Int pos, Int nTab, Int lastCoeffFlag,Int levelMode,Int run, Int maxrun, Int* vlc_adaptive, Int N,
UInt uiTr1, Int iSum_big_coef, Int iBlockType, TComDataCU* pcCU, const UInt **pLumaRunTr1, Int iNextRun
#if CAVLC_RUNLEVEL_TABLE_REM
, Int isIntra
#endif
)
#else
Int TComTrQuant::bitCountRDOQ(Int coeff, Int pos, Int nTab, Int lastCoeffFlag,Int levelMode,Int run, Int maxrun, Int vlc_adaptive, Int N,
UInt uiTr1, Int iSum_big_coef, Int iBlockType, TComDataCU* pcCU, const UInt **pLumaRunTr1, Int iNextRun
#if CAVLC_RUNLEVEL_TABLE_REM
, Int isIntra
#endif
)
#endif
#else
#if TBL_RUN_ADAPT
Int TComTrQuant::bitCountRDOQ(Int coeff, Int pos, Int nTab, Int lastCoeffFlag,Int levelMode,Int run, Int maxrun, Int *vlc_adaptive, Int N,
UInt uiTr1, Int iSum_big_coef, Int iBlockType, TComDataCU* pcCU, const UInt **pLumaRunTr1
#if CAVLC_RUNLEVEL_TABLE_REM
, Int isIntra
#endif
)
#else
Int TComTrQuant::bitCountRDOQ(Int coeff, Int pos, Int nTab, Int lastCoeffFlag,Int levelMode,Int run, Int maxrun, Int vlc_adaptive, Int N,
UInt uiTr1, Int iSum_big_coef, Int iBlockType, TComDataCU* pcCU, const UInt **pLumaRunTr1
#if CAVLC_RUNLEVEL_TABLE_REM
, Int isIntra
#endif
)
#endif
#endif
#else
Int TComTrQuant::bitCountRDOQ(Int coeff, Int pos, Int nTab, Int lastCoeffFlag,Int levelMode,Int run, Int maxrun, Int vlc_adaptive, Int N,
UInt uiTr1, Int iSum_big_coef, Int iBlockType, TComDataCU* pcCU)
#endif
{
UInt cn, n, level, lev;
Int vlc,x,cx,vlcNum,bits;
static const int vlcTable4[3] = {2,2,2}; // Y4x4I,Y4x4P,Y4x4B,
#if CAVLC_RUNLEVEL_TABLE_REM
Int scale = (isIntra && iBlockType < 2) ? 0 : 3;
#endif
#if MOD_INTRA_TABLE
static const int aiTableTr1[2][5] = {{0, 1, 1, 1, 0},{0, 1, 2, 3, 4}};
#endif
#if TBL_RUN_ADAPT
Int vlc_adap = *vlc_adaptive;
#endif
Int sign = coeff < 0 ? 1 : 0;
if ( N==4 )
{
n = max(0, nTab - 2);
}
else
{
n = nTab;
}
UInt uiModZeroCoding = 0;
const UInt *uiVlcTableTemp;
#if CAVLC_COEF_LRG_BLK
uiModZeroCoding = (m_uiRDOQOffset==1 || N>8)? 1:0;
int tmprun = min(maxrun,28);
#if MOD_INTRA_TABLE
if(nTab==2||nTab==5)
{
uiVlcTableTemp = g_auiVlcTable8x8Intra;
}
else
{
uiVlcTableTemp = N<=8? g_auiVlcTable8x8Inter:g_auiVlcTable16x16Inter;
}
#else
if( N<=8 )
{
uiVlcTableTemp = (nTab==2 || nTab==5)? g_auiVlcTable8x8Intra:g_auiVlcTable8x8Inter;
}
else
{
uiVlcTableTemp = (nTab==5)? g_auiVlcTable16x16Intra:g_auiVlcTable16x16Inter;
}
#endif
#else
if( nTab == 2 || nTab == 5 )
{
uiVlcTableTemp = g_auiVlcTable8x8Intra;
}
else
{
uiVlcTableTemp = g_auiVlcTable8x8Inter;
}
#endif
level = abs(coeff);
lev = (level == 1) ? 0 : 1;
if ( level )
{
if ( lastCoeffFlag == 1 )
{
x = pos + (level == 1 ? 0 : N * N);
if( N == 4 )
{
cx = m_uiLPTableE4[(n << 5) + x];
vlcNum = vlcTable4[n];
}
else
{
#if CAVLC_COEF_LRG_BLK
cx = xLastLevelInd(lev, pos, N);
#else
cx = m_uiLPTableE8[(n << 7) + x];
#endif
vlcNum = g_auiLastPosVlcNum[n][min(16u,m_uiLastPosVlcIndex[n])];
}
bits=xCountVlcBits( vlcNum, cx );
if ( level > 1 )
{
bits += xCountVlcBits( 0, 2 * (level - 2) + sign );
}
else
{
bits++;
}
}
else
{ // Level !=0 && lastCoeffFlag==0
if ( !levelMode )
{
#if CAVLC_COEF_LRG_BLK
if(nTab == 2 || nTab == 5)
{
#if MOD_INTRA_TABLE
cn = xRunLevelInd(lev, run, maxrun, pLumaRunTr1[aiTableTr1[(N&4)>>2][uiTr1]][tmprun]);
#else
cn = xRunLevelInd(lev, run, maxrun, pLumaRunTr1[uiTr1][tmprun]);
#endif
}
else
{
#if CAVLC_RUNLEVEL_TABLE_REM
cn = xRunLevelIndInter(lev, run, maxrun, scale);
#else
cn = xRunLevelIndInter(lev, run, maxrun);
#endif
}
#if MOD_INTRA_TABLE
if (tmprun < 28 || N<=8 || (nTab!=2&&nTab!=5) )
{
vlc = uiVlcTableTemp[tmprun];
}
else
{
vlc = 2;
}
#else
vlc = uiVlcTableTemp[tmprun];
#endif
#else
if ( N == 4 )
{
// 4x4
if ( nTab == 2 )
{
cn = xRunLevelInd(lev, run, maxrun, g_auiLumaRunTr14x4[uiTr1][maxrun]);
}
else
{
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(lev, run, maxrun);
#else
cn = g_auiLumaRun8x8[maxrun][lev][run];
#endif
}
vlc = uiVlcTableTemp[maxrun];
}
else
{
// 8x8
if(nTab == 2 || nTab == 5)
{
cn = xRunLevelInd(lev, run, maxrun, g_auiLumaRunTr18x8[uiTr1][min(maxrun,28)]);
}
else
{
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(lev, run, maxrun);
#else
cn = g_auiLumaRun8x8[min(maxrun,28)][lev][run];
#endif
}
vlc = uiVlcTableTemp[min(maxrun,28)];
}
#endif
bits = xCountVlcBits( vlc, cn );
if ( level > 1 )
{
bits += xCountVlcBits( 0, 2 * (level - 2) + sign );
}
else
{
bits++;
}
}
else
{ // Level !=0 && lastCoeffFlag==0 && levelMode
#if TBL_RUN_ADAPT
bits = (xCountVlcBits( vlc_adap, level ) + 1);
#else
bits = (xCountVlcBits( vlc_adaptive, level ) + 1);
#endif
}
}
}
else
{
if (levelMode)
{
#if TBL_RUN_ADAPT
bits=xCountVlcBits( vlc_adap, level );
#else
bits=xCountVlcBits( vlc_adaptive, level );
#endif
}
else
{
if ( pos == 0 && lastCoeffFlag == 0)
{
#if CAVLC_COEF_LRG_BLK
#if MOD_INTRA_TABLE
if (tmprun<28 || N<=8 || (n!=2&&n!=5))
{
vlc = uiVlcTableTemp[tmprun];
}
else
{
vlc = 2;
}
#else
vlc = uiVlcTableTemp[tmprun];
#endif
if(nTab == 2 || nTab == 5)
{
#if MOD_INTRA_TABLE
cn = xRunLevelInd(0, run + 1, maxrun, pLumaRunTr1[aiTableTr1[(N&4)>>2][uiTr1]][tmprun]);
#else
cn = xRunLevelInd(0, run + 1, maxrun, pLumaRunTr1[uiTr1][tmprun]);
#endif
}
else
{
#if CAVLC_RUNLEVEL_TABLE_REM
cn = xRunLevelIndInter(0, run + 1, maxrun, scale);
#else
cn = xRunLevelIndInter(0, run + 1, maxrun);
#endif
}
#else
if ( N == 4 )
{
// 4x4
vlc = uiVlcTableTemp[maxrun];
if ( nTab == 2 )
{
cn = xRunLevelInd(0, run + 1, maxrun, g_auiLumaRunTr14x4[uiTr1][maxrun]);
}
else
{
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(0, run+1, maxrun);
#else
cn = g_auiLumaRun8x8[maxrun][0][run + 1];
#endif
}
}
else
{
// 8x8
vlc = uiVlcTableTemp[min(maxrun, 28)];
if(nTab == 2 || nTab == 5)
{
cn = xRunLevelInd(0, run + 1, maxrun, g_auiLumaRunTr18x8[uiTr1][min(maxrun, 28)]);
}
else
{
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(0, run+1, maxrun);
#else
cn = g_auiLumaRun8x8[min(maxrun, 28)][0][run + 1];
#endif
}
}
#endif
bits=xCountVlcBits( vlc, cn );
}
else
{
bits = 0;
if ( pos > 0 && uiModZeroCoding == 1 )
{
Int iSum_big_coefTemp, levelModeTemp, maxrunTemp;
UInt uiTr1Temp;
if ( lastCoeffFlag == 0 )
{
#if CAVLC_COEF_LRG_BLK
#if MOD_INTRA_TABLE
if (tmprun<28 || N<=8 || (n!=2&&n!=5))
{
vlc = uiVlcTableTemp[tmprun];
}
else
{
vlc = 2;
}
#else
vlc = uiVlcTableTemp[tmprun];
#endif
#if CAVLC_RDOQ_MOD
if(nTab == 2 || nTab == 5)
{
#if MOD_INTRA_TABLE
cn = xRunLevelInd(0, run + 1 + iNextRun, maxrun, pLumaRunTr1[aiTableTr1[(N&4)>>2][uiTr1]][tmprun]);
#else
cn = xRunLevelInd(0, run + 1 + iNextRun, maxrun, pLumaRunTr1[uiTr1][tmprun]);
#endif
}
else
{
#if CAVLC_RUNLEVEL_TABLE_REM
cn = xRunLevelIndInter(0, run + 1 + iNextRun, maxrun, scale);
#else
cn = xRunLevelIndInter(0, run + 1 + iNextRun, maxrun);
#endif
}
#else
if(nTab == 2 || nTab == 5)
{
#if MOD_INTRA_TABLE
cn = xRunLevelInd(0, run + 1, maxrun, pLumaRunTr1[aiTableTr1[(N&4)>>2][uiTr1]][tmprun]);
#else
cn = xRunLevelInd(0, run + 1, maxrun, pLumaRunTr1[uiTr1][tmprun]);
#endif
}
else
{
#if CAVLC_RUNLEVEL_TABLE_REM
cn = xRunLevelIndInter(0, run + 1, maxrun, scale);
#else
cn = xRunLevelIndInter(0, run + 1, maxrun);
#endif
}
#endif
#else
if ( N == 4 )
{
// 4x4
vlc = uiVlcTableTemp[maxrun];
if ( nTab == 2 )
{
cn = xRunLevelInd(0, run + 1, maxrun, g_auiLumaRunTr14x4[uiTr1][maxrun]);
}
else
{
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(0, run+1, maxrun);
#else
cn = g_auiLumaRun8x8[maxrun][0][run + 1];
#endif
}
}
else
{
// 8x8
vlc = uiVlcTableTemp[min(maxrun, 28)];
if(nTab == 2 || nTab == 5)
{
cn = xRunLevelInd(0, run + 1, maxrun, g_auiLumaRunTr18x8[uiTr1][min(maxrun, 28)]);
}
else
{
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(0, run+1, maxrun);
#else
cn = g_auiLumaRun8x8[min(maxrun,28)][0][run + 1];
#endif
}
}
#endif
}
else
{
x = (pos - 1);
if( N == 4 )
{
cn = m_uiLPTableE4[(n << 5) + x];
vlc = vlcTable4[n];
}
else
{
#if CAVLC_COEF_LRG_BLK
cn = xLastLevelInd(lev, pos, N);
#else
cn = m_uiLPTableE8[(n << 7) + x];
#endif
vlc = g_auiLastPosVlcNum[n][min(16u, m_uiLastPosVlcIndex[n])];
}
}
bits+=xCountVlcBits( vlc, cn );
// Next coeff is 1 with run=0
iSum_big_coefTemp = iSum_big_coef;
levelModeTemp = levelMode;
Int switch_thr[10] = {49,49,0,49,49,0,49,49,49,49};
if ( N > 4 )
{
if ( level > 1 )
{
iSum_big_coefTemp += level;
#if TBL_RUN_ADAPT
if ((N * N - pos - 1) > switch_thr[iBlockType] || iSum_big_coefTemp > 2)
{
if (level > atable[vlc_adap])
{
vlc_adap++;
}
levelModeTemp = 1;
}
#else
if ((N * N - pos - 1) > switch_thr[iBlockType] || iSum_big_coefTemp > 2)
{
levelModeTemp = 1;
}
#endif
}
}
else
{
if ( level > 1 )
{
levelModeTemp = 1;
}
}
if ( levelModeTemp == 1 )
{
#if TBL_RUN_ADAPT
bits-=xCountVlcBits( vlc_adap, 1);
#else
bits-=xCountVlcBits( vlc_adaptive, 1);
#endif
}
else
{
maxrunTemp = pos - 1;
uiTr1Temp = uiTr1;
if ( uiTr1Temp > 0 && level < 2 )
{
uiTr1Temp++;
uiTr1Temp = min(unsigned(MAX_TR1), uiTr1Temp);
}
else
{
uiTr1Temp=0;
}
#if CAVLC_COEF_LRG_BLK
#if MOD_INTRA_TABLE
Int iRunMax= min(maxrunTemp,28);
if (iRunMax<28 || N<=8 || (n!=2&&n!=5))
{
vlc = uiVlcTableTemp[iRunMax];
}
else
{
vlc = 2;
}
#else
vlc = uiVlcTableTemp[min(maxrunTemp,28)];
#endif
#if CAVLC_RDOQ_MOD
if(nTab == 2 || nTab == 5)
{
#if MOD_INTRA_TABLE
cn = xRunLevelInd(0, iNextRun, maxrunTemp, pLumaRunTr1[aiTableTr1[(N&4)>>2][uiTr1Temp]][min(maxrunTemp,28)]);
#else
cn = xRunLevelInd(0, iNextRun, maxrunTemp, pLumaRunTr1[uiTr1Temp][min(maxrunTemp,28)]);
#endif
}
else
{
#if CAVLC_RUNLEVEL_TABLE_REM
cn = xRunLevelIndInter(0, iNextRun, maxrunTemp, scale);
#else
cn = xRunLevelIndInter(0, iNextRun, maxrunTemp);
#endif
}
#else
if(nTab == 2 || nTab == 5)
{
#if MOD_INTRA_TABLE
cn = xRunLevelInd(0, 0, maxrunTemp, pLumaRunTr1[aiTableTr1[(N&4)>>2][uiTr1Temp]][min(maxrunTemp,28)]);
#else
cn = xRunLevelInd(0, 0, maxrunTemp, pLumaRunTr1[uiTr1Temp][min(maxrunTemp,28)]);
#endif
}
else
{
#if CAVLC_RUNLEVEL_TABLE_REM
cn = xRunLevelIndInter(0, 0, maxrunTemp, scale);
#else
cn = xRunLevelIndInter(0, 0, maxrunTemp);
#endif
}
#endif
#else
if ( N == 4 )
{
// 4x4
vlc = uiVlcTableTemp[maxrunTemp];
if ( nTab == 2 )
{
cn = xRunLevelInd(0, 0, maxrunTemp, g_auiLumaRunTr14x4[uiTr1Temp][maxrunTemp]);
}
else
{
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(0, 0, maxrunTemp);
#else
cn = g_auiLumaRun8x8[maxrunTemp][0][0];
#endif
}
}
else
{
// 8x8
vlc = uiVlcTableTemp[min(maxrunTemp,28)];
if(nTab == 2 || nTab == 5)
{
cn = xRunLevelInd(0, 0, maxrunTemp, g_auiLumaRunTr18x8[uiTr1Temp][min(maxrunTemp,28)]);
}
else
{
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(0, 0, maxrunTemp);
#else
cn = g_auiLumaRun8x8[min(maxrunTemp,28)][0][0];
#endif
}
}
#endif
bits -= xCountVlcBits( vlc, cn );
}
} // if ( pos > 0 && uiModZeroCoding == 1 )
}
}
}
#if TBL_RUN_ADAPT
*vlc_adaptive = vlc_adap;
#endif
return bits;
}
#if CAVLC_RDOQ_MOD
Int TComTrQuant::xCodeCoeffCountBitsLast(TCoeff* scoeff, levelDataStruct* levelData, Int nTab, UInt N, Int iStartLast
#if CAVLC_RUNLEVEL_TABLE_REM
, Int isIntra
#endif
)
#else
Int TComTrQuant::xCodeCoeffCountBitsLast(TCoeff* scoeff, levelDataStruct* levelData, Int nTab, UInt N
#if CAVLC_RUNLEVEL_TABLE_REM
, Int isIntra
#endif
)
#endif
{
Int i, prevCoeffInd, lastPosMin, iRate;
Int done,last_pos;
#if CAVLC_COEF_LRG_BLK
Int run_done, maxrun,run, bitsLast[1024], bitsRun[1024], bitsLastPrev;
quantLevelStruct quantCoeffInfo[1024];
#else
Int run_done, maxrun,run, bitsLast[256], bitsRun[256], bitsLastPrev;
quantLevelStruct quantCoeffInfo[256];
#endif
UInt last_pos_init, bitsLevel, sign, lev, cn, vlc, uiBitShift=15, uiNoCoeff=N*N, absLevel;
Int n;
double lagrMin, lagr, lagrPrev;
UInt uiLumaRunNoTr14x4[15]={2, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2};
UInt uiLumaRunNoTr18x8[29]={2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 13};
#if CAVLC_RUNLEVEL_TABLE_REM
Int scale = (isIntra && nTab < 2) ? 0 : 3;
#endif
if ( N == 4 )
{
n = max(0, nTab - 2);
}
else
{
n = nTab;
}
/* Do the last coefficient first */
i = uiNoCoeff - 1;
done = 0;
while ( !done && i >= 0 )
{
if (scoeff[i])
{
done = 1;
}
else
{
i--;
}
}
if (i == -1)
{
return(-1);
}
last_pos = last_pos_init = i;
prevCoeffInd = i;
i--;
#if CAVLC_RDOQ_MOD
lastPosMin=iStartLast;
if (last_pos_init>iStartLast)
{
if ( i >= iStartLast )
#else
if ( i >= 0 )
#endif
{
/* Go into run mode */
run_done = 0;
while ( !run_done )
{
maxrun = i;
run = 0;
done = 0;
while ( !done )
{
if ( !scoeff[i] )
{
run++;
}
else
{
quantCoeffInfo[prevCoeffInd].run=run;
quantCoeffInfo[prevCoeffInd].maxrun=maxrun;
quantCoeffInfo[prevCoeffInd].nextLev=(abs(scoeff[i]) == 1) ? 0 : 1;
quantCoeffInfo[prevCoeffInd].nexLevelVal=scoeff[i];
prevCoeffInd = i;
run = 0;
done = 1;
}
if (i == 0)
{
quantCoeffInfo[prevCoeffInd].run=run;
quantCoeffInfo[prevCoeffInd].maxrun=maxrun;
quantCoeffInfo[prevCoeffInd].nextLev=0;
quantCoeffInfo[prevCoeffInd].nexLevelVal=0;
done = 1;
run_done = 1;
}
i--;
}
}
}
#if CAVLC_COEF_LRG_BLK
#if MOD_INTRA_TABLE
UInt const * vlcTableIntra;
vlcTableIntra = g_auiVlcTable8x8Intra;
#else
const UInt *vlcTableIntra = (N<=8)? g_auiVlcTable8x8Intra:g_auiVlcTable16x16Intra;
#endif
const UInt *vlcTableInter = (N<=8)? g_auiVlcTable8x8Inter:g_auiVlcTable16x16Inter;
const UInt *pLumaRunTr1 = (N==4)? uiLumaRunNoTr14x4:uiLumaRunNoTr18x8;
#endif
#if CAVLC_RDOQ_MOD
for (i = last_pos_init; i >= iStartLast; i--)
#else
for (i = last_pos_init; i >= 0; i--)
#endif
{
if (scoeff[i])
{
bitsLast[i] = bitsRun[i] = 0;
last_pos = i;
{
int x,cx,vlcNum;
int vlcTable[3] = {2,2,2};
bitsLevel=0;
absLevel = abs(scoeff[i]);
sign = (scoeff[i] < 0) ? 1 : 0;
lev = (absLevel == 1) ? 0 : 1;
if (absLevel > 1)
{
bitsLevel=xCountVlcBits( 0, 2*(absLevel-2)+sign );
}
else
{
bitsLevel++;
}
x = uiNoCoeff*lev + last_pos;
if ( uiNoCoeff == 16 )
{
cx = m_uiLPTableE4[n * 32 + x];
vlcNum = vlcTable[n];
}
else
{
#if CAVLC_COEF_LRG_BLK
cx = xLastLevelInd(lev, last_pos, N);
#else
cx = m_uiLPTableE8[n * 128 + x];
#endif
vlcNum = g_auiLastPosVlcNum[n][min(16u,m_uiLastPosVlcIndex[n])];
}
bitsLast[i]=bitsLevel + xCountVlcBits( vlcNum, cx);
}
bitsRun[i]=0;
if ( i > 0 )
{
bitsLevel = 0;
if ( quantCoeffInfo[i].nexLevelVal != 0 )
{
absLevel = abs(quantCoeffInfo[i].nexLevelVal);
sign = (quantCoeffInfo[i].nexLevelVal < 0) ? 1 : 0;
lev = (absLevel == 1) ? 0 : 1;
if (absLevel > 1)
{
bitsLevel = xCountVlcBits( 0, 2 * (absLevel - 2) + sign );
}
else
{
bitsLevel++;
}
}
bitsRun[i] = bitsLevel;
run = quantCoeffInfo[i].run;
maxrun = quantCoeffInfo[i].maxrun;
#if CAVLC_COEF_LRG_BLK
Int tmprun = min(maxrun,28);
if(nTab == 2 || nTab == 5)
{
#if MOD_INTRA_TABLE
if (tmprun<28 || uiNoCoeff<=64)
{
vlc = vlcTableIntra[tmprun];
}
else
{
vlc = 2;
}
#else
vlc = vlcTableIntra[tmprun];
#endif
cn = xRunLevelInd(quantCoeffInfo[i].nextLev, run, maxrun, pLumaRunTr1[tmprun]);
}
else
{
vlc = vlcTableInter[tmprun];
#if CAVLC_RUNLEVEL_TABLE_REM
cn = xRunLevelIndInter(quantCoeffInfo[i].nextLev, run, maxrun, scale);
#else
cn = xRunLevelIndInter(quantCoeffInfo[i].nextLev, run, maxrun);
#endif
}
bitsRun[i] += xCountVlcBits( vlc, cn );
#else
if ( uiNoCoeff == 16 )
{
if ( nTab == 2 )
{
vlc = g_auiVlcTable8x8Intra[maxrun];
cn = xRunLevelInd(quantCoeffInfo[i].nextLev, run, maxrun, uiLumaRunNoTr14x4[maxrun]);
}
else
{
vlc = g_auiVlcTable8x8Inter[maxrun];
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(quantCoeffInfo[i].nextLev, run, maxrun);
#else
cn = g_auiLumaRun8x8[maxrun][quantCoeffInfo[i].nextLev][run];
#endif
}
bitsRun[i] += xCountVlcBits( vlc, cn );
}
else
{
if(nTab == 2 || nTab == 5)
{
vlc = g_auiVlcTable8x8Intra[min(maxrun,28)];
cn = xRunLevelInd(quantCoeffInfo[i].nextLev, run, maxrun, uiLumaRunNoTr18x8[min(maxrun,28)]);
}
else
{
vlc = g_auiVlcTable8x8Inter[min(maxrun,28)];
#if RUNLEVEL_TABLE_CUT
cn = xRunLevelIndInter(quantCoeffInfo[i].nextLev, run, maxrun);
#else
cn = g_auiLumaRun8x8[min(maxrun,28)][quantCoeffInfo[i].nextLev][run];
#endif
}
bitsRun[i] += xCountVlcBits( vlc, cn );
}
#endif
}
}
}
lagrMin=0; lastPosMin=-1;
#if CAVLC_RDOQ_MOD
for (i=iStartLast; i<uiNoCoeff; i++)
#else
for (i=0; i<uiNoCoeff; i++)
#endif
{
if ( scoeff[i] != 0 )
{
lagrMin += levelData[i].errLevel[0];
}
}
UInt first=1;
bitsLastPrev=0; lagrPrev=lagrMin;
#if CAVLC_RDOQ_MOD
for (i=iStartLast; i<uiNoCoeff; i++)
#else
for (i=0; i<uiNoCoeff; i++)
#endif
{
if (scoeff[i])
{
iRate = (bitsRun[i] + bitsLast[i] - bitsLastPrev) << uiBitShift;
lagr = lagrPrev-levelData[i].errLevel[0] + levelData[i].errLevel[levelData[i].quantInd] + m_dLambda*iRate;
bitsLastPrev = bitsLast[i];
lagrPrev = lagr;
if ( lagr < lagrMin || abs(scoeff[i]) > 1 || first == 1)
{
lagrMin = lagr;
lastPosMin =i;
first = 0;
}
}
}
#if CAVLC_RDOQ_MOD
}
#endif
return(lastPosMin);
}
static levelDataStruct slevelData [ MAX_CU_SIZE*MAX_CU_SIZE ];
Void TComTrQuant::xRateDistOptQuant_LCEC(TComDataCU* pcCU, Int* pSrcCoeff, TCoeff* pDstCoeff, UInt uiWidth, UInt uiHeight, UInt& uiAbsSum, TextType eTType,
UInt uiAbsPartIdx )
{
Int i, j;
Int iShift = 0;
Double err, lagr, lagrMin;
Double fTemp = 0.0;
Int iQuantCoeff;
Int q_bits;
Int iShiftQBits, iSign, iRate, lastPosMin, iBlockType;
UInt uiBitShift = SCALE_BITS, uiScanPos, levelInd;
Int levelBest, iLevel;
#if CAVLC_RDOQ_MOD
Int iStartLast=0;
#endif
levelDataStruct* levelData = &slevelData[0];
Int iPos, iScanning;
#if CAVLC_COEF_LRG_BLK
static TCoeff sQuantCoeff[1024];
#else
static TCoeff sQuantCoeff[256];
#endif
#if NSQT
Bool bNonSqureFlag = ( uiWidth != uiHeight );
UInt uiNonSqureScanTableIdx = 0;
if( bNonSqureFlag )
{
UInt uiWidthBit = g_aucConvertToBit[ uiWidth ] + 2;
UInt uiHeightBit = g_aucConvertToBit[ uiHeight ] + 2;
uiNonSqureScanTableIdx = ( uiWidth * uiHeight ) == 64 ? 0 : 1;
uiWidth = 1 << ( ( uiWidthBit + uiHeightBit) >> 1 );
uiHeight = uiWidth;
}
#endif
q_bits = m_cQP.m_iBits;
UInt noCoeff=(uiWidth < 8 ? 16 : 64);
#if CAVLC_COEF_LRG_BLK
#if CAVLC_COEF_LRG_BLK_CHROMA
UInt maxBlSize = 32;
#else
UInt maxBlSize = (eTType==TEXT_LUMA)? 32:8;
#endif
UInt uiBlSize = min(uiWidth,maxBlSize);
noCoeff = uiBlSize*uiBlSize;
#endif
UInt uiLog2TrSize = g_aucConvertToBit[ uiWidth ] + 2;
UInt uiQ = g_quantScales[m_cQP.rem()];
#if FULL_NBIT
UInt uiBitDepth = g_uiBitDepth;
#else
UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement;
#endif
Int iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; // Represents scaling through forward transform
double dErrScale = (double)(1<<uiBitShift); // Compensate for scaling of bitcount in Lagrange cost function
dErrScale = dErrScale*pow(2.0,-2.0*iTransformShift); // Compensate for scaling through forward transform
dErrScale = dErrScale/(double)(uiQ*uiQ); // Compensate for qp-dependent multiplier applied before calculating the Lagrange cost function
dErrScale = dErrScale/(double)(1<<(2*g_uiBitIncrement)); // Compensate for Lagrange multiplier that is tuned towards 8-bit input
q_bits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift; // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
iShift = uiLog2TrSize;
if (eTType==TEXT_CHROMA_U || eTType==TEXT_CHROMA_V)
{
iBlockType = eTType-2;
}
else
{
iBlockType = (uiWidth < 16 ? 2 : 5) + ( pcCU->isIntra(uiAbsPartIdx) ? 0 : pcCU->getSlice()->getSliceType() );
}
memset(&pDstCoeff[0],0,uiWidth*uiHeight*sizeof(TCoeff));
iShiftQBits = (1 <<( q_bits - 1));
#if QC_MDCS
#if CAVLC_COEF_LRG_BLK
UInt uiLog2BlkSize = g_aucConvertToBit[ pcCU->isIntra( uiAbsPartIdx ) ? uiWidth : uiBlSize ] + 2;
#else
UInt uiLog2BlkSize = g_aucConvertToBit[ pcCU->isIntra( uiAbsPartIdx ) ? uiWidth : min(8,uiWidth) ] + 2;
#endif
const UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx));
#else
const UInt* pucScan;
if( !pcCU->isIntra(uiAbsPartIdx ))
{
#if CAVLC_COEF_LRG_BLK
pucScan = g_auiFrameScanXY[ g_aucConvertToBit[ uiBlSize ] + 1];
#else
pucScan = g_auiFrameScanXY[ g_aucConvertToBit[ min(uiWidth, 8) ] + 1];
#endif
}
else
{
pucScan = g_auiFrameScanXY[ g_aucConvertToBit[ uiWidth ] + 1];
}
#endif //QC_MDCS
UInt uiShift_local = iShift;
UInt uiRes_local = (uiWidth - 1);
UInt uiWidth_local = uiShift_local;
#if CAVLC_COEF_LRG_BLK
if(!pcCU->isIntra(uiAbsPartIdx) && uiWidth > maxBlSize)
{
uiShift_local = g_aucConvertToBit[ maxBlSize ] + 2;;
uiRes_local = maxBlSize - 1;
}
#else
if( !pcCU->isIntra(uiAbsPartIdx) && uiWidth >= 16 )
{
uiShift_local = 3;
uiRes_local = 7;
}
#endif
Int iAddRDOQ = 0;
/* Code below is consistent with JCTVC-E243 but could preferably be replaced with iAddRDOQ = 171 << (q_bits-9); */
if (q_bits>=15)
{
iAddRDOQ = (uiWidth<16 ? 10922 : 10880) << (q_bits-15);
}
else
{
iAddRDOQ = (uiWidth<16 ? 10922 : 10880) >> (15-q_bits);
}
if (m_uiRDOQOffset==1)
{
iAddRDOQ=iShiftQBits;
}
#if CAVLC_RDOQ_MOD
Int iThLast=(1 << (q_bits-1)) /uiQ;
Int iPrevSigIdx = noCoeff-1;
#endif
for (iScanning=noCoeff-1; iScanning>=0; iScanning--)
{
#if NSQT
if( bNonSqureFlag )
{
iPos = g_auiNonSquareSigLastScan[uiNonSqureScanTableIdx][iScanning];
}
else
#endif
{
#if QC_MDCS
iPos = g_auiSigLastScan[uiScanIdx][uiLog2BlkSize-1][iScanning];
#else
iPos = pucScan[iScanning];
#endif //QC_MDCS
}
j = iPos >> uiShift_local;
i = iPos & uiRes_local;
iPos = (j << uiWidth_local) + i;
#if CAVLC_RDOQ_MOD
Int iAbsCoeff=abs( pSrcCoeff[iPos] );
if (iAbsCoeff>iThLast)
{
#endif
levelDataStruct *psLevelData = &levelData[iScanning];
psLevelData->levelDouble = abs(pSrcCoeff[iPos]) * uiQ;
iQuantCoeff = (Int)((psLevelData->levelDouble + iAddRDOQ) >> q_bits);
psLevelData->levelQ = ( psLevelData->levelDouble >> q_bits );
psLevelData->lowerInt = ( ( psLevelData->levelDouble - (psLevelData->levelQ << q_bits) ) < iShiftQBits ) ? true : false;
iSign = pSrcCoeff[iPos] < 0 ? -1 : 1;
sQuantCoeff[iScanning] = iQuantCoeff*iSign;
#if CAVLC_RDOQ_MOD
if (iQuantCoeff>1)
{
iStartLast=iScanning;
}
#endif
fTemp = dErrScale;
psLevelData->level[0] = 0;
err = (Double)(psLevelData->levelDouble);
psLevelData->errLevel[0] = err * err * fTemp;
if ( !psLevelData->levelQ )
{
if ( psLevelData->lowerInt )
{
psLevelData->noLevels = 1;
#if CAVLC_RDOQ_MOD
if (iScanning == 0)
{
levelData[iPrevSigIdx].iNextRun = iPrevSigIdx;
}
#endif
}
else
{
psLevelData->level[1] = 1;
psLevelData->noLevels = 2;
#if CAVLC_RDOQ_MOD
levelData[iPrevSigIdx].iNextRun = iPrevSigIdx - iScanning - 1;
iPrevSigIdx = iScanning;
#endif
}
if (iQuantCoeff==0)
{
psLevelData->quantInd=0;
}
else
{
psLevelData->quantInd=1;
}
}
else if ( psLevelData->lowerInt )
{
psLevelData->level[1] = psLevelData->levelQ;
psLevelData->noLevels = 2;
if ( psLevelData->levelQ > 1 )
{
psLevelData->noLevels++;
psLevelData->level[2] = 1;
}
psLevelData->quantInd = 1;
#if CAVLC_RDOQ_MOD
levelData[iPrevSigIdx].iNextRun = iPrevSigIdx - iScanning - 1;
iPrevSigIdx = iScanning;
#endif
}
else
{
psLevelData->level[1] = psLevelData->levelQ;
psLevelData->level[2] = psLevelData->levelQ + 1;
psLevelData->noLevels = 3;
if ( psLevelData->levelQ > 1 )
{
psLevelData->noLevels++;
psLevelData->level[3] = 1;
}
if ( iQuantCoeff == psLevelData->level[1] )
{
psLevelData->quantInd = 1;
}
else
{
psLevelData->quantInd = 2;
}
#if CAVLC_RDOQ_MOD
levelData[iPrevSigIdx].iNextRun = iPrevSigIdx - iScanning - 1;
iPrevSigIdx = iScanning;
#endif
}
for ( levelInd = 1; levelInd < psLevelData->noLevels; levelInd++ )
{
err = (Double)((psLevelData->level[levelInd] << q_bits) - psLevelData->levelDouble);
psLevelData->errLevel[levelInd] = err * err * fTemp;
psLevelData->level[levelInd] *= iSign;
}
#if CAVLC_RDOQ_MOD
}
else
{
sQuantCoeff[iScanning] = 0;
levelDataStruct *psLevelData = &levelData[iScanning];
psLevelData->errLevel[0]=0;
psLevelData->noLevels=1;
}
#endif
}
#if CAVLC_COEF_LRG_BLK==0
UInt uiNum;
if ( uiWidth == 4 )
{
uiNum = 4;
}
else
{
uiNum = 8;
}
#endif
// Last Position
#if CAVLC_COEF_LRG_BLK
#if CAVLC_RDOQ_MOD
lastPosMin = xCodeCoeffCountBitsLast(sQuantCoeff, levelData, iBlockType, uiBlSize, iStartLast
#if CAVLC_RUNLEVEL_TABLE_REM
, pcCU->isIntra(uiAbsPartIdx)
#endif
);
#else
lastPosMin = xCodeCoeffCountBitsLast(sQuantCoeff, levelData, iBlockType, uiBlSize
#if CAVLC_RUNLEVEL_TABLE_REM
, pcCU->isIntra(uiAbsPartIdx)
#endif
);
#endif
#else
lastPosMin = xCodeCoeffCountBitsLast(sQuantCoeff, levelData, iBlockType, uiNum);
#endif
memset(&sQuantCoeff[lastPosMin+1],0,sizeof(TCoeff) * (noCoeff - (lastPosMin + 1)));
Int iLpFlag = 1;
Int iLevelMode = 0;
Int iRun = 0;
Int iVlc_adaptive = 0;
Int iMaxrun = 0;
Int iSum_big_coef = 0;
UInt uiTr1=0;
UInt absBestLevel;
#if !TBL_RUN_ADAPT
Int atable[5] = {4,6,14,28,0xfffffff};
#endif
Int switch_thr[10] = {49,49,0,49,49,0,49,49,49,49};
Int iRateMin=0, levelStart;
Double lagrCoded=0, lagrNotCoded=0;
#if CAVLC_COEF_LRG_BLK
#if MOD_INTRA_TABLE
const UInt **pLumaRunTr1 = (uiWidth==4)? g_pLumaRunTr14x4:((uiWidth==8)? g_pLumaRunTr18x8: g_pLumaRunTr116x16);
#else
const UInt **pLumaRunTr1 = (uiWidth==4)? g_pLumaRunTr14x4:g_pLumaRunTr18x8;
#endif
UInt coeffBlkSize = (uiWidth==4)? 4:(noCoeff==64)? 8:(noCoeff==256)? 16:32;
#endif
for (iScanning = lastPosMin; iScanning>=0; iScanning--)
{
uiScanPos = iScanning;
levelStart = (iScanning == lastPosMin) ? 1 : 0;
sQuantCoeff[uiScanPos] = levelBest = 0;
levelDataStruct *psLevelData = &levelData[uiScanPos];
if ( psLevelData->noLevels >1 || iScanning == 0 )
{
lagrMin = 0; iRateMin = 0;
for (levelInd = levelStart; levelInd < psLevelData->noLevels; levelInd++)
{
lagr = psLevelData->errLevel[levelInd];
iLevel=psLevelData->level[levelInd];
#if CAVLC_COEF_LRG_BLK
#if CAVLC_RDOQ_MOD
#if TBL_RUN_ADAPT
iRate = bitCountRDOQ(iLevel,uiScanPos,iBlockType,iLpFlag,iLevelMode,iRun,iMaxrun,&iVlc_adaptive,
coeffBlkSize,uiTr1, iSum_big_coef, iBlockType, pcCU, pLumaRunTr1, psLevelData->iNextRun
#if CAVLC_RUNLEVEL_TABLE_REM
, pcCU->isIntra(uiAbsPartIdx)
#endif
)<<uiBitShift;
#else
iRate = bitCountRDOQ(iLevel,uiScanPos,iBlockType,iLpFlag,iLevelMode,iRun,iMaxrun,iVlc_adaptive,
coeffBlkSize,uiTr1, iSum_big_coef, iBlockType, pcCU, pLumaRunTr1, psLevelData->iNextRun
#if CAVLC_RUNLEVEL_TABLE_REM
, pcCU->isIntra(uiAbsPartIdx)
#endif
)<<uiBitShift;
#endif
#else
#if TBL_RUN_ADAPT
iRate = bitCountRDOQ(iLevel,uiScanPos,iBlockType,iLpFlag,iLevelMode,iRun,iMaxrun, &iVlc_adaptive,
coeffBlkSize,uiTr1, iSum_big_coef, iBlockType, pcCU, pLumaRunTr1
#if CAVLC_RUNLEVEL_TABLE_REM
, pcCU->isIntra(uiAbsPartIdx)
#endif
)<<uiBitShift;
#else
iRate = bitCountRDOQ(iLevel,uiScanPos,iBlockType,iLpFlag,iLevelMode,iRun,iMaxrun,iVlc_adaptive,
coeffBlkSize,uiTr1, iSum_big_coef, iBlockType, pcCU, pLumaRunTr1
#if CAVLC_RUNLEVEL_TABLE_REM
, pcCU->isIntra(uiAbsPartIdx)
#endif
)<<uiBitShift;
#endif
#endif
#else
if ( uiWidth == 4 )
{
iRate = bitCountRDOQ(iLevel,uiScanPos,iBlockType,iLpFlag,iLevelMode,iRun,iMaxrun,iVlc_adaptive,4,uiTr1,
iSum_big_coef,iBlockType, pcCU)<<uiBitShift;
}
else
{
iRate = bitCountRDOQ(iLevel,uiScanPos,iBlockType,iLpFlag,iLevelMode,iRun,iMaxrun,iVlc_adaptive,8,uiTr1,
iSum_big_coef, iBlockType, pcCU) << uiBitShift;
}
#endif
lagr += m_dLambda * iRate;
if ( lagr < lagrMin || levelInd == levelStart)
{
lagrMin = lagr;
iRateMin = iRate;
levelBest = iLevel;
}
}
}
if ( levelBest != 0 )
{
lagrCoded += lagrMin;
lagrNotCoded += psLevelData->errLevel[0];
}
if ( uiScanPos == 0 && levelBest == 0 )
{
lagrCoded += m_dLambda * iRateMin;
}
sQuantCoeff[uiScanPos] = levelBest;
absBestLevel = abs(levelBest);
if ( levelBest != 0 )
{
if ( uiWidth > 4 )
{
if ( !iLpFlag && absBestLevel > 1 )
{
iSum_big_coef += absBestLevel;
#if TBL_RUN_ADAPT
if((noCoeff - uiScanPos - 1) > switch_thr[iBlockType] || iSum_big_coef > 2)
{
if (absBestLevel > atable[iVlc_adaptive])
{
iVlc_adaptive++;
}
iLevelMode = 1;
}
#else
if ((noCoeff - uiScanPos - 1) > switch_thr[iBlockType] || iSum_big_coef > 2) iLevelMode = 1;
#endif
}
}
else
{
if ( absBestLevel > 1 )
{
iLevelMode = 1;
}
}
if ( iLpFlag == 1 )
{
uiTr1 = (absBestLevel > 1) ? 0 : 1;
}
else
{
if ( uiTr1 == 0 || absBestLevel >= 2 )
{
uiTr1 = 0;
}
else if ( uiTr1 < MAX_TR1 )
{
uiTr1++;
}
}
iMaxrun = iScanning - 1;
iLpFlag = 0;
iRun = 0;
if ( iLevelMode && (absBestLevel > atable[iVlc_adaptive]))
{
iVlc_adaptive++;
}
}
else
{
iRun += 1;
}
}
if (lastPosMin >= 0 && lagrCoded > lagrNotCoded)
{
for (iScanning = lastPosMin; iScanning>=0; iScanning--)
{
sQuantCoeff[iScanning] = 0;
}
}
#if CAVLC_COEF_LRG_BLK
if ((!pcCU->isIntra(uiAbsPartIdx) && uiWidth > maxBlSize))
{
for (iScanning=noCoeff-1; iScanning>=0; iScanning--)
{
#if QC_MDCS
iPos = g_auiSigLastScan[uiScanIdx][uiLog2BlkSize-1][iScanning];
#else
iPos = pucScan[iScanning];
#endif //QC_MDCS
j = iPos >> (g_aucConvertToBit[ maxBlSize ] + 2);
i = iPos & (maxBlSize-1);
iPos = (j<<(g_aucConvertToBit[ uiWidth ] + 2))+i;
pDstCoeff[iPos] = sQuantCoeff[iScanning];
uiAbsSum += abs(sQuantCoeff[iScanning]);
}
}
#else
if ((!pcCU->isIntra(uiAbsPartIdx) && uiWidth >= 16))
{
for (iScanning = noCoeff - 1; iScanning >= 0; iScanning--)
{
#if QC_MDCS
iPos = g_auiSigLastScan[uiScanIdx][uiLog2BlkSize-1][iScanning];
#else
iPos = pucScan[iScanning];
#endif //QC_MDCS
j = iPos >> 3;
i = iPos & 0x7;
iPos = uiWidth * j + i;
pDstCoeff[iPos] = sQuantCoeff[iScanning];
uiAbsSum += abs(sQuantCoeff[iScanning]);
}
}
#endif
else
{
for (iScanning = noCoeff - 1; iScanning >= 0; iScanning--)
{
#if NSQT
if( bNonSqureFlag )
{
iPos = g_auiNonSquareSigLastScan[uiNonSqureScanTableIdx][iScanning];
}
else
#endif
{
#if QC_MDCS
iPos = g_auiSigLastScan[uiScanIdx][uiLog2BlkSize-1][iScanning];
#else
iPos = pucScan[iScanning];
#endif //QC_MDCS
}
pDstCoeff[iPos] = sQuantCoeff[iScanning];
uiAbsSum += abs(sQuantCoeff[iScanning]);
}
}
}
Void TComTrQuant::xQuant(TComDataCU* pcCU, Int* pSrc, TCoeff* pDes, Int iWidth, Int iHeight, UInt& uiAcSum, TextType eTType, UInt uiAbsPartIdx )
{
Int* piCoef = pSrc;
TCoeff* piQCoef = pDes;
Int iAdd = 0;
if ( m_bUseRDOQ && (eTType == TEXT_LUMA || RDOQ_CHROMA) )
{
if ( m_iSymbolMode == 0)
{
xRateDistOptQuant_LCEC(pcCU, piCoef, pDes, iWidth, iHeight, uiAcSum, eTType, uiAbsPartIdx );
}
else
{
xRateDistOptQuant( pcCU, piCoef, pDes, iWidth, iHeight, uiAcSum, eTType, uiAbsPartIdx );
}
}
else
{
#if NSQT
Bool bNonSqureFlag = ( iWidth != iHeight );
UInt uiNonSqureScanTableIdx = 0;
if( bNonSqureFlag )
{
UInt uiWidthBit = g_aucConvertToBit[ iWidth ] + 2;
UInt uiHeightBit = g_aucConvertToBit[ iHeight ] + 2;
uiNonSqureScanTableIdx = ( iWidth * iHeight ) == 64 ? 0 : 1;
iWidth = 1 << ( ( uiWidthBit + uiHeightBit) >> 1 );
iHeight = iWidth;
}
#endif
const UInt* pucScan;
UInt uiConvBit = g_aucConvertToBit[ iWidth ];
pucScan = g_auiFrameScanXY [ uiConvBit + 1 ];
#if NSQT
if( bNonSqureFlag)
{
pucScan = g_auiNonSquareSigLastScan[ uiNonSqureScanTableIdx ];
}
#endif
UInt uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2;
UInt uiQ = g_quantScales[m_cQP.rem()];
#if FULL_NBIT
UInt uiBitDepth = g_uiBitDepth;
#else
UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement;
#endif
UInt iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; // Represents scaling through forward transform
Int iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift; // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
iAdd = (pcCU->getSlice()->getSliceType()==I_SLICE ? 171 : 85) << (iQBits-9);
for( Int n = 0; n < iWidth*iHeight; n++ )
{
Int iLevel;
Int iSign;
UInt uiBlockPos = pucScan[n];
iLevel = piCoef[uiBlockPos];
iSign = (iLevel < 0 ? -1: 1);
iLevel = (abs(iLevel) * uiQ + iAdd ) >> iQBits;
#if CAVLC_COEF_LRG_BLK
if (pcCU->isIntra( uiAbsPartIdx ))
{
if (m_iSymbolMode == 0 && n>=64 && eTType != TEXT_LUMA)
{
iLevel = 0;
}
}
else
{
if (m_iSymbolMode == 0 && ((uiBlockPos%iWidth)>=8 || (uiBlockPos/iWidth)>=8) && eTType != TEXT_LUMA)
{
iLevel = 0;
}
}
#else
if (m_iSymbolMode == 0 && iWidth>8)
{
/* Two methods of limiting number of encoded coefficients to 8x8 for intra and inter respectively */
if (pcCU->isIntra( uiAbsPartIdx ))
{
if(n>=64)
{
iLevel = 0;
}
}
else
{
if ((uiBlockPos%iWidth)>=8 || (uiBlockPos/iWidth)>=8)
{
iLevel = 0;
}
}
}
#endif
uiAcSum += iLevel;
iLevel *= iSign;
piQCoef[uiBlockPos] = iLevel;
} // for n
} //if RDOQ
//return;
}
Void TComTrQuant::xDeQuant( const TCoeff* pSrc, Int* pDes, Int iWidth, Int iHeight )
{
const TCoeff* piQCoef = pSrc;
Int* piCoef = pDes;
#if NSQT
if( iWidth != iHeight )
{
UInt uiWidthBit = g_aucConvertToBit[ iWidth ] + 2;
UInt uiHeightBit = g_aucConvertToBit[ iHeight ] + 2;
iWidth = 1 << ( ( uiWidthBit + uiHeightBit) >> 1 );
iHeight = iWidth;
}
#endif
if ( iWidth > (Int)m_uiMaxTrSize )
{
iWidth = m_uiMaxTrSize;
iHeight = m_uiMaxTrSize;
}
Int iShift,iAdd,iCoeffQ;
UInt uiLog2TrSize = g_aucConvertToBit[ iWidth ] + 2;
#if FULL_NBIT
UInt uiBitDepth = g_uiBitDepth;
#else
UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement;
#endif
UInt iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize;
iShift = QUANT_IQUANT_SHIFT - QUANT_SHIFT - iTransformShift;
iAdd = 1 << (iShift-1);
Int scale = g_invQuantScales[m_cQP.m_iRem] << m_cQP.m_iPer;
for( Int n = 0; n < iWidth*iHeight; n++ )
{
iCoeffQ = ( piQCoef[n] * scale + iAdd ) >> iShift;
piCoef[n] = Clip3(-32768,32767,iCoeffQ);
}
}
Void TComTrQuant::init( UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxTrSize, Int iSymbolMode, UInt *aTableLP4, UInt *aTableLP8, UInt *aTableLastPosVlcIndex,
Bool bUseRDOQ, Bool bEnc )
{
m_uiMaxTrSize = uiMaxTrSize;
m_bEnc = bEnc;
m_bUseRDOQ = bUseRDOQ;
m_uiLPTableE8 = aTableLP8;
m_uiLPTableE4 = aTableLP4;
m_uiLastPosVlcIndex=aTableLastPosVlcIndex;
m_iSymbolMode = iSymbolMode;
}
#if INTRA_DST_TYPE_7
Void TComTrQuant::transformNxN( TComDataCU* pcCU, Pel* pcResidual, UInt uiStride, TCoeff* rpcCoeff, UInt uiWidth, UInt uiHeight, UInt& uiAbsSum, TextType eTType, UInt uiAbsPartIdx )
{
UInt uiMode; //luma intra pred
if(eTType == TEXT_LUMA && pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA )
{
uiMode = pcCU->getLumaIntraDir( uiAbsPartIdx );
}
else
{
uiMode = REG_DCT;
}
uiAbsSum = 0;
assert( (pcCU->getSlice()->getSPS()->getMaxTrSize() >= uiWidth) );
#if NSQT
xT( uiMode, pcResidual, uiStride, m_plTempCoeff, uiWidth, uiHeight );
#else
xT( uiMode, pcResidual, uiStride, m_plTempCoeff, uiWidth );
#endif
xQuant( pcCU, m_plTempCoeff, rpcCoeff, uiWidth, uiHeight, uiAbsSum, eTType, uiAbsPartIdx );
}
#else
Void TComTrQuant::transformNxN( TComDataCU* pcCU, Pel* pcResidual, UInt uiStride, TCoeff* rpcCoeff, UInt uiWidth, UInt uiHeight, UInt& uiAbsSum, TextType eTType, UInt uiAbsPartIdx )
{
uiAbsSum = 0;
assert( (pcCU->getSlice()->getSPS()->getMaxTrSize() >= uiWidth) );
#if NSQT
xT( pcResidual, uiStride, m_plTempCoeff, uiWidth, uiHeight );
#else
xT( pcResidual, uiStride, m_plTempCoeff, uiWidth );
#endif
xQuant( pcCU, m_plTempCoeff, rpcCoeff, uiWidth, uiHeight, uiAbsSum, eTType, uiAbsPartIdx );
}
#endif
#if INTRA_DST_TYPE_7
Void TComTrQuant::invtransformNxN( TextType eText,UInt uiMode, Pel* rpcResidual, UInt uiStride, TCoeff* pcCoeff, UInt uiWidth, UInt uiHeight )
{
xDeQuant( pcCoeff, m_plTempCoeff, uiWidth, uiHeight);
#if NSQT
xIT( uiMode, m_plTempCoeff, rpcResidual, uiStride, uiWidth, uiHeight );
#else
xIT( uiMode, m_plTempCoeff, rpcResidual, uiStride, uiWidth);
#endif
}
#else
Void TComTrQuant::invtransformNxN( Pel* rpcResidual, UInt uiStride, TCoeff* pcCoeff, UInt uiWidth, UInt uiHeight )
{
xDeQuant( pcCoeff, m_plTempCoeff, uiWidth, uiHeight);
#if NSQT
xIT( m_plTempCoeff, rpcResidual, uiStride, uiWidth, uiHeight );
#else
xIT( m_plTempCoeff, rpcResidual, uiStride, uiWidth );
#endif
}
#endif
Void TComTrQuant::invRecurTransformNxN( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eTxt, Pel* rpcResidual, UInt uiAddr, UInt uiStride, UInt uiWidth, UInt uiHeight, UInt uiMaxTrMode, UInt uiTrMode, TCoeff* rpcCoeff )
{
if( !pcCU->getCbf(uiAbsPartIdx, eTxt, uiTrMode) )
{
return;
}
UInt uiLumaTrMode, uiChromaTrMode;
pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
const UInt uiStopTrMode = eTxt == TEXT_LUMA ? uiLumaTrMode : uiChromaTrMode;
#if NSQT
UChar uhDepth = pcCU->getDepth( uiAbsPartIdx );
PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
#endif
assert(1); // as long as quadtrees are not used for residual transform
if( uiTrMode == uiStopTrMode )
{
UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ) + uiTrMode;
UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2;
#if NSQT
UInt uiTrModeC = uiTrMode;
#endif
if( eTxt != TEXT_LUMA && uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() )
{
UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 );
if( ( uiAbsPartIdx % uiQPDiv ) != 0 )
{
return;
}
uiWidth <<= 1;
uiHeight <<= 1;
#if NSQT
uiTrModeC--;
#endif
}
Pel* pResi = rpcResidual + uiAddr;
#if NSQT
if( ( eTxt == TEXT_LUMA && pcCU->useNonSquareTrans( uiTrMode ) ) || ( eTxt != TEXT_LUMA && pcCU->useNonSquareTrans( uiTrModeC ) ) )
{
#if AMP
UInt uiTrWidth = ( ePartSize == SIZE_Nx2N || ePartSize == SIZE_nLx2N || ePartSize == SIZE_nRx2N )? uiWidth >> 1 : uiWidth << 1;
UInt uiTrHeight = ( ePartSize == SIZE_Nx2N || ePartSize == SIZE_nLx2N || ePartSize == SIZE_nRx2N )? uiHeight << 1 : uiHeight >> 1;
#else
UInt uiTrWidth = ( ePartSize == SIZE_Nx2N )? uiWidth >> 1 : uiWidth << 1;
UInt uiTrHeight = ( ePartSize == SIZE_Nx2N )? uiHeight << 1 : uiHeight >> 1;
#endif
if( uiWidth == 4 )
{
uiTrWidth = uiTrHeight = 4;
}
if( uiTrWidth != uiTrHeight )
{
TCoeff orgCoeff[ 256 ];
UInt uiNonSqureScanTableIdx = ( uiTrWidth * uiTrHeight ) == 64 ? 0 : 1;
memcpy( &orgCoeff[0], rpcCoeff, uiWidth * uiHeight * sizeof( TCoeff ) );
for( UInt uiScanPos = 0; uiScanPos < uiWidth * uiHeight; uiScanPos++ )
{
UInt uiBlkPos = g_auiNonSquareSigLastScan[ uiNonSqureScanTableIdx ][ uiScanPos ];
rpcCoeff[ uiBlkPos ] = orgCoeff[ g_auiFrameScanXY[ (int)g_aucConvertToBit[ uiWidth ] + 1 ][ uiScanPos ] ];
}
uiWidth = uiTrWidth;
uiHeight = uiTrHeight;
}
}
#endif
#if INTRA_DST_TYPE_7
invtransformNxN( eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight );
#else
invtransformNxN( pResi, uiStride, rpcCoeff, uiWidth, uiHeight );
#endif
}
else
{
uiTrMode++;
uiWidth >>= 1;
uiHeight >>= 1;
UInt uiAddrOffset = uiHeight * uiStride;
UInt uiCoefOffset = uiWidth * uiHeight;
UInt uiPartOffset = pcCU->getTotalNumPart() >> (uiTrMode<<1);
#if NSQT
if( pcCU->useNonSquareTrans( uiTrMode ) && ! ( uiWidth == 4 && uiTrMode == 1 ) )
{
if( uiTrMode == 1 || ( ( uhDepth == 0 || uiWidth == 4 ) && uiTrMode == 2 ) )
{
#if AMP
if( ePartSize == SIZE_Nx2N || ePartSize == SIZE_nLx2N || ePartSize == SIZE_nRx2N )
#else
if( ePartSize == SIZE_Nx2N )
#endif
{
uiAddrOffset = ( uiTrMode == 1 || ( uhDepth == 0 && uiTrMode == 2 ) ) ? uiWidth >> 1 : uiAddrOffset;
}
else
{
uiAddrOffset = ( uiTrMode == 1 || ( uhDepth == 0 && uiTrMode == 2 ) ) ? ( uiWidth >> 1 ) * uiStride : uiWidth;
}
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + uiAddrOffset , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + 2*uiAddrOffset , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + 3*uiAddrOffset , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff );
}
else
{
#if AMP
UInt uiTrWidth = ( ePartSize == SIZE_Nx2N || ePartSize == SIZE_nLx2N || ePartSize == SIZE_nRx2N ) ? uiWidth >> 1 : uiWidth << 1;
UInt uiTrHeight = ( ePartSize == SIZE_Nx2N || ePartSize == SIZE_nLx2N || ePartSize == SIZE_nRx2N ) ? uiWidth << 1 : uiWidth >> 1;
#else
UInt uiTrWidth = ( ePartSize == SIZE_Nx2N ) ? uiWidth >> 1 : uiWidth << 1;
UInt uiTrHeight = ( ePartSize == SIZE_Nx2N ) ? uiWidth << 1 : uiWidth >> 1;
#endif
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + uiTrWidth , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + uiTrHeight*uiStride , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + uiTrHeight*uiStride+uiTrWidth , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff );
}
}
else
#endif
{
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + uiWidth , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + uiAddrOffset , uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff ); rpcCoeff += uiCoefOffset; uiAbsPartIdx += uiPartOffset;
invRecurTransformNxN( pcCU, uiAbsPartIdx, eTxt, rpcResidual, uiAddr + uiAddrOffset + uiWidth, uiStride, uiWidth, uiHeight, uiMaxTrMode, uiTrMode, rpcCoeff );
}
}
}
// ------------------------------------------------------------------------------------------------
// Logical transform
// ------------------------------------------------------------------------------------------------
/** Wrapper function between HM interface and core NxN forward transform (2D)
* \param piBlkResi input data (residual)
* \param psCoeff output data (transform coefficients)
* \param uiStride stride of input residual data
* \param iSize transform size (iSize x iSize)
* \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
*/
#if INTRA_DST_TYPE_7
#if NSQT
Void TComTrQuant::xT( UInt uiMode, Pel* piBlkResi, UInt uiStride, Int* psCoeff, Int iWidth, Int iHeight )
#else
Void TComTrQuant::xT( UInt uiMode, Pel* piBlkResi, UInt uiStride, Int* psCoeff, Int iSize )
#endif
#else
#if NSQT
Void TComTrQuant::xT( Pel* piBlkResi, UInt uiStride, Int* psCoeff, Int iWidth, Int iHeight )
#else
Void TComTrQuant::xT( Pel* piBlkResi, UInt uiStride, Int* psCoeff, Int iSize )
#endif
#endif
{
#if MATRIX_MULT
#if NSQT
Int iSize = iWidth;
if( iWidth != iHeight)
{
xTrMxN( piBlkResi, psCoeff, uiStride, (UInt)iWidth, (UInt)iHeight );
return;
}
#endif
#if INTRA_DST_TYPE_7
xTr(piBlkResi,psCoeff,uiStride,(UInt)iSize,uiMode);
#else
xTr(piBlkResi,psCoeff,uiStride,(UInt)iSize);
#endif
#else
Int j,k;
#if NSQT
Int iSize = iWidth;
if( iWidth != iHeight)
{
Int iMaxSize = max( iWidth , iHeight);
Int iMinSize = min( iWidth , iHeight);
short block[ 64 * 64 ];
short coeff[ 64 * 64 ];
if( iWidth > iHeight)
{
for (j = 0; j < iHeight; j++)
{
memcpy( block + j * iWidth, piBlkResi + j * uiStride, iWidth * sizeof( short ) );
}
}
else
{
for ( j = 0; j < iHeight; j ++)
{
for ( k = 0; k < iWidth; k ++)
{
block[ k * iHeight + j ] = piBlkResi[ k ];
}
piBlkResi += uiStride;
}
}
xTrMxN( block, coeff, iMaxSize, iMinSize );
for ( j = 0; j < iHeight * iWidth; j++ )
{
psCoeff[ j ] = coeff[ j ];
}
return ;
}
#endif
if (iSize==4)
{
short block[4][4];
short coeff[4][4];
for (j=0; j<4; j++)
{
memcpy(block[j],piBlkResi+j*uiStride,4*sizeof(short));
}
#if INTRA_DST_TYPE_7
xTr4(block,coeff,uiMode);
#else
xTr4(block,coeff);
#endif
for (j=0; j<4; j++)
{
for (k=0; k<4; k++)
{
psCoeff[j*4+k] = coeff[j][k];
}
}
}
else if (iSize==8)
{
short block[8][8];
short coeff[8][8];
for (j=0; j<8; j++)
{
memcpy(block[j],piBlkResi+j*uiStride,8*sizeof(short));
}
xTr8(block,coeff);
for (j=0; j<8; j++)
{
for (k=0; k<8; k++)
{
psCoeff[j*8+k] = coeff[j][k];
}
}
}
else if (iSize==16)
{
short block[16][16];
short coeff[16][16];
for (j=0; j<16; j++)
{
memcpy(block[j],piBlkResi+j*uiStride,16*sizeof(short));
}
xTr16(block,coeff);
for (j=0; j<16; j++)
{
for (k=0; k<16; k++)
{
psCoeff[j*16+k] = coeff[j][k];
}
}
}
else if (iSize==32)
{
short block[32][32];
short coeff[32][32];
for (j=0; j<32; j++)
{
memcpy(block[j],piBlkResi+j*uiStride,32*sizeof(short));
}
xTr32(block,coeff);
for (j=0; j<32; j++)
{
for (k=0; k<32; k++)
{
psCoeff[j*32+k] = coeff[j][k];
}
}
}
#endif
}
/** Wrapper function between HM interface and core NxN inverse transform (2D)
* \param plCoef input data (transform coefficients)
* \param pResidual output data (residual)
* \param uiStride stride of input residual data
* \param iSize transform size (iSize x iSize)
* \param uiMode is Intra Prediction mode used in Mode-Dependent DCT/DST only
*/
#if INTRA_DST_TYPE_7
#if NSQT
Void TComTrQuant::xIT( UInt uiMode, Int* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight )
#else
Void TComTrQuant::xIT( UInt uiMode, Int* plCoef, Pel* pResidual, UInt uiStride, Int iSize )
#endif
#else
#if NSQT
Void TComTrQuant::xIT( Int* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight )
#else
Void TComTrQuant::xIT( Int* plCoef, Pel* pResidual, UInt uiStride, Int iSize )
#endif
#endif
{
#if MATRIX_MULT
#if NSQT
Int iSize = iWidth;
if( iWidth != iHeight )
{
xITrMxN( plCoef, pResidual, uiStride, (UInt)iWidth, (UInt)iHeight );
return;
}
#endif
#if INTRA_DST_TYPE_7
xITr(plCoef,pResidual,uiStride,(UInt)iSize,uiMode);
#else
xITr(plCoef,pResidual,uiStride,(UInt)iSize);
#endif
#else
Int j,k;
#if NSQT
Int iSize = iWidth;
if( iWidth != iHeight )
{
Int iMaxSize = max( iWidth , iHeight);
Int iMinSize = min( iWidth , iHeight);
short block[ 64 * 64 ];
short coeff[ 64 * 64 ];
for ( j = 0; j < iHeight * iWidth; j++ )
{
coeff[j] = (short)plCoef[j];
}
xITrMxN( coeff, block, iMaxSize, iMinSize );
if( iWidth > iHeight )
{
for ( j = 0; j < iHeight; j++ )
{
memcpy( pResidual + j * uiStride, block + j * iWidth, iWidth * sizeof(short) );
}
}
else
{
for ( j = 0; j < iHeight; j++ )
{
for ( k = 0; k < iWidth; k++ )
{
pResidual[k] = block[k * iHeight + j];
}
pResidual += uiStride;
}
}
return ;
}
#endif
if (iSize==4)
{
short block[4][4];
short coeff[4][4];
for (j=0; j<4; j++)
{
for (k=0; k<4; k++)
{
coeff[j][k] = (short)plCoef[j*4+k];
}
}
#if INTRA_DST_TYPE_7
xITr4(coeff,block,uiMode);
#else
xITr4(coeff,block);
#endif
for (j=0; j<4; j++)
{
memcpy(pResidual+j*uiStride,block[j],4*sizeof(short));
}
}
else if (iSize==8)
{
short block[8][8];
short coeff[8][8];
for (j=0; j<8; j++)
{
for (k=0; k<8; k++)
{
coeff[j][k] = (short)plCoef[j*8+k];
}
}
xITr8(coeff,block);
for (j=0; j<8; j++)
{
memcpy(pResidual+j*uiStride,block[j],8*sizeof(short));
}
}
else if (iSize==16)
{
short block[16][16];
short coeff[16][16];
for (j=0; j<16; j++)
{
for (k=0; k<16; k++)
{
coeff[j][k] = (short)plCoef[j*16+k];
}
}
xITr16(coeff,block);
for (j=0; j<16; j++)
{
memcpy(pResidual+j*uiStride,block[j],16*sizeof(short));
}
}
else if (iSize==32)
{
short block[32][32];
short coeff[32][32];
for (j=0; j<32; j++)
{
for (k=0; k<32; k++)
{
coeff[j][k] = (short)plCoef[j*32+k];
}
}
xITr32(coeff,block);
for (j=0; j<32; j++)
{
memcpy(pResidual+j*uiStride,block[j],32*sizeof(short));
}
}
#endif
}
#if QC_MDCS
UInt TComTrQuant::getCurrLineNum(UInt uiScanIdx, UInt uiPosX, UInt uiPosY)
{
UInt uiLineNum = 0;
switch (uiScanIdx)
{
case SCAN_ZIGZAG:
uiLineNum = uiPosY + uiPosX;
break;
case SCAN_HOR:
uiLineNum = uiPosY;
break;
case SCAN_VER:
uiLineNum = uiPosX;
break;
}
return uiLineNum;
}
#endif
/** RDOQ with CABAC
* \param pcCU pointer to coding unit structure
* \param plSrcCoeff pointer to input buffer
* \param piDstCoeff reference to pointer to output buffer
* \param uiWidth block width
* \param uiHeight block height
* \param uiAbsSum reference to absolute sum of quantized transform coefficient
* \param eTType plane type / luminance or chrominance
* \param uiAbsPartIdx absolute partition index
* \returns Void
* Rate distortion optimized quantization for entropy
* coding engines using probability models like CABAC
*/
Void TComTrQuant::xRateDistOptQuant ( TComDataCU* pcCU,
Int* plSrcCoeff,
TCoeff* piDstCoeff,
UInt uiWidth,
UInt uiHeight,
UInt& uiAbsSum,
TextType eTType,
UInt uiAbsPartIdx )
{
Int iQBits = m_cQP.m_iBits;
Double dTemp = 0;
#if NSQT
Bool bNonSqureFlag = ( uiWidth != uiHeight );
UInt uiNonSqureScanTableIdx = 0;
if( bNonSqureFlag )
{
UInt uiWidthBit = g_aucConvertToBit[ uiWidth ] + 2;
UInt uiHeightBit = g_aucConvertToBit[ uiHeight ] + 2;
uiNonSqureScanTableIdx = ( uiWidth * uiHeight ) == 64 ? 0 : 1;
uiWidth = 1 << ( ( uiWidthBit + uiHeightBit ) >> 1 );
uiHeight = uiWidth;
}
#endif
UInt uiLog2TrSize = g_aucConvertToBit[ uiWidth ] + 2;
Int uiQ = g_quantScales[m_cQP.rem()];
#if FULL_NBIT
UInt uiBitDepth = g_uiBitDepth;
#else
UInt uiBitDepth = g_uiBitDepth + g_uiBitIncrement;
#endif
Int iTransformShift = MAX_TR_DYNAMIC_RANGE - uiBitDepth - uiLog2TrSize; // Represents scaling through forward transform
double dErrScale = (double)(1<<SCALE_BITS); // Compensate for scaling of bitcount in Lagrange cost function
dErrScale = dErrScale*pow(2.0,-2.0*iTransformShift); // Compensate for scaling through forward transform
dErrScale = dErrScale/(double)(uiQ*uiQ); // Compensate for qp-dependent multiplier applied before calculating the Lagrange cost function
dErrScale = dErrScale/(double)(1<<(2*g_uiBitIncrement)); // Compensate for Lagrange multiplier that is tuned towards 8-bit input
iQBits = QUANT_SHIFT + m_cQP.m_iPer + iTransformShift; // Right shift of non-RDOQ quantizer; level = (coeff*uiQ + offset)>>q_bits
UInt uiGoRiceParam = 0;
#if !UNIFIED_SCAN
UInt uiLastScanPos = 0;
#endif
Double d64BlockUncodedCost = 0;
const UInt uiLog2BlkSize = g_aucConvertToBit[ uiWidth ] + 2;
const UInt uiMaxNumCoeff = 1 << ( uiLog2BlkSize << 1 );
#if !UNIFIED_SCAN
const UInt uiNum4x4Blk = max<UInt>( 1, uiMaxNumCoeff >> 4 );
#endif
#if QC_MDCS
#if DIAG_SCAN
UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx));
uiScanIdx = ( uiScanIdx == SCAN_ZIGZAG ) ? SCAN_DIAG : uiScanIdx; // Map value zigzag to diagonal scan
#else
const UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx));
#endif
#endif //QC_MDCS
#if NSQT
static Int orgSrcCoeff[ 256 ];
if( bNonSqureFlag )
{
memcpy( &orgSrcCoeff[ 0 ], plSrcCoeff, uiMaxNumCoeff * sizeof( Int ) );
for( UInt uiScanPos = 0; uiScanPos < uiMaxNumCoeff; uiScanPos++ )
{
UInt uiBlkPos = g_auiNonSquareSigLastScan[ uiNonSqureScanTableIdx ][ uiScanPos ];
plSrcCoeff[ g_auiFrameScanXY[ (int)g_aucConvertToBit[ uiWidth ] + 1 ][ uiScanPos ] ] = orgSrcCoeff[ uiBlkPos ];
}
}
#endif
#if UNIFIED_SCAN
Double pdCostCoeff [ 32 * 32 ];
Double pdCostSig [ 32 * 32 ];
Double pdCostCoeff0[ 32 * 32 ];
::memset( pdCostCoeff, 0, sizeof(Double) * uiMaxNumCoeff );
::memset( pdCostSig, 0, sizeof(Double) * uiMaxNumCoeff );
UInt uiCtxSet = 0;
Int c1 = 1;
Int c2 = 0;
UInt uiNumOne = 0;
Double d64BaseCost = 0;
Int iLastScanPos = -1;
dTemp = dErrScale;
const UInt * const scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlkSize - 1 ];
for( Int iScanPos = (Int) uiMaxNumCoeff-1; iScanPos >= 0; iScanPos-- )
{
//===== quantization =====
UInt uiBlkPos = scan[iScanPos];
Int lLevelDouble = plSrcCoeff[ uiBlkPos ];
lLevelDouble = abs(lLevelDouble * uiQ);
UInt uiMaxAbsLevel = (lLevelDouble + (1 << (iQBits - 1))) >> iQBits;
Double dErr = Double( lLevelDouble );
pdCostCoeff0[ iScanPos ] = dErr * dErr * dTemp;
d64BlockUncodedCost += pdCostCoeff0[ iScanPos ];
piDstCoeff[ uiBlkPos ] = uiMaxAbsLevel;
if ( uiMaxAbsLevel > 0 && iLastScanPos < 0 )
{
iLastScanPos = iScanPos;
uiCtxSet = iScanPos < SCAN_SET_SIZE ? 0 : 3;
}
if ( iLastScanPos >= 0 )
{
//===== coefficient level estimation =====
UInt uiLevel;
UInt uiOneCtx = 5 * uiCtxSet + c1;
UInt uiAbsCtx = 5 * uiCtxSet + c2;
if( iScanPos == iLastScanPos )
{
uiLevel = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ], lLevelDouble, uiMaxAbsLevel, 0, uiOneCtx, uiAbsCtx, uiGoRiceParam, iQBits, dTemp, 1 );
}
else
{
UInt uiPosY = uiBlkPos >> uiLog2BlkSize;
UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlkSize );
UShort uiCtxSig = getSigCtxInc( piDstCoeff, uiPosX, uiPosY, uiLog2BlkSize, uiWidth );
uiLevel = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ], lLevelDouble, uiMaxAbsLevel, uiCtxSig, uiOneCtx, uiAbsCtx, uiGoRiceParam, iQBits, dTemp, 0 );
}
piDstCoeff[ uiBlkPos ] = uiLevel;
d64BaseCost += pdCostCoeff [ iScanPos ];
//===== update bin model =====
if( uiLevel > 1 )
{
c1 = 0;
c2 += (c2 < 4);
uiNumOne++;
if( uiLevel > 2 )
{
uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiLevel - 3, 15 ) ];
}
}
else if( (c1 & 3) && uiLevel )
{
c1++;
}
//===== context set update =====
if( ( iScanPos % SCAN_SET_SIZE == 0 ) && ( iScanPos > 0 ) )
{
c1 = 1;
c2 = 0;
uiGoRiceParam = 0;
uiCtxSet = iScanPos == SCAN_SET_SIZE ? 0 : 3;
if( uiNumOne > 0 )
{
uiCtxSet++;
if( uiNumOne > 3 )
{
uiCtxSet++;
}
}
uiNumOne >>= 1;
}
}
else
{
d64BaseCost += pdCostCoeff0[ iScanPos ];
}
}
//===== estimate last position =====
if ( iLastScanPos < 0 )
{
return;
}
Double d64BestCost = 0;
Int ui16CtxCbf = 0;
Int iBestLastIdxP1 = 0;
if( !pcCU->isIntra( uiAbsPartIdx ) && eTType == TEXT_LUMA && pcCU->getTransformIdx( uiAbsPartIdx ) == 0 )
{
ui16CtxCbf = pcCU->getCtxQtRootCbf( uiAbsPartIdx );
d64BestCost = d64BlockUncodedCost + xGetICost( m_pcEstBitsSbac->blockRootCbpBits[ ui16CtxCbf ][ 0 ] );
d64BaseCost += xGetICost( m_pcEstBitsSbac->blockRootCbpBits[ ui16CtxCbf ][ 1 ] );
}
else
{
ui16CtxCbf = pcCU->getCtxQtCbf( uiAbsPartIdx, eTType, pcCU->getTransformIdx( uiAbsPartIdx ) );
ui16CtxCbf = ( eTType ? eTType - 1 : eTType ) * NUM_QT_CBF_CTX + ui16CtxCbf;
d64BestCost = d64BlockUncodedCost + xGetICost( m_pcEstBitsSbac->blockCbpBits[ ui16CtxCbf ][ 0 ] );
d64BaseCost += xGetICost( m_pcEstBitsSbac->blockCbpBits[ ui16CtxCbf ][ 1 ] );
}
for( Int iScanPos = iLastScanPos; iScanPos >= 0; iScanPos-- )
{
UInt uiBlkPos = scan[iScanPos];
if( piDstCoeff[ uiBlkPos ] )
{
UInt uiPosY = uiBlkPos >> uiLog2BlkSize;
UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlkSize );
#if MODIFIED_LAST_CODING
Double d64CostLast= uiScanIdx == SCAN_VER ? xGetRateLast( uiPosY, uiPosX, uiWidth ) : xGetRateLast( uiPosX, uiPosY, uiWidth );
#else
Double d64CostLast= uiScanIdx == SCAN_VER ? xGetRateLast( uiPosY, uiPosX ) : xGetRateLast( uiPosX, uiPosY );
#endif
Double totalCost = d64BaseCost + d64CostLast - pdCostSig[ iScanPos ];
if( totalCost < d64BestCost )
{
iBestLastIdxP1 = iScanPos + 1;
d64BestCost = totalCost;
}
if( piDstCoeff[ uiBlkPos ] > 1 )
{
break;
}
d64BaseCost -= pdCostCoeff[ iScanPos ];
d64BaseCost += pdCostCoeff0[ iScanPos ];
}
else
{
d64BaseCost -= pdCostSig[ iScanPos ];
}
}
for ( Int scanPos = 0; scanPos < iBestLastIdxP1; scanPos++ )
{
Int blkPos = scan[ scanPos ];
Int level = piDstCoeff[ blkPos ];
uiAbsSum += level;
piDstCoeff[ blkPos ] = ( plSrcCoeff[ blkPos ] < 0 ) ? -level : level;
}
//===== clean uncoded coefficients =====
for ( Int scanPos = iBestLastIdxP1; scanPos <= iLastScanPos; scanPos++ )
{
piDstCoeff[ scan[ scanPos ] ] = 0;
}
#else
Int piCoeff [ MAX_CU_SIZE * MAX_CU_SIZE ];
Int plLevelDouble[ MAX_CU_SIZE * MAX_CU_SIZE ];
UInt puiEstParams [ 32*32*3 ];
::memset( piDstCoeff, 0, sizeof(TCoeff) * uiMaxNumCoeff );
::memset( piCoeff, 0, sizeof(Int) * uiMaxNumCoeff );
::memset( plLevelDouble, 0, sizeof(Int) * uiMaxNumCoeff );
::memset( puiEstParams, 0, sizeof(UInt) * uiMaxNumCoeff * 3 );
UInt *puiOneCtx = puiEstParams;
UInt *puiAbsCtx = puiEstParams + uiMaxNumCoeff;
UInt *puiAbsGoRice = puiEstParams + ( uiMaxNumCoeff << 1 );
//===== quantization =====
for( UInt uiScanPos = 0; uiScanPos < uiMaxNumCoeff; uiScanPos++ )
{
#if QC_MDCS
UInt uiBlkPos = g_auiSigLastScan[uiScanIdx][uiLog2BlkSize-1][uiScanPos];
#else
UInt uiBlkPos = g_auiFrameScanXY[ uiLog2BlkSize-1 ][ uiScanPos ];
#endif
Int lLevelDouble = plSrcCoeff[ uiBlkPos ];
dTemp = dErrScale;
lLevelDouble = abs(lLevelDouble * uiQ);
plLevelDouble[ uiBlkPos ] = lLevelDouble;
UInt uiMaxAbsLevel = (lLevelDouble + (1 << (iQBits - 1))) >> iQBits;
Double dErr = Double( lLevelDouble );
d64BlockUncodedCost += dErr * dErr * dTemp;
piCoeff[ uiBlkPos ] = plSrcCoeff[ uiBlkPos ] > 0 ? uiMaxAbsLevel : -Int( uiMaxAbsLevel );
if ( uiMaxAbsLevel > 0 )
{
uiLastScanPos = uiScanPos;
}
}
uiLastScanPos++;
//===== estimate context models =====
if ( uiNum4x4Blk > 1 )
{
Bool bFirstBlock = true;
UInt uiNumOne = 0;
for( UInt uiSubBlk = 0; uiSubBlk < uiNum4x4Blk; uiSubBlk++ )
{
UInt uiCtxSet = 0;
UInt uiSubNumSig = 0;
UInt uiSubPosX = 0;
UInt uiSubPosY = 0;
uiGoRiceParam = 0;
uiSubPosX = g_auiFrameScanX[ uiLog2BlkSize - 3 ][ uiSubBlk ] << 2;
uiSubPosY = g_auiFrameScanY[ uiLog2BlkSize - 3 ][ uiSubBlk ] << 2;
Int offset = uiSubPosX + (uiSubPosY << uiLog2BlkSize);
Int* piCurr = &piCoeff[ offset ];
for( UInt uiY = 0; uiY < 4; uiY++ )
{
for( UInt uiX = 0; uiX < 4; uiX++ )
{
if( piCurr[ uiY * uiWidth + uiX ] )
{
uiSubNumSig++;
}
}
}
if( uiSubNumSig > 0 )
{
Int c1 = 1;
Int c2 = 0;
if( bFirstBlock )
{
bFirstBlock = false;
uiCtxSet = 5;
}
else
{
uiCtxSet = ( uiNumOne >> 2 ) + 1;
uiNumOne = 0;
}
for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ )
{
UInt uiBlkPos = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ];
UInt uiPosY = uiBlkPos >> 2;
UInt uiPosX = uiBlkPos & 3;
UInt uiIndex = (uiPosY << uiLog2BlkSize) + uiPosX + offset;
if( piCoeff[ uiIndex ] )
{
puiOneCtx[ uiIndex ] = 5 * uiCtxSet + c1;
puiAbsCtx[ uiIndex ] = 5 * uiCtxSet + c2;
puiAbsGoRice[ uiIndex ] = uiGoRiceParam;
UInt uiAbs = abs( piCoeff[ uiIndex ] );
if( uiAbs > 1 )
{
c1 = 0;
c2 += (c2 < 4);
uiNumOne++;
if( uiAbs > 2 )
{
uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiAbs - 3, 15 ) ];
}
}
else if( c1 & 3 )
{
c1++; // Increment c1 if equal to 1, 2 or 3
}
}
}
}
}
}
else
{
Int c1 = 1;
Int c2 = 0;
for ( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ )
{
UInt uiIndex = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ];
if( piCoeff[ uiIndex ] )
{
puiOneCtx[ uiIndex ] = c1;
puiAbsCtx[ uiIndex ] = c2;
puiAbsGoRice[ uiIndex ] = uiGoRiceParam;
UInt uiAbs = abs( piCoeff[ uiIndex ] );
if( uiAbs > 1 )
{
c1 = 0;
c2 += (c2 < 4);
if( uiAbs > 2 )
{
uiGoRiceParam = g_aauiGoRiceUpdate[ uiGoRiceParam ][ min<UInt>( uiAbs - 3, 15 ) ];
}
}
else if( c1 & 3 )
{
c1++; // Increment c1 if equal to 1, 2 or 3
}
}
}
}
Int ui16CtxCbf = 0;
UInt uiBestLastIdxP1 = 0;
Double d64BestCost = 0;
Double d64BaseCost = 0;
Double d64CodedCost = 0;
Double d64UncodedCost = 0;
if( !pcCU->isIntra( uiAbsPartIdx ) && eTType == TEXT_LUMA && pcCU->getTransformIdx( uiAbsPartIdx ) == 0 )
{
ui16CtxCbf = pcCU->getCtxQtRootCbf( uiAbsPartIdx );
d64BestCost = d64BlockUncodedCost + xGetICost( m_pcEstBitsSbac->blockRootCbpBits[ ui16CtxCbf ][ 0 ] );
d64BaseCost = d64BestCost - xGetICost( m_pcEstBitsSbac->blockRootCbpBits[ ui16CtxCbf ][ 0 ] ) + xGetICost( m_pcEstBitsSbac->blockRootCbpBits[ ui16CtxCbf ][ 1 ] );
}
else
{
ui16CtxCbf = pcCU->getCtxQtCbf( uiAbsPartIdx, eTType, pcCU->getTransformIdx( uiAbsPartIdx ) );
ui16CtxCbf = ( eTType ? eTType - 1 : eTType ) * NUM_QT_CBF_CTX + ui16CtxCbf;
d64BestCost = d64BlockUncodedCost + xGetICost( m_pcEstBitsSbac->blockCbpBits[ ui16CtxCbf ][ 0 ] );
d64BaseCost = d64BestCost - xGetICost( m_pcEstBitsSbac->blockCbpBits[ ui16CtxCbf ][ 0 ] ) + xGetICost( m_pcEstBitsSbac->blockCbpBits[ ui16CtxCbf ][ 1 ] );
}
Double d64CostLast = 0;
TCoeff iLastCoeffLevel = 0;
UInt uiBestNonZeroLevel = 0;
UInt uiBestLastBlkPos = 0;
for( UInt uiScanPos = 0; uiScanPos < uiLastScanPos; uiScanPos++ )
{
#if QC_MDCS
UInt uiBlkPos = g_auiSigLastScan[uiScanIdx][uiLog2BlkSize-1][uiScanPos];
#else
UInt uiBlkPos = g_auiFrameScanXY[ uiLog2BlkSize-1 ][ uiScanPos ];
#endif
UInt uiPosY = uiBlkPos >> uiLog2BlkSize;
UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlkSize );
dTemp = dErrScale;
UShort uiCtxSig = getSigCtxInc( piDstCoeff, uiPosX, uiPosY, uiLog2BlkSize, uiWidth );
UInt uiMaxAbsLevel = abs( piCoeff[ uiBlkPos ] );
UInt uiLevel = xGetCodedLevel( d64UncodedCost, d64CodedCost, d64CostLast, uiBestNonZeroLevel, plLevelDouble[ uiBlkPos ], uiMaxAbsLevel, uiCtxSig, puiOneCtx[ uiBlkPos ], puiAbsCtx[ uiBlkPos ], puiAbsGoRice[ uiBlkPos ], iQBits, dTemp );
piDstCoeff[ uiBlkPos ] = plSrcCoeff[ uiBlkPos ] < 0 ? -Int( uiLevel ) : uiLevel;
d64BaseCost -= d64UncodedCost;
if( uiBestNonZeroLevel != 0 )
{
d64CostLast += d64BaseCost;
#if QC_MDCS
#if MODIFIED_LAST_CODING
d64CostLast += uiScanIdx == SCAN_VER ? xGetRateLast( uiPosY, uiPosX, uiWidth ) : xGetRateLast( uiPosX, uiPosY, uiWidth );
#else
d64CostLast += uiScanIdx == SCAN_VER ? xGetRateLast( uiPosY, uiPosX ) : xGetRateLast( uiPosX, uiPosY );
#endif
#else
d64CostLast += xGetRateLast( uiPosX, uiPosY );
#endif
if( d64CostLast < d64BestCost )
{
d64BestCost = d64CostLast;
uiBestLastIdxP1 = uiScanPos + 1;
uiBestLastBlkPos = uiBlkPos;
iLastCoeffLevel = plSrcCoeff[ uiBlkPos ] < 0 ? -Int( uiBestNonZeroLevel ) : uiBestNonZeroLevel;
}
}
d64BaseCost += d64CodedCost;
}
if( uiBestLastBlkPos > 0)
{
piDstCoeff[ uiBestLastBlkPos ] = iLastCoeffLevel;
}
//===== clean uncoded coefficients =====
{
for( UInt uiScanPos = 0; uiScanPos < uiMaxNumCoeff; uiScanPos++ )
{
#if QC_MDCS
UInt uiBlkPos = g_auiSigLastScan[uiScanIdx][uiLog2BlkSize-1][uiScanPos];
#else
UInt uiBlkPos = g_auiFrameScanXY[ uiLog2BlkSize-1 ][ uiScanPos ];
#endif //QC_MDCS
if( uiScanPos < uiBestLastIdxP1 )
{
uiAbsSum += abs( piDstCoeff[ uiBlkPos ] );
}
else
{
piDstCoeff[ uiBlkPos ] = 0;
}
}
}
#endif
#if NSQT
static TCoeff dstCoeff[ 256 ];
if( bNonSqureFlag )
{
memcpy( plSrcCoeff, &orgSrcCoeff[ 0 ], uiMaxNumCoeff * sizeof( Int ) );
memcpy( &dstCoeff[ 0 ], piDstCoeff, uiMaxNumCoeff * sizeof( TCoeff ) );
for( UInt uiScanPos = 0; uiScanPos < uiMaxNumCoeff; uiScanPos++ )
{
UInt uiBlkPos = g_auiNonSquareSigLastScan[ uiNonSqureScanTableIdx ][ uiScanPos ];
piDstCoeff[ uiBlkPos ] = dstCoeff[ g_auiFrameScanXY[ (int)g_aucConvertToBit[ uiWidth ] + 1 ][ uiScanPos ] ];
}
}
#endif
}
/** Context derivation process of coeff_abs_significant_flag
* \param pcCoeff pointer to prior coded transform coefficients
* \param uiPosX column of current scan position
* \param uiPosY row of current scan position
* \param uiLog2BlkSize log2 value of block size
* \param uiStride stride of the block
* \returns ctxInc for current scan position
*/
UInt TComTrQuant::getSigCtxInc ( TCoeff* pcCoeff,
const UInt uiPosX,
const UInt uiPosY,
const UInt uiLog2BlkSize,
const UInt uiStride )
{
if ( uiLog2BlkSize == 2)
{
return 4 * uiPosY + uiPosX;
}
if ( uiLog2BlkSize == 3 )
{
return 15 + 4 * (uiPosY >> 1) + (uiPosX >> 1);
}
#if UNIFIED_SCAN
if( uiPosX + uiPosY < 2 )
{
return 31 + 2 * uiPosY + uiPosX;
}
const TCoeff *pData = pcCoeff + uiPosX + (uiPosY << uiLog2BlkSize);
Int iStride = uiStride;
if( uiPosX + uiPosY < 5 )
{
UInt cnt = (pData[1] != 0) + (pData[2] != 0) + (pData[iStride] != 0) + (pData[2*iStride] != 0) + (pData[iStride+1] != 0);
return 31 + 3 + min<UInt>( 4, cnt );
}
UInt uiWidthM1 = uiStride - 1;
UInt cnt = 0;
if( uiPosX < uiWidthM1 )
{
cnt += pData[1] != 0;
if( uiPosY < uiWidthM1 )
{
cnt += pData[iStride+1] != 0;
}
if( uiPosX < uiWidthM1 - 1 )
{
cnt += pData[2] != 0;
}
}
if ( uiPosY < uiWidthM1 )
{
cnt += pData[iStride] != 0;
if ( uiPosY < uiWidthM1 - 1 && cnt < 4 )
{
cnt += pData[2*iStride] != 0;
}
}
return 31 + 8 + cnt;
#else
if( uiPosX <= 1 && uiPosY <= 1 )
{
return 31 + 2 * uiPosY + uiPosX + ((uiLog2BlkSize > 4) ? 15 : 0);
}
const Int *pData = pcCoeff + uiPosX + (uiPosY << uiLog2BlkSize);
Int iStride = uiStride;
if( uiPosY == 0 )
{
return 31 + 4 + (pData[-1] != 0) + (pData[-2] != 0);
}
if( uiPosX == 0 )
{
return 31 + 7 + (pData[-iStride] != 0) + (pData[-2*iStride] != 0);
}
UInt cnt = (pData[-1] != 0) + (pData[-iStride] != 0) + (pData[-iStride-1] != 0);
if( uiPosX > 1 )
{
cnt += pData[-2] != 0;
}
if ( uiPosY > 1 && cnt < 4)
{
cnt += pData[-2*iStride] != 0;
}
return 31 + 10 + cnt;
#endif
}
#if UNIFIED_SCAN
/** Get the best level in RD sense
* \param rd64CodedCost reference to coded cost
* \param rd64CodedCost0 reference to cost when coefficient is 0
* \param rd64CodedCostSig reference to cost of significant coefficient
* \param lLevelDouble reference to unscaled quantized level
* \param uiMaxAbsLevel scaled quantized level
* \param ui16CtxNumSig current ctxInc for coeff_abs_significant_flag
* \param ui16CtxNumOne current ctxInc for coeff_abs_level_greater1 (1st bin of coeff_abs_level_minus1 in AVC)
* \param ui16CtxNumAbs current ctxInc for coeff_abs_level_greater2 (remaining bins of coeff_abs_level_minus1 in AVC)
* \param ui16AbsGoRice current Rice parameter for coeff_abs_level_minus3
* \param iQBits quantization step size
* \param dTemp correction factor
* \param bLast indicates if the coefficient is the last significant
* \returns best quantized transform level for given scan position
* This method calculates the best quantized transform level for a given scan position.
*/
__inline UInt TComTrQuant::xGetCodedLevel ( Double& rd64CodedCost,
Double& rd64CodedCost0,
Double& rd64CodedCostSig,
Int lLevelDouble,
UInt uiMaxAbsLevel,
UShort ui16CtxNumSig,
UShort ui16CtxNumOne,
UShort ui16CtxNumAbs,
UShort ui16AbsGoRice,
Int iQBits,
Double dTemp,
Bool bLast ) const
{
Double dCurrCostSig = 0;
UInt uiBestAbsLevel = 0;
if( !bLast && uiMaxAbsLevel < 3 )
{
rd64CodedCostSig = xGetRateSigCoef( 0, ui16CtxNumSig );
rd64CodedCost = rd64CodedCost0 + rd64CodedCostSig;
if( uiMaxAbsLevel == 0 )
{
return uiBestAbsLevel;
}
}
else
{
rd64CodedCost = MAX_DOUBLE;
}
if( !bLast )
{
dCurrCostSig = xGetRateSigCoef( 1, ui16CtxNumSig );
}
UInt uiMinAbsLevel = ( uiMaxAbsLevel > 1 ? uiMaxAbsLevel - 1 : 1 );
for( Int uiAbsLevel = uiMaxAbsLevel; uiAbsLevel >= uiMinAbsLevel ; uiAbsLevel-- )
{
Double dErr = Double( lLevelDouble - ( uiAbsLevel << iQBits ) );
Double dCurrCost = dErr * dErr * dTemp + xGetICRateCost( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice );
dCurrCost += dCurrCostSig;
if( dCurrCost < rd64CodedCost )
{
uiBestAbsLevel = uiAbsLevel;
rd64CodedCost = dCurrCost;
rd64CodedCostSig = dCurrCostSig;
}
}
return uiBestAbsLevel;
}
#else
/** Get the best level in RD sense
* \param rd64UncodedCost reference to uncoded cost
* \param rd64CodedCost reference to current coded cost
* \param rd64CodedLastCost reference to coded cost of coefficient without the significance cost
* \param uiBestNonZeroLevel !!! not available yet
* \param lLevelDouble reference to unscaled quantized level
* \param uiMaxAbsLevel scaled quantized level
* \param ui16CtxNumSig current ctxInc for coeff_abs_significant_flag
* \param ui16CtxNumOne current ctxInc for coeff_abs_level_greater1 (1st bin of coeff_abs_level_minus1 in AVC)
* \param ui16CtxNumAbs current ctxInc for coeff_abs_level_greater2 (remaining bins of coeff_abs_level_minus1 in AVC)
* \param ui16AbsGoRice current Rice parameter for coeff_abs_level_minus3
* \param iQBits quantization step size
* \param dTemp correction factor
* \param ui16CtxBase current global offset for coeff_abs_level_greater1 and coeff_abs_level_greater2
* \returns best quantized transform level for given scan position
* This method calculates the best quantized transform level for a given scan position.
*/
__inline UInt TComTrQuant::xGetCodedLevel ( Double& rd64UncodedCost,
Double& rd64CodedCost,
Double& rd64CodedLastCost,
UInt& ruiBestNonZeroLevel,
Int lLevelDouble,
UInt uiMaxAbsLevel,
UShort ui16CtxNumSig,
UShort ui16CtxNumOne,
UShort ui16CtxNumAbs,
UShort ui16AbsGoRice,
Int iQBits,
Double dTemp
) const
{
UInt uiBestAbsLevel = 0;
Double dErr1 = Double( lLevelDouble );
rd64UncodedCost = dErr1 * dErr1 * dTemp;
rd64CodedCost = rd64UncodedCost + xGetRateSigCoef( 0, ui16CtxNumSig );
ruiBestNonZeroLevel = 0;
if( uiMaxAbsLevel )
{
Int uiAbsLevel = uiMaxAbsLevel;
ruiBestNonZeroLevel = uiMaxAbsLevel;
Double dErr = Double( lLevelDouble - ( uiAbsLevel << iQBits ) );
rd64CodedLastCost = dErr * dErr * dTemp + xGetICRateCost( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice );
}
else
{
return uiBestAbsLevel;
}
Int uiAbsLevel = ( uiMaxAbsLevel > 1 ? uiMaxAbsLevel - 1 : 1 );
if( uiAbsLevel != uiMaxAbsLevel )
{
Double dErr = Double( lLevelDouble - ( uiAbsLevel << iQBits ) );
Double dCurrCost = dErr * dErr * dTemp + xGetICRateCost( uiAbsLevel, ui16CtxNumOne, ui16CtxNumAbs, ui16AbsGoRice );
if( dCurrCost < rd64CodedLastCost )
{
ruiBestNonZeroLevel = uiAbsLevel;
rd64CodedLastCost = dCurrCost;
}
}
Double dCurrCost = rd64CodedLastCost + xGetRateSigCoef( 1, ui16CtxNumSig );
if( dCurrCost < rd64CodedCost )
{
uiBestAbsLevel = ruiBestNonZeroLevel;
rd64CodedCost = dCurrCost;
}
return uiBestAbsLevel;
}
#endif
/** Calculates the cost for specific absolute transform level
* \param uiAbsLevel scaled quantized level
* \param ui16CtxNumOne current ctxInc for coeff_abs_level_greater1 (1st bin of coeff_abs_level_minus1 in AVC)
* \param ui16CtxNumAbs current ctxInc for coeff_abs_level_greater2 (remaining bins of coeff_abs_level_minus1 in AVC)
* \param ui16AbsGoRice Rice parameter for coeff_abs_level_minus3
* \returns cost of given absolute transform level
*/
__inline Double TComTrQuant::xGetICRateCost ( UInt uiAbsLevel,
UShort ui16CtxNumOne,
UShort ui16CtxNumAbs,
UShort ui16AbsGoRice
) const
{
Double iRate = xGetIEPRate();
if( uiAbsLevel == 1 )
{
iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 0 ];
}
else if( uiAbsLevel == 2 )
{
iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 1 ];
iRate += m_pcEstBitsSbac->m_levelAbsBits[ ui16CtxNumAbs ][ 0 ];
}
else
{
UInt uiSymbol = uiAbsLevel - 3;
UInt uiMaxVlc = g_auiGoRiceRange[ ui16AbsGoRice ];
Bool bExpGolomb = ( uiSymbol > uiMaxVlc );
if( bExpGolomb )
{
uiAbsLevel = uiSymbol - uiMaxVlc;
int iEGS = 1; for( UInt uiMax = 2; uiAbsLevel >= uiMax; uiMax <<= 1, iEGS += 2 );
iRate += iEGS << 15;
uiSymbol = min<UInt>( uiSymbol, ( uiMaxVlc + 1 ) );
}
UShort ui16PrefLen = UShort( uiSymbol >> ui16AbsGoRice ) + 1;
UShort ui16NumBins = min<UInt>( ui16PrefLen, g_auiGoRicePrefixLen[ ui16AbsGoRice ] ) + ui16AbsGoRice;
iRate += ui16NumBins << 15;
iRate += m_pcEstBitsSbac->m_greaterOneBits[ ui16CtxNumOne ][ 1 ];
iRate += m_pcEstBitsSbac->m_levelAbsBits[ ui16CtxNumAbs ][ 1 ];
}
return xGetICost( iRate );
}
/** Calculates the cost of signaling the last significant coefficient in the block
* \param uiPosX X coordinate of the last significant coefficient
* \param uiPosY Y coordinate of the last significant coefficient
* \returns cost of last significant coefficient
*/
#if MODIFIED_LAST_CODING
/*
* \param uiWidth width of the transform unit (TU)
*/
__inline Double TComTrQuant::xGetRateLast ( const UInt uiPosX,
const UInt uiPosY,
const UInt uiBlkWdth ) const
{
UInt uiCtxX = uiPosX;
UInt uiCtxY = uiPosY;
const UInt uiMinWidth = min<UInt>( 4, uiBlkWdth );
const UInt uiHalfWidth = uiBlkWdth >> 1;
const UInt uiLog2BlkSize = g_aucConvertToBit[ uiHalfWidth ] + 2;
Double uiCost = 0;
if( uiHalfWidth >= uiMinWidth )
{
if( uiPosX >= uiHalfWidth )
{
uiCost += xGetIEPRate() * uiLog2BlkSize;
uiCtxX = uiHalfWidth;
}
if( uiPosY >= uiHalfWidth )
{
uiCost += xGetIEPRate() * uiLog2BlkSize;
uiCtxY = uiHalfWidth;
}
}
uiCost += m_pcEstBitsSbac->lastXBits[ uiCtxX ] + m_pcEstBitsSbac->lastYBits[ uiCtxY ];
return xGetICost( uiCost );
}
#else
__inline Double TComTrQuant::xGetRateLast ( UInt uiPosX,
UInt uiPosY ) const
{
return xGetICost( m_pcEstBitsSbac->lastXBits[ uiPosX ] + m_pcEstBitsSbac->lastYBits[ uiPosY ] );
}
#endif
/** Calculates the cost for specific absolute transform level
* \param uiAbsLevel scaled quantized level
* \param ui16CtxNumOne current ctxInc for coeff_abs_level_greater1 (1st bin of coeff_abs_level_minus1 in AVC)
* \param ui16CtxNumAbs current ctxInc for coeff_abs_level_greater2 (remaining bins of coeff_abs_level_minus1 in AVC)
* \param ui16CtxBase current global offset for coeff_abs_level_greater1 and coeff_abs_level_greater2
* \returns cost of given absolute transform level
*/
__inline Double TComTrQuant::xGetRateSigCoef ( UShort uiSignificance,
UShort ui16CtxNumSig ) const
{
return xGetICost( m_pcEstBitsSbac->significantBits[ ui16CtxNumSig ][ uiSignificance ] );
}
/** Get the cost for a specific rate
* \param dRate rate of a bit
* \returns cost at the specific rate
*/
__inline Double TComTrQuant::xGetICost ( Double dRate ) const
{
return m_dLambda * dRate;
}
/** Get the cost of an equal probable bit
* \returns cost of equal probable bit
*/
__inline Double TComTrQuant::xGetIEPRate ( ) const
{
return 32768;
}
//! \}
| 31.568068 | 388 | 0.554618 | [
"vector",
"model",
"transform"
] |
7bc17d7b9e4fc086f410932944c4439151125288 | 572 | cpp | C++ | CODECHEF/TILED.cpp | aqfaridi/Competitve-Programming-Codes | d055de2f42d3d6bc36e03e67804a1dd6b212241f | [
"MIT"
] | null | null | null | CODECHEF/TILED.cpp | aqfaridi/Competitve-Programming-Codes | d055de2f42d3d6bc36e03e67804a1dd6b212241f | [
"MIT"
] | null | null | null | CODECHEF/TILED.cpp | aqfaridi/Competitve-Programming-Codes | d055de2f42d3d6bc36e03e67804a1dd6b212241f | [
"MIT"
] | null | null | null | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define MAX 1000010
#define MOD 1000000007
int fib[MAX];
void fibo()
{
fib[1] = 1;
fib[2] = 2;
for(int i=3;i<MAX;i++)
fib[i] = (fib[i-1]+fib[i-2])%MOD;
}
int main()
{
fibo();
ios::sync_with_stdio(false);
int t,n;
cin>>t;
while(t--)
{
cin>>n;
cout<<fib[n]<<endl;
}
return 0;
}
| 15.459459 | 41 | 0.575175 | [
"vector"
] |
dcf40c9961f335151bee51dcf202c27e3d937a96 | 6,054 | cpp | C++ | src/tests/TestJsonDpaApiRaw/TestJsonDpaApiRaw.cpp | iqrfsdk/iqrf-gateway-daemon | 8875a9a0bf67003fc7115a59af12ab12d591b487 | [
"Apache-2.0"
] | 1 | 2021-04-28T07:34:14.000Z | 2021-04-28T07:34:14.000Z | src/tests/TestJsonDpaApiRaw/TestJsonDpaApiRaw.cpp | iqrf/iqrf-gateway-daemon | adf8585749afefb01f274d5b70959d500d35bd6c | [
"Apache-2.0"
] | 1 | 2019-10-31T13:29:55.000Z | 2019-10-31T13:29:55.000Z | src/tests/TestJsonDpaApiRaw/TestJsonDpaApiRaw.cpp | iqrf/iqrf-gateway-daemon | adf8585749afefb01f274d5b70959d500d35bd6c | [
"Apache-2.0"
] | null | null | null | /**
* Copyright 2015-2021 IQRF Tech s.r.o.
* Copyright 2019-2021 MICRORISC s.r.o.
*
* 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 IIqrfChannelService_EXPORTS
#include "TestJsonDpaApiRaw.h"
#include "Trace.h"
#include "GTestStaticRunner.h"
#include "HexStringCoversion.h"
#include "gtest/gtest.h"
#include "rapidjson/pointer.h"
#include "rapidjson/istreamwrapper.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/prettywriter.h"
#include "iqrf__TestJsonDpaApiRaw.hxx"
TRC_INIT_MNAME(iqrf::TestJsonDpaApiRaw)
namespace iqrf {
class Imp {
private:
Imp()
{
}
public:
shape::ILaunchService* m_iLaunchService = nullptr;
iqrf::ITestSimulationIqrfChannel* m_iTestSimulationIqrfChannel = nullptr;
iqrf::ITestSimulationMessaging* m_iTestSimulationMessaging = nullptr;
shape::GTestStaticRunner m_gtest;
static Imp& get()
{
static Imp imp;
return imp;
}
~Imp()
{
}
void activate(const shape::Properties *props)
{
(void)props; //silence -Wunused-parameter
TRC_FUNCTION_ENTER("");
TRC_INFORMATION(std::endl <<
"******************************" << std::endl <<
"TestJsonDpaApiRaw instance activate" << std::endl <<
"******************************"
);
m_gtest.runAllTests(m_iLaunchService);
TRC_FUNCTION_LEAVE("")
}
void deactivate()
{
TRC_FUNCTION_ENTER("");
TRC_INFORMATION(std::endl <<
"******************************" << std::endl <<
"TestJsonDpaApiRaw instance deactivate" << std::endl <<
"******************************"
);
TRC_FUNCTION_LEAVE("")
}
void attachInterface(iqrf::ITestSimulationIqrfChannel* iface)
{
m_iTestSimulationIqrfChannel = iface;
}
void detachInterface(iqrf::ITestSimulationIqrfChannel* iface)
{
if (m_iTestSimulationIqrfChannel == iface) {
m_iTestSimulationIqrfChannel = nullptr;
}
}
void attachInterface(iqrf::ITestSimulationMessaging* iface)
{
m_iTestSimulationMessaging = iface;
}
void detachInterface(iqrf::ITestSimulationMessaging* iface)
{
if (m_iTestSimulationMessaging == iface) {
m_iTestSimulationMessaging = nullptr;
}
}
void attachInterface(shape::ILaunchService* iface)
{
m_iLaunchService = iface;
}
void detachInterface(shape::ILaunchService* iface)
{
if (m_iLaunchService == iface) {
m_iLaunchService = nullptr;
}
}
};
////////////////////////////////////
TestJsonDpaApiRaw::TestJsonDpaApiRaw()
{
}
TestJsonDpaApiRaw::~TestJsonDpaApiRaw()
{
}
void TestJsonDpaApiRaw::activate(const shape::Properties *props)
{
Imp::get().activate(props);
}
void TestJsonDpaApiRaw::deactivate()
{
Imp::get().deactivate();
}
void TestJsonDpaApiRaw::modify(const shape::Properties *props)
{
(void)props; //silence -Wunused-parameter
}
void TestJsonDpaApiRaw::attachInterface(iqrf::ITestSimulationIqrfChannel* iface)
{
Imp::get().attachInterface(iface);
}
void TestJsonDpaApiRaw::detachInterface(iqrf::ITestSimulationIqrfChannel* iface)
{
Imp::get().detachInterface(iface);
}
void TestJsonDpaApiRaw::attachInterface(iqrf::ITestSimulationMessaging* iface)
{
Imp::get().attachInterface(iface);
}
void TestJsonDpaApiRaw::detachInterface(iqrf::ITestSimulationMessaging* iface)
{
Imp::get().detachInterface(iface);
}
void TestJsonDpaApiRaw::attachInterface(shape::ILaunchService* iface)
{
Imp::get().attachInterface(iface);
}
void TestJsonDpaApiRaw::detachInterface(shape::ILaunchService* iface)
{
Imp::get().detachInterface(iface);
}
void TestJsonDpaApiRaw::attachInterface(shape::ITraceService* iface)
{
shape::Tracer::get().addTracerService(iface);
}
void TestJsonDpaApiRaw::detachInterface(shape::ITraceService* iface)
{
shape::Tracer::get().removeTracerService(iface);
}
////////////////////////////////////////////////////////
class JsonDpaApiRawTesting : public ::testing::Test
{
protected:
void SetUp(void) override
{
ASSERT_NE(nullptr, &Imp::get().m_iLaunchService);
};
void TearDown(void) override
{
};
//for debug only
static std::string JsonToStr(const rapidjson::Value* val)
{
rapidjson::Document doc;
doc.CopyFrom(*val, doc.GetAllocator());
rapidjson::StringBuffer buffer;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
doc.Accept(writer);
return buffer.GetString();
}
};
/////////// Tests
const unsigned MILLIS_WAIT = 1000;
TEST_F(JsonDpaApiRawTesting, iqrfEmbedCoordinator_AddrInfo)
{
//JSON message input (jmi) as received from a messaging
std::string jmoexp =
"{\n \"mType\": \"iqrfRaw\",\n \"data\": {\n \"msgId\": \"async\",\n \"rsp\": {\n \"rData\": \"00.00.ff.3f.00.00.00.00.28.02.00.fd.26.00.00.00.00.00.00.01\"\n },\n \"status\": 0,\n \"insId\": \"iqrfgd2-default\"\n }\n}";
//simulate async DPA response
Imp::get().m_iTestSimulationIqrfChannel->pushOutgoingMessage("00.00.ff.3f.00.00.00.00.28.02.00.fd.26.00.00.00.00.00.00.01", 10);
//expected JSON message output (jmo) as result of processing to be sent out by a messaging
std::string jmo = Imp::get().m_iTestSimulationMessaging->popOutgoingMessage(1000);
EXPECT_EQ(jmoexp, jmo);
TRC_DEBUG(jmo);
}
}
| 25.652542 | 281 | 0.640403 | [
"shape"
] |
dcf44b77bbec2f084ba6dfb729b1578564fb3db9 | 18,260 | cpp | C++ | Engine/Src/SFEngineDLL/Java/JniUtil.cpp | blue3k/StormForge | 1557e699a673ae9adcc8f987868139f601ec0887 | [
"Apache-2.0"
] | 1 | 2020-06-20T07:35:25.000Z | 2020-06-20T07:35:25.000Z | Engine/Src/SFEngineDLL/Java/JniUtil.cpp | blue3k/StormForge | 1557e699a673ae9adcc8f987868139f601ec0887 | [
"Apache-2.0"
] | null | null | null | Engine/Src/SFEngineDLL/Java/JniUtil.cpp | blue3k/StormForge | 1557e699a673ae9adcc8f987868139f601ec0887 | [
"Apache-2.0"
] | null | null | null | ////////////////////////////////////////////////////////////////////////////////
//
// CopyRight (c) 2016 StormForge
//
// Author : KyungKun Ko
//
// Description : Basic android application
//
//
////////////////////////////////////////////////////////////////////////////////
#include "SFEngineDLLPCH.h"
#if SF_PLATFORM == SF_PLATFORM_ANDROID
#include "SFAssert.h"
#include "Util/SFUtility.h"
#include "JniUtil.h"
namespace SF
{
/////////////////////////////////////////////////////////////////////////////
//
// Variable map builder for java map object
//
void VariableMapBuilderJObject::SetVariable(const char* varName, Result value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, (uint32_t)value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, bool value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
//void VariableMapBuilderJObject::SetVariable(const char* varName, int value)
//{
// jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
// m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
//}
//void VariableMapBuilderJObject::SetVariable(const char* varName, uint value)
//{
// jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
// m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
//}
void VariableMapBuilderJObject::SetVariable(const char* varName, int8_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, uint8_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, int16_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, uint16_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, int32_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, uint32_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, int64_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, uint64_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, uint128_t value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, float value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, double value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, value);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const char* value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
jstring jstrValue = m_Env->NewStringUTF(value);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jstrValue);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const StringCrc64& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
jstring jstrValue = m_Env->NewStringUTF((const char*)value);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jstrValue);
}
//void VariableMapBuilderJObject::SetVariable(const char* varName, const RouteContext& value)
//{
// static jclass jcls = m_Env->FindClass("java/com/sf/SFRouteContext");
// static jmethodID constructorID = m_Env->GetMethodID(jcls, "<init>", "(J;J)V");
// jobject jobj = m_Env->NewObject(jcls, constructorID, (uint64_t)value.Components.From, (uint64_t)value.Components.To);
// jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
// m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jobj);
//}
//void VariableMapBuilderJObject::SetVariable(const char* varName, const NetAddress& value)
//{
// static jclass jcls = m_Env->FindClass("java/com/sf/SFRouteContext");
// static jmethodID constructorID = m_Env->GetMethodID(jcls, "<init>", "(I;Ljava/lang/String;I)V");
// jstring jstrAddress = m_Env->NewStringUTF(value.Address);
// jobject jobj = m_Env->NewObject(jcls, constructorID, (int)value.SocketFamily, jstrAddress, (int)value.Port);
// jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
// m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jobj);
//}
//void VariableMapBuilderJObject::SetVariable(const char* varName, const PlayerInformation& value)
//{
// static jclass jcls = m_Env->FindClass("java/com/sf/SFPlayerInformation");
// static jmethodID constructorID = m_Env->GetMethodID(jcls, "<init>", "(J;J;Ljava/lang/String;J;I;I)V");
// jstring jstrName = m_Env->NewStringUTF(value.NickName);
// jobject jobj = m_Env->NewObject(jcls, constructorID, (jlong)value.PlayerID, (jlong)value.FBUID, jstrName, (jlong)value.LastActiveTime, (int)value.Level, (int)value.IsPlayingGame);
// jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
// m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jobj);
//}
//void VariableMapBuilderJObject::SetVariable(const char* varName, const RankingPlayerInformation& value)
//{
// static jclass jcls = m_Env->FindClass("java/com/sf/SFRankingPlayerInformation");
// static jmethodID constructorID = m_Env->GetMethodID(jcls, "<init>", "(J;J;Ljava/lang/String;J;I;I;I;I)V");
// jstring jstrName = m_Env->NewStringUTF(value.NickName);
// jobject jobj = m_Env->NewObject(jcls, constructorID, (jlong)value.PlayerID, (jlong)value.FBUID, jstrName, (jlong)value.LastActiveTime, (int)value.Level, (int)value.IsPlayingGame, (int)value.WeeklyWin, (int)value.WeeklyLose);
// jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
// m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jobj);
//}
//void VariableMapBuilderJObject::SetVariable(const char* varName, const FriendInformation& value)
//{
// jobject jobj = ToJavaObject(value);
// jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
// m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jobj);
//}
//void VariableMapBuilderJObject::SetVariable(const char* varName, const TotalRankingPlayerInformation& value)
//{
// jobject jobj = ToJavaObject(value);
// jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
// m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jobj);
//}
void VariableMapBuilderJObject::SetVariable(const char* varName, const char* typeName, const void* value)
{
jobject jobj = ToJavaObject(value);
jstring jstrName = m_Env->NewStringUTF((const char*)varName);
jstring jstrTypeName = m_Env->NewStringUTF((const char*)typeName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrName, jstrTypeName, jobj);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const RelayPlayerInfo& value)
{
jobject jobj = ToJavaObject(value);
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jobj);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<const char*>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
jstring* pValues = new jstring[value.size()];
for (int iValue = 0; iValue < value.size(); iValue++)
pValues[iValue] = m_Env->NewStringUTF(value[iValue]);
auto valueArray = m_Env->NewStringArray(value.size());
m_Env->SetStringArrayRegion(valueArray, 0, value.size(), pValues);
IHeap::Delete(pValues);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<bool>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
jboolean *pJBooleanValues = new jboolean[value.size()];
for (int iValue = 0; iValue < value.size(); iValue++)
pJBooleanValues[iValue] = value[iValue];
auto valueArray = m_Env->NewBooleanArray(value.size());
m_Env->SetBooleanArrayRegion(valueArray, 0, value.size(), pJBooleanValues);
IHeap::Delete(pJBooleanValues);
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<int8_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewByteArray(value.size());
m_Env->SetByteArrayRegion(valueArray, 0, value.size(), value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<uint8_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewByteArray(value.size());
m_Env->SetByteArrayRegion(valueArray, 0, value.size(), (int8_t*)value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<int16_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewShortArray(value.size());
m_Env->SetShortArrayRegion(valueArray, 0, value.size(), value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<uint16_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewShortArray(value.size());
m_Env->SetShortArrayRegion(valueArray, 0, value.size(), (int16_t*)value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<int32_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewIntArray(value.size());
m_Env->SetIntArrayRegion(valueArray, 0, value.size(), value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<uint32_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewIntArray(value.size());
m_Env->SetIntArrayRegion(valueArray, 0, value.size(), (int32_t*)value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<int64_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewLongArray(value.size());
m_Env->SetLongArrayRegion(valueArray, 0, value.size(), (jlong*)value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<uint64_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewLongArray(value.size());
m_Env->SetLongArrayRegion(valueArray, 0, value.size(), (jlong*)value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<float>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewFloatArray(value.size());
m_Env->SetFloatArrayRegion(valueArray, 0, value.size(), value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array< double>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto valueArray = m_Env->NewDoubleArray(value.size());
m_Env->SetDoubleArrayRegion(valueArray, 0, value.size(), value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<PlayerInformation>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto objectClass = m_Env->FindClass("java/lang/Object");
auto valueArray = m_Env->NewObjectArray(value.size(), objectClass, nullptr);
for (int iValue = 0; iValue < value.size(); iValue++)
m_Env->SetObjectArrayElement(valueArray, iValue, ToJavaObject(value[iValue]));
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<FriendInformation>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto objectClass = m_Env->FindClass("java/lang/Object");
auto valueArray = m_Env->NewObjectArray(value.size(), objectClass, nullptr);
for (int iValue = 0; iValue < value.size(); iValue++)
m_Env->SetObjectArrayElement(valueArray, iValue, ToJavaObject(value[iValue]));
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<TotalRankingPlayerInformation>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto objectClass = m_Env->FindClass("java/lang/Object");
auto valueArray = m_Env->NewObjectArray(value.size(), objectClass, nullptr);
for (int iValue = 0; iValue < value.size(); iValue++)
m_Env->SetObjectArrayElement(valueArray, iValue, ToJavaObject(value[iValue]));
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const Array<RelayPlayerInfo>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
auto objectClass = m_Env->FindClass("java/lang/Object");
auto valueArray = m_Env->NewObjectArray(value.size(), objectClass, nullptr);
for (int iValue = 0; iValue < value.size(); iValue++)
m_Env->SetObjectArrayElement(valueArray, iValue, ToJavaObject(value[iValue]));
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, valueArray);
}
void VariableMapBuilderJObject::SetVariable(const char* varName, const char* TypeName, const Array<uint8_t>& value)
{
jstring jstrBuf = m_Env->NewStringUTF((const char*)varName);
jstring jstrBufType = m_Env->NewStringUTF((const char*)TypeName);
auto valueArray = m_Env->NewByteArray(value.size());
m_Env->SetByteArrayRegion(valueArray, 0, value.size(), (int8_t*)value.data());
m_Env->CallVoidMethod(m_MapObject, m_SetMethodID, jstrBuf, jstrBufType, valueArray);
}
jobject VariableMapBuilderJObject::ToJavaObject(const PlayerInformation& value)
{
static jclass jcls = m_Env->FindClass("java/com/sf/SFPlayerInformation");
static jmethodID constructorID = m_Env->GetMethodID(jcls, "<init>", "(J;J;Ljava/lang/String;J;I;I)V");
jstring jstrName = m_Env->NewStringUTF(value.NickName);
jobject jobj = m_Env->NewObject(jcls, constructorID, (jlong)value.PlayerID, (jlong)value.FBUID, jstrName, (jlong)value.LastActiveTime, (int)value.Level, (int)value.IsPlayingGame);
return jobj;
}
jobject VariableMapBuilderJObject::ToJavaObject(const FriendInformation& value)
{
static jclass jcls = m_Env->FindClass("java/com/sf/SFFriendInformation");
static jmethodID constructorID = m_Env->GetMethodID(jcls, "<init>", "(J;J;Ljava/lang/String;J;I;I;I;I;J)V");
jstring jstrName = m_Env->NewStringUTF(value.NickName);
jobject jobj = m_Env->NewObject(jcls, constructorID, (jlong)value.PlayerID, (jlong)value.FBUID, jstrName, (jlong)value.LastActiveTime, (int)value.Level, (int)value.IsPlayingGame, (int)value.WeeklyWin, (int)value.WeeklyLose, (jlong)value.LastStaminaSent);
return jobj;
}
jobject VariableMapBuilderJObject::ToJavaObject(const TotalRankingPlayerInformation& value)
{
static jclass jcls = m_Env->FindClass("java/com/sf/SFTotalRankingPlayerInformation");
static jmethodID constructorID = m_Env->GetMethodID(jcls, "<init>", "(I;I;J;J;Ljava/lang/String;I;I;I)V");
jstring jstrName = m_Env->NewStringUTF(value.NickName);
jobject jobj = m_Env->NewObject(jcls, constructorID, (int)value.RankingID, (int)value.Ranking, (jlong)value.PlayerID, (jlong)value.FBUID, jstrName, (int)value.Level, (int)value.ScoreLow, (int)value.ScoreHigh);
return jobj;
}
jobject VariableMapBuilderJObject::ToJavaObject(const RelayPlayerInfo& value)
{
static jclass jcls = m_Env->FindClass("java/com/sf/SFRelayPlayerInfo");
static jmethodID constructorID = m_Env->GetMethodID(jcls, "<init>", "(J;J)V");
jobject jobj = m_Env->NewObject(jcls, constructorID, (jlong)value.EndpointID, (jlong)value.RelayPlayerID);
return jobj;
}
}
#endif
| 39.017094 | 257 | 0.722289 | [
"object"
] |
0d129692029dafb4dba52e070ef1073c90eb35eb | 5,785 | cpp | C++ | leadd/cpp_core/LEADD/ConvertToReconstruction.cpp | etijskens/LEADD | 93ac83dfcdeb7f069145e50bccc85bfc3b1d8a33 | [
"MIT"
] | null | null | null | leadd/cpp_core/LEADD/ConvertToReconstruction.cpp | etijskens/LEADD | 93ac83dfcdeb7f069145e50bccc85bfc3b1d8a33 | [
"MIT"
] | null | null | null | leadd/cpp_core/LEADD/ConvertToReconstruction.cpp | etijskens/LEADD | 93ac83dfcdeb7f069145e50bccc85bfc3b1d8a33 | [
"MIT"
] | null | null | null | #include <iostream>
#include <boost/serialization/list.hpp>
#include <boost/program_options.hpp>
#include <GraphMol/FileParsers/MolSupplier.h>
#include "Fragmentation.hpp"
#include "Reconstruction.hpp"
ReconstructedMol ConvertToReconstructedMol(const RDKit::ROMol& mol, bool fragment_rings, bool names_as_scores, boost::format& formatter) {
// Initialize an empty ReconstructedMol.
ReconstructedMol reconstruction;
// Set its molecule objects to the input RDKit::ROMol.
reconstruction.pseudomol = mol;
FlagAtoms(reconstruction.pseudomol);
reconstruction.sanitized_mol = reconstruction.pseudomol;
// If the ring systems ought to be fragmented:
if (fragment_rings) {
// Loop over the atoms in the molecule, convert them into Pseudofragments
// and add them to the ReconstructedMol as MolBricks.
for (const RDKit::Atom* atom : reconstruction.pseudomol.atoms()) {
Pseudofragment pseudofragment = AtomToPseudofragment(reconstruction.pseudomol, atom, formatter);
reconstruction.AddLabelledPseudofragment(pseudofragment);
};
// If ring systems should be treated as separate Pseudofragments.
} else {
// Separate the molecule into acyclic and cyclic fragments.
std::vector<RDKit::ROMOL_SPTR> acyclic_fragments, ring_fragments;
std::tie(acyclic_fragments, ring_fragments) = SplitAtRings(reconstruction.pseudomol);
// Convert the cyclic fragments into Pseudofragments and add them to the
// ReconstructedMol as MolBricks.
for (RDKit::ROMOL_SPTR ring_fragment : ring_fragments) {
Pseudofragment pseudofragment = DummyMolToPseudofragment(*ring_fragment, formatter);
reconstruction.AddLabelledPseudofragment(pseudofragment);
};
// Loop over the acyclic atoms in the molecule, convert them into Pseudofragments
// and add them to the ReconstructedMol as MolBricks.
for (const RDKit::Atom* atom : reconstruction.pseudomol.atoms()) {
if (!atom->getProp<bool>("WasInRing")) {
Pseudofragment pseudofragment = AtomToPseudofragment(reconstruction.pseudomol, atom, formatter);
reconstruction.AddLabelledPseudofragment(pseudofragment);
};
};
};
// If required, use the molecule's original name as its score.
if (names_as_scores) {
float score = std::stof(mol.getProp<std::string>("_Name"));
reconstruction.SetScore(score);
};
return reconstruction;
};
int main(int argc, const char* argv[]) {
// Set up a command line argument parser and parse the command line arguments.
std::string input, output;
bool names_as_scores, fragment_rings;
boost::program_options::options_description description("Options");
description.add_options()
("help,h",
"Display this help message.")
("input,i", boost::program_options::value<std::string>(&input)->required(),
"Path to the input file containing molecules in SMILES or SDF format.")
("output,o", boost::program_options::value<std::string>(&output)->required(),
"Path to the output file containing serialized reconstruction versions of the molecules.")
("ringfrag,r", boost::program_options::bool_switch(&fragment_rings)->default_value(false),
"Flag to enable ring fragmentation. If not provided ring systems will be isolated and treated as a single fragment.")
("nascores,s", boost::program_options::bool_switch(&names_as_scores)->default_value(false),
"Flag to use the molecules' names as their scores.");
boost::program_options::positional_options_description positionals_description;
positionals_description.add("input", 1);
positionals_description.add("output", 1);
boost::program_options::variables_map vm;
boost::program_options::command_line_parser parser(argc, argv);
parser.options(description);
parser.positional(positionals_description);
boost::program_options::parsed_options parsed_options = parser.run();
boost::program_options::store(parsed_options, vm);
if (vm.count("help")) {
std::cout << description;
return 1;
};
boost::program_options::notify(vm);
// Initialize a Connection string formatter.
boost::format formatter("(%d, %d, %d)");
// Initialize the list to store the ReconstructedMols.
std::list<ReconstructedMol> reconstructions;
// Create a molecule input stream based on the extension of the input file.
std::experimental::filesystem::path extension = std::experimental::filesystem::path(input).extension();
// If the input file is a SMILES file:
if (extension == ".smi" || extension == ".ism" || extension == ".smiles") {
RDKit::SmilesMolSupplier supplier(input);
while (!supplier.atEnd()) {
RDKit::ROMOL_SPTR mol (supplier.next());
reconstructions.push_back(ConvertToReconstructedMol(*mol, fragment_rings, names_as_scores, formatter));
};
// If the input file is a SDF file:
} else if (extension == ".sdf") {
RDKit::SDMolSupplier supplier(input);
while (!supplier.atEnd()) {
RDKit::ROMOL_SPTR mol (supplier.next());
reconstructions.push_back(ConvertToReconstructedMol(*mol, fragment_rings, names_as_scores, formatter));
};
// If the input format is invalid throw an error.
} else {
throw std::runtime_error("Unrecognized input format. Input should be either SMILES or SDF.");
};
// Assign unique IDs to the ReconstructedMols.
unsigned id = 1;
for (ReconstructedMol& reconstruction : reconstructions) {
reconstruction.SetID(id++);
};
// Store the serialized ReconstructedMols in the output file.
std::ofstream output_stream(output, std::ofstream::binary);
boost::archive::binary_oarchive archive(output_stream);
archive << reconstructions;
// Signal success.
return 0;
};
| 45.551181 | 139 | 0.718928 | [
"vector"
] |
0d1955c37dab5cdccca4a52ce8cbf5c78fa95316 | 3,122 | cc | C++ | aegis/src/model/DescribeStratetyDetailResult.cc | sdk-team/aliyun-openapi-cpp-sdk | d0e92f6f33126dcdc7e40f60582304faf2c229b7 | [
"Apache-2.0"
] | 3 | 2020-01-06T08:23:14.000Z | 2022-01-22T04:41:35.000Z | aegis/src/model/DescribeStratetyDetailResult.cc | sdk-team/aliyun-openapi-cpp-sdk | d0e92f6f33126dcdc7e40f60582304faf2c229b7 | [
"Apache-2.0"
] | null | null | null | aegis/src/model/DescribeStratetyDetailResult.cc | sdk-team/aliyun-openapi-cpp-sdk | d0e92f6f33126dcdc7e40f60582304faf2c229b7 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2009-2017 Alibaba Cloud 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 <alibabacloud/aegis/model/DescribeStratetyDetailResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Aegis;
using namespace AlibabaCloud::Aegis::Model;
DescribeStratetyDetailResult::DescribeStratetyDetailResult() :
ServiceResult()
{}
DescribeStratetyDetailResult::DescribeStratetyDetailResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DescribeStratetyDetailResult::~DescribeStratetyDetailResult()
{}
void DescribeStratetyDetailResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto strategyNode = value["Strategy"];
if(!strategyNode["CycleDays"].isNull())
strategy_.cycleDays = std::stoi(strategyNode["CycleDays"].asString());
if(!strategyNode["Name"].isNull())
strategy_.name = strategyNode["Name"].asString();
if(!strategyNode["Id"].isNull())
strategy_.id = std::stoi(strategyNode["Id"].asString());
if(!strategyNode["CycleStartTime"].isNull())
strategy_.cycleStartTime = std::stoi(strategyNode["CycleStartTime"].asString());
if(!strategyNode["Type"].isNull())
strategy_.type = std::stoi(strategyNode["Type"].asString());
auto allRiskTypeWhiteListQueryResultList = value["RiskTypeWhiteListQueryResultList"]["RiskTypeWhiteListQueryResult"];
for (auto value : allRiskTypeWhiteListQueryResultList)
{
Strategy::RiskTypeWhiteListQueryResult riskTypeWhiteListQueryResultObject;
if(!value["TypeName"].isNull())
riskTypeWhiteListQueryResultObject.typeName = value["TypeName"].asString();
if(!value["Alias"].isNull())
riskTypeWhiteListQueryResultObject.alias = value["Alias"].asString();
if(!value["On"].isNull())
riskTypeWhiteListQueryResultObject.on = value["On"].asString() == "true";
auto allSubTypes = value["SubTypes"]["SubType"];
for (auto value : allSubTypes)
{
Strategy::RiskTypeWhiteListQueryResult::SubType subTypesObject;
if(!value["TypeName"].isNull())
subTypesObject.typeName = value["TypeName"].asString();
if(!value["Alias"].isNull())
subTypesObject.alias = value["Alias"].asString();
if(!value["On"].isNull())
subTypesObject.on = value["On"].asString() == "true";
riskTypeWhiteListQueryResultObject.subTypes.push_back(subTypesObject);
}
strategy_.riskTypeWhiteListQueryResultList.push_back(riskTypeWhiteListQueryResultObject);
}
}
DescribeStratetyDetailResult::Strategy DescribeStratetyDetailResult::getStrategy()const
{
return strategy_;
}
| 36.302326 | 118 | 0.754004 | [
"model"
] |
0d1b80472a8cf1912bd9e9a384d8e2acbab1b7f3 | 270,756 | cpp | C++ | lua-bindings/lua_imgui_auto.cpp | gloomyzen/cocos2d-x-imgui | 5ec858cb6de5fc04b3b83d24d2052e26de1766a7 | [
"MIT"
] | null | null | null | lua-bindings/lua_imgui_auto.cpp | gloomyzen/cocos2d-x-imgui | 5ec858cb6de5fc04b3b83d24d2052e26de1766a7 | [
"MIT"
] | null | null | null | lua-bindings/lua_imgui_auto.cpp | gloomyzen/cocos2d-x-imgui | 5ec858cb6de5fc04b3b83d24d2052e26de1766a7 | [
"MIT"
] | null | null | null | #include "lua_imgui_auto.hpp"
#include "imgui_lua.hpp"
#include "lua_conversion.hpp"
#include "scripting/lua-bindings/manual/tolua_fix.h"
#include "scripting/lua-bindings/manual/LuaBasicConversions.h"
#ifdef COCOS2D_DEBUG
#undef COCOS2D_DEBUG
#endif // COCOS2D_DEBUG
namespace imgui
{
namespace ImGui
{
using namespace ::ImGui;
}
}
using namespace lua;
int lua_x_imgui_ImGui_AlignTextToFramePadding(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_AlignTextToFramePadding'", nullptr);
return 0;
}
imgui::ImGui::AlignTextToFramePadding();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:AlignTextToFramePadding",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_AlignTextToFramePadding'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ArrowButton(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:ArrowButton"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:ArrowButton");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ArrowButton'", nullptr);
return 0;
}
bool ret = imgui::ImGui::ArrowButton(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ArrowButton",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ArrowButton'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginChildFrame(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
unsigned int arg0;
ImVec2 arg1;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:BeginChildFrame");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:BeginChildFrame");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginChildFrame'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginChildFrame(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 3)
{
unsigned int arg0;
ImVec2 arg1;
int arg2;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:BeginChildFrame");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:BeginChildFrame");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "imgui.ImGui:BeginChildFrame");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginChildFrame'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginChildFrame(arg0, arg1, arg2);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginChildFrame",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginChildFrame'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginCombo(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
const char* arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginCombo"); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:BeginCombo"); arg1 = arg1_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginCombo'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginCombo(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 3)
{
const char* arg0;
const char* arg1;
int arg2;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginCombo"); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:BeginCombo"); arg1 = arg1_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "imgui.ImGui:BeginCombo");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginCombo'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginCombo(arg0, arg1, arg2);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginCombo",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginCombo'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginDragDropSource(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginDragDropSource'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginDragDropSource();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:BeginDragDropSource");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginDragDropSource'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginDragDropSource(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginDragDropSource",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginDragDropSource'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginDragDropTarget(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginDragDropTarget'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginDragDropTarget();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginDragDropTarget",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginDragDropTarget'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginGroup(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginGroup'", nullptr);
return 0;
}
imgui::ImGui::BeginGroup();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginGroup",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginGroup'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginMainMenuBar(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginMainMenuBar'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginMainMenuBar();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginMainMenuBar",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginMainMenuBar'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginMenu(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginMenu"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginMenu'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginMenu(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
bool arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginMenu"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "imgui.ImGui:BeginMenu");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginMenu'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginMenu(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginMenu",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginMenu'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginMenuBar(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginMenuBar'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginMenuBar();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginMenuBar",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginMenuBar'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginPopup(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginPopup"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopup'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopup(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginPopup"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:BeginPopup");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopup'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopup(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginPopup",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginPopup'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginPopupContextItem(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextItem'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextItem();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginPopupContextItem"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextItem'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextItem(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginPopupContextItem"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:BeginPopupContextItem");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextItem'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextItem(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginPopupContextItem",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginPopupContextItem'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginPopupContextVoid(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextVoid'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextVoid();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginPopupContextVoid"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextVoid'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextVoid(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginPopupContextVoid"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:BeginPopupContextVoid");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextVoid'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextVoid(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginPopupContextVoid",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginPopupContextVoid'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginPopupContextWindow(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextWindow'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextWindow();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginPopupContextWindow"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextWindow'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextWindow(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginPopupContextWindow"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:BeginPopupContextWindow");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginPopupContextWindow'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginPopupContextWindow(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginPopupContextWindow",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginPopupContextWindow'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginTabBar(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginTabBar"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginTabBar'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginTabBar(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BeginTabBar"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:BeginTabBar");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginTabBar'", nullptr);
return 0;
}
bool ret = imgui::ImGui::BeginTabBar(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginTabBar",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginTabBar'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BeginTooltip(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BeginTooltip'", nullptr);
return 0;
}
imgui::ImGui::BeginTooltip();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BeginTooltip",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BeginTooltip'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Bullet(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Bullet'", nullptr);
return 0;
}
imgui::ImGui::Bullet();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Bullet",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Bullet'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_BulletText(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:BulletText"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_BulletText'", nullptr);
return 0;
}
imgui::ImGui::BulletText("%s", arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:BulletText",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_BulletText'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Button(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:Button"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Button'", nullptr);
return 0;
}
bool ret = imgui::ImGui::Button(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
ImVec2 arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:Button"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:Button");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Button'", nullptr);
return 0;
}
bool ret = imgui::ImGui::Button(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Button",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Button'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_CalcItemWidth(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CalcItemWidth'", nullptr);
return 0;
}
double ret = imgui::ImGui::CalcItemWidth();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:CalcItemWidth",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_CalcItemWidth'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_CalcTextSize(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:CalcTextSize"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CalcTextSize'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::CalcTextSize(arg0);
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
const char* arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:CalcTextSize"); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:CalcTextSize"); arg1 = arg1_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CalcTextSize'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::CalcTextSize(arg0, arg1);
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
if (argc == 3)
{
const char* arg0;
const char* arg1;
bool arg2;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:CalcTextSize"); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:CalcTextSize"); arg1 = arg1_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 4,&arg2, "imgui.ImGui:CalcTextSize");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CalcTextSize'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::CalcTextSize(arg0, arg1, arg2);
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
if (argc == 4)
{
const char* arg0;
const char* arg1;
bool arg2;
double arg3;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:CalcTextSize"); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:CalcTextSize"); arg1 = arg1_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 4,&arg2, "imgui.ImGui:CalcTextSize");
ok &= luaval_to_number(tolua_S, 5,&arg3, "imgui.ImGui:CalcTextSize");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CalcTextSize'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::CalcTextSize(arg0, arg1, arg2, arg3);
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:CalcTextSize",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_CalcTextSize'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_CaptureKeyboardFromApp(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CaptureKeyboardFromApp'", nullptr);
return 0;
}
imgui::ImGui::CaptureKeyboardFromApp();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "imgui.ImGui:CaptureKeyboardFromApp");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CaptureKeyboardFromApp'", nullptr);
return 0;
}
imgui::ImGui::CaptureKeyboardFromApp(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:CaptureKeyboardFromApp",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_CaptureKeyboardFromApp'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_CaptureMouseFromApp(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CaptureMouseFromApp'", nullptr);
return 0;
}
imgui::ImGui::CaptureMouseFromApp();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "imgui.ImGui:CaptureMouseFromApp");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CaptureMouseFromApp'", nullptr);
return 0;
}
imgui::ImGui::CaptureMouseFromApp(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:CaptureMouseFromApp",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_CaptureMouseFromApp'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_CloseCurrentPopup(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_CloseCurrentPopup'", nullptr);
return 0;
}
imgui::ImGui::CloseCurrentPopup();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:CloseCurrentPopup",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_CloseCurrentPopup'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ColorButton(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
ImVec4 arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:ColorButton"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec4(tolua_S, 3, &arg1, "imgui.ImGui:ColorButton");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ColorButton'", nullptr);
return 0;
}
bool ret = imgui::ImGui::ColorButton(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 3)
{
const char* arg0;
ImVec4 arg1;
int arg2;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:ColorButton"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec4(tolua_S, 3, &arg1, "imgui.ImGui:ColorButton");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "imgui.ImGui:ColorButton");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ColorButton'", nullptr);
return 0;
}
bool ret = imgui::ImGui::ColorButton(arg0, arg1, arg2);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 4)
{
const char* arg0;
ImVec4 arg1;
int arg2;
ImVec2 arg3;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:ColorButton"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec4(tolua_S, 3, &arg1, "imgui.ImGui:ColorButton");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "imgui.ImGui:ColorButton");
ok &= luaval_to_ImVec2(tolua_S, 5, &arg3, "imgui.ImGui:ColorButton");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ColorButton'", nullptr);
return 0;
}
bool ret = imgui::ImGui::ColorButton(arg0, arg1, arg2, arg3);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ColorButton",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ColorButton'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ColorConvertFloat4ToU32(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
ImVec4 arg0;
ok &= luaval_to_ImVec4(tolua_S, 2, &arg0, "imgui.ImGui:ColorConvertFloat4ToU32");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ColorConvertFloat4ToU32'", nullptr);
return 0;
}
unsigned int ret = imgui::ImGui::ColorConvertFloat4ToU32(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ColorConvertFloat4ToU32",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ColorConvertFloat4ToU32'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ColorConvertU32ToFloat4(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
unsigned int arg0;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:ColorConvertU32ToFloat4");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ColorConvertU32ToFloat4'", nullptr);
return 0;
}
ImVec4 ret = imgui::ImGui::ColorConvertU32ToFloat4(arg0);
ImVec4_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ColorConvertU32ToFloat4",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ColorConvertU32ToFloat4'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Columns(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Columns'", nullptr);
return 0;
}
imgui::ImGui::Columns();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:Columns");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Columns'", nullptr);
return 0;
}
imgui::ImGui::Columns(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
int arg0;
const char* arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:Columns");
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:Columns"); arg1 = arg1_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Columns'", nullptr);
return 0;
}
imgui::ImGui::Columns(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 3)
{
int arg0;
const char* arg1;
bool arg2;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:Columns");
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:Columns"); arg1 = arg1_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 4,&arg2, "imgui.ImGui:Columns");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Columns'", nullptr);
return 0;
}
imgui::ImGui::Columns(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Columns",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Columns'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_DebugCheckVersionAndDataLayout(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 7)
{
const char* arg0;
unsigned int arg1;
unsigned int arg2;
unsigned int arg3;
unsigned int arg4;
unsigned int arg5;
unsigned int arg6;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:DebugCheckVersionAndDataLayout"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_uint32(tolua_S, 3,&arg1, "imgui.ImGui:DebugCheckVersionAndDataLayout");
ok &= luaval_to_uint32(tolua_S, 4,&arg2, "imgui.ImGui:DebugCheckVersionAndDataLayout");
ok &= luaval_to_uint32(tolua_S, 5,&arg3, "imgui.ImGui:DebugCheckVersionAndDataLayout");
ok &= luaval_to_uint32(tolua_S, 6,&arg4, "imgui.ImGui:DebugCheckVersionAndDataLayout");
ok &= luaval_to_uint32(tolua_S, 7,&arg5, "imgui.ImGui:DebugCheckVersionAndDataLayout");
ok &= luaval_to_uint32(tolua_S, 8,&arg6, "imgui.ImGui:DebugCheckVersionAndDataLayout");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_DebugCheckVersionAndDataLayout'", nullptr);
return 0;
}
bool ret = imgui::ImGui::DebugCheckVersionAndDataLayout(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:DebugCheckVersionAndDataLayout",argc, 7);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_DebugCheckVersionAndDataLayout'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_DestroyPlatformWindows(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_DestroyPlatformWindows'", nullptr);
return 0;
}
imgui::ImGui::DestroyPlatformWindows();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:DestroyPlatformWindows",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_DestroyPlatformWindows'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_DockSpace(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
unsigned int arg0;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:DockSpace");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_DockSpace'", nullptr);
return 0;
}
imgui::ImGui::DockSpace(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
unsigned int arg0;
ImVec2 arg1;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:DockSpace");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:DockSpace");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_DockSpace'", nullptr);
return 0;
}
imgui::ImGui::DockSpace(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 3)
{
unsigned int arg0;
ImVec2 arg1;
int arg2;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:DockSpace");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:DockSpace");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "imgui.ImGui:DockSpace");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_DockSpace'", nullptr);
return 0;
}
imgui::ImGui::DockSpace(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:DockSpace",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_DockSpace'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_DockSpaceOverViewport(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_DockSpaceOverViewport'", nullptr);
return 0;
}
unsigned int ret = imgui::ImGui::DockSpaceOverViewport();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
if (argc == 1)
{
ImGuiViewport* arg0;
ok &= luaval_to_native(tolua_S, 2, &arg0, "DockSpaceOverViewport");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_DockSpaceOverViewport'", nullptr);
return 0;
}
unsigned int ret = imgui::ImGui::DockSpaceOverViewport(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
if (argc == 2)
{
ImGuiViewport* arg0;
int arg1;
ok &= luaval_to_native(tolua_S, 2, &arg0, "DockSpaceOverViewport");
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:DockSpaceOverViewport");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_DockSpaceOverViewport'", nullptr);
return 0;
}
unsigned int ret = imgui::ImGui::DockSpaceOverViewport(arg0, arg1);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:DockSpaceOverViewport",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_DockSpaceOverViewport'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Dummy(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
ImVec2 arg0;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:Dummy");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Dummy'", nullptr);
return 0;
}
imgui::ImGui::Dummy(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Dummy",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Dummy'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndChildFrame(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndChildFrame'", nullptr);
return 0;
}
imgui::ImGui::EndChildFrame();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndChildFrame",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndChildFrame'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndCombo(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndCombo'", nullptr);
return 0;
}
imgui::ImGui::EndCombo();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndCombo",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndCombo'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndDragDropSource(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndDragDropSource'", nullptr);
return 0;
}
imgui::ImGui::EndDragDropSource();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndDragDropSource",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndDragDropSource'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndDragDropTarget(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndDragDropTarget'", nullptr);
return 0;
}
imgui::ImGui::EndDragDropTarget();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndDragDropTarget",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndDragDropTarget'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndFrame(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndFrame'", nullptr);
return 0;
}
imgui::ImGui::EndFrame();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndFrame",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndFrame'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndGroup(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndGroup'", nullptr);
return 0;
}
imgui::ImGui::EndGroup();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndGroup",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndGroup'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndMainMenuBar(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndMainMenuBar'", nullptr);
return 0;
}
imgui::ImGui::EndMainMenuBar();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndMainMenuBar",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndMainMenuBar'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndMenu(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndMenu'", nullptr);
return 0;
}
imgui::ImGui::EndMenu();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndMenu",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndMenu'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndMenuBar(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndMenuBar'", nullptr);
return 0;
}
imgui::ImGui::EndMenuBar();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndMenuBar",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndMenuBar'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndPopup(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndPopup'", nullptr);
return 0;
}
imgui::ImGui::EndPopup();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndPopup",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndPopup'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndTabBar(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndTabBar'", nullptr);
return 0;
}
imgui::ImGui::EndTabBar();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndTabBar",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndTabBar'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndTabItem(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndTabItem'", nullptr);
return 0;
}
imgui::ImGui::EndTabItem();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndTabItem",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndTabItem'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_EndTooltip(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_EndTooltip'", nullptr);
return 0;
}
imgui::ImGui::EndTooltip();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:EndTooltip",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_EndTooltip'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_FindViewportByID(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
unsigned int arg0;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:FindViewportByID");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_FindViewportByID'", nullptr);
return 0;
}
ImGuiViewport* ret = imgui::ImGui::FindViewportByID(arg0);
native_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:FindViewportByID",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_FindViewportByID'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetBackgroundDrawList(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 1)
{
ImGuiViewport* arg0;
ok &= luaval_to_native(tolua_S, 2, &arg0, "GetBackgroundDrawList");
if (!ok) { break; }
ImDrawList* ret = imgui::ImGui::GetBackgroundDrawList(arg0);
native_to_luaval(tolua_S, ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 0)
{
ImDrawList* ret = imgui::ImGui::GetBackgroundDrawList();
native_to_luaval(tolua_S, ret);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "imgui.ImGui:GetBackgroundDrawList",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetBackgroundDrawList'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetClipboardText(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetClipboardText'", nullptr);
return 0;
}
const char* ret = imgui::ImGui::GetClipboardText();
tolua_pushstring(tolua_S,(const char*)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetClipboardText",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetClipboardText'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetColumnIndex(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetColumnIndex'", nullptr);
return 0;
}
int ret = imgui::ImGui::GetColumnIndex();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetColumnIndex",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetColumnIndex'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetColumnOffset(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetColumnOffset'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetColumnOffset();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:GetColumnOffset");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetColumnOffset'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetColumnOffset(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetColumnOffset",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetColumnOffset'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetColumnWidth(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetColumnWidth'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetColumnWidth();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:GetColumnWidth");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetColumnWidth'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetColumnWidth(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetColumnWidth",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetColumnWidth'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetColumnsCount(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetColumnsCount'", nullptr);
return 0;
}
int ret = imgui::ImGui::GetColumnsCount();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetColumnsCount",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetColumnsCount'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetContentRegionAvail(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetContentRegionAvail'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetContentRegionAvail();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetContentRegionAvail",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetContentRegionAvail'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetContentRegionMax(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetContentRegionMax'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetContentRegionMax();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetContentRegionMax",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetContentRegionMax'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetCursorPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetCursorPos'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetCursorPos();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetCursorPos",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetCursorPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetCursorPosX(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetCursorPosX'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetCursorPosX();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetCursorPosX",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetCursorPosX'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetCursorPosY(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetCursorPosY'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetCursorPosY();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetCursorPosY",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetCursorPosY'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetCursorScreenPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetCursorScreenPos'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetCursorScreenPos();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetCursorScreenPos",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetCursorScreenPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetCursorStartPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetCursorStartPos'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetCursorStartPos();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetCursorStartPos",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetCursorStartPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetFontSize(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetFontSize'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetFontSize();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetFontSize",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetFontSize'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetFontTexUvWhitePixel(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetFontTexUvWhitePixel'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetFontTexUvWhitePixel();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetFontTexUvWhitePixel",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetFontTexUvWhitePixel'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetForegroundDrawList(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 1)
{
ImGuiViewport* arg0;
ok &= luaval_to_native(tolua_S, 2, &arg0, "GetForegroundDrawList");
if (!ok) { break; }
ImDrawList* ret = imgui::ImGui::GetForegroundDrawList(arg0);
native_to_luaval(tolua_S, ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 0)
{
ImDrawList* ret = imgui::ImGui::GetForegroundDrawList();
native_to_luaval(tolua_S, ret);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "imgui.ImGui:GetForegroundDrawList",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetForegroundDrawList'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetFrameCount(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetFrameCount'", nullptr);
return 0;
}
int ret = imgui::ImGui::GetFrameCount();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetFrameCount",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetFrameCount'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetFrameHeight(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetFrameHeight'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetFrameHeight();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetFrameHeight",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetFrameHeight'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetFrameHeightWithSpacing(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetFrameHeightWithSpacing'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetFrameHeightWithSpacing();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetFrameHeightWithSpacing",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetFrameHeightWithSpacing'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetID(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 2)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:GetID"); arg0 = arg0_tmp.c_str();
if (!ok) { break; }
const char* arg1;
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:GetID"); arg1 = arg1_tmp.c_str();
if (!ok) { break; }
unsigned int ret = imgui::ImGui::GetID(arg0, arg1);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:GetID"); arg0 = arg0_tmp.c_str();
if (!ok) { break; }
unsigned int ret = imgui::ImGui::GetID(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "imgui.ImGui:GetID",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetID'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetItemRectMax(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetItemRectMax'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetItemRectMax();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetItemRectMax",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetItemRectMax'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetItemRectMin(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetItemRectMin'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetItemRectMin();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetItemRectMin",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetItemRectMin'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetItemRectSize(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetItemRectSize'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetItemRectSize();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetItemRectSize",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetItemRectSize'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetKeyIndex(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:GetKeyIndex");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetKeyIndex'", nullptr);
return 0;
}
int ret = imgui::ImGui::GetKeyIndex(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetKeyIndex",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetKeyIndex'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetKeyPressedAmount(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 3)
{
int arg0;
double arg1;
double arg2;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:GetKeyPressedAmount");
ok &= luaval_to_number(tolua_S, 3,&arg1, "imgui.ImGui:GetKeyPressedAmount");
ok &= luaval_to_number(tolua_S, 4,&arg2, "imgui.ImGui:GetKeyPressedAmount");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetKeyPressedAmount'", nullptr);
return 0;
}
int ret = imgui::ImGui::GetKeyPressedAmount(arg0, arg1, arg2);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetKeyPressedAmount",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetKeyPressedAmount'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetMainViewport(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetMainViewport'", nullptr);
return 0;
}
ImGuiViewport* ret = imgui::ImGui::GetMainViewport();
native_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetMainViewport",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetMainViewport'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetMouseCursor(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetMouseCursor'", nullptr);
return 0;
}
int ret = imgui::ImGui::GetMouseCursor();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetMouseCursor",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetMouseCursor'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetMouseDragDelta(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetMouseDragDelta'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetMouseDragDelta();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:GetMouseDragDelta");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetMouseDragDelta'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetMouseDragDelta(arg0);
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
if (argc == 2)
{
int arg0;
double arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:GetMouseDragDelta");
ok &= luaval_to_number(tolua_S, 3,&arg1, "imgui.ImGui:GetMouseDragDelta");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetMouseDragDelta'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetMouseDragDelta(arg0, arg1);
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetMouseDragDelta",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetMouseDragDelta'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetMousePos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetMousePos'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetMousePos();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetMousePos",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetMousePos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetMousePosOnOpeningCurrentPopup(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetMousePosOnOpeningCurrentPopup'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetMousePosOnOpeningCurrentPopup();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetMousePosOnOpeningCurrentPopup",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetMousePosOnOpeningCurrentPopup'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetScrollMaxX(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetScrollMaxX'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetScrollMaxX();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetScrollMaxX",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetScrollMaxX'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetScrollMaxY(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetScrollMaxY'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetScrollMaxY();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetScrollMaxY",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetScrollMaxY'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetScrollX(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetScrollX'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetScrollX();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetScrollX",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetScrollX'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetScrollY(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetScrollY'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetScrollY();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetScrollY",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetScrollY'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetStyleColorName(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:GetStyleColorName");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetStyleColorName'", nullptr);
return 0;
}
const char* ret = imgui::ImGui::GetStyleColorName(arg0);
tolua_pushstring(tolua_S,(const char*)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetStyleColorName",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetStyleColorName'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetStyleColorVec4(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:GetStyleColorVec4");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetStyleColorVec4'", nullptr);
return 0;
}
const ImVec4& ret = imgui::ImGui::GetStyleColorVec4(arg0);
ImVec4_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetStyleColorVec4",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetStyleColorVec4'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetTextLineHeight(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetTextLineHeight'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetTextLineHeight();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetTextLineHeight",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetTextLineHeight'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetTextLineHeightWithSpacing(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetTextLineHeightWithSpacing'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetTextLineHeightWithSpacing();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetTextLineHeightWithSpacing",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetTextLineHeightWithSpacing'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetTime(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetTime'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetTime();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetTime",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetTime'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetTreeNodeToLabelSpacing(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetTreeNodeToLabelSpacing'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetTreeNodeToLabelSpacing();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetTreeNodeToLabelSpacing",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetTreeNodeToLabelSpacing'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetVersion(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetVersion'", nullptr);
return 0;
}
const char* ret = imgui::ImGui::GetVersion();
tolua_pushstring(tolua_S,(const char*)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetVersion",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetVersion'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowContentRegionMax(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowContentRegionMax'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetWindowContentRegionMax();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowContentRegionMax",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowContentRegionMax'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowContentRegionMin(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowContentRegionMin'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetWindowContentRegionMin();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowContentRegionMin",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowContentRegionMin'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowContentRegionWidth(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowContentRegionWidth'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetWindowContentRegionWidth();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowContentRegionWidth",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowContentRegionWidth'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowDockID(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowDockID'", nullptr);
return 0;
}
unsigned int ret = imgui::ImGui::GetWindowDockID();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowDockID",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowDockID'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowDpiScale(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowDpiScale'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetWindowDpiScale();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowDpiScale",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowDpiScale'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowDrawList(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowDrawList'", nullptr);
return 0;
}
ImDrawList* ret = imgui::ImGui::GetWindowDrawList();
native_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowDrawList",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowDrawList'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowHeight(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowHeight'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetWindowHeight();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowHeight",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowHeight'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowPos'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetWindowPos();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowPos",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowSize(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowSize'", nullptr);
return 0;
}
ImVec2 ret = imgui::ImGui::GetWindowSize();
ImVec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowSize",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowSize'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowViewport(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowViewport'", nullptr);
return 0;
}
ImGuiViewport* ret = imgui::ImGui::GetWindowViewport();
native_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowViewport",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowViewport'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_GetWindowWidth(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_GetWindowWidth'", nullptr);
return 0;
}
double ret = imgui::ImGui::GetWindowWidth();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:GetWindowWidth",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_GetWindowWidth'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Indent(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Indent'", nullptr);
return 0;
}
imgui::ImGui::Indent();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:Indent");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Indent'", nullptr);
return 0;
}
imgui::ImGui::Indent(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Indent",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Indent'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_InvisibleButton(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
ImVec2 arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:InvisibleButton"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:InvisibleButton");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_InvisibleButton'", nullptr);
return 0;
}
bool ret = imgui::ImGui::InvisibleButton(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:InvisibleButton",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_InvisibleButton'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsAnyItemActive(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsAnyItemActive'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsAnyItemActive();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsAnyItemActive",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsAnyItemActive'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsAnyItemFocused(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsAnyItemFocused'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsAnyItemFocused();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsAnyItemFocused",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsAnyItemFocused'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsAnyItemHovered(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsAnyItemHovered'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsAnyItemHovered();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsAnyItemHovered",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsAnyItemHovered'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsAnyMouseDown(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsAnyMouseDown'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsAnyMouseDown();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsAnyMouseDown",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsAnyMouseDown'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemActivated(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemActivated'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemActivated();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemActivated",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemActivated'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemActive(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemActive'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemActive();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemActive",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemActive'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemClicked(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemClicked'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemClicked();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsItemClicked");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemClicked'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemClicked(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemClicked",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemClicked'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemDeactivated(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemDeactivated'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemDeactivated();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemDeactivated",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemDeactivated'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemDeactivatedAfterEdit(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemDeactivatedAfterEdit'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemDeactivatedAfterEdit();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemDeactivatedAfterEdit",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemDeactivatedAfterEdit'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemEdited(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemEdited'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemEdited();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemEdited",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemEdited'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemFocused(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemFocused'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemFocused();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemFocused",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemFocused'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemHovered(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemHovered'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemHovered();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsItemHovered");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemHovered'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemHovered(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemHovered",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemHovered'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemToggledOpen(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemToggledOpen'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemToggledOpen();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemToggledOpen",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemToggledOpen'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsItemVisible(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsItemVisible'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsItemVisible();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsItemVisible",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsItemVisible'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsKeyDown(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsKeyDown");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsKeyDown'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsKeyDown(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsKeyDown",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsKeyDown'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsKeyPressed(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsKeyPressed");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsKeyPressed'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsKeyPressed(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
int arg0;
bool arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsKeyPressed");
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "imgui.ImGui:IsKeyPressed");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsKeyPressed'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsKeyPressed(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsKeyPressed",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsKeyPressed'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsKeyReleased(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsKeyReleased");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsKeyReleased'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsKeyReleased(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsKeyReleased",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsKeyReleased'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsMouseClicked(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsMouseClicked");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseClicked'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseClicked(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
int arg0;
bool arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsMouseClicked");
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "imgui.ImGui:IsMouseClicked");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseClicked'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseClicked(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsMouseClicked",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsMouseClicked'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsMouseDoubleClicked(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsMouseDoubleClicked");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseDoubleClicked'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseDoubleClicked(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsMouseDoubleClicked",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsMouseDoubleClicked'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsMouseDown(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsMouseDown");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseDown'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseDown(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsMouseDown",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsMouseDown'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsMouseDragging(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsMouseDragging");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseDragging'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseDragging(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
int arg0;
double arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsMouseDragging");
ok &= luaval_to_number(tolua_S, 3,&arg1, "imgui.ImGui:IsMouseDragging");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseDragging'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseDragging(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsMouseDragging",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsMouseDragging'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsMouseHoveringRect(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
ImVec2 arg0;
ImVec2 arg1;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:IsMouseHoveringRect");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:IsMouseHoveringRect");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseHoveringRect'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseHoveringRect(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 3)
{
ImVec2 arg0;
ImVec2 arg1;
bool arg2;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:IsMouseHoveringRect");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:IsMouseHoveringRect");
ok &= luaval_to_boolean(tolua_S, 4,&arg2, "imgui.ImGui:IsMouseHoveringRect");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseHoveringRect'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseHoveringRect(arg0, arg1, arg2);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsMouseHoveringRect",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsMouseHoveringRect'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsMouseReleased(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsMouseReleased");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsMouseReleased'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsMouseReleased(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsMouseReleased",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsMouseReleased'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsPopupOpen(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:IsPopupOpen"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsPopupOpen'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsPopupOpen(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:IsPopupOpen"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:IsPopupOpen");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsPopupOpen'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsPopupOpen(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsPopupOpen",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsPopupOpen'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsRectVisible(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 2)
{
ImVec2 arg0;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:IsRectVisible");
if (!ok) { break; }
ImVec2 arg1;
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:IsRectVisible");
if (!ok) { break; }
bool ret = imgui::ImGui::IsRectVisible(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 1)
{
ImVec2 arg0;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:IsRectVisible");
if (!ok) { break; }
bool ret = imgui::ImGui::IsRectVisible(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "imgui.ImGui:IsRectVisible",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsRectVisible'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsWindowAppearing(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsWindowAppearing'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsWindowAppearing();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsWindowAppearing",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsWindowAppearing'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsWindowCollapsed(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsWindowCollapsed'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsWindowCollapsed();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsWindowCollapsed",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsWindowCollapsed'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsWindowDocked(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsWindowDocked'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsWindowDocked();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsWindowDocked",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsWindowDocked'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsWindowFocused(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsWindowFocused'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsWindowFocused();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsWindowFocused");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsWindowFocused'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsWindowFocused(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsWindowFocused",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsWindowFocused'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_IsWindowHovered(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsWindowHovered'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsWindowHovered();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:IsWindowHovered");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_IsWindowHovered'", nullptr);
return 0;
}
bool ret = imgui::ImGui::IsWindowHovered(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:IsWindowHovered",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_IsWindowHovered'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LabelText(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
const char* arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:LabelText"); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:LabelText"); arg1 = arg1_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LabelText'", nullptr);
return 0;
}
imgui::ImGui::LabelText(arg0, "%s", arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LabelText",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LabelText'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ListBoxFooter(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ListBoxFooter'", nullptr);
return 0;
}
imgui::ImGui::ListBoxFooter();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ListBoxFooter",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ListBoxFooter'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LoadIniSettingsFromDisk(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:LoadIniSettingsFromDisk"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LoadIniSettingsFromDisk'", nullptr);
return 0;
}
imgui::ImGui::LoadIniSettingsFromDisk(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LoadIniSettingsFromDisk",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LoadIniSettingsFromDisk'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LoadIniSettingsFromMemory(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:LoadIniSettingsFromMemory"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LoadIniSettingsFromMemory'", nullptr);
return 0;
}
imgui::ImGui::LoadIniSettingsFromMemory(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
const char* arg0;
unsigned int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:LoadIniSettingsFromMemory"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_uint32(tolua_S, 3,&arg1, "imgui.ImGui:LoadIniSettingsFromMemory");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LoadIniSettingsFromMemory'", nullptr);
return 0;
}
imgui::ImGui::LoadIniSettingsFromMemory(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LoadIniSettingsFromMemory",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LoadIniSettingsFromMemory'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LogButtons(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogButtons'", nullptr);
return 0;
}
imgui::ImGui::LogButtons();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LogButtons",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LogButtons'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LogFinish(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogFinish'", nullptr);
return 0;
}
imgui::ImGui::LogFinish();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LogFinish",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LogFinish'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LogText(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:LogText"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogText'", nullptr);
return 0;
}
imgui::ImGui::LogText("%s", arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LogText",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LogText'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LogToClipboard(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogToClipboard'", nullptr);
return 0;
}
imgui::ImGui::LogToClipboard();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:LogToClipboard");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogToClipboard'", nullptr);
return 0;
}
imgui::ImGui::LogToClipboard(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LogToClipboard",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LogToClipboard'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LogToFile(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogToFile'", nullptr);
return 0;
}
imgui::ImGui::LogToFile();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:LogToFile");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogToFile'", nullptr);
return 0;
}
imgui::ImGui::LogToFile(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
int arg0;
const char* arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:LogToFile");
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:LogToFile"); arg1 = arg1_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogToFile'", nullptr);
return 0;
}
imgui::ImGui::LogToFile(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LogToFile",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LogToFile'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_LogToTTY(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogToTTY'", nullptr);
return 0;
}
imgui::ImGui::LogToTTY();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:LogToTTY");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_LogToTTY'", nullptr);
return 0;
}
imgui::ImGui::LogToTTY(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:LogToTTY",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_LogToTTY'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_NewFrame(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_NewFrame'", nullptr);
return 0;
}
imgui::ImGui::NewFrame();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:NewFrame",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_NewFrame'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_NewLine(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_NewLine'", nullptr);
return 0;
}
imgui::ImGui::NewLine();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:NewLine",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_NewLine'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_NextColumn(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_NextColumn'", nullptr);
return 0;
}
imgui::ImGui::NextColumn();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:NextColumn",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_NextColumn'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_OpenPopup(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:OpenPopup"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_OpenPopup'", nullptr);
return 0;
}
imgui::ImGui::OpenPopup(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:OpenPopup"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:OpenPopup");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_OpenPopup'", nullptr);
return 0;
}
imgui::ImGui::OpenPopup(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:OpenPopup",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_OpenPopup'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_OpenPopupContextItem(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_OpenPopupContextItem'", nullptr);
return 0;
}
bool ret = imgui::ImGui::OpenPopupContextItem();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:OpenPopupContextItem"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_OpenPopupContextItem'", nullptr);
return 0;
}
bool ret = imgui::ImGui::OpenPopupContextItem(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
if (argc == 2)
{
const char* arg0;
int arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:OpenPopupContextItem"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:OpenPopupContextItem");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_OpenPopupContextItem'", nullptr);
return 0;
}
bool ret = imgui::ImGui::OpenPopupContextItem(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:OpenPopupContextItem",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_OpenPopupContextItem'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopAllowKeyboardFocus(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopAllowKeyboardFocus'", nullptr);
return 0;
}
imgui::ImGui::PopAllowKeyboardFocus();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopAllowKeyboardFocus",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopAllowKeyboardFocus'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopButtonRepeat(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopButtonRepeat'", nullptr);
return 0;
}
imgui::ImGui::PopButtonRepeat();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopButtonRepeat",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopButtonRepeat'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopClipRect(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopClipRect'", nullptr);
return 0;
}
imgui::ImGui::PopClipRect();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopClipRect",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopClipRect'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopFont(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopFont'", nullptr);
return 0;
}
imgui::ImGui::PopFont();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopFont",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopFont'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopID(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopID'", nullptr);
return 0;
}
imgui::ImGui::PopID();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopID",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopID'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopItemWidth(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopItemWidth'", nullptr);
return 0;
}
imgui::ImGui::PopItemWidth();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopItemWidth",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopItemWidth'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopStyleColor(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopStyleColor'", nullptr);
return 0;
}
imgui::ImGui::PopStyleColor();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:PopStyleColor");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopStyleColor'", nullptr);
return 0;
}
imgui::ImGui::PopStyleColor(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopStyleColor",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopStyleColor'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopStyleVar(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopStyleVar'", nullptr);
return 0;
}
imgui::ImGui::PopStyleVar();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:PopStyleVar");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopStyleVar'", nullptr);
return 0;
}
imgui::ImGui::PopStyleVar(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopStyleVar",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopStyleVar'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PopTextWrapPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PopTextWrapPos'", nullptr);
return 0;
}
imgui::ImGui::PopTextWrapPos();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PopTextWrapPos",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PopTextWrapPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ProgressBar(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:ProgressBar");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ProgressBar'", nullptr);
return 0;
}
imgui::ImGui::ProgressBar(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
double arg0;
ImVec2 arg1;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:ProgressBar");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:ProgressBar");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ProgressBar'", nullptr);
return 0;
}
imgui::ImGui::ProgressBar(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 3)
{
double arg0;
ImVec2 arg1;
const char* arg2;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:ProgressBar");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:ProgressBar");
std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp, "imgui.ImGui:ProgressBar"); arg2 = arg2_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ProgressBar'", nullptr);
return 0;
}
imgui::ImGui::ProgressBar(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ProgressBar",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ProgressBar'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PushAllowKeyboardFocus(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "imgui.ImGui:PushAllowKeyboardFocus");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PushAllowKeyboardFocus'", nullptr);
return 0;
}
imgui::ImGui::PushAllowKeyboardFocus(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PushAllowKeyboardFocus",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PushAllowKeyboardFocus'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PushButtonRepeat(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "imgui.ImGui:PushButtonRepeat");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PushButtonRepeat'", nullptr);
return 0;
}
imgui::ImGui::PushButtonRepeat(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PushButtonRepeat",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PushButtonRepeat'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PushClipRect(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 3)
{
ImVec2 arg0;
ImVec2 arg1;
bool arg2;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:PushClipRect");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:PushClipRect");
ok &= luaval_to_boolean(tolua_S, 4,&arg2, "imgui.ImGui:PushClipRect");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PushClipRect'", nullptr);
return 0;
}
imgui::ImGui::PushClipRect(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PushClipRect",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PushClipRect'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PushItemWidth(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:PushItemWidth");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PushItemWidth'", nullptr);
return 0;
}
imgui::ImGui::PushItemWidth(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PushItemWidth",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PushItemWidth'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_PushTextWrapPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PushTextWrapPos'", nullptr);
return 0;
}
imgui::ImGui::PushTextWrapPos();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:PushTextWrapPos");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_PushTextWrapPos'", nullptr);
return 0;
}
imgui::ImGui::PushTextWrapPos(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:PushTextWrapPos",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_PushTextWrapPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_RadioButton(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
bool arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:RadioButton"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "imgui.ImGui:RadioButton");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_RadioButton'", nullptr);
return 0;
}
bool ret = imgui::ImGui::RadioButton(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:RadioButton",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_RadioButton'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Render(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Render'", nullptr);
return 0;
}
imgui::ImGui::Render();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Render",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Render'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_RenderPlatformWindowsDefault(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_RenderPlatformWindowsDefault'", nullptr);
return 0;
}
imgui::ImGui::RenderPlatformWindowsDefault();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:RenderPlatformWindowsDefault",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_RenderPlatformWindowsDefault'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ResetMouseDragDelta(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ResetMouseDragDelta'", nullptr);
return 0;
}
imgui::ImGui::ResetMouseDragDelta();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:ResetMouseDragDelta");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ResetMouseDragDelta'", nullptr);
return 0;
}
imgui::ImGui::ResetMouseDragDelta(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ResetMouseDragDelta",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ResetMouseDragDelta'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SameLine(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SameLine'", nullptr);
return 0;
}
imgui::ImGui::SameLine();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SameLine");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SameLine'", nullptr);
return 0;
}
imgui::ImGui::SameLine(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
double arg0;
double arg1;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SameLine");
ok &= luaval_to_number(tolua_S, 3,&arg1, "imgui.ImGui:SameLine");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SameLine'", nullptr);
return 0;
}
imgui::ImGui::SameLine(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SameLine",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SameLine'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SaveIniSettingsToDisk(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SaveIniSettingsToDisk"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SaveIniSettingsToDisk'", nullptr);
return 0;
}
imgui::ImGui::SaveIniSettingsToDisk(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SaveIniSettingsToDisk",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SaveIniSettingsToDisk'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Separator(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Separator'", nullptr);
return 0;
}
imgui::ImGui::Separator();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Separator",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Separator'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetClipboardText(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetClipboardText"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetClipboardText'", nullptr);
return 0;
}
imgui::ImGui::SetClipboardText(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetClipboardText",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetClipboardText'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetColorEditOptions(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:SetColorEditOptions");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetColorEditOptions'", nullptr);
return 0;
}
imgui::ImGui::SetColorEditOptions(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetColorEditOptions",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetColorEditOptions'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetColumnOffset(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
int arg0;
double arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:SetColumnOffset");
ok &= luaval_to_number(tolua_S, 3,&arg1, "imgui.ImGui:SetColumnOffset");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetColumnOffset'", nullptr);
return 0;
}
imgui::ImGui::SetColumnOffset(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetColumnOffset",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetColumnOffset'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetColumnWidth(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
int arg0;
double arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:SetColumnWidth");
ok &= luaval_to_number(tolua_S, 3,&arg1, "imgui.ImGui:SetColumnWidth");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetColumnWidth'", nullptr);
return 0;
}
imgui::ImGui::SetColumnWidth(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetColumnWidth",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetColumnWidth'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetCursorPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
ImVec2 arg0;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetCursorPos");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetCursorPos'", nullptr);
return 0;
}
imgui::ImGui::SetCursorPos(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetCursorPos",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetCursorPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetCursorPosX(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetCursorPosX");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetCursorPosX'", nullptr);
return 0;
}
imgui::ImGui::SetCursorPosX(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetCursorPosX",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetCursorPosX'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetCursorPosY(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetCursorPosY");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetCursorPosY'", nullptr);
return 0;
}
imgui::ImGui::SetCursorPosY(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetCursorPosY",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetCursorPosY'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetCursorScreenPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
ImVec2 arg0;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetCursorScreenPos");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetCursorScreenPos'", nullptr);
return 0;
}
imgui::ImGui::SetCursorScreenPos(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetCursorScreenPos",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetCursorScreenPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetItemAllowOverlap(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetItemAllowOverlap'", nullptr);
return 0;
}
imgui::ImGui::SetItemAllowOverlap();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetItemAllowOverlap",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetItemAllowOverlap'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetItemDefaultFocus(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetItemDefaultFocus'", nullptr);
return 0;
}
imgui::ImGui::SetItemDefaultFocus();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetItemDefaultFocus",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetItemDefaultFocus'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetKeyboardFocusHere(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetKeyboardFocusHere'", nullptr);
return 0;
}
imgui::ImGui::SetKeyboardFocusHere();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:SetKeyboardFocusHere");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetKeyboardFocusHere'", nullptr);
return 0;
}
imgui::ImGui::SetKeyboardFocusHere(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetKeyboardFocusHere",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetKeyboardFocusHere'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetMouseCursor(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "imgui.ImGui:SetMouseCursor");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetMouseCursor'", nullptr);
return 0;
}
imgui::ImGui::SetMouseCursor(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetMouseCursor",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetMouseCursor'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextItemOpen(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "imgui.ImGui:SetNextItemOpen");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextItemOpen'", nullptr);
return 0;
}
imgui::ImGui::SetNextItemOpen(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
bool arg0;
int arg1;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "imgui.ImGui:SetNextItemOpen");
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:SetNextItemOpen");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextItemOpen'", nullptr);
return 0;
}
imgui::ImGui::SetNextItemOpen(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextItemOpen",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextItemOpen'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextItemWidth(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetNextItemWidth");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextItemWidth'", nullptr);
return 0;
}
imgui::ImGui::SetNextItemWidth(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextItemWidth",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextItemWidth'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowBgAlpha(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetNextWindowBgAlpha");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowBgAlpha'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowBgAlpha(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowBgAlpha",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowBgAlpha'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowCollapsed(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "imgui.ImGui:SetNextWindowCollapsed");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowCollapsed'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowCollapsed(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
bool arg0;
int arg1;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "imgui.ImGui:SetNextWindowCollapsed");
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:SetNextWindowCollapsed");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowCollapsed'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowCollapsed(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowCollapsed",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowCollapsed'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowContentSize(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
ImVec2 arg0;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetNextWindowContentSize");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowContentSize'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowContentSize(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowContentSize",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowContentSize'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowDockID(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
unsigned int arg0;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:SetNextWindowDockID");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowDockID'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowDockID(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
unsigned int arg0;
int arg1;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:SetNextWindowDockID");
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:SetNextWindowDockID");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowDockID'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowDockID(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowDockID",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowDockID'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowFocus(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowFocus'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowFocus();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowFocus",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowFocus'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
ImVec2 arg0;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetNextWindowPos");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowPos'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowPos(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
ImVec2 arg0;
int arg1;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetNextWindowPos");
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:SetNextWindowPos");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowPos'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowPos(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 3)
{
ImVec2 arg0;
int arg1;
ImVec2 arg2;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetNextWindowPos");
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:SetNextWindowPos");
ok &= luaval_to_ImVec2(tolua_S, 4, &arg2, "imgui.ImGui:SetNextWindowPos");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowPos'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowPos(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowPos",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowSize(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
ImVec2 arg0;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetNextWindowSize");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowSize'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowSize(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
ImVec2 arg0;
int arg1;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetNextWindowSize");
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:SetNextWindowSize");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowSize'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowSize(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowSize",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowSize'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowSizeConstraints(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
ImVec2 arg0;
ImVec2 arg1;
ok &= luaval_to_ImVec2(tolua_S, 2, &arg0, "imgui.ImGui:SetNextWindowSizeConstraints");
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:SetNextWindowSizeConstraints");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowSizeConstraints'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowSizeConstraints(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowSizeConstraints",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowSizeConstraints'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetNextWindowViewport(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
unsigned int arg0;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "imgui.ImGui:SetNextWindowViewport");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetNextWindowViewport'", nullptr);
return 0;
}
imgui::ImGui::SetNextWindowViewport(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetNextWindowViewport",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetNextWindowViewport'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetScrollFromPosX(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetScrollFromPosX");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollFromPosX'", nullptr);
return 0;
}
imgui::ImGui::SetScrollFromPosX(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
double arg0;
double arg1;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetScrollFromPosX");
ok &= luaval_to_number(tolua_S, 3,&arg1, "imgui.ImGui:SetScrollFromPosX");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollFromPosX'", nullptr);
return 0;
}
imgui::ImGui::SetScrollFromPosX(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetScrollFromPosX",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetScrollFromPosX'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetScrollFromPosY(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetScrollFromPosY");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollFromPosY'", nullptr);
return 0;
}
imgui::ImGui::SetScrollFromPosY(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
double arg0;
double arg1;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetScrollFromPosY");
ok &= luaval_to_number(tolua_S, 3,&arg1, "imgui.ImGui:SetScrollFromPosY");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollFromPosY'", nullptr);
return 0;
}
imgui::ImGui::SetScrollFromPosY(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetScrollFromPosY",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetScrollFromPosY'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetScrollHereX(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollHereX'", nullptr);
return 0;
}
imgui::ImGui::SetScrollHereX();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetScrollHereX");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollHereX'", nullptr);
return 0;
}
imgui::ImGui::SetScrollHereX(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetScrollHereX",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetScrollHereX'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetScrollHereY(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollHereY'", nullptr);
return 0;
}
imgui::ImGui::SetScrollHereY();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetScrollHereY");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollHereY'", nullptr);
return 0;
}
imgui::ImGui::SetScrollHereY(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetScrollHereY",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetScrollHereY'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetScrollX(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetScrollX");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollX'", nullptr);
return 0;
}
imgui::ImGui::SetScrollX(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetScrollX",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetScrollX'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetScrollY(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetScrollY");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetScrollY'", nullptr);
return 0;
}
imgui::ImGui::SetScrollY(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetScrollY",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetScrollY'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetTabItemClosed(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetTabItemClosed"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetTabItemClosed'", nullptr);
return 0;
}
imgui::ImGui::SetTabItemClosed(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetTabItemClosed",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetTabItemClosed'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetTooltip(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetTooltip"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetTooltip'", nullptr);
return 0;
}
imgui::ImGui::SetTooltip("%s", arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetTooltip",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetTooltip'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetWindowCollapsed(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
bool arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetWindowCollapsed"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "imgui.ImGui:SetWindowCollapsed");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetWindowCollapsed'", nullptr);
return 0;
}
imgui::ImGui::SetWindowCollapsed(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 3)
{
const char* arg0;
bool arg1;
int arg2;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetWindowCollapsed"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_boolean(tolua_S, 3,&arg1, "imgui.ImGui:SetWindowCollapsed");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "imgui.ImGui:SetWindowCollapsed");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetWindowCollapsed'", nullptr);
return 0;
}
imgui::ImGui::SetWindowCollapsed(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetWindowCollapsed",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetWindowCollapsed'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetWindowFocus(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetWindowFocus"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetWindowFocus'", nullptr);
return 0;
}
imgui::ImGui::SetWindowFocus(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetWindowFocus",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetWindowFocus'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetWindowFontScale(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:SetWindowFontScale");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetWindowFontScale'", nullptr);
return 0;
}
imgui::ImGui::SetWindowFontScale(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetWindowFontScale",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetWindowFontScale'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetWindowPos(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
ImVec2 arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetWindowPos"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:SetWindowPos");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetWindowPos'", nullptr);
return 0;
}
imgui::ImGui::SetWindowPos(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 3)
{
const char* arg0;
ImVec2 arg1;
int arg2;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetWindowPos"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:SetWindowPos");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "imgui.ImGui:SetWindowPos");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetWindowPos'", nullptr);
return 0;
}
imgui::ImGui::SetWindowPos(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetWindowPos",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetWindowPos'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SetWindowSize(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
const char* arg0;
ImVec2 arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetWindowSize"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:SetWindowSize");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetWindowSize'", nullptr);
return 0;
}
imgui::ImGui::SetWindowSize(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 3)
{
const char* arg0;
ImVec2 arg1;
int arg2;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SetWindowSize"); arg0 = arg0_tmp.c_str();
ok &= luaval_to_ImVec2(tolua_S, 3, &arg1, "imgui.ImGui:SetWindowSize");
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2, "imgui.ImGui:SetWindowSize");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SetWindowSize'", nullptr);
return 0;
}
imgui::ImGui::SetWindowSize(arg0, arg1, arg2);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SetWindowSize",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SetWindowSize'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ShowFontSelector(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:ShowFontSelector"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ShowFontSelector'", nullptr);
return 0;
}
imgui::ImGui::ShowFontSelector(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ShowFontSelector",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ShowFontSelector'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ShowStyleSelector(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:ShowStyleSelector"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ShowStyleSelector'", nullptr);
return 0;
}
bool ret = imgui::ImGui::ShowStyleSelector(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ShowStyleSelector",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ShowStyleSelector'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_ShowUserGuide(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_ShowUserGuide'", nullptr);
return 0;
}
imgui::ImGui::ShowUserGuide();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:ShowUserGuide",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_ShowUserGuide'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_SmallButton(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:SmallButton"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_SmallButton'", nullptr);
return 0;
}
bool ret = imgui::ImGui::SmallButton(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:SmallButton",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_SmallButton'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Spacing(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Spacing'", nullptr);
return 0;
}
imgui::ImGui::Spacing();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Spacing",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Spacing'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Text(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:Text"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Text'", nullptr);
return 0;
}
imgui::ImGui::Text("%s", arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Text",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Text'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_TextColored(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
ImVec4 arg0;
const char* arg1;
ok &= luaval_to_ImVec4(tolua_S, 2, &arg0, "imgui.ImGui:TextColored");
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:TextColored"); arg1 = arg1_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_TextColored'", nullptr);
return 0;
}
imgui::ImGui::TextColored(arg0, "%s", arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:TextColored",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_TextColored'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_TextDisabled(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TextDisabled"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_TextDisabled'", nullptr);
return 0;
}
imgui::ImGui::TextDisabled("%s", arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:TextDisabled",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_TextDisabled'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_TextUnformatted(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TextUnformatted"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_TextUnformatted'", nullptr);
return 0;
}
imgui::ImGui::TextUnformatted(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
const char* arg0;
const char* arg1;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TextUnformatted"); arg0 = arg0_tmp.c_str();
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:TextUnformatted"); arg1 = arg1_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_TextUnformatted'", nullptr);
return 0;
}
imgui::ImGui::TextUnformatted(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:TextUnformatted",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_TextUnformatted'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_TextWrapped(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TextWrapped"); arg0 = arg0_tmp.c_str();
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_TextWrapped'", nullptr);
return 0;
}
imgui::ImGui::TextWrapped("%s", arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:TextWrapped",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_TextWrapped'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_TreeNode(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 2)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TreeNode"); arg0 = arg0_tmp.c_str();
if (!ok) { break; }
const char* arg1;
std::string arg1_tmp; ok &= luaval_to_std_string(tolua_S, 3, &arg1_tmp, "imgui.ImGui:TreeNode"); arg1 = arg1_tmp.c_str();
if (!ok) { break; }
bool ret = imgui::ImGui::TreeNode(arg0, "%s", arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TreeNode"); arg0 = arg0_tmp.c_str();
if (!ok) { break; }
bool ret = imgui::ImGui::TreeNode(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "imgui.ImGui:TreeNode",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_TreeNode'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_TreeNodeEx(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 3)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TreeNodeEx"); arg0 = arg0_tmp.c_str();
if (!ok) { break; }
int arg1;
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:TreeNodeEx");
if (!ok) { break; }
const char* arg2;
std::string arg2_tmp; ok &= luaval_to_std_string(tolua_S, 4, &arg2_tmp, "imgui.ImGui:TreeNodeEx"); arg2 = arg2_tmp.c_str();
if (!ok) { break; }
bool ret = imgui::ImGui::TreeNodeEx(arg0, arg1, "%s", arg2);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TreeNodeEx"); arg0 = arg0_tmp.c_str();
if (!ok) { break; }
bool ret = imgui::ImGui::TreeNodeEx(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 2)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TreeNodeEx"); arg0 = arg0_tmp.c_str();
if (!ok) { break; }
int arg1;
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1, "imgui.ImGui:TreeNodeEx");
if (!ok) { break; }
bool ret = imgui::ImGui::TreeNodeEx(arg0, arg1);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "imgui.ImGui:TreeNodeEx",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_TreeNodeEx'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_TreePop(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_TreePop'", nullptr);
return 0;
}
imgui::ImGui::TreePop();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:TreePop",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_TreePop'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_TreePush(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S)-1;
do
{
if (argc == 0)
{
imgui::ImGui::TreePush();
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
do
{
if (argc == 1)
{
const char* arg0;
std::string arg0_tmp; ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "imgui.ImGui:TreePush"); arg0 = arg0_tmp.c_str();
if (!ok) { break; }
imgui::ImGui::TreePush(arg0);
lua_settop(tolua_S, 1);
return 1;
}
} while (0);
ok = true;
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "imgui.ImGui:TreePush",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_TreePush'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_Unindent(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Unindent'", nullptr);
return 0;
}
imgui::ImGui::Unindent();
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 1)
{
double arg0;
ok &= luaval_to_number(tolua_S, 2,&arg0, "imgui.ImGui:Unindent");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_Unindent'", nullptr);
return 0;
}
imgui::ImGui::Unindent(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:Unindent",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_Unindent'.",&tolua_err);
#endif
return 0;
}
int lua_x_imgui_ImGui_UpdatePlatformWindows(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"imgui.ImGui",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_x_imgui_ImGui_UpdatePlatformWindows'", nullptr);
return 0;
}
imgui::ImGui::UpdatePlatformWindows();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "imgui.ImGui:UpdatePlatformWindows",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_x_imgui_ImGui_UpdatePlatformWindows'.",&tolua_err);
#endif
return 0;
}
static int lua_x_imgui_ImGui_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (ImGui)");
return 0;
}
std::vector<luaL_Reg> register_all_x_imgui(lua_State* tolua_S)
{
std::vector<luaL_Reg> f = {
{ "destroyPlatformWindows", lua_x_imgui_ImGui_DestroyPlatformWindows },
{ "showUserGuide", lua_x_imgui_ImGui_ShowUserGuide },
{ "beginTooltip", lua_x_imgui_ImGui_BeginTooltip },
{ "isItemEdited", lua_x_imgui_ImGui_IsItemEdited },
{ "setScrollHereY", lua_x_imgui_ImGui_SetScrollHereY },
{ "setScrollHereX", lua_x_imgui_ImGui_SetScrollHereX },
{ "getBackgroundDrawList", lua_x_imgui_ImGui_GetBackgroundDrawList },
{ "isKeyPressed", lua_x_imgui_ImGui_IsKeyPressed },
{ "endTabBar", lua_x_imgui_ImGui_EndTabBar },
{ "endTabItem", lua_x_imgui_ImGui_EndTabItem },
{ "setWindowPos", lua_x_imgui_ImGui_SetWindowPos },
{ "beginPopupContextWindow", lua_x_imgui_ImGui_BeginPopupContextWindow },
{ "setColumnOffset", lua_x_imgui_ImGui_SetColumnOffset },
{ "isMouseDoubleClicked", lua_x_imgui_ImGui_IsMouseDoubleClicked },
{ "getFontTexUvWhitePixel", lua_x_imgui_ImGui_GetFontTexUvWhitePixel },
{ "labelText", lua_x_imgui_ImGui_LabelText },
{ "textWrapped", lua_x_imgui_ImGui_TextWrapped },
{ "getTime", lua_x_imgui_ImGui_GetTime },
{ "endTooltip", lua_x_imgui_ImGui_EndTooltip },
{ "getScrollMaxX", lua_x_imgui_ImGui_GetScrollMaxX },
{ "getScrollMaxY", lua_x_imgui_ImGui_GetScrollMaxY },
{ "endMainMenuBar", lua_x_imgui_ImGui_EndMainMenuBar },
{ "nextColumn", lua_x_imgui_ImGui_NextColumn },
{ "loadIniSettingsFromDisk", lua_x_imgui_ImGui_LoadIniSettingsFromDisk },
{ "findViewportByID", lua_x_imgui_ImGui_FindViewportByID },
{ "getContentRegionAvail", lua_x_imgui_ImGui_GetContentRegionAvail },
{ "isRectVisible", lua_x_imgui_ImGui_IsRectVisible },
{ "getCursorPos", lua_x_imgui_ImGui_GetCursorPos },
{ "getTextLineHeight", lua_x_imgui_ImGui_GetTextLineHeight },
{ "indent", lua_x_imgui_ImGui_Indent },
{ "endMenu", lua_x_imgui_ImGui_EndMenu },
{ "getCursorScreenPos", lua_x_imgui_ImGui_GetCursorScreenPos },
{ "openPopup", lua_x_imgui_ImGui_OpenPopup },
{ "getItemRectMax", lua_x_imgui_ImGui_GetItemRectMax },
{ "treeNodeEx", lua_x_imgui_ImGui_TreeNodeEx },
{ "setScrollX", lua_x_imgui_ImGui_SetScrollX },
{ "getStyleColorName", lua_x_imgui_ImGui_GetStyleColorName },
{ "getWindowViewport", lua_x_imgui_ImGui_GetWindowViewport },
{ "setTabItemClosed", lua_x_imgui_ImGui_SetTabItemClosed },
{ "logText", lua_x_imgui_ImGui_LogText },
{ "getWindowDpiScale", lua_x_imgui_ImGui_GetWindowDpiScale },
{ "setWindowFontScale", lua_x_imgui_ImGui_SetWindowFontScale },
{ "isMouseHoveringRect", lua_x_imgui_ImGui_IsMouseHoveringRect },
{ "isItemHovered", lua_x_imgui_ImGui_IsItemHovered },
{ "setScrollY", lua_x_imgui_ImGui_SetScrollY },
{ "getFontSize", lua_x_imgui_ImGui_GetFontSize },
{ "getWindowSize", lua_x_imgui_ImGui_GetWindowSize },
{ "render", lua_x_imgui_ImGui_Render },
{ "colorConvertFloat4ToU32", lua_x_imgui_ImGui_ColorConvertFloat4ToU32 },
{ "isItemDeactivatedAfterEdit", lua_x_imgui_ImGui_IsItemDeactivatedAfterEdit },
{ "colorConvertU32ToFloat4", lua_x_imgui_ImGui_ColorConvertU32ToFloat4 },
{ "getMouseDragDelta", lua_x_imgui_ImGui_GetMouseDragDelta },
{ "renderPlatformWindowsDefault", lua_x_imgui_ImGui_RenderPlatformWindowsDefault },
{ "getColumnsCount", lua_x_imgui_ImGui_GetColumnsCount },
{ "setColorEditOptions", lua_x_imgui_ImGui_SetColorEditOptions },
{ "endPopup", lua_x_imgui_ImGui_EndPopup },
{ "getWindowContentRegionMax", lua_x_imgui_ImGui_GetWindowContentRegionMax },
{ "loadIniSettingsFromMemory", lua_x_imgui_ImGui_LoadIniSettingsFromMemory },
{ "getColumnIndex", lua_x_imgui_ImGui_GetColumnIndex },
{ "setColumnWidth", lua_x_imgui_ImGui_SetColumnWidth },
{ "isMouseClicked", lua_x_imgui_ImGui_IsMouseClicked },
{ "getItemRectSize", lua_x_imgui_ImGui_GetItemRectSize },
{ "getWindowContentRegionMin", lua_x_imgui_ImGui_GetWindowContentRegionMin },
{ "popFont", lua_x_imgui_ImGui_PopFont },
{ "popButtonRepeat", lua_x_imgui_ImGui_PopButtonRepeat },
{ "beginMainMenuBar", lua_x_imgui_ImGui_BeginMainMenuBar },
{ "textDisabled", lua_x_imgui_ImGui_TextDisabled },
{ "setNextItemWidth", lua_x_imgui_ImGui_SetNextItemWidth },
{ "beginMenuBar", lua_x_imgui_ImGui_BeginMenuBar },
{ "beginPopupContextVoid", lua_x_imgui_ImGui_BeginPopupContextVoid },
{ "popStyleVar", lua_x_imgui_ImGui_PopStyleVar },
{ "getClipboardText", lua_x_imgui_ImGui_GetClipboardText },
{ "getMouseCursor", lua_x_imgui_ImGui_GetMouseCursor },
{ "setTooltip", lua_x_imgui_ImGui_SetTooltip },
{ "isItemActivated", lua_x_imgui_ImGui_IsItemActivated },
{ "logToFile", lua_x_imgui_ImGui_LogToFile },
{ "getFrameCount", lua_x_imgui_ImGui_GetFrameCount },
{ "calcItemWidth", lua_x_imgui_ImGui_CalcItemWidth },
{ "pushButtonRepeat", lua_x_imgui_ImGui_PushButtonRepeat },
{ "smallButton", lua_x_imgui_ImGui_SmallButton },
{ "setNextWindowFocus", lua_x_imgui_ImGui_SetNextWindowFocus },
{ "isWindowAppearing", lua_x_imgui_ImGui_IsWindowAppearing },
{ "closeCurrentPopup", lua_x_imgui_ImGui_CloseCurrentPopup },
{ "getColumnOffset", lua_x_imgui_ImGui_GetColumnOffset },
{ "isItemToggledOpen", lua_x_imgui_ImGui_IsItemToggledOpen },
{ "dummy", lua_x_imgui_ImGui_Dummy },
{ "setWindowCollapsed", lua_x_imgui_ImGui_SetWindowCollapsed },
{ "popItemWidth", lua_x_imgui_ImGui_PopItemWidth },
{ "getKeyIndex", lua_x_imgui_ImGui_GetKeyIndex },
{ "pushItemWidth", lua_x_imgui_ImGui_PushItemWidth },
{ "logButtons", lua_x_imgui_ImGui_LogButtons },
{ "separator", lua_x_imgui_ImGui_Separator },
{ "isAnyMouseDown", lua_x_imgui_ImGui_IsAnyMouseDown },
{ "getScrollY", lua_x_imgui_ImGui_GetScrollY },
{ "getScrollX", lua_x_imgui_ImGui_GetScrollX },
{ "getForegroundDrawList", lua_x_imgui_ImGui_GetForegroundDrawList },
{ "isMouseReleased", lua_x_imgui_ImGui_IsMouseReleased },
{ "openPopupContextItem", lua_x_imgui_ImGui_OpenPopupContextItem },
{ "pushTextWrapPos", lua_x_imgui_ImGui_PushTextWrapPos },
{ "setNextWindowSize", lua_x_imgui_ImGui_SetNextWindowSize },
{ "showStyleSelector", lua_x_imgui_ImGui_ShowStyleSelector },
{ "setNextWindowContentSize", lua_x_imgui_ImGui_SetNextWindowContentSize },
{ "getWindowContentRegionWidth", lua_x_imgui_ImGui_GetWindowContentRegionWidth },
{ "getTreeNodeToLabelSpacing", lua_x_imgui_ImGui_GetTreeNodeToLabelSpacing },
{ "getTextLineHeightWithSpacing", lua_x_imgui_ImGui_GetTextLineHeightWithSpacing },
{ "popAllowKeyboardFocus", lua_x_imgui_ImGui_PopAllowKeyboardFocus },
{ "radioButton", lua_x_imgui_ImGui_RadioButton },
{ "progressBar", lua_x_imgui_ImGui_ProgressBar },
{ "calcTextSize", lua_x_imgui_ImGui_CalcTextSize },
{ "endMenuBar", lua_x_imgui_ImGui_EndMenuBar },
{ "sameLine", lua_x_imgui_ImGui_SameLine },
{ "debugCheckVersionAndDataLayout", lua_x_imgui_ImGui_DebugCheckVersionAndDataLayout },
{ "popStyleColor", lua_x_imgui_ImGui_PopStyleColor },
{ "arrowButton", lua_x_imgui_ImGui_ArrowButton },
{ "getVersion", lua_x_imgui_ImGui_GetVersion },
{ "setMouseCursor", lua_x_imgui_ImGui_SetMouseCursor },
{ "resetMouseDragDelta", lua_x_imgui_ImGui_ResetMouseDragDelta },
{ "dockSpaceOverViewport", lua_x_imgui_ImGui_DockSpaceOverViewport },
{ "getItemRectMin", lua_x_imgui_ImGui_GetItemRectMin },
{ "beginPopupContextItem", lua_x_imgui_ImGui_BeginPopupContextItem },
{ "newLine", lua_x_imgui_ImGui_NewLine },
{ "isAnyItemFocused", lua_x_imgui_ImGui_IsAnyItemFocused },
{ "isItemFocused", lua_x_imgui_ImGui_IsItemFocused },
{ "isWindowHovered", lua_x_imgui_ImGui_IsWindowHovered },
{ "logFinish", lua_x_imgui_ImGui_LogFinish },
{ "popClipRect", lua_x_imgui_ImGui_PopClipRect },
{ "logToClipboard", lua_x_imgui_ImGui_LogToClipboard },
{ "pushClipRect", lua_x_imgui_ImGui_PushClipRect },
{ "columns", lua_x_imgui_ImGui_Columns },
{ "isKeyReleased", lua_x_imgui_ImGui_IsKeyReleased },
{ "setScrollFromPosX", lua_x_imgui_ImGui_SetScrollFromPosX },
{ "setScrollFromPosY", lua_x_imgui_ImGui_SetScrollFromPosY },
{ "setNextWindowDockID", lua_x_imgui_ImGui_SetNextWindowDockID },
{ "getWindowWidth", lua_x_imgui_ImGui_GetWindowWidth },
{ "popID", lua_x_imgui_ImGui_PopID },
{ "dockSpace", lua_x_imgui_ImGui_DockSpace },
{ "setItemDefaultFocus", lua_x_imgui_ImGui_SetItemDefaultFocus },
{ "isWindowCollapsed", lua_x_imgui_ImGui_IsWindowCollapsed },
{ "updatePlatformWindows", lua_x_imgui_ImGui_UpdatePlatformWindows },
{ "isMouseDown", lua_x_imgui_ImGui_IsMouseDown },
{ "isItemActive", lua_x_imgui_ImGui_IsItemActive },
{ "unindent", lua_x_imgui_ImGui_Unindent },
{ "treeNode", lua_x_imgui_ImGui_TreeNode },
{ "bullet", lua_x_imgui_ImGui_Bullet },
{ "isKeyDown", lua_x_imgui_ImGui_IsKeyDown },
{ "setNextItemOpen", lua_x_imgui_ImGui_SetNextItemOpen },
{ "getCursorStartPos", lua_x_imgui_ImGui_GetCursorStartPos },
{ "beginGroup", lua_x_imgui_ImGui_BeginGroup },
{ "isAnyItemActive", lua_x_imgui_ImGui_IsAnyItemActive },
{ "treePop", lua_x_imgui_ImGui_TreePop },
{ "beginPopup", lua_x_imgui_ImGui_BeginPopup },
{ "setNextWindowPos", lua_x_imgui_ImGui_SetNextWindowPos },
{ "setNextWindowSizeConstraints", lua_x_imgui_ImGui_SetNextWindowSizeConstraints },
{ "beginDragDropTarget", lua_x_imgui_ImGui_BeginDragDropTarget },
{ "showFontSelector", lua_x_imgui_ImGui_ShowFontSelector },
{ "colorButton", lua_x_imgui_ImGui_ColorButton },
{ "beginDragDropSource", lua_x_imgui_ImGui_BeginDragDropSource },
{ "setWindowFocus", lua_x_imgui_ImGui_SetWindowFocus },
{ "popTextWrapPos", lua_x_imgui_ImGui_PopTextWrapPos },
{ "endDragDropTarget", lua_x_imgui_ImGui_EndDragDropTarget },
{ "beginCombo", lua_x_imgui_ImGui_BeginCombo },
{ "text", lua_x_imgui_ImGui_Text },
{ "getMainViewport", lua_x_imgui_ImGui_GetMainViewport },
{ "endGroup", lua_x_imgui_ImGui_EndGroup },
{ "setNextWindowBgAlpha", lua_x_imgui_ImGui_SetNextWindowBgAlpha },
{ "captureMouseFromApp", lua_x_imgui_ImGui_CaptureMouseFromApp },
{ "isItemClicked", lua_x_imgui_ImGui_IsItemClicked },
{ "setItemAllowOverlap", lua_x_imgui_ImGui_SetItemAllowOverlap },
{ "getContentRegionMax", lua_x_imgui_ImGui_GetContentRegionMax },
{ "invisibleButton", lua_x_imgui_ImGui_InvisibleButton },
{ "captureKeyboardFromApp", lua_x_imgui_ImGui_CaptureKeyboardFromApp },
{ "isPopupOpen", lua_x_imgui_ImGui_IsPopupOpen },
{ "setCursorScreenPos", lua_x_imgui_ImGui_SetCursorScreenPos },
{ "setKeyboardFocusHere", lua_x_imgui_ImGui_SetKeyboardFocusHere },
{ "isMouseDragging", lua_x_imgui_ImGui_IsMouseDragging },
{ "textColored", lua_x_imgui_ImGui_TextColored },
{ "getKeyPressedAmount", lua_x_imgui_ImGui_GetKeyPressedAmount },
{ "setClipboardText", lua_x_imgui_ImGui_SetClipboardText },
{ "alignTextToFramePadding", lua_x_imgui_ImGui_AlignTextToFramePadding },
{ "getFrameHeight", lua_x_imgui_ImGui_GetFrameHeight },
{ "bulletText", lua_x_imgui_ImGui_BulletText },
{ "setNextWindowCollapsed", lua_x_imgui_ImGui_SetNextWindowCollapsed },
{ "spacing", lua_x_imgui_ImGui_Spacing },
{ "listBoxFooter", lua_x_imgui_ImGui_ListBoxFooter },
{ "getCursorPosY", lua_x_imgui_ImGui_GetCursorPosY },
{ "getCursorPosX", lua_x_imgui_ImGui_GetCursorPosX },
{ "getWindowPos", lua_x_imgui_ImGui_GetWindowPos },
{ "endCombo", lua_x_imgui_ImGui_EndCombo },
{ "getWindowHeight", lua_x_imgui_ImGui_GetWindowHeight },
{ "endChildFrame", lua_x_imgui_ImGui_EndChildFrame },
{ "isItemVisible", lua_x_imgui_ImGui_IsItemVisible },
{ "beginTabBar", lua_x_imgui_ImGui_BeginTabBar },
{ "treePush", lua_x_imgui_ImGui_TreePush },
{ "setWindowSize", lua_x_imgui_ImGui_SetWindowSize },
{ "getColumnWidth", lua_x_imgui_ImGui_GetColumnWidth },
{ "saveIniSettingsToDisk", lua_x_imgui_ImGui_SaveIniSettingsToDisk },
{ "button", lua_x_imgui_ImGui_Button },
{ "getWindowDrawList", lua_x_imgui_ImGui_GetWindowDrawList },
{ "getMousePos", lua_x_imgui_ImGui_GetMousePos },
{ "getMousePosOnOpeningCurrentPopup", lua_x_imgui_ImGui_GetMousePosOnOpeningCurrentPopup },
{ "isWindowFocused", lua_x_imgui_ImGui_IsWindowFocused },
{ "isWindowDocked", lua_x_imgui_ImGui_IsWindowDocked },
{ "pushAllowKeyboardFocus", lua_x_imgui_ImGui_PushAllowKeyboardFocus },
{ "setCursorPos", lua_x_imgui_ImGui_SetCursorPos },
{ "getWindowDockID", lua_x_imgui_ImGui_GetWindowDockID },
{ "isAnyItemHovered", lua_x_imgui_ImGui_IsAnyItemHovered },
{ "setCursorPosY", lua_x_imgui_ImGui_SetCursorPosY },
{ "setCursorPosX", lua_x_imgui_ImGui_SetCursorPosX },
{ "textUnformatted", lua_x_imgui_ImGui_TextUnformatted },
{ "getFrameHeightWithSpacing", lua_x_imgui_ImGui_GetFrameHeightWithSpacing },
{ "logToTTY", lua_x_imgui_ImGui_LogToTTY },
{ "endFrame", lua_x_imgui_ImGui_EndFrame },
{ "beginMenu", lua_x_imgui_ImGui_BeginMenu },
{ "getID", lua_x_imgui_ImGui_GetID },
{ "isItemDeactivated", lua_x_imgui_ImGui_IsItemDeactivated },
{ "setNextWindowViewport", lua_x_imgui_ImGui_SetNextWindowViewport },
{ "getStyleColorVec4", lua_x_imgui_ImGui_GetStyleColorVec4 },
{ "endDragDropSource", lua_x_imgui_ImGui_EndDragDropSource },
{ "newFrame", lua_x_imgui_ImGui_NewFrame },
{ "beginChildFrame", lua_x_imgui_ImGui_BeginChildFrame },
};
return f;
}
| 29.645899 | 151 | 0.641445 | [
"render",
"object",
"vector"
] |
0d1d880eef372f2d3230754052ffa97b653ae57e | 3,138 | cpp | C++ | v3d_main/neuron_annotator/utility/Icons.cpp | lens-biophotonics/v3d_external | 44ff3b60a297a96eaa77ca092e0de9af5c990ed3 | [
"MIT"
] | 39 | 2015-05-10T23:23:03.000Z | 2022-01-26T01:31:30.000Z | v3d_main/neuron_annotator/utility/Icons.cpp | lens-biophotonics/v3d_external | 44ff3b60a297a96eaa77ca092e0de9af5c990ed3 | [
"MIT"
] | 13 | 2016-03-04T05:29:23.000Z | 2021-02-07T01:11:10.000Z | v3d_main/neuron_annotator/utility/Icons.cpp | lens-biophotonics/v3d_external | 44ff3b60a297a96eaa77ca092e0de9af5c990ed3 | [
"MIT"
] | 44 | 2015-11-11T07:30:59.000Z | 2021-12-26T16:41:21.000Z | #include "Icons.h"
#include "../entity_model/Entity.h"
Icons::Icons()
{
}
QVariant Icons::getCachedIcon(const QString & filename)
{
if (cache.contains(filename)) return cache.value(filename, QVariant());
QString path = ":/neuron_annotator/resources/";
path.append(filename);
QIcon icon(path);
cache.insert(filename, icon);
return icon;
}
//---------------------------------------------------------------------------------------
// Static functions
//---------------------------------------------------------------------------------------
Icons &Icons::get()
{
static Icons obj;
return obj;
}
QVariant Icons::getIcon(const QString & filename)
{
return get().getCachedIcon(filename);
}
QVariant Icons::getOntologyIcon(Entity *entity)
{
QString termType = entity->getValueByAttributeName("Ontology Term Type");
if (termType=="Category")
return getIcon("folder.png");
else if (termType=="Enum")
return getIcon("folder_page.png");
else if (termType=="Interval")
return getIcon("page_white_code.png");
else if (termType=="Tag")
return getIcon("page_white.png");
else if (termType=="Text")
return getIcon("page_white_text.png");
else if (termType=="EnumItem")
return getIcon("page.png");
else if (termType=="EnumText")
return getIcon("page_go.png");
return QVariant();
}
QVariant Icons::getIcon(Entity *entity)
{
QString type = *entity->entityType;
if (type=="Folder") {
return getIcon("folder.png");
}
else if (type=="Sample" || type=="Screen Sample") {
return getIcon("beaker.png");
}
else if (type=="Supporting Data") {
return getIcon("folder_page.png");
}
else if (type=="Sample Processing Result") {
return getIcon("folder_image.png");
}
else if (type=="Alignment Result") {
return getIcon("folder_image.png");
}
else if (type=="Neuron Separator Pipeline Result") {
return getIcon("bricks.png");
}
else if (type=="LSM Stack Pair") {
return getIcon("page_copy.png");
}
else if (type=="Tif 2D Image" || type=="Image 2D") {
return getIcon("image.png");
}
else if (type=="Text File") {
return getIcon("page_white.png");
}
else if (type=="Image 3D" || type=="Tif 3D Image" || type=="LSM Stack" || type=="Tif 3D Label Mask" || type=="Stitched V3D Raw Stack" || type=="Aligned Brain Stack") {
return getIcon("images.png");
}
else if (type=="Neuron Fragment"||type=="Curated Neuron") {
return getIcon("brick.png");
}
else if (type=="Neuron Fragment Collection"||type=="Curated Neuron Collection") {
return getIcon("folder_brick.png");
}
else if (type=="Ontology Element" || type=="Ontology Root") {
return getOntologyIcon(entity);
}
else if (type=="Annotation") {
return getIcon("page_white_edit.png");
}
else if (type=="Annotation") {
return getIcon("fruit_fly_small.png");
}
// return QVariant(); // blank icon
return getIcon("bullet_error.png");
}
| 27.286957 | 171 | 0.578713 | [
"3d"
] |
0d1f04079ed2c2755b040572e919be371b11c198 | 6,965 | cc | C++ | third_party/blink/renderer/core/frame/remote_frame_client_impl.cc | zipated/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | third_party/blink/renderer/core/frame/remote_frame_client_impl.cc | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | third_party/blink/renderer/core/frame/remote_frame_client_impl.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 "third_party/blink/renderer/core/frame/remote_frame_client_impl.h"
#include <memory>
#include "third_party/blink/public/web/web_remote_frame_client.h"
#include "third_party/blink/renderer/core/events/keyboard_event.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/core/events/web_input_event_conversion.h"
#include "third_party/blink/renderer/core/events/wheel_event.h"
#include "third_party/blink/renderer/core/exported/web_remote_frame_impl.h"
#include "third_party/blink/renderer/core/frame/remote_frame.h"
#include "third_party/blink/renderer/core/frame/remote_frame_view.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h"
#include "third_party/blink/renderer/platform/geometry/int_rect.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
namespace blink {
namespace {
// Convenience helper for frame tree helpers in FrameClient to reduce the amount
// of null-checking boilerplate code. Since the frame tree is maintained in the
// web/ layer, the frame tree helpers often have to deal with null WebFrames:
// for example, a frame with no parent will return null for WebFrame::parent().
// TODO(dcheng): Remove duplication between LocalFrameClientImpl and
// RemoteFrameClientImpl somehow...
Frame* ToCoreFrame(WebFrame* frame) {
return frame ? WebFrame::ToCoreFrame(*frame) : nullptr;
}
} // namespace
RemoteFrameClientImpl::RemoteFrameClientImpl(WebRemoteFrameImpl* web_frame)
: web_frame_(web_frame) {}
RemoteFrameClientImpl* RemoteFrameClientImpl::Create(
WebRemoteFrameImpl* web_frame) {
return new RemoteFrameClientImpl(web_frame);
}
void RemoteFrameClientImpl::Trace(blink::Visitor* visitor) {
visitor->Trace(web_frame_);
RemoteFrameClient::Trace(visitor);
}
bool RemoteFrameClientImpl::InShadowTree() const {
return web_frame_->InShadowTree();
}
void RemoteFrameClientImpl::Detached(FrameDetachType type) {
// Alert the client that the frame is being detached.
WebRemoteFrameClient* client = web_frame_->Client();
if (!client)
return;
client->FrameDetached(static_cast<WebRemoteFrameClient::DetachType>(type));
if (type == FrameDetachType::kRemove)
web_frame_->DetachFromParent();
// Clear our reference to RemoteFrame at the very end, in case the client
// refers to it.
web_frame_->SetCoreFrame(nullptr);
}
Frame* RemoteFrameClientImpl::Opener() const {
return ToCoreFrame(web_frame_->Opener());
}
void RemoteFrameClientImpl::SetOpener(Frame* opener) {
WebFrame* opener_frame = WebFrame::FromFrame(opener);
if (web_frame_->Client() && web_frame_->Opener() != opener_frame)
web_frame_->Client()->DidChangeOpener(opener_frame);
web_frame_->SetOpener(opener_frame);
}
Frame* RemoteFrameClientImpl::Parent() const {
return ToCoreFrame(web_frame_->Parent());
}
Frame* RemoteFrameClientImpl::Top() const {
return ToCoreFrame(web_frame_->Top());
}
Frame* RemoteFrameClientImpl::NextSibling() const {
return ToCoreFrame(web_frame_->NextSibling());
}
Frame* RemoteFrameClientImpl::FirstChild() const {
return ToCoreFrame(web_frame_->FirstChild());
}
void RemoteFrameClientImpl::FrameFocused() const {
if (web_frame_->Client())
web_frame_->Client()->FrameFocused();
}
base::UnguessableToken RemoteFrameClientImpl::GetDevToolsFrameToken() const {
if (web_frame_->Client()) {
return web_frame_->Client()->GetDevToolsFrameToken();
}
return base::UnguessableToken::Create();
}
void RemoteFrameClientImpl::Navigate(
const ResourceRequest& request,
bool should_replace_current_entry,
mojom::blink::BlobURLTokenPtr blob_url_token) {
if (web_frame_->Client()) {
web_frame_->Client()->Navigate(WrappedResourceRequest(request),
should_replace_current_entry,
blob_url_token.PassInterface().PassHandle());
}
}
void RemoteFrameClientImpl::Reload(
FrameLoadType load_type,
ClientRedirectPolicy client_redirect_policy) {
DCHECK(IsReloadLoadType(load_type));
if (web_frame_->Client()) {
web_frame_->Client()->Reload(static_cast<WebFrameLoadType>(load_type),
client_redirect_policy);
}
}
unsigned RemoteFrameClientImpl::BackForwardLength() {
// TODO(creis,japhet): This method should return the real value for the
// session history length. For now, return static value for the initial
// navigation and the subsequent one moving the frame out-of-process.
// See https://crbug.com/501116.
return 2;
}
void RemoteFrameClientImpl::CheckCompleted() {
web_frame_->Client()->CheckCompleted();
}
void RemoteFrameClientImpl::ForwardPostMessage(
MessageEvent* event,
scoped_refptr<const SecurityOrigin> target,
LocalFrame* source_frame,
bool has_user_gesture) const {
if (web_frame_->Client()) {
web_frame_->Client()->ForwardPostMessage(
WebLocalFrameImpl::FromFrame(source_frame), web_frame_,
WebSecurityOrigin(std::move(target)), WebDOMMessageEvent(event),
has_user_gesture);
}
}
void RemoteFrameClientImpl::FrameRectsChanged(
const IntRect& local_frame_rect,
const IntRect& screen_space_rect) {
web_frame_->Client()->FrameRectsChanged(local_frame_rect, screen_space_rect);
}
void RemoteFrameClientImpl::UpdateRemoteViewportIntersection(
const IntRect& viewport_intersection) {
web_frame_->Client()->UpdateRemoteViewportIntersection(viewport_intersection);
}
void RemoteFrameClientImpl::AdvanceFocus(WebFocusType type,
LocalFrame* source) {
web_frame_->Client()->AdvanceFocus(type,
WebLocalFrameImpl::FromFrame(source));
}
void RemoteFrameClientImpl::VisibilityChanged(bool visible) {
web_frame_->Client()->VisibilityChanged(visible);
}
void RemoteFrameClientImpl::SetIsInert(bool inert) {
web_frame_->Client()->SetIsInert(inert);
}
void RemoteFrameClientImpl::SetInheritedEffectiveTouchAction(
TouchAction touch_action) {
web_frame_->Client()->SetInheritedEffectiveTouchAction(touch_action);
}
void RemoteFrameClientImpl::UpdateRenderThrottlingStatus(
bool is_throttled,
bool subtree_throttled) {
web_frame_->Client()->UpdateRenderThrottlingStatus(is_throttled,
subtree_throttled);
}
uint32_t RemoteFrameClientImpl::Print(const IntRect& rect,
WebCanvas* canvas) const {
return web_frame_->Client()->Print(rect, canvas);
}
} // namespace blink
| 34.825 | 82 | 0.746447 | [
"geometry"
] |
0d2692903dd6b7952285b851b63db11bd9daab5a | 1,228 | cc | C++ | kernel/disk.cc | Anton-Cao/sv6 | f525c4d588d3cfe750867990902b882cd4a21fad | [
"MIT-0"
] | 147 | 2015-01-13T08:56:18.000Z | 2022-03-10T06:49:25.000Z | kernel/disk.cc | Anton-Cao/sv6 | f525c4d588d3cfe750867990902b882cd4a21fad | [
"MIT-0"
] | 1 | 2018-05-12T11:46:14.000Z | 2018-05-12T11:46:14.000Z | kernel/disk.cc | Anton-Cao/sv6 | f525c4d588d3cfe750867990902b882cd4a21fad | [
"MIT-0"
] | 34 | 2015-01-06T12:36:58.000Z | 2021-09-23T17:56:22.000Z | #include "types.h"
#include "kernel.hh"
#include "disk.hh"
#include "vector.hh"
#include <cstring>
static static_vector<disk*, 64> disks;
void
disk_register(disk* d)
{
cprintf("disk_register: %s: %ld bytes: %s\n",
d->dk_busloc, d->dk_nbytes, d->dk_model);
disks.push_back(d);
}
static void
disk_test(disk *d)
{
char buf[512];
cprintf("testing disk %s\n", d->dk_busloc);
cprintf("writing..\n");
memset(buf, 0xab, 512);
d->write(buf, 512, 0);
cprintf("reading..\n");
memset(buf, 0, 512);
d->read(buf, 512, 0x2000);
for (int i = 0; i < 512; i++)
cprintf("%02x ", ((unsigned char*) buf)[i]);
cprintf("\n");
cprintf("flushing..\n");
d->flush();
cprintf("disk_test: test done\n");
}
static void
disk_test_all()
{
for (disk* d : disks) {
disk_test(d);
}
}
//SYSCALL
void
sys_disktest(void)
{
disk_test_all();
}
#if AHCIIDE
// compat for a single IDE disk..
void
ideread(u32 dev, char* data, u64 count, u64 offset)
{
assert(disks.size() > 0);
disks[0]->read(data, count, offset);
}
void
idewrite(u32 dev, const char* data, u64 count, u64 offset)
{
assert(disks.size() > 0);
disks[0]->write(data, count, offset);
}
void initdisk() {}
void ideintr() {}
#endif
| 15.74359 | 58 | 0.620521 | [
"vector"
] |
0d269cdf951ddc1f5f5435876345f930b79adb45 | 3,478 | cpp | C++ | cabot/src/safety/tf_speed_control_nodelet.cpp | CMU-cabot/cabot | b53874abd2804f23f62dcc8ff97a5ee39d3fe48c | [
"MIT"
] | 14 | 2020-12-05T17:15:57.000Z | 2022-02-09T05:51:09.000Z | cabot/src/safety/tf_speed_control_nodelet.cpp | CMU-cabot/cabot | b53874abd2804f23f62dcc8ff97a5ee39d3fe48c | [
"MIT"
] | 22 | 2021-02-25T06:56:23.000Z | 2022-03-16T13:15:45.000Z | cabot/src/safety/tf_speed_control_nodelet.cpp | CMU-cabot/cabot | b53874abd2804f23f62dcc8ff97a5ee39d3fe48c | [
"MIT"
] | 7 | 2021-01-05T16:07:59.000Z | 2022-03-24T02:48:14.000Z | // Copyright (c) 2020 Carnegie Mellon University
//
// 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.
// tf speed control
// Author: Daisuke Sato <daisukes@cmu.edu>
#include <pluginlib/class_list_macros.h>
#include <nodelet/nodelet.h>
#include <ros/ros.h>
#include <ros/time.h>
#include <geometry_msgs/TransformStamped.h>
#include <std_msgs/Float32.h>
#include <tf2_ros/transform_listener.h>
#include <tf2/utils.h>
#include <boost/thread/thread.hpp>
namespace Safety
{
class TFSpeedControlNodelet : public nodelet::Nodelet
{
public:
std::string limit_topic_;
int check_rate_;
std::string map_frame_;
std::string robot_base_frame_;
ros::Publisher limit_pub_;
tf2_ros::TransformListener *tfListener;
tf2_ros::Buffer tfBuffer;
TFSpeedControlNodelet()
: limit_topic_("tf_limit"),
check_rate_(1),
map_frame_("map"),
robot_base_frame_("base_footprint")
{
NODELET_INFO("TFSpeedControlNodeletClass Constructor");
tfListener = new tf2_ros::TransformListener(tfBuffer);
}
~TFSpeedControlNodelet()
{
NODELET_INFO("TFSpeedControlNodeletClass Destructor");
}
private:
void onInit()
{
NODELET_INFO("tf speed control - %s", __FUNCTION__);
ros::NodeHandle &private_nh = getPrivateNodeHandle();
private_nh.getParam("limit_topic", limit_topic_);
limit_pub_ = private_nh.advertise<std_msgs::Float32>(limit_topic_, 100);
boost::thread thread2(&TFSpeedControlNodelet::tfCheckLoop, this, check_rate_);
}
void tfCheckLoop(int checkRate)
{
ros::Rate loopRate(checkRate);
while (ros::ok())
{
double speed_limit = 1.0;
try
{
geometry_msgs::TransformStamped transform_msg = tfBuffer.lookupTransform(robot_base_frame_, map_frame_,
ros::Time(0), ros::Duration(1.0));
ROS_INFO("TFSpeedControl, lookup transform success");
}
catch (tf2::TransformException &ex)
{
speed_limit = 0.0;
ROS_INFO("TFSpeedControl, lookup transform fail");
}
std_msgs::Float32 msg;
msg.data = speed_limit;
limit_pub_.publish(msg);
loopRate.sleep();
}
}
}; // class TFSpeedControlNodelet
PLUGINLIB_EXPORT_CLASS(Safety::TFSpeedControlNodelet, nodelet::Nodelet)
} // namespace Safety
| 31.333333 | 117 | 0.682289 | [
"transform"
] |
0d274c2fb8d51bd36c5dde6d81c2d6905ec6dbb8 | 1,133 | cpp | C++ | 500-600/565.cpp | Thomaw/Project-Euler | bcad5d8a1fd3ebaa06fa52d92d286607e9372a8d | [
"MIT"
] | null | null | null | 500-600/565.cpp | Thomaw/Project-Euler | bcad5d8a1fd3ebaa06fa52d92d286607e9372a8d | [
"MIT"
] | null | null | null | 500-600/565.cpp | Thomaw/Project-Euler | bcad5d8a1fd3ebaa06fa52d92d286607e9372a8d | [
"MIT"
] | null | null | null | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef unsigned __int64 u64;
typedef unsigned __int128 u128;
#define L 100000000000
#define L1 320000
#define M 2017
#define L2 (L/M)
u64 inv(u64 n,u64 m=M){return n>1?m/n*(m-inv(m%n,m))%m:1;}
unsigned char np[L1],np2[L2];
u64 e[M];
int main() {
vector<pair<u64,u64>> ab;
for(u64 n=2; n<L1; n++) if(!np[n]) {
for(u64 x=n*n; x<L1; x+=n) np[x]=1;
if(n<M)
for(u64 x=(inv(n)*(M-1)%M*n+1)/M; x<L2; x+=n) np2[x]=1;
if(n>M)
for(u64 x=n*n; x<L; x+=n) if((x+1)%M==0) {for(u64 y=(x+1)/M; y<L2; y+=n) np2[y]=1;break;}
for(u64 m=n*n,s=n+1; m<=L; m*=n) if((s+=m)%M==0) {ab.push_back(make_pair(m,n));break;}
}
for(u64 x=1,i=M-1; x<L2; x++,i+=M) if(!np2[x]) ab.push_back(make_pair(i,i));
sort(ab.begin(),ab.end());
u64 s=0;
for(u64 i=0; i<ab.size(); i++) {
u64 a=ab[i].first,b=ab[i].second*a;
s+=a*(L/a)*(L/a+1)/2;
for(u64 c=b; c<=L; c+=b) s-=c;
for(u64 j=i+1; j<ab.size(); j++) {
u64 c=a*ab[j].first; if(c>L) break;
s-=c*(L/c)*(L/c+1)/2;
}
}
cout<<s;
} | 30.621622 | 96 | 0.524272 | [
"vector"
] |
0d29accbcbac25f21d161ccb3438fc94c934c375 | 2,736 | cpp | C++ | shared_from_this/main.cpp | Mizux/snippets | 69c4a5b7e79108824e5fa8a47235c8a36f28295c | [
"Apache-2.0"
] | null | null | null | shared_from_this/main.cpp | Mizux/snippets | 69c4a5b7e79108824e5fa8a47235c8a36f28295c | [
"Apache-2.0"
] | null | null | null | shared_from_this/main.cpp | Mizux/snippets | 69c4a5b7e79108824e5fa8a47235c8a36f28295c | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <memory>
struct Good : std::enable_shared_from_this<Good> {
std::shared_ptr<Good> getptr() { return shared_from_this(); }
~Good() { std::cout << "Good::~Good() called\n"; }
};
struct Base {
std::shared_ptr<Base> getptr() { return std::shared_ptr<Base>(this); }
~Base() { std::cout << "Bad::~Bad() called\n"; }
};
struct IFoo {
virtual ~IFoo() { std::cout << "IFoo::~IFoo() called\n"; }
virtual std::shared_ptr<IFoo> getPtr() = 0;
};
struct FooBase : std::enable_shared_from_this<FooBase>, IFoo {
virtual ~FooBase() { std::cout << "FooBase::~FooBase() called\n"; }
virtual std::shared_ptr<IFoo> getPtr() {
std::cout << "FooBase::getPtr() called\n";
return shared_from_this();
}
};
struct FooDerived : public FooBase {
virtual ~FooDerived() { std::cout << "FooDerived::~FooDerived() called\n"; }
virtual std::shared_ptr<IFoo> getPtr() {
std::cout << "FooDerived::getPtr() called\n";
return shared_from_this();
}
};
int
main() {
{ // Good: the two shared_ptr's share the same object
std::shared_ptr<Good> gp1(new Good);
std::shared_ptr<Good> gp2 = gp1->getptr();
std::cout << "gp2.use_count() = " << gp2.use_count() << '\n';
}
#if 0
{ // Bad, each shared_ptr thinks it's the only owner of the object
std::shared_ptr<Base> bp1(new Base);
std::shared_ptr<Base> bp2 = bp1->getptr();
std::cout << "bp2.use_count() = " << bp2.use_count() << '\n';
} // Ultra Bad: double-delete of Bad
#endif
{
std::shared_ptr<IFoo> fooPtr =
std::make_shared<FooDerived>(); // FooDerived Instantiate...
std::shared_ptr<IFoo> foo2Ptr = fooPtr->getPtr();
std::shared_ptr<FooDerived> foo3Ptr =
std::static_pointer_cast<FooDerived>(fooPtr->getPtr()); // BAD but WORK
std::shared_ptr<FooDerived> foo4Ptr =
std::dynamic_pointer_cast<FooDerived>(fooPtr->getPtr()); // OK
std::cout << "foo2Ptr.use_count() = " << foo2Ptr.use_count() << '\n'; // 4
std::cout << "foo3Ptr.use_count() = " << foo3Ptr.use_count() << '\n'; // 4
std::cout << "foo4Ptr.use_count() = " << foo4Ptr.use_count() << '\n'; // 4
}
{
std::shared_ptr<IFoo> fooPtr =
std::make_shared<FooBase>(); // /!\ FooBase intantiate /!\ .
std::shared_ptr<IFoo> foo2Ptr = fooPtr->getPtr();
std::shared_ptr<FooDerived> foo3Ptr = std::static_pointer_cast<FooDerived>(
fooPtr->getPtr()); // BAD could crash later on call
std::shared_ptr<FooDerived> foo4Ptr = std::dynamic_pointer_cast<FooDerived>(
fooPtr->getPtr()); // OK foo4Ptr will be empty
std::cout << "foo2Ptr.use_count() = " << foo2Ptr.use_count() << '\n'; // 3
std::cout << "foo3Ptr.use_count() = " << foo3Ptr.use_count() << '\n'; // 3
std::cout << "foo4Ptr.use_count() = " << foo4Ptr.use_count() << '\n'; // 0
}
}
| 36 | 78 | 0.634137 | [
"object"
] |
0d3869cf84c39574d37cf624824973d1880eb982 | 2,225 | cpp | C++ | Source/ANGLE/common/string_utils.cpp | wpbest/xpf | cb54ad82a8c6f675f2d5bc840a78f66f03de65e2 | [
"MIT"
] | 2 | 2015-12-12T23:42:56.000Z | 2019-08-06T04:03:54.000Z | Source/ANGLE/common/string_utils.cpp | wpbest/XPF | cb54ad82a8c6f675f2d5bc840a78f66f03de65e2 | [
"MIT"
] | null | null | null | Source/ANGLE/common/string_utils.cpp | wpbest/XPF | cb54ad82a8c6f675f2d5bc840a78f66f03de65e2 | [
"MIT"
] | null | null | null | //
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// string_utils:
// String helper functions.
//
#include "string_utils.h"
#include <fstream>
#include <sstream>
namespace angle
{
void SplitString(const std::string &input,
char delimiter,
std::vector<std::string> *tokensOut)
{
std::istringstream stream(input);
std::string token;
while (std::getline(stream, token, delimiter))
{
if (!token.empty())
{
tokensOut->push_back(token);
}
}
}
void SplitStringAlongWhitespace(const std::string &input,
std::vector<std::string> *tokensOut)
{
const char *delimiters = " \f\n\r\t\v";
std::istringstream stream(input);
std::string line;
while (std::getline(stream, line))
{
size_t prev = 0, pos;
while ((pos = line.find_first_of(delimiters, prev)) != std::string::npos)
{
if (pos > prev)
tokensOut->push_back(line.substr(prev, pos - prev));
prev = pos + 1;
}
if (prev < line.length())
tokensOut->push_back(line.substr(prev, std::string::npos));
}
}
bool HexStringToUInt(const std::string &input, unsigned int *uintOut)
{
unsigned int offset = 0;
if (input.size() >= 2 && input[0] == '0' && input[1] == 'x')
{
offset = 2u;
}
// Simple validity check
if (input.find_first_not_of("0123456789ABCDEFabcdef", offset) != std::string::npos)
{
return false;
}
std::stringstream inStream(input);
inStream >> std::hex >> *uintOut;
return !inStream.fail();
}
bool ReadFileToString(const std::string &path, std::string *stringOut)
{
std::ifstream inFile(path.c_str());
if (inFile.fail())
{
return false;
}
inFile.seekg(0, std::ios::end);
stringOut->reserve(static_cast<std::string::size_type>(inFile.tellg()));
inFile.seekg(0, std::ios::beg);
stringOut->assign(std::istreambuf_iterator<char>(inFile), std::istreambuf_iterator<char>());
return !inFile.fail();
}
}
| 23.924731 | 96 | 0.592809 | [
"vector"
] |
0d3fd41625f464d69ff71624b7acf5f6bb074bf3 | 27,839 | cpp | C++ | vnpy/api/oes/vnoes/generated_files/generated_functions_3.cpp | howyu88/vnpy2 | c8ae445823dc1f71abda1a79fae7d4be3dd92dd4 | [
"MIT"
] | 323 | 2015-11-21T14:45:29.000Z | 2022-03-16T08:54:37.000Z | vnpy/api/oes/vnoes/generated_files/generated_functions_3.cpp | howyu88/vnpy2 | c8ae445823dc1f71abda1a79fae7d4be3dd92dd4 | [
"MIT"
] | 9 | 2017-03-21T08:26:21.000Z | 2021-08-23T06:41:17.000Z | vnpy/api/oes/vnoes/generated_files/generated_functions_3.cpp | howyu88/vnpy2 | c8ae445823dc1f71abda1a79fae7d4be3dd92dd4 | [
"MIT"
] | 148 | 2016-09-26T03:25:39.000Z | 2022-02-06T14:43:48.000Z | #include "config.h"
#include <iostream>
#include <string>
#include <pybind11/pybind11.h>
#include <pybind11/functional.h>
#include <pybind11/stl.h>
#include <c2py/c2py.hpp>
#include "module.hpp"
#include "wrappers.hpp"
#include "generated_functions.h"
#include "oes_api/oes_api.h"
#include "mds_api/mds_api.h"
void generate_class_OesQryTrdFilter(pybind11::object & parent)
{
// _OesQryTrdFilter
pybind11::class_<_OesQryTrdFilter> c(parent, "_OesQryTrdFilter");
if constexpr (std::is_default_constructible_v<_OesQryTrdFilter>)
c.def(pybind11::init<>());
// _OesQryTrdFilter::custId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "custId", custId);
// _OesQryTrdFilter::invAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "invAcctId", invAcctId);
// _OesQryTrdFilter::mktId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "mktId", mktId);
// _OesQryTrdFilter::clEnvId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "clEnvId", clEnvId);
// _OesQryTrdFilter::securityType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "securityType", securityType);
// _OesQryTrdFilter::bsType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "bsType", bsType);
// _OesQryTrdFilter::__filler
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "__filler", __filler);
// _OesQryTrdFilter::clOrdId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "clOrdId", clOrdId);
// _OesQryTrdFilter::clSeqNo
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "clSeqNo", clSeqNo);
// _OesQryTrdFilter::startTime
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "startTime", startTime);
// _OesQryTrdFilter::endTime
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "endTime", endTime);
// _OesQryTrdFilter::userInfo
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdFilter, "userInfo", userInfo);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryTrdFilter, c);
module_vnoes::objects.emplace("_OesQryTrdFilter", c);
}
void generate_class_OesQryTrdReq(pybind11::object & parent)
{
// _OesQryTrdReq
pybind11::class_<_OesQryTrdReq> c(parent, "_OesQryTrdReq");
if constexpr (std::is_default_constructible_v<_OesQryTrdReq>)
c.def(pybind11::init<>());
// _OesQryTrdReq::reqHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdReq, "reqHead", reqHead);
// _OesQryTrdReq::qryFilter
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdReq, "qryFilter", qryFilter);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryTrdReq, c);
module_vnoes::objects.emplace("_OesQryTrdReq", c);
}
void generate_class_OesQryTrdRsp(pybind11::object & parent)
{
// _OesQryTrdRsp
pybind11::class_<_OesQryTrdRsp> c(parent, "_OesQryTrdRsp");
if constexpr (std::is_default_constructible_v<_OesQryTrdRsp>)
c.def(pybind11::init<>());
// _OesQryTrdRsp::rspHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdRsp, "rspHead", rspHead);
// _OesQryTrdRsp::qryItems
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryTrdRsp, "qryItems", qryItems);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryTrdRsp, c);
module_vnoes::objects.emplace("_OesQryTrdRsp", c);
}
void generate_class_OesQryCashAssetFilter(pybind11::object & parent)
{
// _OesQryCashAssetFilter
pybind11::class_<_OesQryCashAssetFilter> c(parent, "_OesQryCashAssetFilter");
if constexpr (std::is_default_constructible_v<_OesQryCashAssetFilter>)
c.def(pybind11::init<>());
// _OesQryCashAssetFilter::custId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCashAssetFilter, "custId", custId);
// _OesQryCashAssetFilter::cashAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCashAssetFilter, "cashAcctId", cashAcctId);
// _OesQryCashAssetFilter::userInfo
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCashAssetFilter, "userInfo", userInfo);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryCashAssetFilter, c);
module_vnoes::objects.emplace("_OesQryCashAssetFilter", c);
}
void generate_class_OesCashAssetItem(pybind11::object & parent)
{
// _OesCashAssetItem
pybind11::class_<_OesCashAssetItem> c(parent, "_OesCashAssetItem");
if constexpr (std::is_default_constructible_v<_OesCashAssetItem>)
c.def(pybind11::init<>());
// _OesCashAssetItem::cashAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "cashAcctId", cashAcctId);
// _OesCashAssetItem::custId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "custId", custId);
// _OesCashAssetItem::currType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "currType", currType);
// _OesCashAssetItem::cashType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "cashType", cashType);
// _OesCashAssetItem::cashAcctStatus
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "cashAcctStatus", cashAcctStatus);
// _OesCashAssetItem::isFundTrsfDisabled
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "isFundTrsfDisabled", isFundTrsfDisabled);
// _OesCashAssetItem::__CASH_ASSET_BASE_filler
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "__CASH_ASSET_BASE_filler", __CASH_ASSET_BASE_filler);
// _OesCashAssetItem::beginningBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "beginningBal", beginningBal);
// _OesCashAssetItem::beginningAvailableBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "beginningAvailableBal", beginningAvailableBal);
// _OesCashAssetItem::beginningDrawableBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "beginningDrawableBal", beginningDrawableBal);
// _OesCashAssetItem::disableBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "disableBal", disableBal);
// _OesCashAssetItem::reversalAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "reversalAmt", reversalAmt);
// _OesCashAssetItem::manualFrzAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "manualFrzAmt", manualFrzAmt);
// _OesCashAssetItem::totalDepositAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "totalDepositAmt", totalDepositAmt);
// _OesCashAssetItem::totalWithdrawAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "totalWithdrawAmt", totalWithdrawAmt);
// _OesCashAssetItem::withdrawFrzAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "withdrawFrzAmt", withdrawFrzAmt);
// _OesCashAssetItem::totalSellAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "totalSellAmt", totalSellAmt);
// _OesCashAssetItem::totalBuyAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "totalBuyAmt", totalBuyAmt);
// _OesCashAssetItem::buyFrzAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "buyFrzAmt", buyFrzAmt);
// _OesCashAssetItem::totalFeeAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "totalFeeAmt", totalFeeAmt);
// _OesCashAssetItem::feeFrzAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "feeFrzAmt", feeFrzAmt);
// _OesCashAssetItem::marginAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "marginAmt", marginAmt);
// _OesCashAssetItem::marginFrzAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "marginFrzAmt", marginFrzAmt);
// _OesCashAssetItem::currentTotalBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "currentTotalBal", currentTotalBal);
// _OesCashAssetItem::currentAvailableBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "currentAvailableBal", currentAvailableBal);
// _OesCashAssetItem::currentDrawableBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCashAssetItem, "currentDrawableBal", currentDrawableBal);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesCashAssetItem, c);
module_vnoes::objects.emplace("_OesCashAssetItem", c);
}
void generate_class_OesQryCashAssetReq(pybind11::object & parent)
{
// _OesQryCashAssetReq
pybind11::class_<_OesQryCashAssetReq> c(parent, "_OesQryCashAssetReq");
if constexpr (std::is_default_constructible_v<_OesQryCashAssetReq>)
c.def(pybind11::init<>());
// _OesQryCashAssetReq::reqHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCashAssetReq, "reqHead", reqHead);
// _OesQryCashAssetReq::qryFilter
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCashAssetReq, "qryFilter", qryFilter);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryCashAssetReq, c);
module_vnoes::objects.emplace("_OesQryCashAssetReq", c);
}
void generate_class_OesQryCashAssetRsp(pybind11::object & parent)
{
// _OesQryCashAssetRsp
pybind11::class_<_OesQryCashAssetRsp> c(parent, "_OesQryCashAssetRsp");
if constexpr (std::is_default_constructible_v<_OesQryCashAssetRsp>)
c.def(pybind11::init<>());
// _OesQryCashAssetRsp::rspHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCashAssetRsp, "rspHead", rspHead);
// _OesQryCashAssetRsp::qryItems
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCashAssetRsp, "qryItems", qryItems);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryCashAssetRsp, c);
module_vnoes::objects.emplace("_OesQryCashAssetRsp", c);
}
void generate_class_OesCounterCashItem(pybind11::object & parent)
{
// _OesCounterCashItem
pybind11::class_<_OesCounterCashItem> c(parent, "_OesCounterCashItem");
if constexpr (std::is_default_constructible_v<_OesCounterCashItem>)
c.def(pybind11::init<>());
// _OesCounterCashItem::cashAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "cashAcctId", cashAcctId);
// _OesCounterCashItem::custId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "custId", custId);
// _OesCounterCashItem::custName
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "custName", custName);
// _OesCounterCashItem::bankId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "bankId", bankId);
// _OesCounterCashItem::cashType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "cashType", cashType);
// _OesCounterCashItem::cashAcctStatus
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "cashAcctStatus", cashAcctStatus);
// _OesCounterCashItem::currType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "currType", currType);
// _OesCounterCashItem::isFundTrsfDisabled
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "isFundTrsfDisabled", isFundTrsfDisabled);
// _OesCounterCashItem::__filler
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "__filler", __filler);
// _OesCounterCashItem::counterAvailableBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "counterAvailableBal", counterAvailableBal);
// _OesCounterCashItem::counterDrawableBal
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "counterDrawableBal", counterDrawableBal);
// _OesCounterCashItem::counterCashUpdateTime
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "counterCashUpdateTime", counterCashUpdateTime);
// _OesCounterCashItem::__reserve
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesCounterCashItem, "__reserve", __reserve);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesCounterCashItem, c);
module_vnoes::objects.emplace("_OesCounterCashItem", c);
}
void generate_class_OesQryCounterCashReq(pybind11::object & parent)
{
// _OesQryCounterCashReq
pybind11::class_<_OesQryCounterCashReq> c(parent, "_OesQryCounterCashReq");
if constexpr (std::is_default_constructible_v<_OesQryCounterCashReq>)
c.def(pybind11::init<>());
// _OesQryCounterCashReq::cashAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCounterCashReq, "cashAcctId", cashAcctId);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryCounterCashReq, c);
module_vnoes::objects.emplace("_OesQryCounterCashReq", c);
}
void generate_class_OesQryCounterCashRsp(pybind11::object & parent)
{
// _OesQryCounterCashRsp
pybind11::class_<_OesQryCounterCashRsp> c(parent, "_OesQryCounterCashRsp");
if constexpr (std::is_default_constructible_v<_OesQryCounterCashRsp>)
c.def(pybind11::init<>());
// _OesQryCounterCashRsp::counterCashItem
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCounterCashRsp, "counterCashItem", counterCashItem);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryCounterCashRsp, c);
module_vnoes::objects.emplace("_OesQryCounterCashRsp", c);
}
void generate_class_OesQryStkHoldingFilter(pybind11::object & parent)
{
// _OesQryStkHoldingFilter
pybind11::class_<_OesQryStkHoldingFilter> c(parent, "_OesQryStkHoldingFilter");
if constexpr (std::is_default_constructible_v<_OesQryStkHoldingFilter>)
c.def(pybind11::init<>());
// _OesQryStkHoldingFilter::custId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingFilter, "custId", custId);
// _OesQryStkHoldingFilter::invAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingFilter, "invAcctId", invAcctId);
// _OesQryStkHoldingFilter::securityId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingFilter, "securityId", securityId);
// _OesQryStkHoldingFilter::mktId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingFilter, "mktId", mktId);
// _OesQryStkHoldingFilter::securityType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingFilter, "securityType", securityType);
// _OesQryStkHoldingFilter::productType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingFilter, "productType", productType);
// _OesQryStkHoldingFilter::__filler
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingFilter, "__filler", __filler);
// _OesQryStkHoldingFilter::userInfo
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingFilter, "userInfo", userInfo);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryStkHoldingFilter, c);
module_vnoes::objects.emplace("_OesQryStkHoldingFilter", c);
}
void generate_class_OesStkHoldingItem(pybind11::object & parent)
{
// _OesStkHoldingItem
pybind11::class_<_OesStkHoldingItem> c(parent, "_OesStkHoldingItem");
if constexpr (std::is_default_constructible_v<_OesStkHoldingItem>)
c.def(pybind11::init<>());
// _OesStkHoldingItem::invAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "invAcctId", invAcctId);
// _OesStkHoldingItem::securityId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "securityId", securityId);
// _OesStkHoldingItem::mktId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "mktId", mktId);
// _OesStkHoldingItem::securityType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "securityType", securityType);
// _OesStkHoldingItem::subSecurityType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "subSecurityType", subSecurityType);
// _OesStkHoldingItem::productType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "productType", productType);
// _OesStkHoldingItem::__HOLD_BASE_filler
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "__HOLD_BASE_filler", __HOLD_BASE_filler);
// _OesStkHoldingItem::originalHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "originalHld", originalHld);
// _OesStkHoldingItem::originalCostAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "originalCostAmt", originalCostAmt);
// _OesStkHoldingItem::totalBuyHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "totalBuyHld", totalBuyHld);
// _OesStkHoldingItem::totalSellHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "totalSellHld", totalSellHld);
// _OesStkHoldingItem::sellFrzHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "sellFrzHld", sellFrzHld);
// _OesStkHoldingItem::manualFrzHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "manualFrzHld", manualFrzHld);
// _OesStkHoldingItem::totalBuyAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "totalBuyAmt", totalBuyAmt);
// _OesStkHoldingItem::totalSellAmt
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "totalSellAmt", totalSellAmt);
// _OesStkHoldingItem::totalBuyFee
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "totalBuyFee", totalBuyFee);
// _OesStkHoldingItem::totalSellFee
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "totalSellFee", totalSellFee);
// _OesStkHoldingItem::totalTrsfInHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "totalTrsfInHld", totalTrsfInHld);
// _OesStkHoldingItem::totalTrsfOutHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "totalTrsfOutHld", totalTrsfOutHld);
// _OesStkHoldingItem::trsfOutFrzHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "trsfOutFrzHld", trsfOutFrzHld);
// _OesStkHoldingItem::lockHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "lockHld", lockHld);
// _OesStkHoldingItem::lockFrzHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "lockFrzHld", lockFrzHld);
// _OesStkHoldingItem::unlockFrzHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "unlockFrzHld", unlockFrzHld);
// _OesStkHoldingItem::coveredFrzHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "coveredFrzHld", coveredFrzHld);
// _OesStkHoldingItem::coveredHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "coveredHld", coveredHld);
// _OesStkHoldingItem::sellAvlHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "sellAvlHld", sellAvlHld);
// _OesStkHoldingItem::trsfOutAvlHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "trsfOutAvlHld", trsfOutAvlHld);
// _OesStkHoldingItem::lockAvlHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "lockAvlHld", lockAvlHld);
// _OesStkHoldingItem::coveredAvlHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "coveredAvlHld", coveredAvlHld);
// _OesStkHoldingItem::sumHld
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "sumHld", sumHld);
// _OesStkHoldingItem::costPrice
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesStkHoldingItem, "costPrice", costPrice);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesStkHoldingItem, c);
module_vnoes::objects.emplace("_OesStkHoldingItem", c);
}
void generate_class_OesQryStkHoldingReq(pybind11::object & parent)
{
// _OesQryStkHoldingReq
pybind11::class_<_OesQryStkHoldingReq> c(parent, "_OesQryStkHoldingReq");
if constexpr (std::is_default_constructible_v<_OesQryStkHoldingReq>)
c.def(pybind11::init<>());
// _OesQryStkHoldingReq::reqHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingReq, "reqHead", reqHead);
// _OesQryStkHoldingReq::qryFilter
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingReq, "qryFilter", qryFilter);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryStkHoldingReq, c);
module_vnoes::objects.emplace("_OesQryStkHoldingReq", c);
}
void generate_class_OesQryStkHoldingRsp(pybind11::object & parent)
{
// _OesQryStkHoldingRsp
pybind11::class_<_OesQryStkHoldingRsp> c(parent, "_OesQryStkHoldingRsp");
if constexpr (std::is_default_constructible_v<_OesQryStkHoldingRsp>)
c.def(pybind11::init<>());
// _OesQryStkHoldingRsp::qryHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingRsp, "qryHead", qryHead);
// _OesQryStkHoldingRsp::qryItems
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryStkHoldingRsp, "qryItems", qryItems);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryStkHoldingRsp, c);
module_vnoes::objects.emplace("_OesQryStkHoldingRsp", c);
}
void generate_class_OesOptHoldingItem(pybind11::object & parent)
{
// _OesOptHoldingItem
pybind11::class_<_OesOptHoldingItem> c(parent, "_OesOptHoldingItem");
if constexpr (std::is_default_constructible_v<_OesOptHoldingItem>)
c.def(pybind11::init<>());
// _OesOptHoldingItem::invAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "invAcctId", invAcctId);
// _OesOptHoldingItem::securityId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "securityId", securityId);
// _OesOptHoldingItem::mktId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "mktId", mktId);
// _OesOptHoldingItem::__HOLD_BASE_filler
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "__HOLD_BASE_filler", __HOLD_BASE_filler);
// _OesOptHoldingItem::hldA
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "hldA", hldA);
// _OesOptHoldingItem::hldB
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "hldB", hldB);
// _OesOptHoldingItem::hldC
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "hldC", hldC);
// _OesOptHoldingItem::hldC2
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "hldC2", hldC2);
// _OesOptHoldingItem::hldRA
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "hldRA", hldRA);
// _OesOptHoldingItem::hldRB
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "hldRB", hldRB);
// _OesOptHoldingItem::hldRC
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesOptHoldingItem, "hldRC", hldRC);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesOptHoldingItem, c);
module_vnoes::objects.emplace("_OesOptHoldingItem", c);
}
void generate_class_OesQryOptHoldingReq(pybind11::object & parent)
{
// _OesQryOptHoldingReq
pybind11::class_<_OesQryOptHoldingReq> c(parent, "_OesQryOptHoldingReq");
if constexpr (std::is_default_constructible_v<_OesQryOptHoldingReq>)
c.def(pybind11::init<>());
// _OesQryOptHoldingReq::reqHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryOptHoldingReq, "reqHead", reqHead);
// _OesQryOptHoldingReq::qryFilter
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryOptHoldingReq, "qryFilter", qryFilter);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryOptHoldingReq, c);
module_vnoes::objects.emplace("_OesQryOptHoldingReq", c);
}
void generate_class_OesQryHoldRsp(pybind11::object & parent)
{
// _OesQryHoldRsp
pybind11::class_<_OesQryHoldRsp> c(parent, "_OesQryHoldRsp");
if constexpr (std::is_default_constructible_v<_OesQryHoldRsp>)
c.def(pybind11::init<>());
// _OesQryHoldRsp::rspHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryHoldRsp, "rspHead", rspHead);
// _OesQryHoldRsp::qryItems
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryHoldRsp, "qryItems", qryItems);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryHoldRsp, c);
module_vnoes::objects.emplace("_OesQryHoldRsp", c);
}
void generate_class_OesQryCustFilter(pybind11::object & parent)
{
// _OesQryCustFilter
pybind11::class_<_OesQryCustFilter> c(parent, "_OesQryCustFilter");
if constexpr (std::is_default_constructible_v<_OesQryCustFilter>)
c.def(pybind11::init<>());
// _OesQryCustFilter::custId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCustFilter, "custId", custId);
// _OesQryCustFilter::userInfo
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCustFilter, "userInfo", userInfo);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryCustFilter, c);
module_vnoes::objects.emplace("_OesQryCustFilter", c);
}
void generate_class_OesQryCustReq(pybind11::object & parent)
{
// _OesQryCustReq
pybind11::class_<_OesQryCustReq> c(parent, "_OesQryCustReq");
if constexpr (std::is_default_constructible_v<_OesQryCustReq>)
c.def(pybind11::init<>());
// _OesQryCustReq::reqHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCustReq, "reqHead", reqHead);
// _OesQryCustReq::qryFilter
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCustReq, "qryFilter", qryFilter);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryCustReq, c);
module_vnoes::objects.emplace("_OesQryCustReq", c);
}
void generate_class_OesQryCustRsp(pybind11::object & parent)
{
// _OesQryCustRsp
pybind11::class_<_OesQryCustRsp> c(parent, "_OesQryCustRsp");
if constexpr (std::is_default_constructible_v<_OesQryCustRsp>)
c.def(pybind11::init<>());
// _OesQryCustRsp::rspHead
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCustRsp, "rspHead", rspHead);
// _OesQryCustRsp::qryItems
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryCustRsp, "qryItems", qryItems);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryCustRsp, c);
module_vnoes::objects.emplace("_OesQryCustRsp", c);
}
void generate_class_OesQryInvAcctFilter(pybind11::object & parent)
{
// _OesQryInvAcctFilter
pybind11::class_<_OesQryInvAcctFilter> c(parent, "_OesQryInvAcctFilter");
if constexpr (std::is_default_constructible_v<_OesQryInvAcctFilter>)
c.def(pybind11::init<>());
// _OesQryInvAcctFilter::custId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryInvAcctFilter, "custId", custId);
// _OesQryInvAcctFilter::invAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryInvAcctFilter, "invAcctId", invAcctId);
// _OesQryInvAcctFilter::mktId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryInvAcctFilter, "mktId", mktId);
// _OesQryInvAcctFilter::__filler
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryInvAcctFilter, "__filler", __filler);
// _OesQryInvAcctFilter::userInfo
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesQryInvAcctFilter, "userInfo", userInfo);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesQryInvAcctFilter, c);
module_vnoes::objects.emplace("_OesQryInvAcctFilter", c);
}
void generate_class_OesInvAcctItem(pybind11::object & parent)
{
// _OesInvAcctItem
pybind11::class_<_OesInvAcctItem> c(parent, "_OesInvAcctItem");
if constexpr (std::is_default_constructible_v<_OesInvAcctItem>)
c.def(pybind11::init<>());
// _OesInvAcctItem::invAcctId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "invAcctId", invAcctId);
// _OesInvAcctItem::mktId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "mktId", mktId);
// _OesInvAcctItem::acctType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "acctType", acctType);
// _OesInvAcctItem::status
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "status", status);
// _OesInvAcctItem::ownerType
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "ownerType", ownerType);
// _OesInvAcctItem::optInvLevel
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "optInvLevel", optInvLevel);
// _OesInvAcctItem::isTradeDisabled
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "isTradeDisabled", isTradeDisabled);
// _OesInvAcctItem::__INV_ACCT_BASE_filler
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "__INV_ACCT_BASE_filler", __INV_ACCT_BASE_filler);
// _OesInvAcctItem::limits
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "limits", limits);
// _OesInvAcctItem::permissions
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "permissions", permissions);
// _OesInvAcctItem::pbuId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "pbuId", pbuId);
// _OesInvAcctItem::__INV_ACCT_BASE_filler2
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "__INV_ACCT_BASE_filler2", __INV_ACCT_BASE_filler2);
// _OesInvAcctItem::subscriptionQuota
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "subscriptionQuota", subscriptionQuota);
// _OesInvAcctItem::kcSubscriptionQuota
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "kcSubscriptionQuota", kcSubscriptionQuota);
// _OesInvAcctItem::__INV_ACCT_BASE_reserve
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "__INV_ACCT_BASE_reserve", __INV_ACCT_BASE_reserve);
// _OesInvAcctItem::custId
c.AUTOCXXPY_DEF_PROPERTY(tag_vnoes, _OesInvAcctItem, "custId", custId);
AUTOCXXPY_POST_REGISTER_CLASS(tag_vnoes, _OesInvAcctItem, c);
module_vnoes::objects.emplace("_OesInvAcctItem", c);
}
| 54.161479 | 113 | 0.775926 | [
"object"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.