hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 108 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count 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 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 77k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count 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 7 1.05M | avg_line_length float64 1.21 653k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7ef52b1b9f1a18d736be163263fe1a1ea515f441 | 17,553 | cpp | C++ | src/state/TimeTrial.cpp | agral/SimpleGames | 75779520dbd35b4434b4ee0634ca421624e6876c | [
"MIT"
] | null | null | null | src/state/TimeTrial.cpp | agral/SimpleGames | 75779520dbd35b4434b4ee0634ca421624e6876c | [
"MIT"
] | null | null | null | src/state/TimeTrial.cpp | agral/SimpleGames | 75779520dbd35b4434b4ee0634ca421624e6876c | [
"MIT"
] | null | null | null | #include "TimeTrial.hpp"
#include "../global/globals.hpp"
#include <SDL2/SDL.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
namespace state
{
const int ORB_SIZE = global::ORB_SIZE;
const int DRAG_THRESHOLD = 0.3 * ORB_SIZE;
const double swapAnimationTime = 400; //milliseconds
const double explodeAnimationTime = 1000; // milliseconds
const int BORDER_SIZE = 44;
inline int Signum(int value)
{
return (value > 0) - (value < 0);
}
void BtnExitIngameOnClick()
{
SetNextStateId(STATE_MAINMENU);
}
TimeTrial::TimeTrial()
{
orbClips[0] = {0, 0, ORB_SIZE, ORB_SIZE};
orbClips[1] = {ORB_SIZE, 0, ORB_SIZE, ORB_SIZE};
orbClips[2] = {2 * ORB_SIZE, 0, ORB_SIZE, ORB_SIZE};
orbClips[3] = {3 * ORB_SIZE, 0, ORB_SIZE, ORB_SIZE};
orbClips[4] = {4 * ORB_SIZE, 0, ORB_SIZE, ORB_SIZE};
// boardClip #5 is used for board filling; #1-#4 and #6-#9 are used as borders same as numpad keys
// (e.g. #1 is used for bottom-left border piece, #6 is used for central-right border piece). #0 is unused.
boardClips[1] = {0, 108, 44, 44};
boardClips[2] = {44, 108, 64, 44};
boardClips[3] = {108, 108, 44, 44};
boardClips[4] = {0, 44, 44, 64};
boardClips[5] = {44, 44, 64, 64};
boardClips[6] = {108, 44, 44, 64};
boardClips[7] = {0, 0, 44, 44};
boardClips[8] = {44, 0, 64, 44};
boardClips[9] = {108, 0, 44, 44};
boardGeometry = {
(global::SCREEN_WIDTH - (global::GAMEBOARD_WIDTH * ORB_SIZE) - BORDER_SIZE), BORDER_SIZE,
global::GAMEBOARD_WIDTH * ORB_SIZE,
global::GAMEBOARD_HEIGHT * ORB_SIZE
};
board.SetSize(global::GAMEBOARD_WIDTH, global::GAMEBOARD_HEIGHT);
board.FillRandomlyWithoutChains();
for (auto y = 0; y < board.Height(); ++y)
{
for (auto x = 0; x < board.Width(); ++x)
{
board.At(x, y).posY = ORB_SIZE * (y - board.Height());
board.At(x, y).isFalling = true;
}
}
isDragging = false;
selectedGemXIndex = -1;
selectedGemYIndex = -1;
remainingIdleTime = global::ROUND_TIME_IN_MILLISECONDS;
playerScore = 0;
multiplier = 1;
pbTime = std::make_unique<gse::ProgressBar>(resMgr.spProgressBar, 520, 10, gse::ProgressBarColors::BLUE);
pbTime->SetPosition(boardGeometry.x + (boardGeometry.w - 520) / 2, 10);
btnExit = std::make_unique<gse::Button>(resMgr.spBtnIngameExit.Width(), resMgr.spBtnIngameExit.Height() / 3,
resMgr.spBtnIngameExit);
btnExit->SetPosition((200 - resMgr.spBtnIngameExit.Width()) / 2, global::SCREEN_HEIGHT - 90);
btnExit->SetOnClick(&BtnExitIngameOnClick);
resMgr.txIngameScore.RenderFromTtf(resMgr.fIngameScore, "00000", global::CL_INGAME_SCORE, nullptr);
phase = GamePhase::FALLING;
nextPhase = GamePhase::NONE;
}
void TimeTrial::ProcessInput()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
SetNextStateId(STATE_EXIT);
}
if ((event.type == SDL_MOUSEBUTTONDOWN) || (event.type == SDL_MOUSEBUTTONUP) || (event.type == SDL_MOUSEMOTION))
{
int mouseX, mouseY;
SDL_GetMouseState(&mouseX, &mouseY);
// Regardless of the position of the cursor, the dragging ends when the user releases the mouse:
if (event.type == SDL_MOUSEBUTTONUP)
{
isDragging = false;
}
// If the mouse is over the board, and the game accepts user input (is in "IDLE" state):
if ((phase == GamePhase::IDLE) &&
(mouseX >= boardGeometry.x) && (mouseX < boardGeometry.x + boardGeometry.w) &&
(mouseY >= boardGeometry.y) && (mouseY < boardGeometry.y + boardGeometry.h))
{
if (event.type == SDL_MOUSEBUTTONUP)
{
if (std::max(std::abs(filteredDragDistanceX), std::abs(filteredDragDistanceY)) < DRAG_THRESHOLD)
{
int pointedGemXIndex = (mouseX - boardGeometry.x) / ORB_SIZE;
int pointedGemYIndex = (mouseY - boardGeometry.y) / ORB_SIZE;
if (selectedGemXIndex >= 0)
{
if ((pointedGemXIndex == selectedGemXIndex) && (pointedGemYIndex == selectedGemYIndex))
{
// Unselects the selected Gem when it's clicked again:
selectedGemXIndex = -1;
selectedGemYIndex = -1;
}
else
{
// Performs the swappping, but only iff selected and this Gem are horizontal or vertical neighbors:
int deltaX = std::abs(selectedGemXIndex - pointedGemXIndex);
int deltaY = std::abs(selectedGemYIndex - pointedGemYIndex);
if (((deltaX == 1) && (deltaY == 0)) || ((deltaX == 0) && (deltaY == 1)))
{
CheckAndSwap(selectedGemXIndex, selectedGemYIndex, pointedGemXIndex, pointedGemYIndex);
}
}
}
else
{
// Selects the clicked Gem when no other Gem is selected:
selectedGemXIndex = (mouseX - boardGeometry.x) / ORB_SIZE;
selectedGemYIndex = (mouseY - boardGeometry.y) / ORB_SIZE;
}
}
else
{
otherGemXIndex = draggedGemXIndex;
otherGemYIndex = draggedGemYIndex;
if (filteredDragDistanceX < -DRAG_THRESHOLD)
{
otherGemXIndex -= 1;
}
else if (filteredDragDistanceX > DRAG_THRESHOLD)
{
otherGemXIndex += 1;
}
else if (filteredDragDistanceY < -DRAG_THRESHOLD)
{
otherGemYIndex -= 1;
}
else if (filteredDragDistanceY > DRAG_THRESHOLD)
{
otherGemYIndex += 1;
}
CheckAndSwap(draggedGemXIndex, draggedGemYIndex, otherGemXIndex, otherGemYIndex);
}
}
else if (event.type == SDL_MOUSEBUTTONDOWN)
{
dragOriginX = mouseX;
dragOriginY = mouseY;
dragDistanceX = 0;
dragDistanceY = 0;
draggedGemXIndex = (mouseX - boardGeometry.x) / ORB_SIZE;
draggedGemYIndex = (mouseY - boardGeometry.y) / ORB_SIZE;
isDragging = true;
}
else if (event.type == SDL_MOUSEMOTION)
{
if (isDragging)
{
dragDistanceX = mouseX - dragOriginX;
dragDistanceY = mouseY - dragOriginY;
}
}
}
btnExit->ProcessInput(event, mouseX, mouseY);
}
}
}
void TimeTrial::Logic(gse::GameTimeData td)
{
// Switches to the next state, if applicable:
if (nextPhase != GamePhase::NONE)
{
phase = nextPhase;
nextPhase = GamePhase::NONE;
phaseBirth = td.timeTotal;
std::cout << "[TimeTrial] Switched to " << GamePhaseNames[phase] << " game phase." << std::endl;
}
if (phase == GamePhase::IDLE)
{
// Decrements the game time:
remainingIdleTime -= td.timeSinceLastFrame;
pbTime->SetNormalizedProgress(remainingIdleTime / global::ROUND_TIME_IN_MILLISECONDS);
if (remainingIdleTime <= 0.0)
{
std::cout << "End of remaining idle time." << std::endl;
nextPhase = GamePhase::OVER;
}
}
if (phase == GamePhase::FALLING)
{
bool isStillFalling = false;
for (auto y = 0; y < board.Height(); ++y)
{
for (auto x = 0; x < board.Width(); ++x)
{
if (board.At(x, y).isFalling)
{
isStillFalling = true;
board.At(x, y).velocityY += global::gravityConstant * td.timeSinceLastFrame;
board.At(x, y).posY += board.At(x, y).velocityY * td.timeSinceLastFrame;
if (board.At(x, y).posY > y * ORB_SIZE)
{
board.At(x, y).isFalling = false;
board.At(x, y).posY = y * ORB_SIZE;
}
}
}
}
if (!isStillFalling)
{
if (board.FindChains())
{
nextPhase = GamePhase::EXPLODING;
}
else
{
multiplier = 1;
pbTime->SetForegroundColor(gse::ProgressBarColors::GREEN);
nextPhase = GamePhase::IDLE;
}
}
}
else if (phase == GamePhase::SWAPPING)
{
double animTime = td.timeTotal - phaseBirth;
// Easing function: sin(t) from 0.5PI (max) to 1.5PI (min), mapped to [ORB_SIZE -> 0] range
double distance = animTime > swapAnimationTime ?
0 : (0.5 * ORB_SIZE * (1 + std::sin(M_PI * (animTime / swapAnimationTime + 0.5))));
double swapDirectionX = (draggedGemXIndex - otherGemXIndex);
double swapDirectionY = (draggedGemYIndex - otherGemYIndex);
if (swapDirectionX != 0)
{
board.At(draggedGemXIndex, draggedGemYIndex).posX = (draggedGemXIndex * ORB_SIZE) - (swapDirectionX * distance);
board.At(otherGemXIndex, otherGemYIndex).posX = (otherGemXIndex * ORB_SIZE) + (swapDirectionX * distance);
}
else if (swapDirectionY != 0)
{
board.At(draggedGemXIndex, draggedGemYIndex).posY = (draggedGemYIndex * ORB_SIZE) - (swapDirectionY * distance);
board.At(otherGemXIndex, otherGemYIndex).posY = (otherGemYIndex * ORB_SIZE) + (swapDirectionY * distance);
}
if (animTime >= swapAnimationTime)
{
// Puts the swapped gems both in their exact places:
board.At(draggedGemXIndex, draggedGemYIndex).posX = draggedGemXIndex * ORB_SIZE;
board.At(draggedGemXIndex, draggedGemYIndex).posY = draggedGemYIndex * ORB_SIZE;
board.At(otherGemXIndex, otherGemYIndex).posX = otherGemXIndex * ORB_SIZE;
board.At(otherGemXIndex, otherGemYIndex).posY = otherGemYIndex * ORB_SIZE;
nextPhase = GamePhase::EXPLODING;
}
}
else if (phase == GamePhase::EXPLODING)
{
double animTime = td.timeTotal - phaseBirth;
if ( animTime > explodeAnimationTime )
{
std::cout << "End of Explode animation" << std::endl;
for (int x = 0; x < board.Width(); ++x)
{
int explodedBelowCounter = 0;
for (int y = board.Height() - 1; y >= 0; --y)
{
if (board.At(x, y).isPartOfChain)
{
explodedBelowCounter += 1;
playerScore += multiplier;
}
else
{
if (explodedBelowCounter > 0)
{
// Sets the Gem at its target position on the GameBoard model (as if it already fell):
board.At(x, y + explodedBelowCounter).color = board.At(x, y).color;
// Sets its rendering Y-position exactly where it were so that its fall will be smooth:
board.At(x, y + explodedBelowCounter).posY = y * ORB_SIZE;
board.At(x, y + explodedBelowCounter).velocityY = 0;
board.At(x, y + explodedBelowCounter).isPartOfChain = false;
board.At(x, y + explodedBelowCounter).isFalling = true;
}
}
}
// Adds "new" random Gems in place of those exploded. They start their fall from just above the board:
for (int z = explodedBelowCounter - 1; z >= 0; --z)
{
board.SetRandomColor(x, z);
board.At(x, z).posY = (z - explodedBelowCounter) * ORB_SIZE;
board.At(x, z).velocityY = 0;
board.At(x, z).isPartOfChain = false;
board.At(x, z).isFalling = true;
}
}
multiplier += 1;
nextPhase = GamePhase::FALLING;
}
else
{
// Easing function: cos^2(t) from 0 (max) to PI (min), mapped to [255 -> 0] range:
double factor = 0.5 * (1 + std::cos(M_PI * (animTime / explodeAnimationTime)));
explodingAlpha = 255 * factor * factor;
}
}
}
void TimeTrial::Render()
{
DrawBoard();
DrawBoardBorder();
pbTime->Render();
btnExit->Render();
resMgr.txIngameScoreCaption.Render(35, 5);
resMgr.txIngameScoreBg.Render(35, 35);
std::stringstream ss;
ss << std::setw(5) << std::setfill('0') << playerScore;
resMgr.txIngameScore.RenderFromTtf(resMgr.fIngameScore, ss.str(), global::CL_INGAME_SCORE, nullptr);
resMgr.txIngameScore.Render(35, 35);
if (phase == GamePhase::OVER)
{
resMgr.txGameOver.Render(boardGeometry.x + (boardGeometry.w - resMgr.txGameOver.Width()) / 2,
boardGeometry.y + (boardGeometry.h - resMgr.txGameOver.Height()) / 2);
}
}
void TimeTrial::DrawBoard()
{
// Draws the board background:
for (int x = 0; x < board.Width(); ++x)
{
for (int y = 0; y < board.Height(); ++y)
{
resMgr.spBoard.Render(boardGeometry.x + x * ORB_SIZE, boardGeometry.y + y * ORB_SIZE, &boardClips[5]);
}
}
// Draws the Gems:
for (int x = 0; x < board.Width(); ++x)
{
for (int y = 0; y < board.Height(); ++y)
{
// Indicates the selected gem by drawing a halo underneath it (exclusively in IDLE phase):
if ((phase == GamePhase::IDLE) && (x == selectedGemXIndex) && (y == selectedGemYIndex))
{
resMgr.txHalo.Render(boardGeometry.x + x * ORB_SIZE, boardGeometry.y + y * ORB_SIZE);
}
// Renders all the static gems normally:
if ((!(isDragging && (x == draggedGemXIndex) && (y == draggedGemYIndex))) &&
(!((phase == GamePhase::EXPLODING) && (board.At(x, y).isPartOfChain))))
{
resMgr.spOrbs.Render(
boardGeometry.x + board.At(x, y).posX,
boardGeometry.y + board.At(x, y).posY,
&orbClips[board.At(x, y).color]
);
}
else if (isDragging && (x == draggedGemXIndex) && (y == draggedGemYIndex))
{
resMgr.spOrbs.SetAlpha(0.25 * 255);
resMgr.spOrbs.Render(
boardGeometry.x + board.At(x, y).posX,
boardGeometry.y + board.At(x, y).posY,
&orbClips[board.At(x, y).color]
);
resMgr.spOrbs.SetAlpha(255);
}
else if ((phase == GamePhase::EXPLODING) && (board.At(x, y).isPartOfChain))
{
resMgr.spOrbs.SetAlpha(explodingAlpha);
resMgr.spOrbs.Render(
boardGeometry.x + board.At(x, y).posX,
boardGeometry.y + board.At(x, y).posY,
&orbClips[board.At(x, y).color]
);
resMgr.spOrbs.SetAlpha(255);
}
}
}
// Renders the currently dragged gem (if any) at nonstandard position:
if (isDragging)
{
filteredDragDistanceX = std::abs(dragDistanceX) > std::abs(dragDistanceY) ? dragDistanceX : 0;
filteredDragDistanceY = std::abs(dragDistanceX) > std::abs(dragDistanceY) ? 0 : dragDistanceY;
if (std::abs(filteredDragDistanceX) > ORB_SIZE)
{
filteredDragDistanceX =
Signum(filteredDragDistanceX) * (ORB_SIZE + std::log(std::abs(filteredDragDistanceX) - ORB_SIZE));
}
else if (std::abs(filteredDragDistanceY) > ORB_SIZE)
{
filteredDragDistanceY =
Signum(filteredDragDistanceY) * (ORB_SIZE + std::log(std::abs(filteredDragDistanceY) - ORB_SIZE));
}
resMgr.spOrbs.SetAlpha(0.8 * 255);
resMgr.spOrbs.Render(
boardGeometry.x + board.At(draggedGemXIndex, draggedGemYIndex).posX + filteredDragDistanceX,
boardGeometry.y + board.At(draggedGemXIndex, draggedGemYIndex).posY + filteredDragDistanceY,
&orbClips[board.At(draggedGemXIndex, draggedGemYIndex).color]
);
resMgr.spOrbs.SetAlpha(255);
}
}
void TimeTrial::DrawBoardBorder()
{
resMgr.spBoard.Render(boardGeometry.x - boardClips[7].w, boardGeometry.y - boardClips[7].h, &boardClips[7]);
resMgr.spBoard.Render(boardGeometry.x + boardGeometry.w, boardGeometry.y - boardClips[9].h, &boardClips[9]);
resMgr.spBoard.Render(boardGeometry.x - boardClips[1].w, boardGeometry.y + boardGeometry.h, &boardClips[1]);
resMgr.spBoard.Render(boardGeometry.x + boardGeometry.w, boardGeometry.y + boardGeometry.h, &boardClips[3]);
for (int x = 0; x < board.Width(); ++x)
{
resMgr.spBoard.Render(boardGeometry.x + boardClips[8].w * x, boardGeometry.y - boardClips[8].h, &boardClips[8]);
resMgr.spBoard.Render(boardGeometry.x + boardClips[2].w * x, boardGeometry.y + boardGeometry.h, &boardClips[2]);
}
for (int y = 0; y < board.Height(); ++y)
{
resMgr.spBoard.Render(boardGeometry.x - boardClips[4].w, boardGeometry.y + boardClips[4].h * y, &boardClips[4]);
resMgr.spBoard.Render(boardGeometry.x + boardGeometry.w, boardGeometry.y + boardClips[6].h * y, &boardClips[6]);
}
}
void TimeTrial::CheckAndSwap(int gemAIndexX, int gemAIndexY, int gemBIndexX, int gemBIndexY)
{
// Safeguards against dragging Gems off the board:
if ((gemAIndexX >= 0) && (gemAIndexX < board.Width()) &&
(gemAIndexY >= 0) && (gemAIndexY < board.Height()) &&
(gemBIndexX >= 0) && (gemBIndexX < board.Width()) &&
(gemBIndexY >= 0) && (gemBIndexY < board.Height()))
{
// Swaps the two gems on a model board:
std::cout << "SWAP: [" << gemAIndexX << ", " << gemAIndexY << "] and ["
<< gemBIndexX << ", " << gemBIndexY << "]" << std::endl;
board.SwapColors(gemAIndexX, gemAIndexY, gemBIndexX, gemBIndexY);
if (board.FindChains())
{
// Marks gems A&B as the ones to be dragged around when swapping:
draggedGemXIndex = gemAIndexX;
draggedGemYIndex = gemAIndexY;
otherGemXIndex = gemBIndexX;
otherGemYIndex = gemBIndexY;
// Unselects the previously selected Gem, if applicable:
selectedGemXIndex = -1;
selectedGemYIndex = -1;
pbTime->SetForegroundColor(gse::ProgressBarColors::BLUE);
// Enters the SWAPPING phase in this iteration's logic handling:
nextPhase = GamePhase::SWAPPING;
}
else
{
std::cout << "Swap failed - no new chains." << std::endl;
// Reverts the color change back:
board.SwapColors(gemAIndexX, gemAIndexY, gemBIndexX, gemBIndexY);
}
}
}
} // namespace state
| 34.966135 | 118 | 0.607873 |
7efd5d7e2973f268cd492a27fca8f8d3bd86520b | 4,191 | cpp | C++ | qtxmlpatterns/src/xmlpatterns/janitors/qatomizer.cpp | wgnet/wds_qt | 8db722fd367d2d0744decf99ac7bafaba8b8a3d3 | [
"Apache-2.0"
] | 1 | 2020-04-30T15:47:35.000Z | 2020-04-30T15:47:35.000Z | qtxmlpatterns/src/xmlpatterns/janitors/qatomizer.cpp | wgnet/wds_qt | 8db722fd367d2d0744decf99ac7bafaba8b8a3d3 | [
"Apache-2.0"
] | null | null | null | qtxmlpatterns/src/xmlpatterns/janitors/qatomizer.cpp | wgnet/wds_qt | 8db722fd367d2d0744decf99ac7bafaba8b8a3d3 | [
"Apache-2.0"
] | null | null | null | /****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtXmlPatterns module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qatomictype_p.h"
#include "qbuiltintypes_p.h"
#include "qcommonsequencetypes_p.h"
#include "qgenericsequencetype_p.h"
#include "qsequencemappingiterator_p.h"
#include "qatomizer_p.h"
QT_BEGIN_NAMESPACE
using namespace QPatternist;
Atomizer::Atomizer(const Expression::Ptr &operand) : SingleContainer(operand)
{
}
Item::Iterator::Ptr Atomizer::mapToSequence(const Item &item, const DynamicContext::Ptr &) const
{
/* Function & Operators, 2.4.2 fn:data, says "If the node does not have a
* typed value an error is raised [err:FOTY0012]."
* When does a node not have a typed value? */
Q_ASSERT(item);
return item.sequencedTypedValue();
}
Item::Iterator::Ptr Atomizer::evaluateSequence(const DynamicContext::Ptr &context) const
{
return makeSequenceMappingIterator<Item>(ConstPtr(this),
m_operand->evaluateSequence(context),
context);
}
Item Atomizer::evaluateSingleton(const DynamicContext::Ptr &context) const
{
const Item item(m_operand->evaluateSingleton(context));
if(!item) /* Empty is allowed, cardinality is considered '?' */
return Item();
const Item::Iterator::Ptr it(mapToSequence(item, context));
Q_ASSERT_X(it, Q_FUNC_INFO, "A valid QAbstractXmlForwardIterator must always be returned.");
Item result(it->next());
Q_ASSERT_X(!it->next(), Q_FUNC_INFO,
"evaluateSingleton should never be used if the cardinality is two or more");
return result;
}
Expression::Ptr Atomizer::typeCheck(const StaticContext::Ptr &context,
const SequenceType::Ptr &reqType)
{
/* Compress -- the earlier the better. */
if(BuiltinTypes::xsAnyAtomicType->xdtTypeMatches(m_operand->staticType()->itemType()))
return m_operand->typeCheck(context, reqType);
return SingleContainer::typeCheck(context, reqType);
}
SequenceType::Ptr Atomizer::staticType() const
{
const SequenceType::Ptr opt(m_operand->staticType());
return makeGenericSequenceType(opt->itemType()->atomizedType(),
opt->cardinality());
}
SequenceType::List Atomizer::expectedOperandTypes() const
{
SequenceType::List result;
result.append(CommonSequenceTypes::ZeroOrMoreItems);
return result;
}
ExpressionVisitorResult::Ptr Atomizer::accept(const ExpressionVisitor::Ptr &visitor) const
{
return visitor->visit(this);
}
const SourceLocationReflection *Atomizer::actualReflection() const
{
return m_operand->actualReflection();
}
QT_END_NAMESPACE
| 35.516949 | 96 | 0.69005 |
7d05eabaa6c9d139c099cd7f61b47358ca174b85 | 935 | cpp | C++ | platforms/gfg/0234_largest_subset_gcd_1.cpp | idfumg/algorithms | 06f85c5a1d07a965df44219b5a6bf0d43a129256 | [
"MIT"
] | 2 | 2020-09-17T09:04:00.000Z | 2020-11-20T19:43:18.000Z | platforms/gfg/0234_largest_subset_gcd_1.cpp | idfumg/algorithms | 06f85c5a1d07a965df44219b5a6bf0d43a129256 | [
"MIT"
] | null | null | null | platforms/gfg/0234_largest_subset_gcd_1.cpp | idfumg/algorithms | 06f85c5a1d07a965df44219b5a6bf0d43a129256 | [
"MIT"
] | null | null | null | #include "../../template.hpp"
int LargestSubsetWithGcd1(vi arr) { // size <= 32
int n = arr.size();
int ans = 0;
for (int i = 0; i < (1 << n); ++i) {
int g = 0;
int count = 0;
for (int j = 0; j < n; ++j) {
if (i & (1 << j)) {
++count;
g = gcd(g, arr[j]);
}
}
if (g == 1) {
ans = max(ans, count);
}
}
return ans;
}
int fast(vi arr) {
int n = arr.size();
int g = 0;
for (int i = 0; i < n; ++i) {
g = gcd(g, arr[i]);
if (g == 1) {
return n;
}
}
return 0;
}
int main() { TimeMeasure _; __x();
cout << LargestSubsetWithGcd1({2, 3, 5}) << endl; // 3 // O(n*logn*2^n)
cout << LargestSubsetWithGcd1({3, 18, 12}) << endl; // 0
cout << endl;
cout << fast({2, 3, 5}) << endl; // 3 // O(n)
cout << fast({3, 18, 12}) << endl; // 0
}
| 22.804878 | 75 | 0.387166 |
7d0aa05c46f1372bd499f5ec56029f30c8b6d2df | 1,072 | cpp | C++ | Source/UModEditor/SUModPalette.cpp | StoneLineDevTeam/UMod | e57e41b95d8cdcc4479965453ac86e5116178795 | [
"BSD-4-Clause"
] | 21 | 2015-09-03T13:17:55.000Z | 2022-03-28T15:55:42.000Z | Source/UModEditor/SUModPalette.cpp | StoneLineDevTeam/UMod | e57e41b95d8cdcc4479965453ac86e5116178795 | [
"BSD-4-Clause"
] | 24 | 2015-09-19T18:03:30.000Z | 2018-12-21T10:53:01.000Z | Source/UModEditor/SUModPalette.cpp | StoneLineDevTeam/UMod | e57e41b95d8cdcc4479965453ac86e5116178795 | [
"BSD-4-Clause"
] | 17 | 2015-09-03T13:18:04.000Z | 2021-11-24T02:14:11.000Z | #include "UModEditor.h"
#include "SUModPalette.h"
void SUModPalette::Construct(const FArguments& Args)
{
/*ChildSlot
[
//Creating the button that adds a new item on the list when pressed
SNew(SScrollBox)
+ SScrollBox::Slot()
[
//The actual list view creation
+ SScrollBox::Slot()
[
SAssignNew(ListViewWidget, SListView<TSharedPtr<FString>>)
.ItemHeight(24)
.ListItemsSource(&Items) //The Items array is the source of this listview
.OnGenerateRow(this, &SUModPalette::OnGenerateRowForList)
]
];*/
}
FReply SUModPalette::ButtonPressed()
{
//Adds a new item to the array (do whatever you want with this)
Items.Add(MakeShareable(new FString("Hello 1")));
//Update the listview
ListViewWidget->RequestListRefresh();
return FReply::Handled();
}
TSharedRef<ITableRow> SUModPalette::OnGenerateRowForList(TSharedPtr<FString> Item, const TSharedRef<STableViewBase>& OwnerTable)
{
//Create the row
return
SNew(STableRow<TSharedPtr<FString>>, OwnerTable)
.Padding(2.0f)
[
SNew(SButton).Text(FText::FromString(*Item.Get()))
];
} | 23.822222 | 128 | 0.726679 |
7d0c6614694712d3b9099d1ddf3df2b30ef9d34d | 11,175 | cpp | C++ | automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp | dalihub/dali-toolk | 980728a7e35b8ddd28f70c090243e8076e21536e | [
"Apache-2.0",
"BSD-3-Clause"
] | 7 | 2016-11-18T10:26:51.000Z | 2021-01-28T13:51:59.000Z | automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp | dalihub/dali-toolk | 980728a7e35b8ddd28f70c090243e8076e21536e | [
"Apache-2.0",
"BSD-3-Clause"
] | 13 | 2020-07-15T11:33:03.000Z | 2021-04-09T21:29:23.000Z | automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp | dalihub/dali-toolk | 980728a7e35b8ddd28f70c090243e8076e21536e | [
"Apache-2.0",
"BSD-3-Clause"
] | 10 | 2019-05-17T07:15:09.000Z | 2021-05-24T07:28:08.000Z | /*
* Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "dummy-control.h"
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
namespace Dali
{
namespace Toolkit
{
DummyControl::DummyControl()
{
}
DummyControl::DummyControl(const DummyControl& control)
: Control( control )
{
}
DummyControl::~DummyControl()
{
}
DummyControl DummyControl::DownCast( BaseHandle handle )
{
return Control::DownCast<DummyControl, DummyControlImpl>(handle);
}
DummyControl& DummyControl::operator=(const DummyControl& control)
{
Control::operator=( control );
return *this;
}
// Used to test signal connections
void DummyControlImpl::CustomSlot1( Actor actor )
{
mCustomSlot1Called = true;
}
namespace {
BaseHandle Create()
{
return DummyControlImpl::New();
}
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::DummyControl, Toolkit::Control, Create );
DALI_TYPE_REGISTRATION_END()
Dali::PropertyRegistration dummyControlVisualProperty01(
typeRegistration, "testVisual", Dali::Toolkit::DummyControl::Property::TEST_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
Dali::PropertyRegistration dummyControlVisualProperty02(
typeRegistration, "testVisual2", Dali::Toolkit::DummyControl::Property::TEST_VISUAL2, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
Dali::PropertyRegistration dummyControlVisualProperty03(
typeRegistration, "foregroundVisual", Dali::Toolkit::DummyControl::Property::FOREGROUND_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
Dali::PropertyRegistration dummyControlVisualProperty04(
typeRegistration, "focusVisual", Dali::Toolkit::DummyControl::Property::FOCUS_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
Dali::PropertyRegistration dummyControlVisualProperty05(
typeRegistration, "labelVisual", Dali::Toolkit::DummyControl::Property::LABEL_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
}
DummyControl DummyControlImpl::New()
{
IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
DummyControl control( *impl );
impl->Initialize();
return control;
}
DummyControlImpl::DummyControlImpl()
: Control( ControlBehaviour() ),
mCustomSlot1Called(false)
{
}
DummyControlImpl::~DummyControlImpl()
{
}
void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
{
DevelControl::RegisterVisual( *this, index, visual );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter == mRegisteredVisualIndices.end() )
{
mRegisteredVisualIndices.push_back(index);
}
}
void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
{
DevelControl::RegisterVisual( *this, index, visual, enabled );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter == mRegisteredVisualIndices.end() )
{
mRegisteredVisualIndices.push_back(index);
}
}
void DummyControlImpl::UnregisterVisual( Property::Index index )
{
DevelControl::UnregisterVisual( *this, index );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter != mRegisteredVisualIndices.end() )
{
mRegisteredVisualIndices.erase(iter);
}
}
Toolkit::Visual::Base DummyControlImpl::GetVisual( Property::Index index )
{
return DevelControl::GetVisual( *this, index );
}
void DummyControlImpl::EnableVisual( Property::Index index, bool enabled )
{
DevelControl::EnableVisual( *this, index, enabled );
}
bool DummyControlImpl::IsVisualEnabled( Property::Index index )
{
return DevelControl::IsVisualEnabled( *this, index );
}
Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
{
return DevelControl::CreateTransition( *this, transition );
}
void DummyControlImpl::DoAction( Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes )
{
DummyControl control( *this );
DevelControl::DoAction( control, index, action, attributes);
}
void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value )
{
Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) );
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(control.GetImplementation());
switch(index)
{
case Toolkit::DummyControl::Property::TEST_VISUAL:
case Toolkit::DummyControl::Property::TEST_VISUAL2:
case Toolkit::DummyControl::Property::FOREGROUND_VISUAL:
case Toolkit::DummyControl::Property::FOCUS_VISUAL:
case Toolkit::DummyControl::Property::LABEL_VISUAL:
{
const Property::Map* map = value.GetMap();
if( map != NULL )
{
VisualFactory visualFactory = VisualFactory::Get();
Visual::Base visual = visualFactory.CreateVisual(*map);
dummyImpl.RegisterVisual(index, visual);
}
break;
}
}
}
Property::Value DummyControlImpl::GetProperty( BaseObject* object, Dali::Property::Index propertyIndex )
{
Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) );
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>( control.GetImplementation() );
Visual::Base visual = dummyImpl.GetVisual( propertyIndex );
Property::Map map;
if( visual )
{
visual.CreatePropertyMap( map );
}
Dali::Property::Value value = map;
return value;
}
Toolkit::DummyControl Impl::DummyControl::New()
{
IntrusivePtr< Toolkit::Impl::DummyControl > impl = new Toolkit::Impl::DummyControl;
Toolkit::DummyControl control( *impl );
impl->Initialize();
return control;
}
int Impl::DummyControl::constructorCount;
int Impl::DummyControl::destructorCount;
Impl::DummyControl::DummyControl()
: DummyControlImpl(),
initializeCalled(false),
activatedCalled(false),
onAccValueChangeCalled(false),
themeChangeCalled(false),
fontChangeCalled(false),
pinchCalled(false),
panCalled(false),
tapCalled(false),
longPressCalled(false),
stageConnectionCalled(false),
stageDisconnectionCalled(false),
childAddCalled(false),
childRemoveCalled(false),
sizeSetCalled(false),
sizeAnimationCalled(false),
hoverEventCalled(false),
wheelEventCalled(false),
keyEventCalled(false),
keyInputFocusGained(false),
keyInputFocusLost(false)
{
++constructorCount;
}
Impl::DummyControl::~DummyControl()
{
++destructorCount;
}
void Impl::DummyControl::OnInitialize() { initializeCalled = true; }
bool Impl::DummyControl::OnAccessibilityActivated() { activatedCalled = true; return true; }
bool Impl::DummyControl::OnAccessibilityValueChange( bool isIncrease )
{
onAccValueChangeCalled = true; return true;
}
void Impl::DummyControl::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
{
themeChangeCalled = change == StyleChange::THEME_CHANGE;
fontChangeCalled = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
}
void Impl::DummyControl::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
void Impl::DummyControl::OnPan(const PanGesture& pan) { panCalled = true; }
void Impl::DummyControl::OnTap(const TapGesture& tap) { tapCalled = true; }
void Impl::DummyControl::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
void Impl::DummyControl::OnSceneConnection( int depth ) { Control::OnSceneConnection( depth ); stageConnectionCalled = true; }
void Impl::DummyControl::OnSceneDisconnection() { stageDisconnectionCalled = true; Control::OnSceneDisconnection(); }
void Impl::DummyControl::OnChildAdd(Actor& child) { childAddCalled = true; }
void Impl::DummyControl::OnChildRemove(Actor& child) { childRemoveCalled = true; }
void Impl::DummyControl::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
void Impl::DummyControl::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
bool Impl::DummyControl::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
void Impl::DummyControl::OnKeyInputFocusGained() { keyInputFocusGained = true; }
void Impl::DummyControl::OnKeyInputFocusLost() { keyInputFocusLost = true; }
void Impl::DummyControl::SetLayout( Property::Index visualIndex, Property::Map& map )
{
Property::Value value( map );
mLayouts[visualIndex] = value;
}
void Impl::DummyControl::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
if ( mRelayoutCallback )
{
mRelayoutCallback( size ); // Execute callback if set
}
Property::Map emptyMap;
for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter )
{
Visual::Base visual = GetVisual(*iter);
Property::Value value = mLayouts[*iter];
Property::Map* map = NULL;
if( value.GetType() != Property::NONE )
{
map = value.GetMap();
}
if( map == NULL )
{
map = &emptyMap;
}
visual.SetTransformAndSize( *map, size );
}
}
void Impl::DummyControl::SetRelayoutCallback( RelayoutCallbackFunc callback )
{
mRelayoutCallback = callback;
}
Vector3 Impl::DummyControl::GetNaturalSize()
{
Vector2 currentSize;
for( auto elem : mRegisteredVisualIndices )
{
Vector2 naturalSize;
Visual::Base visual = GetVisual(elem);
visual.GetNaturalSize( naturalSize );
currentSize.width = std::max( naturalSize.width, currentSize.width );
currentSize.height = std::max( naturalSize.height, currentSize.height );
}
return Vector3( currentSize );
}
DummyControl DummyControl::New( bool override )
{
DummyControl control;
if (override)
{
control = Impl::DummyControl::New();
}
else
{
control = DummyControlImpl::New();
}
return control;
}
DummyControl::DummyControl( DummyControlImpl& implementation )
: Control( implementation )
{
}
DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
: Control( internal )
{
VerifyCustomActorPointer<DummyControlImpl>(internal);
}
} // namespace Toolkit
} // namespace Dali
| 30.955679 | 214 | 0.747383 |
7d10dd6416879b3113cbbcf6fc45aee5d1edc9f8 | 2,847 | cpp | C++ | example/tutorial.cpp | anarthal/mysql-asio | 13d3615464f41222052d9ad8fa0c86bcdddee537 | [
"BSL-1.0"
] | 47 | 2019-10-21T14:54:39.000Z | 2020-07-06T19:36:58.000Z | example/tutorial.cpp | anarthal/mysql-asio | 13d3615464f41222052d9ad8fa0c86bcdddee537 | [
"BSL-1.0"
] | 5 | 2020-03-05T12:03:02.000Z | 2020-07-06T18:18:35.000Z | example/tutorial.cpp | anarthal/mysql-asio | 13d3615464f41222052d9ad8fa0c86bcdddee537 | [
"BSL-1.0"
] | 4 | 2020-03-05T11:28:55.000Z | 2020-05-20T09:06:21.000Z | //
// Copyright (c) 2019-2022 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "boost/mysql/connection.hpp"
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/context.hpp>
#include <boost/mysql.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/system/system_error.hpp>
#include <iostream>
#include <string>
/**
* For this example, we will be using the 'boost_mysql_examples' database.
* You can get this database by running db_setup.sql.
* This example assumes you are connecting to a localhost MySQL server.
*
* This example uses synchronous functions and handles errors using exceptions.
*/
void main_impl(int argc, char** argv)
{
if (argc != 4)
{
std::cerr << "Usage: " << argv[0] << " <username> <password> <server-hostname>\n";
exit(1);
}
//[tutorial_connection
// The execution context, required to run I/O operations
boost::asio::io_context ctx;
// The SSL context, required to establish TLS connections.
// The default SSL options are good enough for us at this point.
boost::asio::ssl::context ssl_ctx (boost::asio::ssl::context::tls_client);
// The object defining the connection to the MySQL server.
boost::mysql::tcp_ssl_connection conn (ctx.get_executor(), ssl_ctx);
//]
//[tutorial_connect
// Resolve the hostname to get a collection of endpoints
boost::asio::ip::tcp::resolver resolver (ctx.get_executor());
auto endpoints = resolver.resolve(argv[3], boost::mysql::default_port_string);
// The username and password to use
boost::mysql::connection_params params (
argv[1], // username
argv[2] // password
);
// Connect to the server using the first endpoint returned by the resolver
conn.connect(*endpoints.begin(), params);
//]
//[tutorial_query
const char* sql = "SELECT \"Hello world!\"";
boost::mysql::tcp_ssl_resultset result = conn.query(sql);
//]
//[tutorial_read
std::vector<boost::mysql::row> employees = result.read_all();
//]
//[tutorial_values
const boost::mysql::row& first_row = employees.at(0);
boost::mysql::value first_value = first_row.values().at(0);
std::cout << first_value << std::endl;
//]
//[tutorial_close
conn.close();
//]
}
int main(int argc, char** argv)
{
try
{
main_impl(argc, argv);
}
catch (const boost::system::system_error& err)
{
std::cerr << "Error: " << err.what() << ", error code: " << err.code() << std::endl;
return 1;
}
catch (const std::exception& err)
{
std::cerr << "Error: " << err.what() << std::endl;
return 1;
}
}
| 29.05102 | 92 | 0.645592 |
7d1125330c9522ef1fd250f11ab7a4f8dbb1bc06 | 3,497 | cpp | C++ | CNN/activation_test.cpp | suiyili/projects | 29b4ab0435c8994809113c444b3dea4fff60b75c | [
"MIT"
] | null | null | null | CNN/activation_test.cpp | suiyili/projects | 29b4ab0435c8994809113c444b3dea4fff60b75c | [
"MIT"
] | null | null | null | CNN/activation_test.cpp | suiyili/projects | 29b4ab0435c8994809113c444b3dea4fff60b75c | [
"MIT"
] | null | null | null | #ifdef TEST
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "activation_mock.hpp"
#include "layer_mock.hpp"
#include "test_value.hpp"
#include "value_factory_mock.hpp"
#include <array>
#include <forward_list>
#include <future>
#include <numeric>
using namespace Catch;
namespace cnn::neuron {
SCENARIO("activation test", "[activation]") {
GIVEN("a previous layer") {
value_array prev_layer_values{.40f, .25f, .13f, .61f, 1.0f};
constexpr unsigned short prev_size = 4U;
auto prev_layer = std::make_unique<layer_mock>(prev_size);
auto &prev = *prev_layer;
for (size_t i = 0U; i < prev_size; ++i)
prev[i].set_output(prev_layer_values[i]);
AND_GIVEN("a series of W values") {
value_array init_weights{.20f, .31f, .22f, .85f, .58f};
value_factory_mock factory(init_weights);
activation_mock n(std::move(prev_layer), factory);
WHEN("activation forward") {
n.forward();
THEN("it should get argument from linear product") {
auto expected = factory[prev.size()];
for (size_t i = 0; i < prev.size(); ++i)
expected += prev[i].output() * factory[i];
REQUIRE(n.get_argument() == Approx(expected).margin(test_precision));
}
}
AND_GIVEN("a series of error gredients") {
std::array<float, 4> error_gradient{.25f, .22f, .38f, .18f};
WHEN("activation propagates back") {
n.propagate_back(error_gradient[0]);
n.train();
THEN("it should call previous layer with curated value") {
for (size_t i = 0; i < prev.size(); ++i) {
auto expected = error_gradient[0] * factory[i];
REQUIRE(prev[i].propagate_back_called_with() ==
Approx(expected).margin(test_precision));
}
AND_WHEN("learn from more back propagation") {
for (size_t i = 1U; i < error_gradient.size(); ++i) {
n.propagate_back(error_gradient[i]);
n.train();
}
const float learning_rate = .2f;
n.learn(learning_rate);
auto gradient_sum = std::accumulate(error_gradient.begin(),
error_gradient.end(), 0.0f);
value_array delta = prev_layer_values * gradient_sum;
delta /= (float)error_gradient.size();
delta *= learning_rate;
auto weights = init_weights - delta;
for (size_t i = 0; i < prev.size(); ++i)
prev[i].set_output(1.0f);
n.forward();
REQUIRE(n.get_argument() ==
Approx(weights.sum()).margin(test_precision));
}
}
}
WHEN("propagate back with multi-threads") {
std::forward_list<std::future<void>> tasks;
float total_error = 0.0f;
for (auto e : error_gradient) {
tasks.emplace_front(std::async(std::launch::async,
[&n, e] { n.propagate_back(e); }));
total_error += e;
}
for (auto &t : tasks)
t.wait();
n.train();
THEN("it should sum all propagation currectly") {
REQUIRE(n.get_back_prop() ==
Approx(total_error).margin(test_precision));
}
}
}
}
}
}
} // namespace cnn::neuron
#endif // TEST | 32.37963 | 79 | 0.547612 |
7d12722e884fe5221263bcfc371a702b1c0ca7bf | 1,832 | cpp | C++ | tests/depthai_pybind11_tests.cpp | 4ndr3aR/depthai-python | b4fe1211d19280b2f2be8a43912ea818f6f4b5b3 | [
"MIT"
] | 182 | 2020-06-25T00:27:12.000Z | 2022-03-31T05:06:04.000Z | tests/depthai_pybind11_tests.cpp | 4ndr3aR/depthai-python | b4fe1211d19280b2f2be8a43912ea818f6f4b5b3 | [
"MIT"
] | 206 | 2020-07-28T22:32:14.000Z | 2022-03-31T13:57:59.000Z | tests/depthai_pybind11_tests.cpp | 4ndr3aR/depthai-python | b4fe1211d19280b2f2be8a43912ea818f6f4b5b3 | [
"MIT"
] | 102 | 2020-08-06T23:02:35.000Z | 2022-03-24T19:43:30.000Z | /*
tests/pybind11_tests.cpp -- pybind example plugin
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
All rights reserved. Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.
*/
#include "depthai_pybind11_tests.hpp"
#include <functional>
#include <list>
/*
For testing purposes, we define a static global variable here in a function that each individual
test .cpp calls with its initialization lambda. It's convenient here because we can just not
compile some test files to disable/ignore some of the test code.
It is NOT recommended as a way to use pybind11 in practice, however: the initialization order will
be essentially random, which is okay for our test scripts (there are no dependencies between the
individual pybind11 test .cpp files), but most likely not what you want when using pybind11
productively.
Instead, see the "How can I reduce the build time?" question in the "Frequently asked questions"
section of the documentation for good practice on splitting binding code over multiple files.
*/
std::list<std::function<void(py::module_ &)>> &initializers() {
static std::list<std::function<void(py::module_ &)>> inits;
return inits;
}
test_initializer::test_initializer(Initializer init) {
initializers().emplace_back(init);
}
test_initializer::test_initializer(const char *submodule_name, Initializer init) {
initializers().emplace_back([=](py::module_ &parent) {
auto m = parent.def_submodule(submodule_name);
init(m);
});
}
PYBIND11_MODULE(depthai_pybind11_tests, m) {
m.doc() = "depthai pybind11 test module";
#if !defined(NDEBUG)
m.attr("debug_enabled") = true;
#else
m.attr("debug_enabled") = false;
#endif
for (const auto &initializer : initializers())
initializer(m);
}
| 32.714286 | 98 | 0.736354 |
7d12d9242afa2c4b4ec88bd2508da5bb7ffba34f | 3,377 | cpp | C++ | Code/Tools/TestImpactFramework/Runtime/Code/Source/Artifact/Factory/TestImpactTestEnumerationSuiteFactory.cpp | cypherdotXd/o3de | bb90c4ddfe2d495e9c00ebf1e2650c6d603a5676 | [
"Apache-2.0",
"MIT"
] | 11 | 2021-07-08T09:58:26.000Z | 2022-03-17T17:59:26.000Z | Code/Tools/TestImpactFramework/Runtime/Code/Source/Artifact/Factory/TestImpactTestEnumerationSuiteFactory.cpp | RoddieKieley/o3de | e804fd2a4241b039a42d9fa54eaae17dc94a7a92 | [
"Apache-2.0",
"MIT"
] | 29 | 2021-07-06T19:33:52.000Z | 2022-03-22T10:27:49.000Z | Code/Tools/TestImpactFramework/Runtime/Code/Source/Artifact/Factory/TestImpactTestEnumerationSuiteFactory.cpp | RoddieKieley/o3de | e804fd2a4241b039a42d9fa54eaae17dc94a7a92 | [
"Apache-2.0",
"MIT"
] | 4 | 2021-07-06T19:24:43.000Z | 2022-03-31T12:42:27.000Z | /*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Artifact/Factory/TestImpactTestEnumerationSuiteFactory.h>
#include <Artifact/TestImpactArtifactException.h>
#include <AzCore/XML/rapidxml.h>
#include <AzCore/std/containers/vector.h>
namespace TestImpact
{
namespace GTest
{
AZStd::vector<TestEnumerationSuite> TestEnumerationSuitesFactory(const AZStd::string& testEnumerationData)
{
// Keys for pertinent XML node and attribute names
constexpr const char* Keys[] =
{
"testsuites",
"testsuite",
"name",
"testcase"
};
enum
{
TestSuitesKey,
TestSuiteKey,
NameKey,
TestCaseKey
};
AZ_TestImpact_Eval(!testEnumerationData.empty(), ArtifactException, "Cannot parse enumeration, string is empty");
AZStd::vector<TestEnumerationSuite> testSuites;
AZStd::vector<char> rawData(testEnumerationData.begin(), testEnumerationData.end());
try
{
AZ::rapidxml::xml_document<> doc;
// Parse the XML doc with default flags
doc.parse<0>(rawData.data());
const auto testsuites_node = doc.first_node(Keys[TestSuitesKey]);
AZ_TestImpact_Eval(testsuites_node, ArtifactException, "Could not parse enumeration, XML is invalid");
for (auto testsuite_node = testsuites_node->first_node(Keys[TestSuiteKey]); testsuite_node;
testsuite_node = testsuite_node->next_sibling())
{
const auto isEnabled = [](const AZStd::string& name)
{
return !name.starts_with("DISABLED_") && name.find("/DISABLED_") == AZStd::string::npos;
};
TestEnumerationSuite testSuite;
testSuite.m_name = testsuite_node->first_attribute(Keys[NameKey])->value();
testSuite.m_enabled = isEnabled(testSuite.m_name);
for (auto testcase_node = testsuite_node->first_node(Keys[TestCaseKey]); testcase_node;
testcase_node = testcase_node->next_sibling())
{
TestEnumerationCase testCase;
testCase.m_name = testcase_node->first_attribute(Keys[NameKey])->value();
testCase.m_enabled = isEnabled(testCase.m_name);
testSuite.m_tests.emplace_back(AZStd::move(testCase));
}
testSuites.emplace_back(AZStd::move(testSuite));
}
}
catch (const std::exception& e)
{
AZ_Error("TestEnumerationSuitesFactory", false, e.what());
throw ArtifactException(e.what());
}
catch (...)
{
throw ArtifactException("An unknown error occured parsing the XML data");
}
return testSuites;
}
} // namespace GTest
} // namespace TestImpact
| 38.375 | 125 | 0.55878 |
7d16eb73ad5ad9f95d96c26644eecb823e05d550 | 26,472 | cc | C++ | Ghidra/rulecompile.cc | fjqisba/E-Decompiler | f598c4205d8b9e4d29172dab0bb2672c75e48af9 | [
"MIT"
] | 74 | 2021-03-04T08:12:43.000Z | 2022-03-14T13:50:20.000Z | Ghidra/rulecompile.cc | fjqisba/E-Decompiler | f598c4205d8b9e4d29172dab0bb2672c75e48af9 | [
"MIT"
] | 10 | 2021-03-05T09:52:10.000Z | 2021-07-05T13:48:33.000Z | Ghidra/rulecompile.cc | fjqisba/E-Decompiler | f598c4205d8b9e4d29172dab0bb2672c75e48af9 | [
"MIT"
] | 15 | 2021-04-06T14:22:39.000Z | 2022-03-29T13:14:47.000Z | /* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef CPUI_RULECOMPILE
#include "rulecompile.hh"
#include "ruleparse.hh"
RuleCompile *rulecompile;
extern int4 ruleparsedebug;
extern int4 ruleparseparse(void);
class MyLoadImage : public LoadImage { // Dummy loadimage
public:
MyLoadImage(void) : LoadImage("nofile") {}
virtual void loadFill(uint1 *ptr,int4 size,const Address &addr) { for(int4 i=0;i<size;++i) ptr[i] = 0; }
virtual string getArchType(void) const { return "myload"; }
virtual void adjustVma(long adjust) { }
};
int4 RuleLexer::identlist[256] = {
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,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0,
0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 5,
0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 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, 0, 0, 0, 0, 0, 0, 0, 0
};
int4 RuleLexer::scanIdentifier(void)
{
int4 i=0;
identifier[i] = (char)getNextChar(); // Scan at least the first character
i += 1;
do {
if ((identlist[next(0)]&1) != 0) {
identifier[i] = (char) getNextChar();
i += 1;
}
else
break;
} while(i<255);
if ((i==255)||(i==0))
return -1; // Identifier is too long
identifier[i] = '\0';
identlength = i;
if ((identlist[(int4)identifier[0]]&2) != 0) // First number is digit
return scanNumber();
switch(identifier[0]) {
case 'o':
return buildString(OP_IDENTIFIER);
case 'v':
return buildString(VAR_IDENTIFIER);
case '#':
return buildString(CONST_IDENTIFIER);
case 'O':
return buildString(OP_NEW_IDENTIFIER);
case 'V':
return buildString(VAR_NEW_IDENTIFIER);
case '.':
return buildString(DOT_IDENTIFIER);
default:
return otherIdentifiers();
}
}
int4 RuleLexer::scanNumber(void)
{
istringstream s(identifier);
s.unsetf(ios::dec | ios::hex | ios::oct);
uint8 val;
s >> val;
if (!s)
return BADINTEGER;
ruleparselval.big = new int8(val);
return INTB;
}
int4 RuleLexer::buildString(int4 tokentype)
{
if (identlength <= 1) return -1;
for(int4 i=1;i<identlength;++i) {
if ((identlist[(int4)identifier[i]]&4)==0) return -1;
}
if (identifier[0] == '.') {
ruleparselval.str = new string(identifier+1);
return tokentype;
}
if (identifier[0] == '#')
identifier[0] = 'c';
ruleparselval.str = new string(identifier);
return tokentype;
}
int4 RuleLexer::otherIdentifiers(void)
{
map<string,int4>::const_iterator iter;
iter = keywordmap.find(string(identifier));
if (iter != keywordmap.end())
return (*iter).second;
return -1;
}
void RuleLexer::initKeywords(void)
{
keywordmap["COPY"] = OP_COPY;
keywordmap["ZEXT"] = OP_INT_ZEXT;
keywordmap["CARRY"] = OP_INT_CARRY;
keywordmap["SCARRY"] = OP_INT_SCARRY;
keywordmap["SEXT"] = OP_INT_SEXT;
keywordmap["SBORROW"] = OP_INT_SBORROW;
keywordmap["NAN"] = OP_FLOAT_NAN;
keywordmap["ABS"] = OP_FLOAT_ABS;
keywordmap["SQRT"] = OP_FLOAT_SQRT;
keywordmap["CEIL"] = OP_FLOAT_CEIL;
keywordmap["FLOOR"] = OP_FLOAT_FLOOR;
keywordmap["ROUND"] = OP_FLOAT_ROUND;
keywordmap["INT2FLOAT"] = OP_FLOAT_INT2FLOAT;
keywordmap["FLOAT2FLOAT"] = OP_FLOAT_FLOAT2FLOAT;
keywordmap["TRUNC"] = OP_FLOAT_TRUNC;
keywordmap["GOTO"] = OP_BRANCH;
keywordmap["GOTOIND"] = OP_BRANCHIND;
keywordmap["CALL"] = OP_CALL;
keywordmap["CALLIND"] = OP_CALLIND;
keywordmap["RETURN"] = OP_RETURN;
keywordmap["CBRANCH"] = OP_CBRANCH;
keywordmap["USEROP"] = OP_CALLOTHER;
keywordmap["LOAD"] = OP_LOAD;
keywordmap["STORE"] = OP_STORE;
keywordmap["CONCAT"] = OP_PIECE;
keywordmap["SUBPIECE"] = OP_SUBPIECE;
keywordmap["before"] = BEFORE_KEYWORD;
keywordmap["after"] = AFTER_KEYWORD;
keywordmap["remove"] = REMOVE_KEYWORD;
keywordmap["set"] = SET_KEYWORD;
keywordmap["istrue"] = ISTRUE_KEYWORD;
keywordmap["isfalse"] = ISFALSE_KEYWORD;
}
int4 RuleLexer::nextToken(void)
{
for(;;) {
int4 mychar = next(0);
switch(mychar) {
case '(':
case ')':
case ',':
case '[':
case ']':
case ';':
case '{':
case '}':
case ':':
getNextChar();
ruleparselval.ch = (char)mychar;
return mychar;
case '\r':
case ' ':
case '\t':
case '\v':
getNextChar();
break;
case '\n':
getNextChar();
lineno += 1;
break;
case '-':
getNextChar();
if (next(0) == '>') {
getNextChar();
return RIGHT_ARROW;
}
else if (next(0) == '-') {
getNextChar();
if (next(0) == '>') {
getNextChar();
return DOUBLE_RIGHT_ARROW;
}
return ACTION_TICK;
}
return OP_INT_SUB;
case '<':
getNextChar();
if (next(0) == '-') {
getNextChar();
if (next(0) == '-') {
getNextChar();
return DOUBLE_LEFT_ARROW;
}
return LEFT_ARROW;
}
else if (next(0) == '<') {
getNextChar();
return OP_INT_LEFT;
}
else if (next(0) == '=') {
getNextChar();
return OP_INT_LESSEQUAL;
}
return OP_INT_LESS;
case '|':
getNextChar();
if (next(0) == '|') {
getNextChar();
return OP_BOOL_OR;
}
return OP_INT_OR;
case '&':
getNextChar();
if (next(0) == '&') {
getNextChar();
return OP_BOOL_AND;
}
return OP_INT_AND;
case '^':
getNextChar();
if (next(0) == '^') {
getNextChar();
return OP_BOOL_XOR;
}
return OP_INT_XOR;
case '>':
if (next(1) == '>') {
getNextChar();
getNextChar();
return OP_INT_RIGHT;
}
return -1;
case '=':
getNextChar();
if (next(0) == '=') {
getNextChar();
return OP_INT_EQUAL;
}
ruleparselval.ch = (char)mychar;
return mychar;
case '!':
getNextChar();
if (next(0) == '=') {
getNextChar();
return OP_INT_NOTEQUAL;
}
return OP_BOOL_NEGATE;
case 's':
if (next(1) == '/') {
getNextChar();
getNextChar();
return OP_INT_SDIV;
}
else if (next(1) == '%') {
getNextChar();
getNextChar();
return OP_INT_SREM;
}
else if ((next(1)=='>')&&(next(2)=='>')) {
getNextChar();
getNextChar();
getNextChar();
return OP_INT_SRIGHT;
}
else if (next(1)=='<') {
getNextChar();
getNextChar();
if (next(0) == '=') {
getNextChar();
return OP_INT_SLESSEQUAL;
}
return OP_INT_SLESS;
}
return scanIdentifier();
case 'f':
if (next(1) == '+') {
getNextChar();
getNextChar();
return OP_FLOAT_ADD;
}
else if (next(1) == '-') {
getNextChar();
getNextChar();
return OP_FLOAT_SUB;
}
else if (next(1) == '*') {
getNextChar();
getNextChar();
return OP_FLOAT_MULT;
}
else if (next(1) == '/') {
getNextChar();
getNextChar();
return OP_FLOAT_DIV;
}
else if ((next(1) == '=')&&(next(2) == '=')) {
getNextChar();
getNextChar();
getNextChar();
return OP_FLOAT_EQUAL;
}
else if ((next(1) == '!')&&(next(2) == '=')) {
getNextChar();
getNextChar();
getNextChar();
return OP_FLOAT_NOTEQUAL;
}
else if (next(1) == '<') {
getNextChar();
getNextChar();
if (next(0) == '=') {
getNextChar();
return OP_FLOAT_LESSEQUAL;
}
return OP_FLOAT_LESS;
}
return -1;
case '+':
getNextChar();
return OP_INT_ADD;
case '*':
getNextChar();
return OP_INT_MULT;
case '/':
getNextChar();
return OP_INT_DIV;
case '%':
getNextChar();
return OP_INT_REM;
case '~':
getNextChar();
return OP_INT_NEGATE;
case '#':
if ((identlist[next(1)]&6)==4)
return scanIdentifier();
getNextChar();
ruleparselval.ch = (char)mychar; // Return '#' as single token
return mychar;
default:
return scanIdentifier();
}
}
return -1;
}
RuleLexer::RuleLexer(void)
{
initKeywords();
}
void RuleLexer::initialize(istream &t)
{
s = &t;
pos = 0;
endofstream = false;
lineno = 1;
getNextChar();
getNextChar();
getNextChar();
getNextChar(); // Fill lookahead buffer
}
RuleCompile::RuleCompile(void)
{
DummyTranslate dummy;
error_stream = (ostream *)0;
errors = 0;
finalrule = (ConstraintGroup *)0;
OpBehavior::registerInstructions(inst,&dummy);
}
RuleCompile::~RuleCompile(void)
{
if (finalrule != (ConstraintGroup *)0)
delete finalrule;
for(int4 i=0;i<inst.size();++i) {
OpBehavior *t_op = inst[i];
if (t_op != (OpBehavior *)0)
delete t_op;
}
}
void RuleCompile::ruleError(const char *s)
{
if (error_stream != (ostream *)0) {
*error_stream << "Error at line " << dec << lexer.getLineNo() << endl;
*error_stream << " " << s << endl;
}
errors += 1;
}
int4 RuleCompile::findIdentifier(string *nm)
{
int4 resid;
map<string,int4>::const_iterator iter;
iter = namemap.find(*nm);
if (iter == namemap.end()) {
resid = namemap.size();
namemap[*nm] = resid;
}
else
resid = (*iter).second;
delete nm;
return resid;
}
ConstraintGroup *RuleCompile::newOp(int4 id)
{
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(new DummyOpConstraint(id));
return res;
}
ConstraintGroup *RuleCompile::newVarnode(int4 id)
{
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(new DummyVarnodeConstraint(id));
return res;
}
ConstraintGroup *RuleCompile::newConst(int4 id)
{
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(new DummyConstConstraint(id));
return res;
}
ConstraintGroup *RuleCompile::opCopy(ConstraintGroup *base,int4 opid)
{
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpCopy(opindex,opid);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opInput(ConstraintGroup *base,int8 *slot,int4 varid)
{
int4 ourslot = (int4) *slot;
delete slot;
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpInput(opindex,varid,ourslot);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opInputAny(ConstraintGroup *base,int4 varid)
{
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpInputAny(opindex,varid);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opInputConstVal(ConstraintGroup *base,int8 *slot,RHSConstant *val)
{
int4 ourslot = (int4) *slot;
delete slot;
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint;
ConstantAbsolute *myconst = dynamic_cast<ConstantAbsolute *>(val);
if (myconst != (ConstantAbsolute *)0) {
newconstraint = new ConstraintParamConstVal(opindex,ourslot,myconst->getVal());
}
else {
ConstantNamed *mynamed = dynamic_cast<ConstantNamed *>(val);
if (mynamed != (ConstantNamed *)0) {
newconstraint = new ConstraintParamConst(opindex,ourslot,mynamed->getId());
}
else {
ruleError("Can only use absolute constant here");
newconstraint = new ConstraintParamConstVal(opindex,ourslot,0);
}
}
delete val;
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opOutput(ConstraintGroup *base,int4 varid)
{
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpOutput(opindex,varid);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varCopy(ConstraintGroup *base,int4 varid)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintVarnodeCopy(varid,varindex);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varConst(ConstraintGroup *base,RHSConstant *ex,RHSConstant *sz)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintVarConst(varindex,ex,sz);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varDef(ConstraintGroup *base,int4 opid)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintDef(opid,varindex);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varDescend(ConstraintGroup *base,int4 opid)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintDescend(opid,varindex);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varUniqueDescend(ConstraintGroup *base,int4 opid)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintLoneDescend(opid,varindex);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opCodeConstraint(ConstraintGroup *base,vector<OpCode> *oplist)
{
if (oplist->size() != 1)
throw LowlevelError("Not currently supporting multiple opcode constraints");
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpcode(opindex,*oplist);
delete oplist;
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opCompareConstraint(ConstraintGroup *base,int4 opid,OpCode opc)
{
int4 op1index = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpCompare(op1index,opid,(opc==CPUI_INT_EQUAL));
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varCompareConstraint(ConstraintGroup *base,int4 varid,OpCode opc)
{
int4 var1index = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintVarCompare(var1index,varid,(opc==CPUI_INT_EQUAL));
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::constCompareConstraint(ConstraintGroup *base,int4 constid,OpCode opc)
{
int4 const1index = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintConstCompare(const1index,constid,opc);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::constNamedExpression(int4 id,RHSConstant *expr)
{
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(new ConstraintNamedExpression(id,expr));
return res;
}
ConstraintGroup *RuleCompile::emptyGroup(void)
{
return new ConstraintGroup();
}
ConstraintGroup *RuleCompile::emptyOrGroup(void)
{
return new ConstraintOr();
}
ConstraintGroup *RuleCompile::mergeGroups(ConstraintGroup *a,ConstraintGroup *b)
{
a->mergeIn(b);
return a;
}
ConstraintGroup *RuleCompile::addOr(ConstraintGroup *base,ConstraintGroup *newor)
{
base->addConstraint(newor);
return base;
}
ConstraintGroup *RuleCompile::opCreation(int4 newid,OpCode oc,bool iafter,int4 oldid)
{
OpBehavior *behave = inst[oc];
int4 numparms = behave->isUnary() ? 1 : 2;
UnifyConstraint *newconstraint = new ConstraintNewOp(newid,oldid,oc,iafter,numparms);
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(newconstraint);
return res;
}
ConstraintGroup *RuleCompile::newUniqueOut(ConstraintGroup *base,int4 varid,int4 sz)
{
UnifyConstraint *newconstraint = new ConstraintNewUniqueOut(base->getBaseIndex(),varid,sz);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::newSetInput(ConstraintGroup *base,RHSConstant *slot,int4 varid)
{
UnifyConstraint *newconstraint = new ConstraintSetInput(base->getBaseIndex(),slot,varid);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::newSetInputConstVal(ConstraintGroup *base,RHSConstant *slot,RHSConstant *val,RHSConstant *sz)
{
UnifyConstraint *newconstraint = new ConstraintSetInputConstVal(base->getBaseIndex(),slot,val,sz);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::removeInput(ConstraintGroup *base,RHSConstant *slot)
{
UnifyConstraint *newconstraint = new ConstraintRemoveInput(base->getBaseIndex(),slot);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::newSetOpcode(ConstraintGroup *base,OpCode opc)
{
int4 opid = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintSetOpcode(opid,opc);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::booleanConstraint(bool ist,RHSConstant *expr)
{
ConstraintGroup *base = new ConstraintGroup();
UnifyConstraint *newconstraint = new ConstraintBoolean(ist,expr);
base->addConstraint(newconstraint);
return base;
}
RHSConstant *RuleCompile::constNamed(int4 id)
{
RHSConstant *res = new ConstantNamed(id);
return res;
}
RHSConstant *RuleCompile::constAbsolute(int8 *val)
{
RHSConstant *res = new ConstantAbsolute(*val);
delete val;
return res;
}
RHSConstant *RuleCompile::constBinaryExpression(RHSConstant *ex1,OpCode opc,RHSConstant *ex2)
{
RHSConstant *res = new ConstantExpression( ex1, ex2, opc );
return res;
}
RHSConstant *RuleCompile::constVarnodeSize(int4 varindex)
{
RHSConstant *res = new ConstantVarnodeSize(varindex);
return res;
}
RHSConstant *RuleCompile::dotIdentifier(int4 id,string *str)
{
RHSConstant *res;
if ((*str) == "offset")
res = new ConstantOffset(id);
else if ((*str) == "size")
res = new ConstantVarnodeSize(id);
else if ((*str) == "isconstant")
res = new ConstantIsConstant(id);
else if ((*str) == "heritageknown")
res = new ConstantHeritageKnown(id);
else if ((*str) == "consume")
res = new ConstantConsumed(id);
else if ((*str) == "nzmask")
res = new ConstantNZMask(id);
else {
string errmsg = "Unknown variable attribute: " + *str;
ruleError(errmsg.c_str());
res = new ConstantAbsolute(0);
}
delete str;
return res;
}
void RuleCompile::run(istream &s,bool debug)
{
#ifdef YYDEBUG
ruleparsedebug = debug ? 1 : 0;
#endif
if (!s) {
if (error_stream != (ostream *)0)
*error_stream << "Bad input stream to rule compiler" << endl;
return;
}
errors = 0;
if (finalrule != (ConstraintGroup *)0) {
delete finalrule;
finalrule = (ConstraintGroup *)0;
}
lexer.initialize(s);
rulecompile = this; // Setup the global pointer
int4 parseres = ruleparseparse(); // Try to parse
if (parseres!=0) {
errors += 1;
if (error_stream != (ostream *)0)
*error_stream << "Parsing error" << endl;
}
if (errors!=0) {
if (error_stream != (ostream *)0)
*error_stream << "Parsing incomplete" << endl;
}
}
void RuleCompile::postProcess(void)
{
int4 id = 0;
finalrule->removeDummy();
finalrule->setId(id); // Set id for everybody
}
int4 RuleCompile::postProcessRule(vector<OpCode> &opcodelist)
{ // Do normal post processing but also remove initial opcode check
finalrule->removeDummy();
if (finalrule->numConstraints() == 0)
throw LowlevelError("Cannot postprocess empty rule");
ConstraintOpcode *subconst = dynamic_cast<ConstraintOpcode *>(finalrule->getConstraint(0));
if (subconst == (ConstraintOpcode *)0)
throw LowlevelError("Rule does not start with opcode constraint");
opcodelist = subconst->getOpCodes();
int4 opinit = subconst->getMaxNum();
finalrule->deleteConstraint(0);
int4 id = 0;
finalrule->setId(id);
return opinit;
}
ConstraintGroup *RuleCompile::buildUnifyer(const string &rule,const vector<string> &idlist,
vector<int4> &res)
{
RuleCompile ruler;
istringstream s(rule);
ruler.run(s,false);
if (ruler.numErrors() != 0)
throw LowlevelError("Could not build rule");
ConstraintGroup *resconst = ruler.releaseRule();
for(int4 i=0;i<idlist.size();++i) {
char initc;
int4 id = -1;
map<string,int4>::const_iterator iter;
if (idlist[i].size() != 0) {
initc = idlist[i][0];
if ((initc == 'o')||(initc == 'O')||(initc == 'v')||(initc == 'V')||(initc == '#')) {
iter = ruler.namemap.find(idlist[i]);
if (iter != ruler.namemap.end())
id = (*iter).second;
}
}
if (id == -1)
throw LowlevelError("Bad initializer name: "+idlist[i]);
res.push_back(id);
}
return resconst;
}
RuleGeneric::RuleGeneric(const string &g,const string &nm,const vector<OpCode> &sops,int4 opi,ConstraintGroup *c)
: Rule(g,0,nm), state(c)
{
starterops = sops;
opinit = opi;
constraint = c;
}
void RuleGeneric::getOpList(vector<uint4> &oplist) const
{
for(int4 i=0;i<starterops.size();++i)
oplist.push_back((uint4)starterops[i]);
}
int4 RuleGeneric::applyOp(PcodeOp *op,Funcdata &data)
{
state.setFunction(&data);
state.initialize(opinit,op);
constraint->initialize(state);
return constraint->step(state);
}
RuleGeneric *RuleGeneric::build(const string &nm,const string &gp,const string &content)
{
RuleCompile compiler;
istringstream s(content);
compiler.run(s,false);
if (compiler.numErrors() != 0)
throw LowlevelError("Unable to parse dynamic rule: "+nm);
vector<OpCode> opcodelist;
int4 opinit = compiler.postProcessRule(opcodelist);
RuleGeneric *res = new RuleGeneric(gp,nm,opcodelist,opinit,compiler.releaseRule());
return res;
}
#endif
/*
Here is the original flex parser
%{
#include "rulecompile.hh"
#include "ruleparse.hh"
#define ruleparsewrap() 1
#define YY_SKIP_YYWRAP
extern RuleCompile *rulecompile;
int4 scan_number(char *numtext,YYSTYPE *lval)
{
istringstream s(numtext);
s.unsetf(ios::dec | ios::hex | ios::oct);
uintb val;
s >> val;
if (!s)
return BADINTEGER;
lval->big = new intb(val);
return INTB;
}
int4 find_op_identifier(void)
{
string ident(yytext);
ruleparselval.id = rulecompile->findOpIdentifier(ident);
return OP_IDENTIFIER;
}
int4 find_var_identifier(void)
{
string ident(yytext);
ruleparselval.id = rulecompile->findVarIdentifier(ident);
return VAR_IDENTIFIER;
}
int4 find_const_identifier(void)
{
string ident(yytext);
ruleparselval.id = rulecompile->findConstIdentifier(ident);
return CONST_IDENTIFIER;
}
%}
%%
[(),\[\];\{\}\#] { ruleparselval.ch = yytext[0]; return yytext[0]; }
[0-9]+ { return scan_number(yytext,&ruleparselval); }
0x[0-9a-fA-F]+ { return scan_number(yytext,&ruleparselval); }
[\r\ \t\v]+
\n { rulecompile->nextLine(); }
\-\> { return RIGHT_ARROW; }
\<\- { return LEFT_ARROW; }
\|\| { return OP_BOOL_OR; }
\&\& { return OP_BOOL_AND; }
\^\^ { return OP_BOOL_XOR; }
\>\> { return OP_INT_RIGHT; }
\<\< { return OP_INT_LEFT; }
\=\= { return OP_INT_EQUAL; }
\!\= { return OP_INT_NOTEQUAL; }
\<\= { return OP_INT_LESSEQUAL; }
s\/ { return OP_INT_SDIV; }
s\% { return OP_INT_SREM; }
s\>\> { return OP_INT_SRIGHT; }
s\< { return OP_INT_SLESS; }
s\<\= { return OP_INT_SLESSEQUAL; }
f\+ { return OP_FLOAT_ADD; }
f\- { return OP_FLOAT_SUB; }
f\* { return OP_FLOAT_MULT; }
f\/ { return OP_FLOAT_DIV; }
f\=\= { return OP_FLOAT_EQUAL; }
f\!\= { return OP_FLOAT_NOTEQUAL; }
f\< { return OP_FLOAT_LESS; }
f\<\= { return OP_FLOAT_LESSEQUAL; }
ZEXT { return OP_INT_ZEXT; }
CARRY { return OP_INT_CARRY; }
SEXT { return OP_INT_SEXT; }
SCARRY { return OP_INT_SCARRY; }
SBORROW { return OP_INT_SBORROW; }
NAN { return OP_FLOAT_NAN; }
ABS { return OP_FLOAT_ABS; }
SQRT { return OP_FLOAT_SQRT; }
CEIL { return OP_FLOAT_CEIL; }
FLOOR { return OP_FLOAT_FLOOR; }
ROUND { return OP_FLOAT_ROUND; }
INT2FLOAT { return OP_FLOAT_INT2FLOAT; }
FLOAT2FLOAT { return OP_FLOAT_FLOAT2FLOAT; }
TRUNC { return OP_FLOAT_TRUNC; }
GOTO { return OP_BRANCH; }
GOTOIND { return OP_BRANCHIND; }
CALL { return OP_CALL; }
CALLIND { return OP_CALLIND; }
RETURN { return OP_RETURN; }
CBRRANCH { return OP_CBRANCH; }
USEROP { return OP_CALLOTHER; }
LOAD { return OP_LOAD; }
STORE { return OP_STORE; }
CONCAT { return OP_PIECE; }
SUBPIECE { return OP_SUBPIECE; }
\+ { return OP_INT_ADD; }
\- { return OP_INT_SUB; }
\! { return OP_BOOL_NEGATE; }
\& { return OP_INT_AND; }
\| { return OP_INT_OR; }
\^ { return OP_INT_XOR; }
\* { return OP_INT_MULT; }
\/ { return OP_INT_DIV; }
\% { return OP_INT_REM; }
\~ { return OP_INT_NEGATE; }
\< { return OP_INT_LESS; }
o[a-zA-Z0-9_]+ { return find_op_identifier(); }
v[a-zA-Z0-9_]+ { return find_var_identifier(); }
#[a-zA-Z0-9_]+ { return find_const_identifier(); }
*/
| 26.183976 | 124 | 0.624169 |
7d1b701c9c52c0c08dbe982a77322b9a4b100356 | 263 | cpp | C++ | include-engine/utility.cpp | sgorsten/include-engine | 67af882e24beba73ad44621397993e1b6818cf5b | [
"Unlicense"
] | 47 | 2017-03-27T12:37:02.000Z | 2021-05-31T12:34:01.000Z | include-engine/utility.cpp | sgorsten/include-engine | 67af882e24beba73ad44621397993e1b6818cf5b | [
"Unlicense"
] | 3 | 2017-03-27T12:46:28.000Z | 2018-03-24T16:05:05.000Z | include-engine/utility.cpp | sgorsten/include-engine | 67af882e24beba73ad44621397993e1b6818cf5b | [
"Unlicense"
] | 4 | 2017-09-05T11:22:40.000Z | 2020-05-07T13:17:31.000Z | #include "utility.h"
/////////////////
// fail_fast() //
/////////////////
#include <Windows.h>
#include <iostream>
void fail_fast()
{
if(IsDebuggerPresent()) DebugBreak();
std::cerr << "fail_fast() called." << std::endl;
std::exit(EXIT_FAILURE);
} | 17.533333 | 52 | 0.547529 |
7d20aaa9218edb194a674a4700ca96d0bde3c7d5 | 1,120 | cpp | C++ | source/problem0003.cpp | quisseh/project-euler-solutions | 68a7d0c1c6cff7a80d6afca7f3542715ee4339eb | [
"MIT"
] | 1 | 2015-12-19T03:48:46.000Z | 2015-12-19T03:48:46.000Z | source/problem0003.cpp | quisseh/project-euler-solutions | 68a7d0c1c6cff7a80d6afca7f3542715ee4339eb | [
"MIT"
] | null | null | null | source/problem0003.cpp | quisseh/project-euler-solutions | 68a7d0c1c6cff7a80d6afca7f3542715ee4339eb | [
"MIT"
] | null | null | null | /*
* Largest prime factor
*
* Problem 3
*
* Created by quisseh on 11/2/15.
*/
#include "problem0003.h"
/*
* A number will have at most one prime factor
* greater than its square root. So loop through
* potential prime factors of [target], and
* if one is found, reduce [target] by the current
* [factor]. If [factor] exceeds the square root of
* [target], then it is the largest prime factor.
*/
void problem0003::run() {
long target = m_target;
long factor = 2; /* Start with the smallest prime numbers. */
long lastFactor = 1;
long topFactor = (long) sqrt(target);
while (target > 0 && factor <= topFactor) {
while (target % factor == 0) { /* If [factor] is a factor of [target], */
target /= factor; /* reduce [target] by [factor]. */
lastFactor = factor;
topFactor = (long) sqrt(target); /* Get the new square root of the updated [target]. */
}
factor += factor == 2 ? 1 : 2; /* Increment [factor] by 2 once it reaches 3 so only odd numbers are checked. */
}
std::cout << ((target == 1) ? lastFactor : target);
}
| 32.941176 | 119 | 0.608036 |
7d277e232f3c927894e50b38bf10455e88f25aac | 14 | hpp | C++ | src/arrays.hpp | radio-rogal/c-pointers | a4036d0b8ee982f924463dd2fa79afcca7da9d72 | [
"Apache-2.0"
] | null | null | null | src/arrays.hpp | radio-rogal/c-pointers | a4036d0b8ee982f924463dd2fa79afcca7da9d72 | [
"Apache-2.0"
] | null | null | null | src/arrays.hpp | radio-rogal/c-pointers | a4036d0b8ee982f924463dd2fa79afcca7da9d72 | [
"Apache-2.0"
] | null | null | null | void arrays(); | 14 | 14 | 0.714286 |
7d3060c0d0ec2fa7ab587beb1e24987212f8d78a | 2,625 | cpp | C++ | Chapter10/testBSPDE1.cpp | alamlam1982/fincpp | 470469d35d90fc0fde96f119e329aedbc5f68f89 | [
"CECILL-B"
] | null | null | null | Chapter10/testBSPDE1.cpp | alamlam1982/fincpp | 470469d35d90fc0fde96f119e329aedbc5f68f89 | [
"CECILL-B"
] | null | null | null | Chapter10/testBSPDE1.cpp | alamlam1982/fincpp | 470469d35d90fc0fde96f119e329aedbc5f68f89 | [
"CECILL-B"
] | null | null | null | // testBSPDE1.cpp
//
// Testing 1 factor BS model.
//
// (C) Datasim Education BV 2005
//
#include "fdmdirector.cpp"
#include "arraymechanisms.cpp"
#include <iostream>
#include <string>
using namespace std;
#include "exceldriver.cpp"
void printOneExcel(Vector<double, long> & x,
Vector<double, long>& functionResult,
string& title)
{
// N.B. Excel has a limit of 8 charts; after that you get a run-time error
cout << "Starting Excel\n";
ExcelDriver & excel = ExcelDriver::Instance();
excel.MakeVisible(true); // Default is INVISIBLE!
excel.CreateChart(x, functionResult, title, "X", "Y");
}
// Excel output as well
void printInExcel(const Vector<double, long>& x, // X array
const list<string>& labels, // Names of each vector
const list<Vector<double, long> >& functionResult) // The list of Y values
{ // Print a list of Vectors in Excel. Each vector is the output of
// a finite difference scheme for a scalar IVP
cout << "Starting Excel\n";
ExcelDriver & excel = ExcelDriver::Instance();
excel.MakeVisible(true); // Default is INVISIBLE!
// Don't make the string names too long!!
excel.CreateChart(x, labels, functionResult, string("FDM Scalar IVP"),
string("Time Axis"), string ("Value"));
}
double mySigma (double x, double t)
{
double sigmaS = 0.30 * 0.30;
return 0.5 * sigmaS * x * x;
}
double myMu (double x, double t)
{
double r = 0.06;
double D = 0.00;
return (r - D) * x;
}
double myB (double x, double t)
{
double r = 0.06;
return -r;
}
double myF (double x, double t)
{
return 0.0;
}
double myBCL (double t)
{
//return 0.0; // C
double K = 10;
double r = 0.06;
double T = 1.0;
return K * ::exp(-r * (T - t));
}
double myBCR (double t)
{
double Smax = 100;
// return Smax;
return 0.0; // P
}
double myIC (double x)
{
double K = 10;
if (x < K)
return -(x - K);
return 0.0;
}
int main()
{
using namespace BlackScholesOneFactorIBVP;
// Assignment of functions
sigma = mySigma;
mu = myMu;
b = myB;
f = myF;
BCL = myBCL;
BCR = myBCR;
IC = myIC;
double T = 1.0; int J= 200; int N = 4000-1;
double Smax = 100.0;
FDMDirector fdir(Smax, T, J, N);
fdir.Start();
L1:
fdir.doit();
// print(fdir.current());
if (fdir.isDone() == false)
goto L1;
Vector<double, long> xresult(J+1, 1);
xresult[xresult.MinIndex()] = 0.0;
double h = Smax / (double) (J);
for (long j = xresult.MinIndex()+1; j <= xresult.MaxIndex(); j++)
{
xresult[j] = xresult[j-1] + h;
}
print (xresult);
//print(fdir.current());
printOneExcel(xresult, fdir.current(), string("Value"));
return 0;
}
| 16.719745 | 79 | 0.629333 |
7d30e4b25432f8b5510a995ec877ba89010e29f6 | 16,006 | hpp | C++ | Classes/LineDrawer.hpp | bennyk/SmoothDrawing-x | c6095ee078948b82804c30398a65c4f06e522d1b | [
"MIT"
] | 4 | 2016-07-21T10:37:24.000Z | 2019-08-22T13:13:53.000Z | Classes/LineDrawer.hpp | bennyk/SmoothDrawing-x | c6095ee078948b82804c30398a65c4f06e522d1b | [
"MIT"
] | 1 | 2017-07-14T10:02:12.000Z | 2017-07-14T12:54:33.000Z | Classes/LineDrawer.hpp | bennyk/SmoothDrawing-x | c6095ee078948b82804c30398a65c4f06e522d1b | [
"MIT"
] | 7 | 2016-02-26T04:07:03.000Z | 2021-05-31T01:59:30.000Z | //
// LineDrawer.hpp
// SmoothDrawing
//
// Created by Benny Khoo on 18/10/2015.
//
//
#ifndef LineDrawer_hpp
#define LineDrawer_hpp
#include <stdio.h>
#include "GestureRecognizers.hpp"
using namespace cocos2d;
class LineDrawer : public Node {
public:
static constexpr float DefaultLineWidth = 1.0f;
static constexpr float Overdraw = .5f;
static const Color4F BackgroundColor;
struct LinePoint {
Vec2 pos;
float width;
LinePoint (Vec2 p, float w) : pos(p), width(w) {}
LinePoint() : pos {0, 0}, width {DefaultLineWidth} {}
};
struct CirclePoint {
Vec2 pos;
float width;
Vec2 dir;
CirclePoint (Vec2 p, float w, Vec2 d) : pos(p), width(w), dir(d) {}
};
public:
static LineDrawer *create()
{
LineDrawer *node = new (std::nothrow) LineDrawer();
if (node)
{
node->init();
node->autorelease();
}
else
{
CC_SAFE_DELETE(node);
}
return node;
}
LineDrawer () : _enableLineSmoothing(true), _lastSize(0.0) {}
~LineDrawer() {
if (_renderTexture != nullptr)
_renderTexture->release();
if (_panGestureRecognizer != nullptr)
_panGestureRecognizer->release();
if (_longPressGestureRecognizer != nullptr)
_longPressGestureRecognizer->release();
}
virtual bool init()
{
_panGestureRecognizer = PanGestureRecognizer::create();
_panGestureRecognizer->retain();
_panGestureRecognizer->setTarget(CC_CALLBACK_1(LineDrawer::handlePanGestureRecognizer, this));
_panGestureRecognizer->addWithSceneGraphPriority(this->getEventDispatcher(), this);
_longPressGestureRecognizer = LongPressGestureRecognizer::create();
_longPressGestureRecognizer->retain();
_longPressGestureRecognizer->setTarget(CC_CALLBACK_1(LineDrawer::handleLongPressGestureRecognizer, this));
_longPressGestureRecognizer->addWithSceneGraphPriority(this->getEventDispatcher(), this);
Size size = Director::getInstance()->getWinSize();
_renderTexture = RenderTexture::create(size.width, size.height, Texture2D::PixelFormat::RGBA8888);
_renderTexture->retain();
_renderTexture->clear(BackgroundColor.r, BackgroundColor.g, BackgroundColor.b, BackgroundColor.a);
_renderTexture->setAnchorPoint(Vec2 {0, 0});
_renderTexture->setPosition(Vec2 {size.width * .5f, size.height * .5f});
this->addChild(_renderTexture);
return true;
}
void handleLongPressGestureRecognizer(BasicGestureRecognizer *r)
{
// LongPressGestureRecognizer *recognizer = static_cast<LongPressGestureRecognizer *>(r);
// CCLOG("got long press");
_renderTexture->beginWithClear(BackgroundColor.r, BackgroundColor.g, BackgroundColor.b, BackgroundColor.a);
_renderTexture->end();
}
void handlePanGestureRecognizer(BasicGestureRecognizer *r)
{
// CCLOG("received gesture %d", recognizer->getState());
PanGestureRecognizer *recognizer = static_cast<PanGestureRecognizer *>(r);
switch (recognizer->getState()) {
case PanGestureRecognizer::Began: {
Vec2 location = recognizer->getLocation();
// CCLOG("touch began: %.2f %.2f", location.x, location.y);
_points.clear();
_lastSize = 0.0;
float size = extractSize(recognizer->getVelocity());
startNewLine(location, size);
addPoint(location, size);
addPoint(location, size);
break;
}
case PanGestureRecognizer::Changed: {
Vec2 location = recognizer->getLocation();
// CCLOG("touch moved: %.2f %.2f", location.x, location.y);
//! skip points that are too close
float eps = 1.5f;
if (_points.size() > 0) {
auto v = _points.back().pos - location;
float length = v.getLength();
if (length < eps) {
return;
} else {
}
}
float size = extractSize(recognizer->getVelocity());
addPoint(location, size);
break;
}
case PanGestureRecognizer::Completed: {
Vec2 location = recognizer->getLocation();
float size = extractSize(recognizer->getVelocity());
endLine(location, size);
// CCLOG("touch ended: %.2f %.2f", location.x, location.y);
// CCLOG("line has points %lu", _points.size());
break;
}
default:
break;
}
}
void startNewLine(Vec2 point, float size)
{
_connectingLine = false;
addPoint(point, size);
}
void addPoint(Vec2 point, float size)
{
_points.push_back(LinePoint(point, size));
}
void endLine(Vec2 point, float size)
{
addPoint(point, size);
_finishingLine = true;
}
float extractSize(Vec2 velocity)
{
float vel = velocity.getLength();
float size = vel / 166.0f;
size = clampf(size, 1, 40);
if (_lastSize != 0.0) {
size = size * 0.8f + _lastSize * 0.2f;
}
_lastSize = size;
// CCLOG("extracted size %.2f", size);
return size;
}
static void triangulateRect(Vec2 A, Vec2 B, Vec2 C, Vec2 D, Color4F color, std::vector<V3F_C4B_T2F> &vertices, std::vector<unsigned short> &indices, float z = 0)
{
triangulateRect(A, color, B, color, C, color, D, color, vertices, indices, z);
}
static void triangulateRect(Vec2 A, Color4F a, Vec2 B, Color4F b, Vec2 C, Color4F c, Vec2 D, Color4F d, std::vector<V3F_C4B_T2F> &vertices, std::vector<unsigned short> &indices, float z)
{
// CCLOG("triangulate rect (%.2f %.2f) (%.2f %.2f) (%.2f %.2f) (%.2f %.2f)", A.x, A.y, B.x, B.y, C.x, C.y, D.x, D.y);
auto startIndex = vertices.size();
vertices.push_back(V3F_C4B_T2F {Vec3 {A.x, A.y, z}, Color4B {a}, Tex2F {}});
vertices.push_back(V3F_C4B_T2F {Vec3 {B.x, B.y, z}, Color4B {b}, Tex2F {}});
vertices.push_back(V3F_C4B_T2F {Vec3 {C.x, C.y, z}, Color4B {c}, Tex2F {}});
vertices.push_back(V3F_C4B_T2F {Vec3 {D.x, D.y, z}, Color4B {d}, Tex2F {}});
indices.push_back(startIndex); //A
indices.push_back(startIndex + 1); //B
indices.push_back(startIndex + 2); //C
indices.push_back(startIndex + 1); //B
indices.push_back(startIndex + 2); //C
indices.push_back(startIndex + 3); //D
}
static void triangulateCircle(CirclePoint circle, Color4F color, float overdraw, std::vector<V3F_C4B_T2F> &vertices, std::vector<unsigned short> &indices, float z = 0)
{
Color4F fadeOutColor = Color4F {};
// Color4F fadeOutColor = Color4F {1, 0, 0, .5};
int numberOfSegments = 32;
float anglePerSegment = (float)(M_PI / (numberOfSegments - 1));
//! we need to cover M_PI from this, dot product of normalized vectors is equal to cos angle between them... and if you include rightVec dot you get to know the correct direction :)
Vec2 perp = circle.dir.getPerp();
float angle = acosf(perp.dot(Vec2 {0, 1}));
const float rightDot = perp.dot(Vec2 {1, 0});
if (rightDot < 0.0f) {
angle *= -1;
}
const float radius = circle.width * .5;
const unsigned short centerIndex = vertices.size();
vertices.push_back(V3F_C4B_T2F {Vec3 {circle.pos.x, circle.pos.y, z}, Color4B {color}, Tex2F {}});
int prevIndex;
Vec2 prevPoint, prevDir;
for (unsigned int i = 0; i < numberOfSegments; ++i) {
Vec2 dir = Vec2 {sinf(angle), cosf(angle)};
Vec2 curPoint = Vec2 {circle.pos.x + radius * dir.x, circle.pos.y + radius * dir.y};
int currentIndex = vertices.size();
vertices.push_back(V3F_C4B_T2F {Vec3 {curPoint.x, curPoint.y, z}, Color4B {color}, Tex2F {}});
if (i > 0) {
indices.push_back(centerIndex);
indices.push_back(prevIndex);
indices.push_back(currentIndex);
// CCLOG("circle %d %lu %lu", centerIndex, vertices.size() - 2, vertices.size() - 1);
// triangulate a overdrawn rect
Vec2 prevOverdrawnPoint = prevPoint + prevDir * overdraw;
Vec2 currentOverdrawnPoint = curPoint + dir * overdraw;
auto prevOverdrawIndex = vertices.size();
vertices.push_back(V3F_C4B_T2F {Vec3 {prevOverdrawnPoint.x, prevOverdrawnPoint.y, z}, Color4B {fadeOutColor}, Tex2F {}});
auto curOverdrawIndex = vertices.size();
vertices.push_back(V3F_C4B_T2F {Vec3 {currentOverdrawnPoint.x, currentOverdrawnPoint.y, z}, Color4B {fadeOutColor}, Tex2F {}});
indices.push_back(prevIndex);
indices.push_back(curOverdrawIndex);
indices.push_back(prevOverdrawIndex);
indices.push_back(prevIndex);
indices.push_back(currentIndex);
indices.push_back(curOverdrawIndex);
}
prevIndex = currentIndex;
prevPoint = curPoint;
prevDir = dir;
angle += anglePerSegment;
}
}
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_renderTexture->begin();
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_COLOR));
if (_points.size() > 2) {
Color4F brushColor {0, 0, 0, 1};
if (_enableLineSmoothing) {
auto smoothPoints = smoothLinePoints(_points);
drawLines(renderer, transform, smoothPoints, brushColor);
}
else {
drawLines(renderer, transform, _points, brushColor);
}
_points.erase(_points.begin(), _points.end() - 2);
}
_renderTexture->end();
Node::draw(renderer, transform, flags);
}
void drawLines(Renderer *renderer, const Mat4 &transform, std::vector<LinePoint> &linePoints, Color4F color)
{
const Color4F fadeOutColor {0, 0, 0, 0};
LinePoint &prevPoint = linePoints[0];
_vertices.clear();
_indices.clear();
std::vector<CirclePoint> circles;
for (int i = 1; i < linePoints.size(); i++) {
auto curPoint = linePoints[i];
if (curPoint.pos.fuzzyEquals(prevPoint.pos, 0.0001f)) {
continue;
}
Vec2 dir = curPoint.pos - prevPoint.pos;
Vec2 perp = dir.getPerp().getNormalized();
Vec2 A = prevPoint.pos + perp * prevPoint.width / 2;
Vec2 B = prevPoint.pos - perp * prevPoint.width / 2;
Vec2 C = curPoint.pos + perp * curPoint.width / 2;
Vec2 D = curPoint.pos - perp * curPoint.width / 2;
if (_connectingLine || _indices.size() > 0) {
A = _prevC;
B = _prevD;
} else if (_indices.size() == 0) {
circles.push_back(CirclePoint {curPoint.pos, curPoint.width, (linePoints[i - 1].pos - curPoint.pos).getNormalized()});
}
triangulateRect(A, B, C, D, color, _vertices, _indices);
_prevD = D;
_prevC = C;
if (_finishingLine && (i == linePoints.size() - 1)) {
circles.push_back(CirclePoint {curPoint.pos, curPoint.width, (curPoint.pos - linePoints[i - 1].pos).getNormalized()});
_finishingLine = false;
}
prevPoint = curPoint;
//! Add overdraw
Vec2 F = A + perp * Overdraw;
Vec2 G = C + perp * Overdraw;
Vec2 H = B - perp * Overdraw;
Vec2 I = D - perp * Overdraw;
if (_connectingLine || _indices.size() > 6) {
F = _prevG;
H = _prevI;
}
_prevG = G;
_prevI = I;
triangulateRect(F, fadeOutColor, A, color, G, fadeOutColor, C, color, _vertices, _indices, 0);
triangulateRect(B, color, H, fadeOutColor, D, color, I, fadeOutColor, _vertices, _indices, 0);
}
for (auto c : circles) {
triangulateCircle(c, color, Overdraw, _vertices, _indices);
}
TrianglesCommand::Triangles trs{&_vertices[0], &_indices[0], static_cast<ssize_t>(_vertices.size()), static_cast<ssize_t>(_indices.size())};
_triangleCommand.init(getGlobalZOrder(), 0, getGLProgramState(), cocos2d::BlendFunc::ALPHA_PREMULTIPLIED, trs, transform, 0);
renderer->addCommand(&_triangleCommand);
if (_indices.size() > 0) {
_connectingLine = true;
}
}
static std::vector<LinePoint> smoothLinePoints(std::vector<LinePoint> &linePoints)
{
std::vector<LinePoint> result;
if (linePoints.size() > 2) {
for (unsigned int i = 2; i < linePoints.size(); ++i) {
auto prev2 = linePoints[i - 2];
auto prev1 = linePoints[i - 1];
auto cur = linePoints[i];
Vec2 midPoint1 = (prev1.pos + prev2.pos) * .5;
Vec2 midPoint2 = (cur.pos + prev1.pos) * .5;
int segmentDistance = 2;
float distance = (midPoint1 - midPoint2).getLength();
int numberOfSegments = MIN(128, MAX(floorf(distance / segmentDistance), 32));
float t = 0.0f;
float step = 1.0f / numberOfSegments;
for (int j = 0; j < numberOfSegments; j++) {
LinePoint newPoint;
newPoint.pos = midPoint1 * powf(1 - t, 2) + prev1.pos * 2.0f * (1 - t) * t + midPoint2 * t * t;
newPoint.width = powf(1 - t, 2) * ((prev1.width + prev2.width) * 0.5f) + 2.0f * (1 - t) * t * prev1.width + t * t * ((cur.width + prev1.width) * 0.5f);
result.push_back(newPoint);
t += step;
}
LinePoint finalPoint;
finalPoint.pos = midPoint2;
finalPoint.width = (cur.width + prev1.width) * 0.5f;
result.push_back(finalPoint);
}
}
return result;
}
private:
std::vector<LinePoint> _points;
bool _connectingLine, _finishingLine;
Vec2 _prevC, _prevD, _prevG, _prevI;
bool _enableLineSmoothing;
PanGestureRecognizer *_panGestureRecognizer;
LongPressGestureRecognizer *_longPressGestureRecognizer;
TrianglesCommand _triangleCommand;
std::vector<V3F_C4B_T2F> _vertices;
std::vector<unsigned short> _indices;
RenderTexture *_renderTexture;
float _lastSize;
};
#endif /* LineDrawer_hpp */
| 36.711009 | 190 | 0.539423 |
7d37fd34801cbb6ed2d8a69cdc5b11c3d096f0e4 | 978 | cpp | C++ | Linux/Linux开发/code/fifo/fifo_write.cpp | fengjixuchui/Document-1 | 62c74d94c4f16f94f4a5e473636d3248af0c37fe | [
"Apache-2.0"
] | 1 | 2021-02-26T02:40:03.000Z | 2021-02-26T02:40:03.000Z | Linux/Linux开发/code/fifo/fifo_write.cpp | fengjixuchui/Document-1 | 62c74d94c4f16f94f4a5e473636d3248af0c37fe | [
"Apache-2.0"
] | null | null | null | Linux/Linux开发/code/fifo/fifo_write.cpp | fengjixuchui/Document-1 | 62c74d94c4f16f94f4a5e473636d3248af0c37fe | [
"Apache-2.0"
] | null | null | null | #include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#define FIFO_NAME "/var/tmp/fifo_test"
int main()
{
int ret = 0;
int pipefd = 0;
// 判断fifo文件是否已存在
if (access(FIFO_NAME, F_OK) == -1) {
// 不存在则创建
ret = mkfifo(FIFO_NAME, 0666);
if (ret == -1) {
perror("mkfifo error");
return -1;
}
}
// 以写端打开
pipefd = open(FIFO_NAME, O_WRONLY);
printf("write open success\n");
if (pipefd == -1) {
perror("open error");
return -1;
}
char buf[BUFSIZ] = {0};
while (1) {
// 从控制台获取输入
int read_bytes = read(STDIN_FILENO, buf, BUFSIZ);
if( read_bytes == -1 ) {
perror("read error");
close(pipefd);
return -1;
}
// 写到管道
int write_bytes = write(pipefd, buf, read_bytes);
}
close(pipefd);
return 0;
}
| 16.862069 | 57 | 0.501022 |
7d3e7c50c315d62a9e01aa1befec07345b2ea650 | 140 | cpp | C++ | module8/quiz.cpp | canmenzo/CppExamples | e569edbedeb9ac1afec7b33602ce32014cbe2b05 | [
"MIT"
] | null | null | null | module8/quiz.cpp | canmenzo/CppExamples | e569edbedeb9ac1afec7b33602ce32014cbe2b05 | [
"MIT"
] | null | null | null | module8/quiz.cpp | canmenzo/CppExamples | e569edbedeb9ac1afec7b33602ce32014cbe2b05 | [
"MIT"
] | null | null | null | //quiz.cpp
#include <iostream>
using namespace std;
int main()
{
char c = 'x';
char *pC = &c;
cout << ++(*pC) << endl;
}
| 11.666667 | 26 | 0.492857 |
7d44240b68e343d7452b77f8ac30aafaa0bddca4 | 494 | cpp | C++ | flame/toSystem.cpp | ChaosKit/ChaosKit | e7cba03db1ae34160868656ea357c7166ae1d84a | [
"Apache-2.0"
] | 3 | 2021-01-09T17:25:18.000Z | 2021-07-11T00:04:22.000Z | flame/toSystem.cpp | ChaosKit/ChaosKit | e7cba03db1ae34160868656ea357c7166ae1d84a | [
"Apache-2.0"
] | 1 | 2021-03-21T13:17:04.000Z | 2021-03-21T14:03:46.000Z | flame/toSystem.cpp | ChaosKit/ChaosKit | e7cba03db1ae34160868656ea357c7166ae1d84a | [
"Apache-2.0"
] | 1 | 2020-04-03T16:32:53.000Z | 2020-04-03T16:32:53.000Z | #include "toSystem.h"
namespace chaoskit::flame {
core::TransformSystem toTransformSystem(const System& system) {
return {toTransform(system), toParams(system)};
}
core::CameraSystem toCameraSystem(const System& system) {
core::CameraSystem result{toTransformSystem(system)};
auto cameraTransform = toCameraTransform(system);
if (cameraTransform) {
result.camera = {*std::move(cameraTransform), *toCameraParams(system)};
}
return result;
}
} // namespace chaoskit::flame
| 23.52381 | 75 | 0.742915 |
7d472d0cf518b331645510c063203095f8a14064 | 1,544 | cpp | C++ | TP1/ex7.cpp | biromiro/feup-cal | d0fe01603e13729a5b91ca2758d8db5aafd2a13c | [
"MIT"
] | null | null | null | TP1/ex7.cpp | biromiro/feup-cal | d0fe01603e13729a5b91ca2758d8db5aafd2a13c | [
"MIT"
] | null | null | null | TP1/ex7.cpp | biromiro/feup-cal | d0fe01603e13729a5b91ca2758d8db5aafd2a13c | [
"MIT"
] | 2 | 2021-04-11T17:31:16.000Z | 2021-04-27T14:04:44.000Z | #include "exercises.h"
#include <algorithm>
#include <vector>
#include <numeric>
double minimumAverageCompletionTime(std::vector<unsigned int> tasks, std::vector<unsigned int> &orderedTasks) {
sort(tasks.begin(), tasks.end());
/* What they want you to do
do {
permutations.push_back(tasks);
} while (std::next_permutation(tasks.begin(), tasks.end()));
double bestAverage = 99999;
for (const auto &elem: permutations) {
double average = 0;
for (size_t i = 1; i <= elem.size(); i++) {
average += std::accumulate(elem.begin(), elem.begin() + i, 0);
}
average /= elem.size();
if (bestAverage > average) {
bestAverage = average;
orderedTasks = elem;
}
}
*/
//What you can do (the exercise is just stupid, the best solution will always be the sorted vector)
double bestAverage = 0.0;
orderedTasks = tasks;
for (size_t i = 1; i <= tasks.size(); i++) {
bestAverage += std::accumulate(tasks.begin(), tasks.begin() + i, 0);
}
return bestAverage / tasks.size();
}
/// TESTS ///
#include <gtest/gtest.h>
#include <gmock/gmock.h>
TEST(TP1_Ex7, taskOrdering) {
std::vector<unsigned int> tasks = {15, 8, 3, 10};
std::vector<unsigned int> orderedTasks;
double averageTime = minimumAverageCompletionTime(tasks, orderedTasks);
EXPECT_EQ(orderedTasks.size(), 4 );
ASSERT_NEAR(averageTime, 17.75, 0.00001);
ASSERT_THAT(orderedTasks, ::testing::ElementsAre(3,8,10,15));
} | 28.072727 | 111 | 0.619819 |
7d489a715ea88a71eb316a2f9d76283ec7a3169a | 67,258 | cpp | C++ | Visualization/JuceLibraryCode/BinaryData.cpp | opendragon/Core_MPlusM | c82bb00761551a86abe50c86e0df1f247704c848 | [
"BSD-3-Clause"
] | null | null | null | Visualization/JuceLibraryCode/BinaryData.cpp | opendragon/Core_MPlusM | c82bb00761551a86abe50c86e0df1f247704c848 | [
"BSD-3-Clause"
] | null | null | null | Visualization/JuceLibraryCode/BinaryData.cpp | opendragon/Core_MPlusM | c82bb00761551a86abe50c86e0df1f247704c848 | [
"BSD-3-Clause"
] | null | null | null | /* ==================================== JUCER_BINARY_RESOURCE ====================================
This is an auto-generated file: Any edits you make may be overwritten!
*/
namespace BinaryData
{
//================== PDOicon.ico ==================
static const unsigned char temp_binary_data_0[] =
{ 0,0,1,0,4,0,16,16,0,0,1,0,32,0,40,5,0,0,70,0,0,0,32,32,0,0,1,0,32,0,40,20,0,0,110,5,0,0,48,48,0,0,1,0,32,0,40,45,0,0,150,25,0,0,0,0,0,0,1,0,32,0,90,29,0,0,190,70,0,0,40,0,0,0,16,0,0,0,32,0,0,0,1,0,32,0,0,0,0,0,0,5,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,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,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,145,36,7,0,154,0,28,0,127,0,2,0,156,0,26,0,141,0,9,0,135,0,17,0,145,12,21,0,147,13,19,0,150,11,22,0,
145,36,7,0,148,0,31,0,85,0,3,0,158,0,29,0,127,0,10,0,0,0,0,0,0,0,0,0,154,5,48,1,162,0,190,14,141,0,18,1,159,1,179,4,153,0,63,0,153,0,116,1,152,0,142,0,154,0,122,1,157,0,136,0,144,11,44,1,154,1,198,14,141,0,18,1,159,1,185,4,152,4,62,0,0,0,0,0,0,0,0,0,
147,0,52,1,161,1,202,15,111,0,16,1,156,0,191,3,156,0,70,0,156,0,39,0,153,0,53,0,153,0,45,0,151,0,47,0,148,5,48,1,154,0,208,17,119,0,15,1,158,1,196,3,150,0,66,0,0,0,0,0,0,0,0,0,153,0,50,1,160,0,223,0,144,0,53,0,158,0,208,2,157,0,110,0,156,2,101,2,154,
2,101,0,154,0,86,1,158,0,130,0,152,0,77,1,156,0,232,0,153,0,58,1,159,1,208,3,151,0,64,0,0,0,0,0,0,0,0,0,151,0,37,1,159,1,166,1,153,0,164,1,158,0,175,1,153,1,141,0,157,0,197,3,153,0,68,0,154,0,94,1,156,0,168,1,157,0,178,1,156,0,147,1,154,0,163,1,158,0,
167,14,155,0,18,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,127,0,4,0,0,0,1,0,0,0,0,0,127,0,6,0,0,0,0,0,0,0,1,0,0,0,0,0,153,0,5,0,0,0,0,0,170,0,3,0,0,0,1,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,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,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,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,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,40,0,0,0,32,0,0,0,64,0,0,0,1,0,32,0,0,0,0,0,0,20,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,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,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,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,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,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,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,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,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,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,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,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,151,5,47,0,158,
0,77,0,155,0,36,0,0,0,0,0,0,0,1,0,153,0,58,0,154,0,76,0,148,0,24,0,0,0,0,0,127,31,8,0,151,0,69,0,155,0,72,0,139,0,11,0,127,0,2,0,153,0,68,0,158,0,79,0,147,0,19,0,0,0,0,0,127,0,12,0,155,0,77,3,153,0,73,28,141,0,9,0,0,0,0,0,153,0,25,0,158,0,82,4,153,0,
63,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,157,9,162,1,170,1,255,4,155,0,126,0,0,0,0,0,85,85,3,0,155,3,203,2,165,0,255,9,156,0,83,0,0,0,0,0,140,17,29,0,157,2,239,1,157,0,248,6,154,0,38,0,95,31,8,0,156,2,221,2,163,1,255,7,155,0,64,0,0,0,0,0,
147,20,38,0,156,0,250,2,159,0,237,16,148,0,31,0,0,0,0,0,157,9,81,2,165,3,255,2,156,0,205,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,155,3,162,2,166,2,255,4,155,0,125,0,0,0,0,0,127,127,2,0,154,3,202,2,163,1,255,9,155,0,82,0,0,0,0,0,149,17,29,
0,155,0,249,2,158,0,255,6,146,0,40,0,109,36,7,0,156,2,227,2,164,3,255,3,150,0,66,0,0,0,0,0,151,20,37,0,155,0,248,2,156,0,236,17,144,0,30,0,0,0,0,0,156,15,80,2,163,1,255,2,153,0,203,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,3,161,2,166,
2,255,4,155,0,125,0,0,0,0,0,127,127,2,0,154,3,201,2,163,1,255,9,155,0,82,0,0,0,0,0,135,30,17,0,153,1,143,1,155,0,149,0,144,11,23,0,127,63,4,0,155,0,131,1,156,1,153,6,151,0,37,0,0,0,0,0,151,20,37,0,155,0,247,2,156,0,235,17,144,0,30,0,0,0,0,0,156,15,80,
2,163,1,255,2,154,0,202,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,3,161,2,166,2,255,4,155,0,125,0,0,0,0,0,127,127,2,0,154,3,201,2,163,1,255,3,155,0,82,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,151,
20,37,0,155,0,247,2,156,0,235,17,144,0,30,0,0,0,0,0,156,15,80,2,163,1,255,2,154,0,202,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,3,161,1,167,2,255,3,155,0,133,0,0,0,0,0,0,255,1,1,156,3,201,2,164,1,255,8,156,0,91,0,0,0,0,0,139,0,11,2,153,
0,103,4,154,0,107,15,135,0,17,0,85,0,3,2,154,0,94,4,156,2,111,17,153,0,30,0,0,0,0,0,155,21,36,1,155,0,248,1,158,0,240,14,155,0,36,0,0,0,0,0,156,9,80,2,163,1,255,2,154,0,202,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,3,161,2,164,0,255,2,
157,2,197,31,143,0,16,0,153,12,20,1,156,0,223,2,164,1,255,3,155,0,167,42,127,0,6,4,156,8,57,1,159,1,254,1,156,0,252,15,150,0,34,0,127,31,8,0,156,2,223,1,167,2,255,3,155,0,146,0,109,0,7,3,150,7,71,1,156,0,253,2,161,2,255,4,153,0,111,0,127,0,6,2,156,6,
119,2,164,0,255,3,155,0,197,255,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,4,166,2,165,0,255,2,157,2,239,1,158,0,215,1,158,0,209,2,162,2,255,1,156,3,241,1,157,0,230,1,161,0,207,1,158,0,224,2,165,3,255,2,155,2,203,31,127,0,8,0,127,0,10,0,157,
2,225,2,160,2,255,1,156,0,236,1,160,0,208,1,157,0,231,2,163,1,255,1,158,0,222,1,156,0,234,1,160,0,205,1,156,0,245,2,166,0,255,3,155,0,138,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,157,0,110,1,164,0,175,3,155,0,77,1,158,1,140,1,159,1,214,1,160,
1,191,0,156,3,75,0,154,11,43,1,161,1,175,1,158,0,217,1,158,0,175,5,154,0,48,0,0,0,0,0,127,0,8,1,158,0,143,1,158,0,154,4,153,0,63,1,158,0,167,1,158,0,209,1,159,1,165,14,153,0,35,0,153,6,73,1,161,1,188,1,159,0,205,3,157,0,141,14,155,0,18,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,127,0,6,0,85,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,145,0,7,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,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,4,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,40,0,0,0,48,0,0,0,96,0,0,0,1,0,32,0,0,0,0,0,0,45,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,144,11,23,0,153,0,120,0,155,0,121,2,153,0,115,0,127,0,14,0,0,0,0,0,0,0,0,0,0,0,2,0,151,5,99,0,155,0,121,0,155,0,121,5,144,0,44,0,0,0,0,0,0,0,0,0,0,0,0,0,150,7,71,0,158,0,121,0,158,0,121,6,149,0,75,0,0,0,0,0,0,0,0,0,144,
0,46,0,158,0,132,0,156,0,132,2,153,0,110,0,85,0,3,0,0,0,0,0,0,0,0,0,127,0,14,0,152,0,124,0,156,0,132,1,153,0,131,19,137,0,26,0,0,0,0,0,0,0,0,0,0,0,1,0,150,5,100,0,158,0,132,0,160,0,132,4,149,0,58,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,145,20,51,2,161,5,255,2,165,3,255,2,155,0,252,16,148,0,31,0,0,0,0,0,0,0,0,0,63,63,4,0,153,6,219,2,166,2,255,3,168,2,255,10,148,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,153,6,155,2,169,2,255,2,169,2,255,4,154,0,165,0,0,0,0,0,0,0,0,0,149,2,92,2,168,5,
255,2,166,2,255,2,153,0,222,42,85,0,6,0,0,0,0,0,0,0,0,0,140,17,29,0,154,1,250,2,165,3,255,4,161,2,255,14,137,0,52,0,0,0,0,0,0,0,0,0,0,127,2,0,154,3,201,2,168,2,255,2,169,2,255,6,152,0,117,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,145,5,49,0,153,1,253,2,158,0,255,2,154,0,242,17,144,0,30,0,0,0,0,0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,161,2,255,11,149,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,150,5,149,2,162,2,255,2,162,2,255,4,153,1,158,0,0,0,0,0,0,0,0,0,147,5,88,2,161,5,255,2,159,
2,255,3,152,0,213,42,85,0,6,0,0,0,0,0,0,0,0,0,136,18,28,0,153,1,240,2,158,0,255,2,153,0,253,15,142,0,50,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,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,145,5,
49,0,153,1,253,2,158,0,255,2,154,0,242,17,144,0,30,0,0,0,0,0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,161,2,255,11,149,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,152,8,152,2,165,3,255,2,165,3,255,4,153,1,161,0,0,0,0,0,0,0,0,0,147,2,90,2,164,4,255,2,162,2,255,3,
152,0,218,42,85,0,6,0,0,0,0,0,0,0,0,0,136,18,28,0,153,1,240,2,158,0,255,2,153,0,253,15,142,0,50,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,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,145,5,49,0,153,
1,253,2,158,0,255,2,154,0,242,17,144,0,30,0,0,0,0,0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,161,2,255,11,149,0,92,0,0,0,0,0,0,0,0,0,0,0,0,2,152,4,122,1,161,1,209,1,161,1,209,9,152,1,129,0,0,0,0,0,0,0,0,0,148,7,72,1,159,1,209,1,156,0,209,4,153,1,174,
51,51,0,5,0,0,0,0,0,0,0,0,0,136,18,28,0,153,1,240,2,158,0,255,2,153,0,253,15,142,0,50,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,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,145,5,49,0,153,1,253,2,158,
0,255,2,154,0,242,17,144,0,30,0,0,0,0,0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,161,2,255,11,149,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,85,0,3,0,85,0,3,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,1,0,85,0,3,0,85,0,3,0,85,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,136,18,28,0,
153,1,240,2,158,0,255,2,153,0,253,15,142,0,50,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,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,145,5,49,0,153,1,253,2,158,0,255,2,154,0,242,17,144,0,30,0,0,0,0,
0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,162,2,255,8,153,0,93,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,136,18,28,0,153,1,240,2,158,0,255,2,155,0,254,15,145,0,
51,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,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,145,5,49,0,153,1,253,2,158,0,255,2,154,1,246,21,145,0,35,0,0,0,0,0,0,0,0,0,63,63,4,0,153,1,211,2,159,2,255,
2,162,2,255,7,152,5,102,0,0,0,0,0,0,0,0,0,0,0,0,0,139,11,22,0,154,0,38,0,154,0,38,0,144,0,23,0,0,0,0,0,0,0,0,0,137,0,13,0,147,6,38,0,151,0,37,0,146,0,33,0,0,0,1,0,0,0,0,0,0,0,0,0,145,18,28,0,154,1,240,2,158,0,255,4,157,0,255,12,151,0,59,0,0,0,0,0,0,0,
0,0,0,0,1,0,152,1,194,2,160,2,255,2,162,2,255,9,152,0,112,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,145,5,49,0,153,1,253,2,157,0,255,1,157,0,254,12,151,0,59,0,0,0,0,0,0,0,0,0,127,42,6,1,153,4,217,2,159,2,255,2,163,1,255,9,153,
0,138,0,0,0,0,0,0,0,0,0,0,0,0,1,153,6,154,1,161,1,247,1,161,1,247,6,153,5,153,0,0,0,0,0,0,0,0,3,147,9,85,1,160,1,247,1,156,0,247,3,154,0,232,20,142,0,25,0,0,0,0,0,0,0,0,0,146,7,33,1,154,1,246,2,157,0,255,3,161,2,255,5,151,0,94,0,0,0,0,0,0,0,0,0,0,0,1,
1,151,5,203,2,160,2,255,2,162,2,255,9,152,0,112,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,145,5,49,0,153,1,253,2,157,0,255,2,161,2,255,4,153,0,164,0,63,0,4,0,0,0,0,0,151,20,37,0,155,0,242,2,157,0,255,2,159,2,255,2,154,0,223,15,
143,0,32,0,0,0,0,0,102,51,5,0,154,1,206,2,161,2,255,2,164,1,255,6,152,0,147,0,0,0,0,0,0,0,0,0,147,5,88,2,162,5,255,2,157,0,255,2,161,2,255,5,154,1,130,255,0,0,1,0,0,0,0,0,151,9,81,0,159,0,254,2,156,1,255,2,160,2,255,3,153,0,198,14,155,0,18,0,0,0,0,0,
146,30,33,0,154,1,236,2,157,0,255,3,162,2,255,10,151,0,99,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,145,5,49,0,153,1,253,2,157,0,255,2,156,1,255,2,162,2,255,3,153,0,196,1,151,0,148,0,154,1,211,2,159,2,255,2,156,1,255,2,158,0,255,
2,162,2,255,1,155,0,225,1,153,0,151,0,153,0,189,2,158,0,255,2,156,1,255,3,163,1,255,7,150,0,98,0,0,0,0,0,0,0,0,0,147,5,88,2,161,5,255,2,156,1,255,3,156,4,255,3,160,2,255,2,153,0,189,1,153,1,161,0,153,1,233,2,158,0,255,2,157,0,255,3,157,3,255,2,162,2,
255,1,155,0,216,1,154,0,160,0,153,1,215,2,158,0,255,2,157,0,255,2,156,0,254,14,147,0,52,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,145,20,51,2,160,6,255,2,166,2,255,5,155,0,216,3,153,1,168,2,167,2,255,2,167,2,255,2,162,2,255,2,
160,2,255,2,164,1,255,3,152,0,149,3,153,7,131,2,162,5,255,2,168,2,255,2,163,1,255,2,160,2,255,2,165,3,255,3,153,1,199,17,136,0,15,0,0,0,0,0,0,0,0,0,149,2,92,2,168,5,255,2,167,2,255,5,155,2,185,0,154,1,183,2,168,2,255,2,167,2,255,2,161,2,255,2,162,2,255,
1,158,0,254,9,149,0,109,1,153,1,154,2,165,3,255,2,167,2,255,2,162,2,255,2,161,2,255,2,164,1,255,4,153,1,154,0,0,0,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,144,17,30,1,153,1,154,1,157,0,155,6,154,0,119,0,63,0,4,2,153,2,100,0,
157,2,188,0,156,0,214,1,158,0,196,4,153,0,113,0,102,0,5,0,0,0,1,0,152,6,82,0,158,0,180,0,156,0,214,1,156,0,202,3,156,0,137,0,150,0,22,0,0,0,0,0,0,0,0,0,0,0,0,0,147,5,50,1,159,0,144,1,161,0,144,3,154,0,84,0,127,0,8,2,153,4,111,0,155,0,188,0,156,0,205,
1,157,0,176,3,151,0,79,0,0,0,0,0,0,0,2,0,151,0,94,1,156,0,181,0,156,0,205,2,157,0,185,4,153,0,106,0,127,0,6,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,127,0,6,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,127,0,6,0,0,0,1,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,1,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,0,0,0,1,0,8,6,0,0,0,92,114,
168,102,0,0,0,1,115,82,71,66,0,174,206,28,233,0,0,29,20,73,68,65,84,120,1,237,221,11,124,21,213,157,7,240,115,102,238,220,103,114,115,3,33,33,144,240,136,81,20,16,20,148,181,128,149,186,213,138,173,186,171,27,124,180,86,219,186,90,45,214,23,85,171,221,
221,208,79,235,123,165,64,17,80,91,93,235,174,214,104,125,176,104,125,84,176,162,86,1,121,40,85,121,9,129,64,222,239,251,156,199,217,115,38,92,26,66,66,114,103,230,222,220,116,127,243,249,132,203,189,153,57,243,159,239,57,231,63,103,230,206,76,8,193,
4,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,
0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,
128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,
32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,
8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,
2,16,128,0,4,32,144,65,1,154,193,117,13,202,170,24,97,116,225,156,133,242,147,115,42,93,163,75,103,41,49,45,38,121,93,94,227,189,240,123,137,57,127,168,212,215,174,253,15,157,16,202,6,35,184,74,194,164,170,138,201,174,17,115,136,123,20,157,170,212,203,
95,24,245,237,251,181,173,213,117,90,197,82,166,85,17,98,116,197,53,56,241,13,134,73,255,235,100,221,218,172,112,17,239,179,193,135,209,74,30,8,255,225,49,37,227,201,150,216,250,86,237,134,217,247,76,67,233,55,66,255,252,123,202,11,190,8,53,76,77,200,
198,180,118,119,236,36,201,144,203,91,89,108,152,68,37,47,161,68,162,6,211,117,194,98,62,234,107,97,18,249,210,173,230,108,215,136,178,181,168,125,220,150,171,22,188,183,175,146,208,67,29,207,217,45,23,201,104,214,227,19,199,84,107,7,167,235,114,252,
244,184,100,28,223,201,212,178,4,97,185,110,162,184,53,170,25,18,99,9,141,209,120,158,228,175,139,80,163,58,168,6,118,81,67,218,154,171,143,250,228,170,249,31,167,45,54,103,183,212,126,105,194,234,107,75,74,70,87,187,58,79,140,83,114,60,239,83,229,53,
158,206,188,128,68,125,58,147,36,157,26,154,206,88,164,48,81,216,146,32,209,93,9,61,103,87,81,100,212,142,105,183,125,116,160,138,80,158,212,211,55,173,188,246,90,229,177,83,222,44,171,149,106,39,73,146,255,248,6,169,101,172,230,162,65,63,83,220,113,
170,243,182,165,71,117,141,36,10,244,145,181,81,35,82,29,32,161,221,193,104,222,142,43,110,221,124,48,93,109,203,234,214,166,53,1,220,114,75,137,239,245,73,234,229,181,84,13,41,134,148,90,167,146,120,151,164,33,35,247,224,21,85,159,221,125,207,193,254,
54,240,202,5,83,2,27,202,247,157,213,226,234,172,104,99,250,217,113,153,141,38,50,149,197,114,134,88,115,114,31,47,94,249,86,139,95,232,60,81,75,82,23,129,193,155,140,196,164,6,15,11,188,155,163,142,248,125,110,219,37,175,239,190,243,254,54,62,155,237,
233,242,149,39,20,124,204,26,206,107,86,34,23,183,18,117,182,46,145,17,68,226,113,137,88,186,255,28,170,13,51,54,137,199,70,187,62,48,155,179,65,27,101,18,252,48,79,43,120,33,167,233,164,87,191,188,251,149,58,219,129,13,160,128,27,151,148,123,94,243,
69,79,141,40,204,180,28,192,34,71,204,66,245,225,70,205,190,75,182,144,202,202,200,17,191,232,229,141,153,32,151,20,149,29,148,99,115,219,189,241,111,68,153,122,122,76,98,5,28,66,22,94,135,235,176,151,101,137,198,52,131,200,45,126,226,249,216,167,230,
173,14,24,101,171,171,111,120,119,15,175,236,212,218,93,111,101,155,171,174,148,78,95,254,196,212,58,185,225,155,45,146,122,94,130,232,147,53,153,228,153,113,29,90,70,172,72,132,121,196,196,235,151,25,76,101,134,212,236,39,222,45,138,145,247,102,94,172,
244,213,234,31,255,229,115,167,98,59,98,125,41,190,57,212,228,82,92,106,128,179,223,117,83,97,209,211,39,54,110,222,151,75,70,166,156,147,121,231,116,105,57,100,84,211,117,103,236,249,201,67,31,246,181,202,27,111,44,15,174,61,233,192,101,7,60,137,107,
90,136,62,157,184,168,36,58,179,57,8,19,157,43,133,73,12,216,36,23,227,251,15,137,200,70,206,38,79,98,220,210,188,29,119,63,187,127,209,188,104,10,197,28,158,181,226,129,17,35,255,154,215,118,245,126,89,255,65,135,204,202,13,161,157,140,237,240,92,3,
251,143,57,240,229,93,80,52,48,69,245,236,244,26,133,143,106,123,167,62,21,190,39,189,137,224,142,251,38,141,121,58,255,179,141,53,94,22,76,185,43,241,96,189,250,240,246,9,29,183,207,220,124,211,237,59,250,218,82,70,42,165,51,22,47,158,185,39,39,254,
125,62,82,187,64,85,72,129,153,28,133,149,88,104,32,245,200,103,20,179,73,50,255,151,39,78,67,147,235,21,173,232,185,220,142,9,203,155,23,188,101,185,179,49,126,232,120,218,188,7,190,81,163,36,174,171,167,198,63,18,133,248,197,14,197,180,24,72,92,34,
254,67,177,137,189,142,216,223,80,85,106,115,147,130,87,130,177,209,203,234,230,111,216,192,63,225,91,58,56,211,81,9,203,201,48,220,138,232,134,44,198,18,252,95,53,245,31,62,196,139,73,84,237,53,131,51,82,33,159,190,204,127,193,51,167,236,121,99,91,32,
182,178,73,50,78,231,93,87,18,235,73,169,114,186,109,176,25,173,202,27,15,111,125,9,185,253,212,176,255,211,223,214,78,188,254,229,162,135,207,63,153,71,111,182,197,110,179,247,249,95,86,241,156,60,117,121,224,202,53,195,90,214,126,230,213,238,109,147,
88,57,19,141,89,227,63,3,109,52,61,74,23,203,137,229,25,255,137,203,177,242,14,207,190,7,226,227,215,174,41,92,62,229,146,10,98,109,239,220,99,21,189,190,141,52,31,20,99,109,153,15,151,220,196,72,237,135,111,179,91,55,84,183,228,226,89,181,143,105,238,
146,49,19,75,86,254,242,201,77,57,173,127,170,115,197,190,199,135,251,5,102,29,38,173,250,92,178,71,129,194,135,255,48,141,154,109,141,16,173,80,245,30,152,223,28,122,239,157,188,21,19,238,152,94,89,233,239,177,196,49,223,138,209,200,153,75,134,207,40,
249,206,47,94,217,234,142,190,82,171,24,23,240,22,224,55,99,19,221,117,160,113,137,181,28,138,205,172,63,222,62,249,225,75,94,84,169,191,178,206,183,101,141,119,249,216,21,161,135,46,30,123,204,96,210,248,203,180,38,128,116,197,253,195,7,139,10,143,95,
241,218,146,205,222,216,139,141,146,241,15,150,42,165,159,224,168,206,27,146,198,136,225,110,62,167,33,248,231,63,142,122,108,214,133,188,38,251,245,186,246,190,81,99,142,63,247,187,79,125,230,137,62,213,40,27,19,14,39,164,126,214,151,202,175,41,31,74,
136,68,160,185,58,78,106,84,182,61,187,122,249,201,11,167,175,100,74,42,101,12,116,222,214,246,230,132,193,207,75,152,243,139,70,159,250,143,88,226,168,105,3,63,142,158,188,60,231,199,239,5,246,191,93,227,213,175,84,9,117,83,145,188,123,157,251,168,197,
251,253,128,242,222,42,202,35,52,94,208,225,219,121,207,199,197,143,61,119,220,178,239,149,246,187,32,159,225,65,126,56,57,249,145,192,191,109,14,52,191,89,227,50,230,106,148,74,162,243,166,212,233,143,177,34,51,153,139,216,136,225,75,4,246,95,19,9,189,
245,250,176,135,206,61,135,175,96,192,59,153,99,20,159,210,175,250,109,208,41,149,150,129,153,191,190,36,116,234,170,252,166,85,187,253,145,27,120,157,200,233,30,60,49,49,34,144,195,163,26,164,245,79,143,88,122,222,85,188,146,250,56,22,102,244,188,135,
242,103,175,46,168,95,189,219,147,184,66,229,13,57,221,177,153,73,138,50,87,196,247,217,221,187,61,37,139,175,126,226,9,111,6,170,192,246,42,42,126,81,50,122,222,140,39,158,218,238,141,44,110,39,164,200,236,168,14,117,252,158,193,137,68,32,146,48,243,
29,248,102,157,103,213,203,99,23,221,124,82,207,121,186,191,191,226,222,162,178,101,19,62,127,110,135,63,182,176,131,208,160,147,29,191,251,122,196,255,205,17,11,79,173,9,87,199,132,182,208,186,170,81,143,77,159,87,57,128,157,76,207,114,236,188,31,82,
9,96,238,131,242,5,235,3,29,175,240,172,60,195,220,39,165,169,209,244,4,21,29,77,165,90,78,131,239,207,191,30,255,232,89,151,244,204,212,162,175,127,237,215,197,21,235,134,181,189,88,35,27,147,51,25,155,57,188,212,25,105,161,7,175,127,41,113,239,67,100,
122,122,70,2,61,77,172,190,255,206,125,161,169,239,140,172,91,181,71,209,47,19,7,119,78,237,241,251,139,135,38,40,233,116,53,157,122,32,240,236,243,211,150,221,80,222,219,252,115,151,140,59,227,141,194,166,213,123,20,245,124,53,121,8,210,219,140,14,127,
70,249,97,139,46,69,243,26,148,45,143,255,246,145,153,71,181,47,135,87,119,68,113,217,159,0,36,126,58,156,79,179,238,147,231,125,148,111,252,55,63,158,46,49,179,242,17,155,145,254,55,98,216,77,164,152,255,75,233,227,101,69,15,94,62,35,185,70,30,156,52,
247,65,242,253,77,190,186,39,59,9,41,72,247,94,63,185,222,35,94,69,6,226,135,43,173,238,47,127,148,119,245,172,91,120,130,202,202,122,189,168,210,55,115,77,126,219,43,245,46,253,84,177,87,118,106,72,125,132,197,49,222,152,29,205,83,55,241,115,229,165,
39,74,42,31,30,214,125,214,75,31,32,231,110,242,85,255,129,31,82,158,40,230,203,244,36,218,151,106,24,57,213,238,79,31,13,61,116,201,153,153,90,127,86,54,148,238,27,31,72,228,199,207,127,128,124,235,243,2,227,241,38,153,230,14,74,7,59,20,144,168,36,201,
21,46,104,10,173,91,82,182,242,185,60,209,239,206,95,20,188,252,131,124,250,235,86,74,125,41,159,37,239,190,161,118,255,47,14,31,13,141,116,122,183,222,85,250,240,15,166,217,45,206,201,229,101,18,138,95,250,115,114,250,134,81,177,223,215,120,232,152,
193,72,224,201,237,17,135,116,49,79,237,236,230,145,79,252,124,14,97,46,241,249,229,247,122,207,94,151,79,158,174,117,145,226,193,111,95,157,161,104,238,95,22,141,185,247,145,252,100,204,233,124,205,238,4,192,168,26,12,172,251,250,250,124,250,216,96,
119,254,100,37,136,179,204,154,114,112,70,189,246,171,155,231,174,56,225,236,117,161,240,210,54,137,122,7,181,243,31,10,78,28,239,234,74,56,175,193,255,238,194,73,21,204,157,140,121,48,95,117,201,149,40,78,188,61,229,253,17,228,127,106,220,116,80,70,
111,61,183,223,224,163,165,136,178,243,218,45,139,42,206,169,88,122,226,201,111,23,170,79,214,184,164,17,131,217,249,147,49,138,246,165,122,106,167,53,6,159,190,41,19,35,185,62,78,104,37,195,177,247,58,103,102,78,96,211,176,240,191,182,185,104,40,245,
99,61,126,22,151,168,174,102,121,239,217,45,178,17,50,135,224,246,194,113,110,105,198,136,46,31,156,86,79,155,47,110,167,198,176,108,138,77,56,107,82,251,120,54,114,253,134,200,31,183,111,183,187,209,83,79,35,129,157,69,228,250,136,66,115,82,173,67,113,
29,19,53,116,169,222,179,251,236,58,37,49,94,156,75,201,134,73,180,44,34,105,178,172,212,78,171,149,234,254,165,78,49,202,179,161,243,39,109,248,87,144,68,163,29,19,61,51,14,190,164,175,249,176,57,249,121,58,94,179,122,4,192,207,17,201,157,178,230,17,
123,182,108,154,68,60,6,213,131,252,124,196,240,108,234,252,166,145,176,114,105,174,86,255,39,243,167,15,246,9,65,30,11,165,170,175,153,182,151,102,155,147,136,39,44,181,156,84,171,104,19,7,243,144,164,183,118,45,98,99,158,246,66,87,193,186,107,210,61,
10,200,234,4,112,184,65,247,166,212,227,51,209,238,197,17,29,229,223,134,83,241,154,252,225,239,197,231,226,247,142,78,162,113,243,189,237,64,39,198,207,101,30,142,141,143,187,146,241,153,177,57,93,11,252,66,21,157,212,157,217,116,233,143,38,13,52,190,
116,205,39,174,153,25,112,2,23,117,200,45,76,19,81,143,162,238,146,245,231,180,209,161,184,82,58,116,19,241,241,186,59,220,206,186,199,230,116,251,226,223,236,36,228,234,138,227,42,31,42,72,87,221,136,114,121,215,24,218,19,19,151,126,138,33,157,46,213,
249,53,207,70,126,129,253,150,124,150,191,175,73,110,234,204,35,185,10,53,194,37,252,166,160,73,81,22,159,25,151,105,137,121,25,103,10,29,215,174,142,104,44,50,31,250,82,67,249,194,173,121,62,240,51,255,167,113,89,109,164,252,2,73,191,238,42,140,73,241,
83,162,114,98,150,42,147,113,78,197,38,58,28,117,39,252,109,254,77,231,240,248,55,219,221,134,180,47,207,51,41,117,241,152,53,202,24,147,246,42,186,180,51,96,248,106,162,180,35,28,36,126,111,140,196,75,98,84,43,231,140,101,26,79,4,153,30,174,139,164,
36,241,31,126,52,19,86,24,253,34,87,207,221,149,96,225,38,225,226,165,210,168,118,170,158,168,49,189,220,224,151,161,59,53,154,16,59,23,93,110,29,215,22,90,35,190,113,250,223,116,213,193,208,77,0,162,209,200,148,200,106,238,231,10,191,46,190,184,101,
220,11,223,189,243,205,253,149,188,171,69,72,215,125,39,49,18,51,221,196,101,157,231,223,95,50,122,103,126,219,117,251,165,240,205,81,137,31,207,246,122,129,177,115,204,93,95,196,81,226,209,188,107,130,122,225,242,49,45,231,188,177,241,206,149,237,145,
110,227,6,126,17,12,63,218,99,244,162,95,149,21,254,213,91,255,237,122,37,178,160,93,166,142,156,137,54,248,6,170,114,231,87,230,240,253,213,90,243,34,98,231,182,205,201,146,68,130,36,154,187,221,23,207,123,41,72,66,207,134,26,75,63,58,121,211,117,173,
147,170,42,88,37,231,17,53,185,176,114,33,125,157,84,133,162,197,53,95,173,165,157,183,214,43,198,153,76,212,95,186,19,57,223,175,136,219,201,168,46,127,25,136,135,158,25,22,31,251,188,254,229,248,207,175,89,244,92,92,196,198,35,32,29,252,231,156,59,
78,11,214,140,175,153,213,194,26,175,111,144,140,111,117,141,122,196,111,109,76,98,200,170,24,52,234,110,156,205,75,73,91,2,112,122,224,114,196,22,87,46,40,42,252,237,113,245,31,86,123,232,56,39,59,156,24,78,243,118,29,243,233,165,139,71,55,126,243,63,
119,222,181,164,145,87,83,191,205,65,116,182,89,75,67,23,127,18,232,248,77,7,35,121,253,47,113,196,230,12,248,141,24,149,184,13,127,45,77,28,247,243,11,223,254,217,111,170,170,230,117,93,74,219,79,9,151,221,175,156,246,65,174,246,204,94,31,181,125,82,
138,201,6,81,180,209,159,158,176,105,209,87,182,61,50,143,95,162,96,109,186,242,135,164,240,143,39,147,173,13,62,169,200,201,58,20,213,197,120,239,242,104,35,94,246,118,158,250,139,182,91,87,127,204,235,176,223,180,252,224,149,231,6,86,206,126,231,190,
47,21,117,254,225,187,41,173,109,218,49,151,50,219,152,33,199,253,90,233,227,197,225,210,251,119,221,246,206,254,254,218,152,184,7,228,180,179,174,186,105,167,55,246,203,54,202,191,25,234,183,69,30,51,4,62,42,98,196,31,41,123,125,238,178,157,23,86,109,
163,3,106,67,199,46,241,232,223,242,129,205,208,154,204,99,105,73,110,41,72,204,250,94,244,218,93,119,239,188,107,105,67,127,21,147,220,66,113,212,254,222,141,173,127,152,18,245,45,244,242,27,239,147,159,59,249,106,30,146,196,242,119,23,54,206,190,40,
126,253,150,21,3,237,252,34,134,103,239,80,55,156,213,145,251,237,17,6,171,183,125,206,130,119,37,77,15,23,199,70,109,207,200,247,201,169,24,50,222,51,248,229,245,137,225,177,201,119,79,94,121,160,162,237,214,87,197,29,113,253,118,126,177,142,159,252,
238,141,240,203,111,93,120,91,89,66,121,190,235,102,239,84,214,60,176,121,205,206,175,251,154,134,37,166,93,25,249,225,238,155,118,221,246,231,125,3,105,99,180,106,158,190,97,126,244,87,51,162,174,59,249,125,112,186,56,50,181,51,137,4,151,144,98,99,55,
126,235,45,159,157,114,142,181,236,208,74,0,34,165,50,111,172,56,50,103,126,227,245,107,126,207,43,69,140,182,82,154,68,18,88,188,37,111,101,169,42,175,239,235,170,254,148,10,236,54,115,215,94,35,183,182,52,60,231,178,253,119,188,254,209,64,26,77,183,
197,205,255,254,215,29,237,235,203,99,202,34,55,31,122,218,153,248,118,242,91,99,213,32,203,109,25,107,167,28,199,151,53,235,80,54,134,169,167,220,117,246,13,155,238,223,184,209,188,19,32,165,213,76,170,170,74,204,109,31,125,87,129,198,234,108,39,202,
30,107,22,201,73,98,238,54,127,203,236,171,155,111,248,136,63,148,41,181,54,198,251,188,241,198,147,83,30,57,62,33,191,104,187,125,137,36,238,234,40,32,227,87,21,246,8,211,177,183,67,42,1,240,83,44,36,20,153,248,224,129,27,222,124,206,74,231,74,170,157,
246,232,129,200,216,68,224,73,183,205,12,157,44,207,124,53,27,182,59,17,108,255,234,130,125,11,94,224,123,52,107,19,15,137,205,14,143,169,10,170,164,217,110,227,54,40,83,246,70,182,23,89,139,36,61,75,137,243,54,57,234,228,21,141,215,109,88,108,231,201,
61,139,111,223,189,107,116,220,253,162,228,228,89,44,209,249,197,147,32,162,103,252,123,228,246,215,87,91,21,160,27,55,170,83,59,131,143,230,240,135,148,88,45,35,185,28,31,71,4,91,107,235,134,39,223,59,253,58,100,18,128,24,90,203,90,225,167,165,53,183,
46,226,157,223,54,236,164,176,242,118,126,130,180,216,237,100,201,10,97,252,44,182,47,86,246,242,241,79,175,178,149,156,68,121,15,220,94,178,119,36,147,54,154,143,45,74,174,32,213,87,190,97,212,21,35,197,5,181,105,107,60,41,135,196,207,221,176,248,240,
29,35,171,249,77,111,54,235,80,236,105,167,104,161,231,253,170,120,210,130,51,147,216,99,123,227,227,94,45,125,103,237,10,59,59,24,17,205,140,206,49,235,71,232,174,157,93,39,131,173,197,39,246,41,84,9,43,133,69,109,121,214,74,232,127,169,33,147,0,36,
158,155,125,241,9,143,125,114,223,21,173,253,111,86,255,115,252,180,120,238,126,89,114,29,60,250,25,78,253,47,123,212,28,98,36,145,240,196,115,195,51,22,91,25,210,30,85,30,89,107,132,248,163,173,236,30,67,242,230,67,58,98,185,71,220,244,114,244,186,50,
247,9,127,38,35,241,171,19,86,236,188,247,167,252,164,173,253,105,124,75,209,23,126,74,27,28,73,226,162,14,53,119,60,24,157,242,240,182,42,251,39,220,110,174,12,117,6,117,105,155,189,246,197,131,162,148,198,104,48,109,117,56,36,18,128,121,210,72,11,213,
140,104,61,231,69,187,153,57,217,236,138,190,251,187,120,113,92,175,179,223,201,248,152,157,143,78,188,198,200,191,4,215,60,105,121,232,159,140,75,188,138,189,91,94,152,109,207,29,208,105,177,238,75,246,252,63,37,109,97,35,208,243,211,193,120,47,234,
144,37,242,107,71,182,158,39,142,171,249,190,205,254,52,108,71,164,125,88,130,52,216,235,100,93,113,152,117,168,141,250,40,231,173,23,222,183,31,153,168,195,53,122,158,33,127,118,232,145,147,22,139,228,15,164,225,27,87,221,156,8,89,44,160,223,197,134,
68,2,16,67,97,183,90,252,254,174,159,221,221,239,195,65,251,221,226,195,51,84,26,177,156,192,126,39,18,128,24,157,248,163,163,87,237,124,141,198,15,23,111,243,63,90,32,84,173,49,187,195,91,70,124,174,118,15,79,81,98,255,54,184,19,63,86,247,24,197,127,
42,117,176,14,111,220,124,106,140,120,252,252,91,32,251,147,168,195,92,173,248,121,231,234,144,50,191,63,184,211,101,59,137,243,71,157,42,29,252,154,195,244,76,67,34,1,240,19,51,196,167,143,248,128,231,85,219,199,254,73,70,74,42,141,96,123,164,206,54,
128,185,103,243,198,115,232,201,107,147,101,59,241,58,190,182,161,41,200,31,45,109,167,235,26,252,90,21,201,29,79,91,227,73,101,59,37,126,128,237,139,23,190,203,145,28,59,102,39,219,248,227,245,162,209,6,123,123,89,190,21,188,14,13,205,31,38,241,147,
222,77,101,155,250,155,215,221,208,120,192,47,90,172,229,244,203,191,201,225,231,77,188,238,246,180,221,217,105,187,253,247,135,96,251,247,162,114,84,197,48,18,165,142,94,210,42,206,175,132,244,67,151,12,218,8,210,236,160,44,119,191,123,115,105,181,141,
98,142,90,244,132,225,39,119,232,68,182,127,241,135,237,61,208,81,161,165,254,129,56,166,209,60,9,37,54,226,19,179,183,165,94,66,31,75,84,177,97,81,198,159,220,213,199,175,7,248,177,56,60,81,244,220,253,101,202,157,187,6,184,200,128,102,27,171,6,59,92,
252,129,100,142,28,239,12,104,141,169,207,148,245,9,192,196,163,158,150,113,17,31,191,18,203,217,137,250,139,218,108,95,78,202,5,253,52,184,215,243,209,79,29,249,27,2,201,45,140,150,148,116,240,235,10,98,102,227,22,13,220,250,143,205,238,97,30,64,136,
203,10,44,199,32,58,152,76,148,182,227,220,51,246,38,183,207,169,87,57,16,178,237,46,254,54,132,68,243,118,124,248,227,242,174,107,200,29,10,174,53,183,172,147,223,127,18,177,93,1,14,197,211,91,49,78,126,139,218,91,249,246,63,227,141,199,163,5,155,27,
34,51,249,125,209,43,237,151,119,168,4,94,41,108,142,71,14,219,77,0,226,143,119,36,98,158,234,109,219,136,99,135,39,34,196,130,247,63,141,13,47,145,219,154,252,70,72,124,123,102,101,195,249,159,207,225,247,216,40,182,70,17,46,133,95,116,77,229,40,47,
139,63,177,219,98,28,252,230,105,37,54,114,223,222,53,95,109,177,178,29,125,47,195,24,255,146,204,210,223,108,56,162,76,94,135,146,238,217,193,63,115,118,188,212,208,17,206,241,178,120,135,184,209,233,136,21,102,207,155,33,144,0,40,113,43,137,166,41,
103,206,236,172,185,215,89,56,213,205,207,41,216,234,30,93,241,4,61,114,13,191,53,204,82,39,237,107,139,222,218,61,189,115,66,81,241,197,69,81,157,159,196,179,54,49,221,71,213,88,126,221,135,54,206,186,43,239,79,111,61,101,140,255,194,176,79,181,220,
86,152,206,168,75,42,11,175,93,53,189,235,238,44,107,155,211,235,82,49,201,229,192,137,87,74,2,164,168,134,103,18,71,235,80,238,108,99,138,72,222,162,247,59,90,114,175,20,150,62,180,92,169,150,214,102,97,33,113,27,102,71,115,168,237,181,101,229,206,102,
103,30,11,255,75,161,58,79,206,68,181,16,87,114,17,195,144,73,188,51,231,160,179,199,182,132,84,85,85,233,164,138,159,230,26,228,233,81,126,85,27,217,72,182,218,15,67,252,113,167,103,236,23,211,163,4,171,163,146,238,197,240,219,124,249,73,102,173,198,
233,58,52,215,209,213,253,187,175,46,171,254,159,245,231,0,132,86,192,21,104,79,135,154,92,211,25,245,136,115,210,54,198,103,50,79,0,146,81,230,240,208,54,29,91,251,247,87,38,31,88,179,188,166,214,176,199,206,174,65,156,159,48,220,236,64,211,72,219,231,
18,122,10,231,234,9,141,239,97,237,236,95,122,22,233,248,251,172,79,0,162,110,125,254,72,251,156,141,217,57,136,146,249,97,227,232,17,212,241,198,227,120,77,255,157,22,104,14,177,109,110,27,255,115,209,234,152,225,174,176,205,98,142,90,124,100,188,89,
247,18,187,215,114,28,85,172,163,31,100,125,2,16,187,103,77,211,194,115,156,62,65,227,16,163,161,51,67,150,195,24,1,56,228,57,56,197,24,113,87,160,45,45,163,204,193,217,158,129,175,53,235,207,1,136,139,216,226,97,127,164,114,128,247,139,15,124,211,29,
152,147,15,31,53,221,109,212,213,187,236,159,137,118,32,28,20,145,186,128,56,55,167,25,62,181,186,46,232,232,87,128,169,71,50,56,75,12,129,17,0,63,129,154,229,81,50,157,255,221,41,76,16,24,130,2,89,222,181,134,136,104,86,92,108,59,68,172,16,102,86,9,
32,1,216,168,142,174,235,115,188,90,123,243,88,7,190,139,182,17,8,22,181,46,192,15,227,152,225,50,226,137,81,142,94,200,101,61,160,204,46,137,4,96,219,91,54,18,17,175,115,55,184,216,142,7,5,164,44,192,207,227,144,3,227,145,0,82,134,195,2,16,128,192,144,
22,192,8,96,72,87,31,130,135,128,61,1,36,0,123,126,88,26,2,67,90,0,9,96,72,87,31,130,135,128,61,1,36,0,123,126,88,26,2,67,90,0,9,96,72,87,31,130,135,128,61,129,236,191,20,216,222,246,13,217,165,215,204,33,174,127,255,167,194,139,182,231,210,16,191,13,
202,210,221,228,10,255,219,169,90,199,152,205,181,55,175,95,111,21,162,162,130,248,62,249,106,209,63,183,248,137,207,106,28,252,198,107,201,215,58,113,221,158,5,111,124,110,53,14,44,151,30,1,36,128,244,184,218,46,181,161,129,120,195,174,250,251,234,60,
82,185,100,241,27,106,131,215,174,191,179,112,41,191,152,90,252,237,61,75,73,36,238,34,193,6,87,221,146,102,183,52,60,181,63,146,245,55,2,230,146,136,151,149,222,194,63,65,2,248,27,75,86,252,15,9,32,43,170,225,232,32,242,100,115,127,171,137,187,201,237,
220,80,74,153,97,235,34,37,153,63,213,82,50,136,198,196,93,237,22,239,187,55,83,143,248,123,229,152,178,78,0,231,0,178,174,74,16,16,4,50,39,128,4,144,57,107,172,9,2,89,39,128,4,144,117,85,130,128,32,144,57,1,36,128,204,89,99,77,16,200,58,1,36,128,172,
171,18,4,4,129,204,9,32,1,100,206,26,107,130,64,214,9,32,1,100,93,149,32,32,8,100,78,0,9,32,115,214,88,19,4,178,78,0,9,32,235,170,4,1,65,32,115,2,72,0,153,179,198,154,32,144,117,2,72,0,89,87,37,8,8,2,153,19,64,2,200,156,53,214,4,129,172,19,64,2,200,186,
42,65,64,16,200,156,0,18,64,230,172,177,38,8,100,157,0,18,64,214,85,9,2,130,64,230,4,144,0,50,103,141,53,65,32,235,4,144,0,178,174,74,16,16,4,50,39,128,4,144,57,107,172,9,2,89,39,128,4,144,117,85,130,128,32,144,57,129,180,63,19,144,63,137,82,34,148,111,
144,248,177,50,153,203,73,86,151,62,246,26,13,70,69,92,140,7,73,173,172,161,107,153,180,37,81,71,236,204,45,60,54,3,126,251,255,87,32,173,9,192,173,80,70,101,218,65,36,214,201,172,62,18,146,119,47,23,147,18,105,169,34,23,229,207,219,101,157,201,36,144,
242,58,68,215,151,72,44,229,229,6,184,0,79,123,17,211,206,234,99,61,121,124,154,78,109,217,185,100,34,25,50,241,80,133,39,73,139,113,48,209,202,92,226,25,197,206,79,60,133,203,102,108,86,18,184,8,71,230,45,32,33,185,137,174,90,45,161,207,141,114,105,
230,110,207,77,108,216,9,53,67,166,60,202,244,76,105,169,148,100,168,137,15,106,91,228,34,114,9,239,36,10,127,162,172,165,199,82,147,8,147,88,155,212,144,44,211,201,215,214,54,233,205,248,112,54,147,87,147,181,244,36,170,69,229,57,164,233,224,30,39,227,
18,101,125,176,149,68,121,241,151,146,4,115,91,183,35,146,28,245,52,90,125,36,184,136,35,223,61,170,93,81,15,92,203,226,134,151,105,22,235,144,26,178,222,65,63,20,229,57,61,37,84,253,85,53,106,52,242,103,31,91,171,67,23,175,125,149,197,72,123,99,147,
211,177,69,93,164,213,208,200,124,18,55,252,252,213,90,251,215,136,28,78,40,252,177,238,152,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,
0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,
0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,
0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,
128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,
32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,224,239,85,224,255,0,196,61,49,167,17,160,232,27,0,0,0,0,73,69,78,68,174,66,96,130,0,0 };
const char* PDOicon_ico = (const char*) temp_binary_data_0;
//================== PDOResources.rc ==================
static const unsigned char temp_binary_data_1[] =
"#undef WIN32_LEAN_AND_MEAN\r\n"
"#define WIN32_LEAN_AND_MEAN\r\n"
"#include <windows.h>\r\n"
"\r\n"
"VS_VERSION_INFO VERSIONINFO\r\n"
"FILEVERSION 1,6,8,0\r\n"
"BEGIN\r\n"
" BLOCK \"StringFileInfo\"\r\n"
" BEGIN\r\n"
" BLOCK \"040904E4\"\r\n"
" BEGIN\r\n"
" VALUE \"CompanyName\", \"OpenDragon\\0\"\r\n"
" VALUE \"FileDescription\", \"Platonic display output service\\0\"\r\n"
" VALUE \"FileVersion\", \"1.6.9\\0\"\r\n"
" VALUE \"LegalCopyright\", \"(c) 2016 by OpenDragon\\0\"\r\n"
" VALUE \"ProductName\", \"Platonic display output service\\0\"\r\n"
" VALUE \"ProductVersion\", \"1.6.9\\0\"\r\n"
" END\r\n"
" END\r\n"
"\r\n"
" BLOCK \"VarFileInfo\"\r\n"
" BEGIN\r\n"
" VALUE \"Translation\", 0x409, 65001\r\n"
" END\r\n"
"END\r\n"
"\r\n"
"/* Add the application icon */\r\n"
"IDI_ICON1 ICON DISCARDABLE \"PDOicon.ico\"\r\n"
"IDI_ICON2 ICON DISCARDABLE \"PDOicon.ico\"\r\n";
const char* PDOResources_rc = (const char*) temp_binary_data_1;
const char* getNamedResource (const char*, int&) throw();
const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw()
{
unsigned int hash = 0;
if (resourceNameUTF8 != 0)
while (*resourceNameUTF8 != 0)
hash = 31 * hash + (unsigned int) *resourceNameUTF8++;
switch (hash)
{
case 0xac8e7ca6: numBytes = 25624; return PDOicon_ico;
case 0x396c3602: numBytes = 750; return PDOResources_rc;
default: break;
}
numBytes = 0;
return 0;
}
const char* namedResourceList[] =
{
"PDOicon_ico",
"PDOResources_rc"
};
}
| 201.371257 | 254 | 0.597624 |
7d494e85ccd5ee6a0140412d8217faae1735c7f7 | 15,433 | cpp | C++ | src/engine/components/collider/collidermath.cpp | senaademr/CS1950UFinal | efb1d223e68ee02b1386cb8a97200db6faad893d | [
"MIT"
] | null | null | null | src/engine/components/collider/collidermath.cpp | senaademr/CS1950UFinal | efb1d223e68ee02b1386cb8a97200db6faad893d | [
"MIT"
] | null | null | null | src/engine/components/collider/collidermath.cpp | senaademr/CS1950UFinal | efb1d223e68ee02b1386cb8a97200db6faad893d | [
"MIT"
] | null | null | null | #include "collidermath.h"
#include "cylindercollider.h"
#include "spherecollider.h"
#include "boxcollider.h"
#include "compoundcollider.h"
#include "engine/components/transformcomponent.h"
#include "engine/components/physicscomponent.h"
#include "engine/components/collisioncomponent.h"
#include "engine/basics/gameobject.h"
#include "engine/util/CommonIncludes.h"
#include "collisionresponse.h"
/*****************************Actual Collisions ***************************/
CollisionResponse ColliderMath::collideCylinderCylinder(CylinderCollider* collider1, CylinderCollider* collider2){
Transform transform1 = collider1->getTransform();
Transform transform2 = collider2->getTransform();
//std::cout << "testing cylinder collide with cylinder" << std::endl;
bool areColliding = collideLineCylinder(transform1, transform2) && collideCircles(transform1, transform2);
if(areColliding){
glm::vec3 circleMtv = getCircleCircleMtv(transform1, transform2);
glm::vec3 lineMtv = getLineMtvCylinder(transform1, transform2);
glm::vec3 mtv = getSmallerMtv(circleMtv, lineMtv);
return CollisionResponse(mtv);
//ColliderMath::resolveMtv(collider1, collider2, circleMtv, lineMtv);
}
return CollisionResponse();
}
CollisionResponse ColliderMath::collideCylinderBox(CylinderCollider *cylinderCollider, BoxCollider *boxCollider){
Transform transformCylinder = cylinderCollider->getTransform();
Transform transformBox = boxCollider->getTransform();
glm::vec2 clampedPoint = clampPointXZ(transformBox, transformCylinder);
bool colliding = collideCylinderLineBox(transformCylinder, transformBox)
&& collidePointCircle(transformCylinder, clampedPoint);
if(colliding){
glm::vec2 cylinderRangeY = getRangeCylinder(transformCylinder);
glm::vec2 boxRangeY = getRangeBox(transformBox, DIMENSION::Y);
glm::vec3 lineMtv = getLineLineMtv(cylinderRangeY, boxRangeY, DIMENSION::Y);
glm::vec3 circleMtv = getPointCircleMtv(transformCylinder, transformBox);
//std::cout << "lineMtv: " << lineMtv << " circleMtv: " << circleMtv << std::endl;
glm::vec3 mtv = getSmallerMtv(lineMtv, circleMtv);
return CollisionResponse(mtv);
}
return CollisionResponse();
}
CollisionResponse ColliderMath::collideCylinderSphere(CylinderCollider *cylinderCollider, SphereCollider * sphereCollider){
//std::cout << "unimplemented collision: cylinder sphere" << std::endl;
return CollisionResponse();
}
CollisionResponse ColliderMath::collideBoxBox(BoxCollider* collider1, BoxCollider* collider2){
Transform transform1 = collider1->getTransform();
Transform transform2 = collider2->getTransform();
bool collideX = collideLineBox(transform1, transform2, DIMENSION::X);
bool collideY = collideLineBox(transform1, transform2, DIMENSION::Y);
bool collideZ = collideLineBox(transform1, transform2, DIMENSION::Z);
bool result = collideX && collideY && collideZ;
if(result){
glm::vec3 lineMtvX = getLineLineMtvBox(transform1, transform2, DIMENSION::X);
glm::vec3 lineMtvY = getLineLineMtvBox(transform1, transform2, DIMENSION::Y);
glm::vec3 lineMtvZ = getLineLineMtvBox(transform1, transform2, DIMENSION::Z);
//resolveMtv(collider1, collider2, lineMtvX, lineMtvY, lineMtvZ);
glm::vec3 mtv = getSmallerMtv(lineMtvX, lineMtvY, lineMtvZ);
return CollisionResponse(mtv);
}
return CollisionResponse();
}
CollisionResponse ColliderMath::collideBoxSphere(BoxCollider* boxCollider, SphereCollider* sphereCollider){
Transform transformBox = boxCollider->getTransform();
Transform transformSphere = sphereCollider->getTransform();
glm::vec3 clampedPoint = clampPoint(transformBox, transformSphere);
bool colliding = collidePointSphere(transformSphere, clampedPoint);
if(colliding){
glm::vec3 mtv = getPointSphereMtv(transformSphere, clampedPoint);
return CollisionResponse(mtv);
}
return CollisionResponse();
}
CollisionResponse ColliderMath::collideSphereSphere(SphereCollider* collider1, SphereCollider* collider2){
Transform transform1 = collider1->getTransform();
Transform transform2 = collider2->getTransform();
bool colliding = collideSpheres(transform1, transform2);
if(colliding){
glm::vec3 mtv = getSphereSphereMtv(transform1, transform2);
return CollisionResponse(mtv);
}
return CollisionResponse();
}
/*************************** dummy collisions *****************/
CollisionResponse ColliderMath::negateResponse(CollisionResponse response){
if(response.didCollide){
return CollisionResponse(-1.f *response.mtv);
}
return response;
}
CollisionResponse ColliderMath::collideSphereBox(SphereCollider* sphereCollider, BoxCollider* boxCollider){
return negateResponse(collideBoxSphere(boxCollider, sphereCollider));
}
CollisionResponse ColliderMath::collideBoxCylinder(BoxCollider *boxCollider, CylinderCollider *cylinderCollider){
return negateResponse(collideCylinderBox(cylinderCollider, boxCollider));
}
CollisionResponse ColliderMath::collideSphereCylinder(SphereCollider * sphereCollider, CylinderCollider *cylinderCollider){
return negateResponse(collideCylinderSphere(cylinderCollider, sphereCollider));
}
/***************************** Line collisions ***************************/
bool ColliderMath::collideLineCylinder(Transform &transform1, Transform &transform2)
{
glm::vec2 range1 = ColliderMath::getRangeCylinder(transform1);
glm::vec2 range2 = ColliderMath::getRangeCylinder(transform2);
return collideLine(range1, range2);
}
bool ColliderMath::collideLine(glm::vec2 range1, glm::vec2 range2){
bool result= (range1.x < range2.y && range2.x < range1.y);
return result;
}
bool ColliderMath::collideLineBox(Transform &transform1, Transform &transform2, DIMENSION dim){
glm::vec2 range1 = getRangeBox(transform1, dim);
glm::vec2 range2 = getRangeBox(transform2, dim);
return collideLine(range1, range2);
}
bool ColliderMath::collideSpheres(Transform &transform1, Transform &transform2){
float distance2 = glm::distance2(transform1.getPosition(), transform2.getPosition());
float radius1 = getRadius(transform1.getSize());
float radius2 = getRadius(transform2.getSize());
bool result = distance2 < powf(radius1 + radius2, 2);
return result;
}
glm::vec3 ColliderMath::getSphereSphereMtv(Transform &transform1, Transform &transform2){
glm::vec3 locationDifference = transform1.getPosition()-transform2.getPosition();
float distance = glm::length(locationDifference);
glm::vec3 direction = glm::normalize(locationDifference);
float radius1 = getRadius(transform1.getSize());
float radius2 = getRadius(transform2.getSize());
glm::vec3 mtv = (distance -radius1 - radius2 )*direction;
return mtv;
}
bool ColliderMath::collideCylinderLineBox(Transform &transformCylinder, Transform &transformBox){
glm::vec2 yRangeCylinder = getRangeCylinder(transformCylinder);
glm::vec2 yRangeBox = getRangeBox(transformBox, DIMENSION::Y);
return collideLine(yRangeCylinder, yRangeBox);
}
glm::vec3 ColliderMath::getCircleCircleMtv(Transform &transform1, Transform &transform2){
glm::vec2 circlePos1 = toCircle(transform1.getPosition());
glm::vec2 circlePos2 = toCircle(transform2.getPosition());
float length = glm::distance(circlePos1, circlePos2);
float radius1 = getRadius(transform1.getSize());
float radius2 = getRadius(transform2.getSize());
glm::vec2 mtv2d = (circlePos2-circlePos1);
mtv2d /= length;
mtv2d *= (radius1 + radius2-length);
glm::vec3 mtv = glm::vec3(mtv2d.x, 0, mtv2d.y);
return mtv;
}
glm::vec3 ColliderMath::getLineMtvCylinder(Transform &transform1, Transform &transform2){
glm::vec2 yRange1 = ColliderMath::getRangeCylinder(transform1);
glm::vec2 yRange2 = ColliderMath::getRangeCylinder(transform2);
return getLineLineMtv(yRange1, yRange2, DIMENSION::Y);
}
glm::vec3 ColliderMath::getLineLineMtvBox(Transform &transform1, Transform &transform2, DIMENSION dim){
glm::vec2 range1 = ColliderMath::getRangeBox(transform1, dim);
glm::vec2 range2 = ColliderMath::getRangeBox(transform2, dim);
return getLineLineMtv(range1, range2, dim);
}
glm::vec3 ColliderMath::getLineLineMtv(glm::vec2 range1, glm::vec2 range2, DIMENSION dim){
float aRight = range2.y - range1.x;
float aLeft = range1.y - range2.x;
float value = 1;
if(aLeft < 0 || aRight < 0){
std::cout << "error? " << std::endl;
}
if(aRight < aLeft){
value = -aRight;
}
else{
value = aLeft;
}
switch(dim){
case(DIMENSION::X):
return glm::vec3(value, 0, 0);
case(DIMENSION::Y):
return glm::vec3(0, value, 0);
case(DIMENSION::Z):
return glm::vec3(0, 0, value);
}
assert(false);
return glm::vec3(0);
}
bool ColliderMath::collideCircles(Transform &transform1, Transform &transform2){
glm::vec2 circlePos1 = toCircle(transform1.getPosition());
glm::vec2 circlePos2 = toCircle(transform2.getPosition());
float distance2 = glm::distance2(circlePos1, circlePos2);
float radius1 = getRadius(transform1.getSize());
float radius2 = getRadius(transform2.getSize());
bool result = distance2 < powf(radius1 + radius2, 2);
if(result){
}
return result;
}
glm::vec3 ColliderMath::getPointSphereMtv(Transform &transformSphere, glm::vec3 point){
float radius = getRadius(transformSphere.getSize());
glm::vec3 mtv = transformSphere.getPosition()- point;
float size = glm::length(mtv);
mtv = glm::normalize(mtv);
mtv = (radius - size)*mtv;
return mtv;
}
//if inside, find the dimension that is shortest
//TODO FIXXXXXXXX
glm::vec3 ColliderMath::getPointCircleMtv(Transform &transformCylinder,Transform &transformBox){
glm::vec2 point = clampPointXZ(transformBox, transformCylinder);
float radius = getRadius(transformCylinder.getSize());
glm::vec2 circle = toCircle(transformCylinder.getPosition());
glm::vec2 mtv = circle - point;
float size = glm::length(mtv);
if(size==0){
glm::vec2 xRange = getRangeBox(transformBox, DIMENSION::X);
glm::vec2 zRange = getRangeBox(transformBox, DIMENSION::Z);
glm::vec3 mtvX1 = glm::vec3(circle.x - xRange.x, 0, 0 );
glm::vec3 mtvX2 = glm::vec3(circle.x - xRange.y, 0, 0 );
glm::vec3 mtvX = getSmallerMtv(mtvX1, mtvX2);
//std::cout << "circleX: " << circle.x << " xRange: " << xRange << std::endl;
//std::cout << "mtvX " <<mtvX << std::endl;
glm::vec3 mtvY1 = glm::vec3(0, 0, circle.y - zRange.x);
glm::vec3 mtvY2 = glm::vec3(0, 0, circle.y - zRange.y);
glm::vec3 mtvY = getSmallerMtv(mtvY1, mtvY2);
glm::vec3 mtv = getSmallerMtv(mtvX, mtvY);
float newSize = glm::length(mtv);
return glm::normalize(mtv)* (radius + newSize);
//float toXMin = glm::distance(circle.x, xRange.x);
//return glm::vec3(100000);
}
else{
mtv = glm::normalize(mtv);
mtv = (size - radius)*mtv;
return glm::vec3(mtv.x, 0, mtv.y);
}
}
bool ColliderMath::collidePointSphere(Transform &transformSphere, glm::vec3 point){
float radius = getRadius(transformSphere.getSize());
float distance = glm::distance(transformSphere.getPosition(), point);
return distance <= radius;
}
bool ColliderMath::collidePointCircle(Transform &transformCylinder, glm::vec2 point){
glm::vec2 circle = toCircle(transformCylinder.getPosition());
float radius = getRadius(transformCylinder.getSize());
return glm::distance(circle, point) <= radius;
}
/*************************** Helper *****************************/
float ColliderMath::getRadius(glm::vec3 size){
return std::abs(size.x/2.f);
}
glm::vec2 ColliderMath::toCircle(glm::vec3 pos){
return glm::vec2(pos.x, pos.z);
}
glm::vec3 ColliderMath::clampPoint(Transform &transformBox, Transform &transformSphere){
float x = clampDimension(transformBox, transformSphere, DIMENSION::X);
float y = clampDimension(transformBox, transformSphere, DIMENSION::Y);
float z = clampDimension(transformBox, transformSphere, DIMENSION::Z);
glm::vec3 clampedPoint = glm::vec3(x,y,z);
return clampedPoint;
}
glm::vec2 ColliderMath::clampPointXZ(Transform &transformBox,Transform &transformCylinder){
float x = clampDimension(transformBox, transformCylinder, DIMENSION::X);
float z = clampDimension(transformBox, transformCylinder, DIMENSION::Z);
glm::vec2 clampedPoint = glm::vec2(x, z);
return clampedPoint;
}
float ColliderMath::clampDimension(Transform &transformBox,Transform &transformSphere, DIMENSION dim){
glm::vec2 range = getRangeBox(transformBox, dim);
glm::vec3 pos = transformSphere.getPosition();
switch(dim){
case(DIMENSION::X):
return glm::clamp(pos.x, range.x, range.y);
case(DIMENSION::Y):
return glm::clamp(pos.y, range.x, range.y);
case(DIMENSION::Z):
return glm::clamp(pos.z, range.x, range.y);
}
assert(false);
return -1;
}
/**
* @brief ColliderMath::getRangeCylinder
* Returns a vec2 representing the vertical dimension of the cylinder.
* This is different from the box range because the starting point of the cylinder is the bottom
* @param transformComponent
* @return
*/
glm::vec2 ColliderMath::getRangeCylinder(Transform &transformCylinder){
glm::vec3 pos = transformCylinder.getPosition();
glm::vec3 size = transformCylinder.getSize();
return glm::vec2(pos.y, pos.y + size.y);
}
/**
* @brief ColliderMath::getRangeBox
* Returns a vec2 representing a dimension of a box.
* This is different from the cylinder range because the starting point of a box is the center
* @param transformComponent
* @param dim
* @return
*/
glm::vec2 ColliderMath::getRangeBox(Transform &transformBox, DIMENSION dim){
glm::vec3 pos = transformBox.getPosition();
glm::vec3 size = transformBox.getSize();
switch(dim){
case(DIMENSION::X):
return getRangeBox(pos.x, size.x);
case(DIMENSION::Y):
return getRangeBox(pos.y, size.y);
case(DIMENSION::Z):
return getRangeBox(pos.z, size.z);
}
assert(false); //should never reach here
return glm::vec2(0);
}
/**
* @brief ColliderMath::getRangeBox
* Returns a vec2 representing a dimension of a box.
* This is different from the cylinder range because the starting point of a box is the center
* @param pos
* @param size
* @return
*/
glm::vec2 ColliderMath::getRangeBox(float pos, float size){
assert(size >= 0);
return glm::vec2(pos-size/2.f, pos + size/2.f);
}
glm::vec3 ColliderMath::getSmallerMtv(glm::vec3 mtv1, glm::vec3 mtv2){
if(glm::length2(mtv1) < glm::length2(mtv2)){
return mtv1;
}
else{
return mtv2;
}
}
glm::vec3 ColliderMath::getSmallerMtv(glm::vec3 mtv1, glm::vec3 mtv2, glm::vec3 mtv3){
float length1 = glm::length2(mtv1);
float length2 = glm::length2(mtv2);
float length3 = glm::length2(mtv3);
if(length1 < length2 && length1 < length3){
return mtv1;
}
else if(length2 < length3){
return mtv2;
}
else{
return mtv3;
}
}
| 36.142857 | 123 | 0.694227 |
7d4a266a5b7ad0d0c4cd35de51f121afff7cfadf | 6,674 | cpp | C++ | data/reddit/extract_train.cpp | Sanzo00/NeutronStarLite | 57d92d1f7f6cd55c55a83ca086096a710185d531 | [
"Apache-2.0"
] | 38 | 2022-03-09T10:29:08.000Z | 2022-03-30T13:56:16.000Z | data/reddit/extract_train.cpp | Sanzo00/NeutronStarLite | 57d92d1f7f6cd55c55a83ca086096a710185d531 | [
"Apache-2.0"
] | 3 | 2022-03-09T10:55:27.000Z | 2022-03-17T02:53:58.000Z | data/reddit/extract_train.cpp | Sanzo00/NeutronStarLite | 57d92d1f7f6cd55c55a83ca086096a710185d531 | [
"Apache-2.0"
] | 6 | 2022-03-10T07:41:31.000Z | 2022-03-21T06:36:31.000Z | #include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#include <string.h>
#include <cstring>
using namespace std;
int generate_Mask(int vertices,std::string mask_file){
FILE *fp_mask;
fp_mask=fopen(mask_file.c_str(),"w");
for(int i=0;i<vertices;i++){
int a=rand()%10;
if(a<6){
fprintf(fp_mask,"%d train\n",i);
}else
if(a<8){
fprintf(fp_mask,"%d test\n",i);
}else
if(a<10){
fprintf(fp_mask,"%d val\n",i);
}
}
fclose(fp_mask);
return 0;
}
void writeLabels(int vertices,std::string label_file)
{
std::string str;
std::string label_file_output=label_file+"_nts";
std::ifstream input_lbl(label_file.c_str(), std::ios::in);
std::ofstream output_lbl(label_file_output.c_str(), std::ios::out);
// ID F F F F F F F L
std::cout<<"called"<<std::endl;
if (!input_lbl.is_open())
{
std::cout<<"open label file fail!"<<std::endl;
return;
}
std::string la;
//std::cout<<"finish1"<<std::endl;
int id=0;
int label;
for(int j=0;j<vertices;j++)
{
input_lbl >> label;
output_lbl<<j<<" "<<label<<std::endl;
}
input_lbl.close();
output_lbl.close();
}
int sort_Mask(int vertices,std::string mask_file){
std::cout<<vertices<<std::endl;
std::string mask_file_sorted=mask_file+"sorted";
std::ifstream fp_mask(mask_file.c_str(), std::ios::in);
std::ofstream fp_mask_sorted(mask_file_sorted.c_str(), std::ios::out);
if (!fp_mask.is_open())
{
std::cout<<"open"<<mask_file<<" fail!"<<std::endl;
return 0;
}
int* value=new int[vertices];
memset(value,0,sizeof(int)*vertices);
while(!fp_mask.eof()){
int id;
std::string s;
fp_mask>>id>>s;
std::cout<<id<<" "<<s<<std::endl;
if(s.compare("train")==0){
value[id]=1;
}else if(s.compare("val")==0){
value[id]=2;
}else if(s.compare("test")==0){
value[id]=3;
}else{
;
}
}
for(int i=0;i<vertices;i++){
std::string s;
if(value[i]==1){
fp_mask_sorted<<i<<" train"<<std::endl;
}else if(value[i]==2){
fp_mask_sorted<<i<<" val"<<std::endl;
}
if(value[i]==3){
fp_mask_sorted<<i<<" test"<<std::endl;
}
}
fp_mask_sorted.close();
fp_mask.close();
//fclose(fp_mask);
return 0;
}
int sort_Label(int vertices,std::string label_file){
std::string label_file_sorted=label_file+"sorted";
std::ifstream fp_label(label_file.c_str(), std::ios::in);
std::ofstream fp_label_sorted(label_file_sorted.c_str(), std::ios::out);
if (!fp_label.is_open())
{
std::cout<<"open "<< label_file<<" fail!"<<std::endl;
return 0;
}
int* value=new int[vertices];
memset(value,0,sizeof(int)*vertices);
while(!fp_label.eof()){
int id;
int v;
fp_label>>id>>v;
value[id]=v;
}
for(int i=0;i<vertices;i++){
fp_label_sorted<<i<<" "<<value[i]<<std::endl;
}
fp_label_sorted.close();
fp_label.close();
//fclose(fp_label);
return 0;
}
void generate_edge(int vertices,std::string edge_file){
std::string edge_file_sorted=edge_file+".bin";
std::ifstream fp_edge(edge_file.c_str(), std::ios::in);
std::ofstream fp_edge_sorted(edge_file_sorted.c_str(), std::ios::binary);
if (!fp_edge.is_open())
{
std::cout<<"open "<< edge_file<<" fail!"<<std::endl;
return;
}
while(!fp_edge.eof()){
int src;
int dst;
fp_edge>>src>>dst;
fp_edge_sorted.write((char*)&src,sizeof(int));
fp_edge_sorted.write((char*)&dst,sizeof(int));
fp_edge_sorted.write((char*)&dst,sizeof(int));
fp_edge_sorted.write((char*)&src,sizeof(int));
//fp_edge_sorted<<dst<<" "<<src<<std::endl;
}
for(int i=0;i<vertices;i++){
fp_edge_sorted.write((char*)&i,sizeof(int));
fp_edge_sorted.write((char*)&i,sizeof(int));
}
fp_edge_sorted.close();
fp_edge.close();
//fclose(fp_label);
std::ifstream fp_edge_test(edge_file_sorted.c_str(), std::ios::binary);
for(int i=0;i<23446805;i++){
int src;
int dst;
fp_edge_test.read((char*)&src,sizeof(int));
fp_edge_test.read((char*)&dst,sizeof(int));
if(i>23446705)
std::cout<<"edge[0]: "<<src<<" edge[1]: "<<dst<<std::endl;
//fp_edge_sorted<<dst<<" "<<src<<std::endl;
}
return;
}
void writeFeature(int vertices, int features,std::string input_feature)
{
std::string str;
std::string output_feature=input_feature+"_nts";
std::ifstream input_ftr(input_feature.c_str(), std::ios::in);
std::ofstream output_ftr(output_feature.c_str(), std::ios::out);
std::cout<<"called"<<std::endl;
if (!input_ftr.is_open())
{
std::cout<<"open feature file fail!"<<std::endl;
return;
}
// if (!input_lbl.is_open())
// {
// std::cout<<"open label file fail!"<<std::endl;
// return;
// }
float *con_tmp = new float[features];
std::string la;
//std::cout<<"finish1"<<std::endl;
int id=0;
int label;
for(int j=0;j<vertices;j++)
{
int size_0=features;
output_ftr<<j<<" ";
for (int i = 0; i < size_0; i++){
input_ftr >> con_tmp[i];
if(i!=(size_0-1)){
output_ftr<<con_tmp[i]<<" ";
}else{
output_ftr<<con_tmp[i]<<std::endl;
}
}
// input_lbl >> label;
// output_lbl<<j<<" "<<label<<std::endl;
}
free(con_tmp);
input_ftr.close();
// input_lbl.close();
output_ftr.close();
// output_lbl.close();
}
int main(int argc, char ** argv){
//for reddit
//sort_Mask(232965, "./redditdata/reddit_small/reddit.mask");
//sort_Label(232965, "./redditdata/reddit_small/reddit.labeltable");
generate_edge(232965,"./redditdata/reddit_small/reddit_full.edge.txt");
//writeFeature(232965,602,"./redditdata/reddit_small/reddit.featuretablenorm");
return 0;
}
| 30.336364 | 79 | 0.526521 |
7d4a3b1a7ab527c9acc73bb0b253608a9dc3274c | 1,751 | hpp | C++ | LetsGo/ThirdParty/ApproxMVBB/Includes/ApproxMVBB/Common/LogDefines.hpp | wis1906/letsgo-ar-space-generation | 02d888a44bb9eb112f308356ab42720529349338 | [
"MIT"
] | null | null | null | LetsGo/ThirdParty/ApproxMVBB/Includes/ApproxMVBB/Common/LogDefines.hpp | wis1906/letsgo-ar-space-generation | 02d888a44bb9eb112f308356ab42720529349338 | [
"MIT"
] | null | null | null | LetsGo/ThirdParty/ApproxMVBB/Includes/ApproxMVBB/Common/LogDefines.hpp | wis1906/letsgo-ar-space-generation | 02d888a44bb9eb112f308356ab42720529349338 | [
"MIT"
] | null | null | null | // ========================================================================================
// ApproxMVBB
// Copyright (C) 2014 by Gabriel Nützi <nuetzig (at) imes (d0t) mavt (d0t) ethz
// (døt) ch>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================================
#ifndef ApproxMVBB_Common_LogDefines_hpp
#define ApproxMVBB_Common_LogDefines_hpp
#include <iostream>
#include "ApproxMVBB/Config/Config.hpp"
#define ApproxMVBB_LOG(message) std::cout << message;
#define ApproxMVBB_LOGLEVEL(level, setlevel, message) \
if(level <= setlevel) \
{ \
ApproxMVBB_LOG(message); \
}
// Message Log
// ==================================================================================
#if ApproxMVBB_FORCE_MSGLOG_LEVEL >= 0
# define ApproxMVBB_MSGLOG_LEVEL ApproxMVBB_FORCE_MSGLOG_LEVEL // force the output level if set in the config!
#else
# ifndef NDEBUG
// Debug!
# define ApproxMVBB_MSGLOG_LEVEL 2 // 0 = no output
# else
# define ApproxMVBB_MSGLOG_LEVEL 0 // 0 = no output
# endif
#endif
#define ApproxMVBB_MSGLOG_L1(message) ApproxMVBB_LOGLEVEL(1, ApproxMVBB_MSGLOG_LEVEL, message)
#define ApproxMVBB_MSGLOG_L2(message) ApproxMVBB_LOGLEVEL(2, ApproxMVBB_MSGLOG_LEVEL, message)
#define ApproxMVBB_MSGLOG_L3(message) ApproxMVBB_LOGLEVEL(3, ApproxMVBB_MSGLOG_LEVEL, message)
// ==================================================================================
#endif
| 39.795455 | 114 | 0.5494 |
7d4d41c341c2038489316081bf0031565dc3a428 | 2,456 | cc | C++ | Assignment1/Q3/daxpy.cc | Gurupradeep/Parallel-Programming | fe54eb921f8895518c9d041075a92a5bd1499737 | [
"MIT"
] | null | null | null | Assignment1/Q3/daxpy.cc | Gurupradeep/Parallel-Programming | fe54eb921f8895518c9d041075a92a5bd1499737 | [
"MIT"
] | null | null | null | Assignment1/Q3/daxpy.cc | Gurupradeep/Parallel-Programming | fe54eb921f8895518c9d041075a92a5bd1499737 | [
"MIT"
] | null | null | null | /*
* DAXPI program.
* Run the program as follows.
* Compilation:
* g++ daxpy.cc -fopenmp
* Run:
* ./a.out
*/
#include <stdio.h>
#include <omp.h>
#include <iostream>
#define SIZE 1 << 16
namespace {
std::pair<double, int> get_parallel_execution_time(int X[], int Y[], int a, int num_of_threads) {
omp_set_num_threads(num_of_threads);
double start_time = omp_get_wtime();
int thread_id;
#pragma omp parallel shared(X, Y)
{
thread_id = omp_get_thread_num();
if (thread_id == 0) {
num_of_threads = omp_get_num_threads();
}
#pragma omp for
for (int i = 0; i < SIZE; i++)
X[i] = a*X[i] + Y[i];
}
double end_time = omp_get_wtime();
return std::make_pair(end_time - start_time, num_of_threads);
}
/*
* Unroll the loop to maximum the work done in a single iteration. This will save few thread operations (like computing the range to operate on etc) and compiler work.
*
*/
std::pair<double, int> get_parallel_execution_time_2(int X[], int Y[], int a, int num_of_threads) {
omp_set_num_threads(num_of_threads);
double start_time = omp_get_wtime();
int thread_id;
#pragma omp parallel shared(X, Y) private(thread_id)
{
thread_id = omp_get_thread_num();
if (thread_id == 0) {
num_of_threads = omp_get_num_threads();
}
#pragma omp for
for (int i = 0; i < SIZE; i += 2) {
X[i] = a * X[i] + Y[i];
X[i+1] = a * X[i+1] + Y[i + 1];
}
}
double end_time = omp_get_wtime();
return std::make_pair(end_time - start_time, num_of_threads);
}
void reset_dataset(int X[], int Y[], int size) {
for (int i = 0; i < SIZE; i++) {
X[i] = 1;
Y[i] = 2;
}
}
}
int main() {
int X[SIZE];
int Y[SIZE];
int a = 6;
reset_dataset(X, Y, SIZE);
double single_thread_time = get_parallel_execution_time(X, Y, a, 1).first;
printf("Time taken for execution using one thread is %lf seconds.\n", single_thread_time);
double time_taken;
for(int thread = 2; thread <= 15; thread++) {
reset_dataset(X, Y, SIZE);
std::pair<double, int> result = get_parallel_execution_time(X, Y, a, thread);
double speed_up = result.first / single_thread_time;
printf("Approach 1: For number of threads: %d speedup is: %lf.\n", result.second, speed_up);
reset_dataset(X, Y, SIZE);
std::pair<double, int> result_2 = get_parallel_execution_time_2(X, Y, a, thread);
speed_up = result_2.first / single_thread_time;
printf("Approach 2: For number of threads: %d speedup is: %lf.\n\n", result_2.second, speed_up);
}
return 0;
}
| 27.909091 | 167 | 0.671824 |
7d506758d667e9491d9f20c2cc5ec99e20a09365 | 9,141 | cpp | C++ | source/tools/finite/opt-internal/ceres_direct.cpp | DavidAce/DMRG | e465fd903eade1bf6aa74daacd8e2cf02e9e9332 | [
"MIT"
] | 9 | 2017-10-31T22:50:28.000Z | 2022-03-10T15:45:27.000Z | source/tools/finite/opt-internal/ceres_direct.cpp | DavidAce/DMRG | e465fd903eade1bf6aa74daacd8e2cf02e9e9332 | [
"MIT"
] | null | null | null | source/tools/finite/opt-internal/ceres_direct.cpp | DavidAce/DMRG | e465fd903eade1bf6aa74daacd8e2cf02e9e9332 | [
"MIT"
] | 1 | 2019-07-16T00:27:56.000Z | 2019-07-16T00:27:56.000Z | //
// Created by david on 2019-07-09.
//
#include "ceres_direct_functor.h"
#include <algorithms/class_algorithm_status.h>
#include <ceres/gradient_problem.h>
#include <config/nmspc_settings.h>
#include <tensors/class_tensors_finite.h>
#include <tensors/model/class_model_finite.h>
#include <tensors/state/class_state_finite.h>
#include <tools/common/fmt.h>
#include <tools/common/log.h>
#include <tools/common/prof.h>
#include <tools/finite/measure.h>
#include <tools/finite/opt-internal/opt-internal.h>
#include <tools/finite/opt-internal/report.h>
#include <tools/finite/opt_mps.h>
tools::finite::opt::opt_mps tools::finite::opt::internal::ceres_direct_optimization(const class_tensors_finite &tensors, const class_algorithm_status &status,
OptType optType, OptMode optMode, OptSpace optSpace) {
std::vector<size_t> sites(tensors.active_sites.begin(), tensors.active_sites.end());
opt_mps initial_state("current state", tensors.state->get_multisite_mps(), sites,
tools::finite::measure::energy(tensors) - tensors.model->get_energy_reduced(), // Eigval
tensors.model->get_energy_reduced(), // Energy reduced for full system
tools::finite::measure::energy_variance(tensors),
1.0, // Overlap
tensors.get_length());
return ceres_direct_optimization(tensors, initial_state, status, optType, optMode, optSpace);
}
tools::finite::opt::opt_mps tools::finite::opt::internal::ceres_direct_optimization(const class_tensors_finite &tensors, const opt_mps &initial_mps,
const class_algorithm_status &status, OptType optType, OptMode optMode,
OptSpace optSpace) {
tools::log->trace("Optimizing in DIRECT mode");
auto t_opt_dir = tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir"]->tic_token();
if constexpr(settings::debug)
if(initial_mps.has_nan()) throw std::runtime_error("initial_mps has nan's");
reports::bfgs_add_entry("Direct", "init", initial_mps);
const auto ¤t_mps = tensors.state->get_multisite_mps();
const auto current_map = Eigen::Map<const Eigen::VectorXcd>(current_mps.data(), current_mps.size());
auto options = internal::ceres_default_options;
auto summary = ceres::GradientProblemSolver::Summary();
opt_mps optimized_mps;
optimized_mps.set_name(initial_mps.get_name());
optimized_mps.set_sites(initial_mps.get_sites());
optimized_mps.set_length(initial_mps.get_length());
optimized_mps.set_energy_reduced(initial_mps.get_energy_reduced());
// When we use "reduced-energy mpo's", the current energy per site is subtracted from all the MPO's at the beginning of every iteration.
// The subtracted number is called "energy_reduced".
// Directly after the energy subtraction, the target energy is exactly zero, and Var H = <(H-Er)²>
// However, after some steps in the same iteration, the optimizer may have found a state with slightly different energy,
// so the target energy is actually 0 + dE.
// We can obtain the shift amount dE = <H-Er>, which we call "eigval", i.e. the eigenvalue of the operator <H-Er>
// Then, technically Var H = <(H-E+|dE|)²>, and if unaccounted for, we may get Var H < 0, which is a real pain since
// we are optimizing the logarithm of Var H.
// Here we use functor->set_shift in order to account for the shifted energy and reach better precision.
// Note 1: shifting only works if the mpo is not already compressed
// Note 2: shifting only makes sense if we are using reduced-energy mpos
switch(optType) {
case OptType::CPLX: {
auto t_opt_dir_bfgs = tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_bfgs"]->tic_token();
// Copy the initial guess and operate directly on it
optimized_mps.set_tensor(initial_mps.get_tensor());
auto * functor = new ceres_direct_functor<std::complex<double>>(tensors, status);
if(settings::precision::use_reduced_energy and settings::precision::use_shifted_mpo and not tensors.model->is_compressed_mpo_squared())
functor->set_shift(-std::abs(initial_mps.get_eigval())); // Account for the shange in energy since the last energy reduction
functor->compress(); // Compress the virtual bond between MPO² and the environments
CustomLogCallback ceres_logger(*functor);
options.callbacks.emplace_back(&ceres_logger);
ceres::GradientProblem problem(functor);
tools::log->trace("Running LBFGS direct cplx");
ceres::Solve(options, problem, optimized_mps.get_vector_cplx_as_2xreal().data(), &summary);
// Copy the results from the functor
optimized_mps.set_counter(functor->get_count());
optimized_mps.set_delta_f(functor->get_delta_f());
optimized_mps.set_grad_norm(functor->get_grad_max_norm());
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_vH2"] += *functor->t_H2n;
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_vH2v"] += *functor->t_nH2n;
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_vH"] += *functor->t_Hn;
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_vHv"] += *functor->t_nHn;
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_step"] += *functor->t_step;
break;
}
case OptType::REAL: {
auto t_opt_dir_bfgs = tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_bfgs"]->tic_token();
// Here we make a temporary
auto initial_state_real = initial_mps.get_vector_cplx_as_1xreal();
auto * functor = new ceres_direct_functor<double>(tensors, status);
if(settings::precision::use_reduced_energy and settings::precision::use_shifted_mpo and not tensors.model->is_compressed_mpo_squared())
functor->set_shift(initial_mps.get_eigval()); // Account for the shange in energy since the last energy reduction
functor->compress(); // Compress the virtual bond between MPO² and the environments
CustomLogCallback ceres_logger(*functor);
options.callbacks.emplace_back(&ceres_logger);
ceres::GradientProblem problem(functor);
tools::log->trace("Running LBFGS direct real");
if constexpr(settings::debug) if(initial_state_real.hasNaN()) throw std::runtime_error("initial_state_real has nan's");
ceres::Solve(options, problem, initial_state_real.data(), &summary);
// Copy the results from the functor
optimized_mps.set_counter(functor->get_count());
optimized_mps.set_delta_f(functor->get_delta_f());
optimized_mps.set_grad_norm(functor->get_grad_max_norm());
optimized_mps.set_tensor_real(initial_state_real.data(), initial_mps.get_tensor().dimensions());
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_vH2"] += *functor->t_H2n;
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_vH2v"] += *functor->t_nH2n;
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_vH"] += *functor->t_Hn;
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_vHv"] += *functor->t_nHn;
*tools::common::profile::prof[AlgorithmType::xDMRG]["t_opt_dir_step"] += *functor->t_step;
break;
}
}
// Copy and set the rest of the tensor metadata
optimized_mps.normalize();
optimized_mps.set_energy(tools::finite::measure::energy(optimized_mps.get_tensor(), tensors));
optimized_mps.set_variance(tools::finite::measure::energy_variance(optimized_mps.get_tensor(), tensors));
optimized_mps.set_overlap(std::abs(current_map.dot(optimized_mps.get_vector())));
optimized_mps.set_iter(summary.iterations.size());
optimized_mps.set_time(summary.total_time_in_seconds);
reports::time_add_dir_entry();
int hrs = static_cast<int>(summary.total_time_in_seconds / 3600);
int min = static_cast<int>(std::fmod(summary.total_time_in_seconds, 3600) / 60);
double sec = std::fmod(std::fmod(summary.total_time_in_seconds, 3600), 60);
tools::log->debug("Finished LBFGS in {:0<2}:{:0<2}:{:0<.1f} seconds and {} iters. Exit status: {}. Message: {}", hrs, min, sec, summary.iterations.size(),
ceres::TerminationTypeToString(summary.termination_type), summary.message.c_str());
reports::bfgs_add_entry("Direct", "opt", optimized_mps);
tools::log->trace("Returning theta from optimization mode {} space {}", optMode, optSpace);
return optimized_mps;
}
| 65.76259 | 158 | 0.665791 |
7d552bfe40a9a06401a279e7d57c941c60e47bc7 | 271 | cpp | C++ | Shape/Triangle.cpp | AKoudounis/refactored-journey | 81719c57104f14b141f0f7cd2aa805f9007ed79e | [
"MIT"
] | null | null | null | Shape/Triangle.cpp | AKoudounis/refactored-journey | 81719c57104f14b141f0f7cd2aa805f9007ed79e | [
"MIT"
] | null | null | null | Shape/Triangle.cpp | AKoudounis/refactored-journey | 81719c57104f14b141f0f7cd2aa805f9007ed79e | [
"MIT"
] | null | null | null | //Andreas Koudounis 40089191
#include "Triangle.h"
Triangle::Triangle(Point* pt1, Point* pt2, Point* pt3) {
p1 = pt1;
p2 = pt2;
p3 = pt3;
}
Triangle::~Triangle()
{
std::cout << "Triangle object deleted";
}
void Triangle::print() const
{
} | 12.318182 | 57 | 0.594096 |
7d5563f2172b8cb46a14800424ba74e408bcb2fd | 833 | cc | C++ | cudarap/tests/CDeviceTest.cc | seriksen/opticks | 2173ea282bdae0bbd1abf4a3535bede334413ec1 | [
"Apache-2.0"
] | 1 | 2020-05-13T06:55:49.000Z | 2020-05-13T06:55:49.000Z | cudarap/tests/CDeviceTest.cc | seriksen/opticks | 2173ea282bdae0bbd1abf4a3535bede334413ec1 | [
"Apache-2.0"
] | null | null | null | cudarap/tests/CDeviceTest.cc | seriksen/opticks | 2173ea282bdae0bbd1abf4a3535bede334413ec1 | [
"Apache-2.0"
] | null | null | null | #include <vector>
#include "CDevice.hh"
#include "OPTICKS_LOG.hh"
void test_SaveLoad(const char* dirpath)
{
std::vector<CDevice> devs, devs2 ;
bool nosave = true ;
CDevice::Visible(devs, dirpath, nosave );
CDevice::Dump( devs, "visible devices");
CDevice::Save(devs, dirpath );
CDevice::Load(devs2, dirpath );
CDevice::Dump( devs2, "loaded devs2");
}
void test_Visible(const char* dirpath)
{
bool nosave = false ;
std::vector<CDevice> devs ;
CDevice::Visible(devs, dirpath, nosave );
CDevice::Dump( devs , "visible devices");
}
int main(int argc, char** argv)
{
OPTICKS_LOG(argc, argv);
//const char* dirpath = "/tmp" ;
const char* dirpath = "/home/blyth/.opticks/runcache" ;
//test_SaveLoad(dirpath);
test_Visible(dirpath);
return 0 ;
}
| 20.825 | 60 | 0.631453 |
7d556cb8fda76759552fbb07b74ac1e8578d8717 | 1,632 | cpp | C++ | 01.Introduction/01.Introduction/01.Introduction.cpp | zvet80/CppCourse | a8d488dba1ba649dfc6e6d906ed25e506ff30d99 | [
"MIT"
] | null | null | null | 01.Introduction/01.Introduction/01.Introduction.cpp | zvet80/CppCourse | a8d488dba1ba649dfc6e6d906ed25e506ff30d99 | [
"MIT"
] | null | null | null | 01.Introduction/01.Introduction/01.Introduction.cpp | zvet80/CppCourse | a8d488dba1ba649dfc6e6d906ed25e506ff30d99 | [
"MIT"
] | null | null | null | // 01.Introduction.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <array>
using namespace std;
void GetLowerUpper(string a)
{
int lower = 0;
int upper = 0;
int total = a.length();
for (int i = 0; i < total; i++)
{
if (int(a[i]) >= 65 && int(a[i]) <= 90)
{
upper++;
}
else if (int(a[i]) >= 97 && int(a[i]) <= 122)
{
lower++;
}
}
cout << "lower: " << lower << endl << "upper: " << upper << endl << "other:" << total - upper - lower << endl;
;
}
int CountLetter(string text, char letter)
{
int count = 0;
for (int i = 0; i < text.length(); i++)
{
if (text[i] == letter)
{
count++;
}
}
return count;
}
double SquareRoot(double x)
{
return sqrt(x);
}
int main()
{
cout << "Task1: Enter symbols: " << endl;
string letters;
getline(cin, letters);
GetLowerUpper(letters);
////////////////////////
cout << "Task2: Count letters: " << endl;
string text;
char letter;
cout << "Enter text: ";
getline(cin, text);
cout << "Enter a letter to search: ";
cin >> letter;
cout << "Letter: " << letter << " is found " << CountLetter(text, letter) << " times" << endl;
//////////////////////////
cout << "Task2: Get square root: " << endl;
double x;
cout << "Enter a positive number: ";
cin >> x;
cout << "The square root of " << x << " is: " << SquareRoot(x) << endl;
//////////////////////////
cout << "Task2: Sum the numbers in array: " << endl;
int arr[] = { 24, 2, 3, 53, 3, 5, 2, 27, 2, 1 };
int sum = 0;
for (int i = 0; i < 10; i++)
{
sum += arr[i];
}
cout << sum << endl;
return 0;
}
| 19.902439 | 111 | 0.53125 |
7d556cf7f7616a1629e824147d5bebb561c7d7fb | 13,760 | cpp | C++ | ocs2_pinocchio/ocs2_sphere_approximation/src/SphereApproximation.cpp | RIVeR-Lab/ocs2 | 399d3fad27b4a49e48e075a544f2f717944c5da9 | [
"BSD-3-Clause"
] | null | null | null | ocs2_pinocchio/ocs2_sphere_approximation/src/SphereApproximation.cpp | RIVeR-Lab/ocs2 | 399d3fad27b4a49e48e075a544f2f717944c5da9 | [
"BSD-3-Clause"
] | null | null | null | ocs2_pinocchio/ocs2_sphere_approximation/src/SphereApproximation.cpp | RIVeR-Lab/ocs2 | 399d3fad27b4a49e48e075a544f2f717944c5da9 | [
"BSD-3-Clause"
] | null | null | null | /******************************************************************************
Copyright (c) 2021, Farbod Farshidian. 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 copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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 "ocs2_sphere_approximation/SphereApproximation.h"
#include <algorithm>
#include <cmath>
namespace ocs2 {
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
SphereApproximation::SphereApproximation(const hpp::fcl::CollisionGeometry& geometry, size_t geomObjId, scalar_t maxExcess,
scalar_t shrinkRatio)
: geomObjId_(geomObjId), maxExcess_(maxExcess), shrinkRatio_(shrinkRatio) {
if (shrinkRatio <= 0.0 || shrinkRatio >= 1.0) {
throw std::runtime_error("[SphereApproximation] shrinkRation must be larger than 0.0 and smaller than 1.0!");
}
const auto& nodeType = geometry.getNodeType();
switch (nodeType) {
case hpp::fcl::NODE_TYPE::GEOM_BOX: {
const auto* boxPtr = dynamic_cast<const hpp::fcl::Box*>(&geometry);
approximateBox(boxPtr->halfSide * 2);
break;
}
case hpp::fcl::NODE_TYPE::GEOM_CYLINDER: {
const auto* cylinderPtr = dynamic_cast<const hpp::fcl::Cylinder*>(&geometry);
approximateCylinder(cylinderPtr->radius, cylinderPtr->halfLength * 2);
break;
}
case hpp::fcl::NODE_TYPE::GEOM_SPHERE: {
const auto* spherePtr = dynamic_cast<const hpp::fcl::Sphere*>(&geometry);
numSpheres_ = 1;
sphereRadius_ = spherePtr->radius;
sphereCentersToObjectCenter_.resize(1);
sphereCentersToObjectCenter_[0] = vector_t::Zero(3);
break;
}
default:
throw std::runtime_error("[SphereApproximation] Undefined shape primitive for sphere approximation");
}
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
void SphereApproximation::approximateBox(const vector_t& sides) {
// indices of the shortest, medium, and longest side
size_array_t idxSorted = {0, 1, 2};
std::stable_sort(idxSorted.begin(), idxSorted.end(),
[&sides](const size_t& idx1, const size_t& idx2) { return sides[idx1] < sides[idx2]; });
vector_t initSphereRadii(3);
size_t caseIdx;
initSphereRadii << sides.norm() / 2, sides[idxSorted[0]] / 2 + maxExcess_, std::sqrt(3) * maxExcess_ / (std::sqrt(3) - 1);
sphereRadius_ = initSphereRadii.minCoeff(&caseIdx);
// Distance between the first sphere center and the corner along x, y, z
vector_t distances(3);
// Number of spheres along x, y, z
vector_t numSpheres(3);
switch (caseIdx) {
case 0:
distances = sides / 2;
numSpheres = vector_t::Ones(3);
// No re-calculation of the distances is required
break;
case 1: {
scalar_t dist = std::sqrt(std::pow(sphereRadius_, 2) - std::pow(sides[idxSorted[0]] / 2, 2)) / std::sqrt(2);
if (dist >= sides[idxSorted[1]] / 2) {
distances[idxSorted[0]] = sides[idxSorted[0]] / 2;
distances[idxSorted[1]] = sides[idxSorted[1]] / 2;
distances[idxSorted[2]] =
std::sqrt(std::pow(sphereRadius_, 2) - std::pow(distances[idxSorted[0]], 2) - std::pow(distances[idxSorted[1]], 2));
numSpheres[idxSorted[0]] = numSpheres[idxSorted[1]] = 1;
numSpheres[idxSorted[2]] = std::ceil(sides[idxSorted[2]] / (2 * distances[idxSorted[2]]));
// Re-calculate the distances
distances[idxSorted[2]] = std::max(sides[idxSorted[2]] / (2 * numSpheres[idxSorted[2]]), sphereRadius_ - maxExcess_);
} else {
distances[idxSorted[0]] = sides[idxSorted[0]] / 2;
distances[idxSorted[1]] = distances[idxSorted[2]] = dist;
numSpheres[idxSorted[0]] = 1;
numSpheres[idxSorted[1]] = std::ceil(sides[idxSorted[1]] / (2 * distances[idxSorted[1]]));
numSpheres[idxSorted[2]] = std::ceil(sides[idxSorted[2]] / (2 * distances[idxSorted[2]]));
// Re-calculate the distances
distances[idxSorted[1]] = distances[idxSorted[2]] =
std::max(sides[idxSorted[1]] / (2 * numSpheres[idxSorted[1]]), sides[idxSorted[2]] / (2 * numSpheres[idxSorted[2]]));
}
break;
}
case 2:
distances = (sphereRadius_ - maxExcess_) * vector_t::Ones(3);
numSpheres[idxSorted[0]] = std::ceil(sides[idxSorted[0]] / (2 * distances[idxSorted[0]]));
numSpheres[idxSorted[1]] = std::ceil(sides[idxSorted[1]] / (2 * distances[idxSorted[1]]));
numSpheres[idxSorted[2]] = std::ceil(sides[idxSorted[2]] / (2 * distances[idxSorted[2]]));
// Re-calculate the distances
distances = std::max({sides[idxSorted[0]] / (2 * numSpheres[idxSorted[0]]), sides[idxSorted[1]] / (2 * numSpheres[idxSorted[1]]),
sides[idxSorted[2]] / (2 * numSpheres[idxSorted[2]])}) *
vector_t::Ones(3);
break;
}
// re-calculate the sphere radius
sphereRadius_ = distances.norm();
numSpheres_ = numSpheres[0] * numSpheres[1] * numSpheres[2];
sphereCentersToObjectCenter_.resize(numSpheres_);
// Sphere spacings along x, y, z
vector_t spacings(3);
for (size_t i = 0; i < numSpheres.size(); i++) {
if (numSpheres[i] > 1) {
spacings[i] = (sides[i] - 2 * distances[i]) / (numSpheres[i] - 1);
}
}
size_t count = 0;
for (size_t i = 0; i < numSpheres[0]; i++) {
for (size_t j = 0; j < numSpheres[1]; j++) {
for (size_t k = 0; k < numSpheres[2]; k++) {
sphereCentersToObjectCenter_[count] << distances[0] + i * spacings[0] - sides[0] / 2, distances[1] + j * spacings[1] - sides[1] / 2,
distances[2] + k * spacings[2] - sides[2] / 2;
count++;
}
}
}
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
void SphereApproximation::approximateCylinder(const scalar_t radius, const scalar_t length) {
// First, approximate the rectangle cross-section of the cylinder
vector_t sides(2);
sides << 2 * radius, length;
size_array_t idxSorted = {0, 1};
if (sides(0) > sides(1)) {
std::swap(idxSorted[0], idxSorted[1]);
}
scalar_t maxExcessL = maxExcess_ * shrinkRatio_;
vector_t distances(2);
vector_t numSpheres(2);
approximateRectanglularCrossSection(sides, idxSorted, maxExcess_, sphereRadius_, numSpheres, distances);
bool recursiveApproximation = false; // If recursive approximation of the cylinder base is necessary.
if (numSpheres[0] > 1) {
// More than one sphere is required along radial direction with maxExcess. Re-approximate the rectangular cross-section using the
// reduced threshold in favor of the later approximation of the circular base.
approximateRectanglularCrossSection(sides, idxSorted, maxExcessL, sphereRadius_, numSpheres, distances);
recursiveApproximation = true;
}
scalar_t spacingLength;
if (numSpheres[1] > 1) {
spacingLength = (sides[1] - 2 * distances[1]) / (numSpheres[1] - 1);
}
// Second, approximate the circle base of the cylinder
vector_array_t circleCentersToBaseCenter;
if (!recursiveApproximation) {
circleCentersToBaseCenter.push_back(vector_t::Zero(2));
} else {
scalar_t radiusBase = radius;
scalar_t radiusCircle = std::sqrt(std::pow(sphereRadius_, 2) - std::pow(distances[1], 2));
scalar_t maxExcessR = maxExcess_ - maxExcessL;
while (recursiveApproximation) {
scalar_t shift, alpha, numCircles;
recursiveApproximation = approximateCircleBase(radiusBase, radiusCircle, maxExcessR, shift, alpha, numCircles);
for (size_t i = 0; i < numCircles; i++) {
vector_t circleCenter(2);
circleCenter << shift * std::sin(i * alpha), shift * std::cos(i * alpha);
circleCentersToBaseCenter.push_back(circleCenter);
}
// Enclose the uncovered area by another circle with radiusBase
radiusBase = shift / std::cos(alpha / 2) - radiusCircle;
}
}
numSpheres[0] = circleCentersToBaseCenter.size();
numSpheres_ = numSpheres[0] * numSpheres[1];
sphereCentersToObjectCenter_.resize(numSpheres_);
size_t count = 0;
for (size_t i = 0; i < numSpheres[1]; i++) {
for (size_t j = 0; j < numSpheres[0]; j++) {
sphereCentersToObjectCenter_[count] << circleCentersToBaseCenter[j], distances[1] + i * spacingLength - sides[1] / 2;
count++;
}
}
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
void SphereApproximation::approximateRectanglularCrossSection(const vector_t& sides, const size_array_t& idxSorted,
const scalar_t maxExcess, scalar_t& sphereRadius, vector_t& numSpheres,
vector_t& distances) {
vector_t initSphereRadii(3);
size_t caseIdx;
initSphereRadii << sides.norm() / 2, sides[idxSorted[0]] / 2 + maxExcess, std::sqrt(2) * maxExcess / (std::sqrt(2) - 1);
sphereRadius = initSphereRadii.minCoeff(&caseIdx);
switch (caseIdx) {
case 0:
distances = sides / 2;
numSpheres = vector_t::Ones(2);
break;
case 1:
distances[idxSorted[0]] = sides[idxSorted[0]] / 2;
distances[idxSorted[1]] = std::sqrt(std::pow(sphereRadius, 2) - std::pow(distances[idxSorted[0]], 2));
numSpheres[idxSorted[0]] = 1;
numSpheres[idxSorted[1]] = std::ceil(sides[idxSorted[1]] / (2 * distances[idxSorted[1]]));
// Re-calculate the distances
distances[idxSorted[1]] = sides[idxSorted[1]] / (2 * numSpheres[idxSorted[1]]);
break;
case 2:
distances = (sphereRadius - maxExcess) * vector_t::Ones(2);
numSpheres[idxSorted[0]] = std::ceil(sides[idxSorted[0]] / (2 * distances[idxSorted[0]]));
numSpheres[idxSorted[1]] = std::ceil(sides[idxSorted[1]] / (2 * distances[idxSorted[1]]));
// Re-calculate the distances
distances = std::max(sides[idxSorted[0]] / (2 * numSpheres[idxSorted[0]]), sides[idxSorted[1]] / (2 * numSpheres[idxSorted[1]])) *
vector_t::Ones(2);
break;
}
sphereRadius = distances.norm();
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
bool SphereApproximation::approximateCircleBase(const scalar_t radiusBase, const scalar_t radiusSphereCrossSection,
const scalar_t maxExcessR, scalar_t& shift, scalar_t& alpha, scalar_t& numCircles) {
if (radiusSphereCrossSection < radiusBase - std::numeric_limits<scalar_t>::epsilon()) {
shift = radiusBase + std::min(0.0, maxExcessR - radiusSphereCrossSection);
alpha =
2 * std::acos((std::pow(radiusBase, 2) + std::pow(shift, 2) - std::pow(radiusSphereCrossSection, 2)) / (2 * radiusBase * shift));
numCircles = std::ceil(2 * M_PI / alpha);
// Re-calculate alpha & shift
alpha = 2 * M_PI / numCircles;
vector_t intersection(2);
intersection << radiusBase * std::sin(alpha / 2), radiusBase * std::cos(alpha / 2);
shift = intersection[1] - std::sqrt(std::pow(radiusSphereCrossSection, 2) - std::pow(intersection[0], 2));
return true;
} else {
shift = 0;
alpha = 0;
numCircles = 1;
return false;
}
}
} // namespace ocs2
| 45.263158 | 140 | 0.579433 |
7d57e5f2f52270ca7a9a1e338350d563caeaa06d | 8,942 | cpp | C++ | Source/MapperDefinitions.cpp | hamzahamidi/Xidi | d7585ecf23fd17dd5be4e69f63bae08aa0e96988 | [
"BSD-3-Clause"
] | 1 | 2021-06-05T00:22:08.000Z | 2021-06-05T00:22:08.000Z | Source/MapperDefinitions.cpp | hamzahamidi/Xidi | d7585ecf23fd17dd5be4e69f63bae08aa0e96988 | [
"BSD-3-Clause"
] | null | null | null | Source/MapperDefinitions.cpp | hamzahamidi/Xidi | d7585ecf23fd17dd5be4e69f63bae08aa0e96988 | [
"BSD-3-Clause"
] | null | null | null | /*****************************************************************************
* Xidi
* DirectInput interface for XInput controllers.
*****************************************************************************
* Authored by Samuel Grossman
* Copyright (c) 2016-2021
*************************************************************************//**
* @file MapperDefinitions.cpp
* Definitions of all known mapper types.
*****************************************************************************/
#include "ControllerTypes.h"
#include "ElementMapper.h"
#include "Mapper.h"
namespace Xidi
{
namespace Controller
{
// -------- MAPPER DEFINITIONS ------------------------------------- //
/// Defines all known mapper types, one element per type. The first element is the default mapper.
/// Any field that corresponds to an XInput controller element can be omitted or assigned `nullptr` and the mapper will simply ignore input from that XInput controller element.
static const Mapper kMappers[] = {
Mapper(L"StandardGamepad", {
.stickLeftX = std::make_unique<AxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<AxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<AxisMapper>(EAxis::Z),
.stickRightY = std::make_unique<AxisMapper>(EAxis::RotZ),
.dpadUp = std::make_unique<PovMapper>(EPovDirection::Up),
.dpadDown = std::make_unique<PovMapper>(EPovDirection::Down),
.dpadLeft = std::make_unique<PovMapper>(EPovDirection::Left),
.dpadRight = std::make_unique<PovMapper>(EPovDirection::Right),
.triggerLT = std::make_unique<ButtonMapper>(EButton::B7),
.triggerRT = std::make_unique<ButtonMapper>(EButton::B8),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B9),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B10),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B11),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B12)
}),
Mapper(L"DigitalGamepad", {
.stickLeftX = std::make_unique<DigitalAxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<DigitalAxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<DigitalAxisMapper>(EAxis::Z),
.stickRightY = std::make_unique<DigitalAxisMapper>(EAxis::RotZ),
.dpadUp = std::make_unique<DigitalAxisMapper>(EAxis::Y, AxisMapper::EDirection::Negative),
.dpadDown = std::make_unique<DigitalAxisMapper>(EAxis::Y, AxisMapper::EDirection::Positive),
.dpadLeft = std::make_unique<DigitalAxisMapper>(EAxis::X, AxisMapper::EDirection::Negative),
.dpadRight = std::make_unique<DigitalAxisMapper>(EAxis::X, AxisMapper::EDirection::Positive),
.triggerLT = std::make_unique<ButtonMapper>(EButton::B7),
.triggerRT = std::make_unique<ButtonMapper>(EButton::B8),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B9),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B10),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B11),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B12)
}),
Mapper(L"ExtendedGamepad", {
.stickLeftX = std::make_unique<AxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<AxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<AxisMapper>(EAxis::Z),
.stickRightY = std::make_unique<AxisMapper>(EAxis::RotZ),
.dpadUp = std::make_unique<PovMapper>(EPovDirection::Up),
.dpadDown = std::make_unique<PovMapper>(EPovDirection::Down),
.dpadLeft = std::make_unique<PovMapper>(EPovDirection::Left),
.dpadRight = std::make_unique<PovMapper>(EPovDirection::Right),
.triggerLT = std::make_unique<AxisMapper>(EAxis::RotX),
.triggerRT = std::make_unique<AxisMapper>(EAxis::RotY),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B7),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B8),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B9),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B10)
}),
Mapper(L"XInputNative", {
.stickLeftX = std::make_unique<AxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<AxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<AxisMapper>(EAxis::RotX),
.stickRightY = std::make_unique<AxisMapper>(EAxis::RotY),
.dpadUp = std::make_unique<PovMapper>(EPovDirection::Up),
.dpadDown = std::make_unique<PovMapper>(EPovDirection::Down),
.dpadLeft = std::make_unique<PovMapper>(EPovDirection::Left),
.dpadRight = std::make_unique<PovMapper>(EPovDirection::Right),
.triggerLT = std::make_unique<AxisMapper>(EAxis::Z),
.triggerRT = std::make_unique<AxisMapper>(EAxis::RotZ),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B7),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B8),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B9),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B10)
}),
Mapper(L"XInputSharedTriggers", {
.stickLeftX = std::make_unique<AxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<AxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<AxisMapper>(EAxis::RotX),
.stickRightY = std::make_unique<AxisMapper>(EAxis::RotY),
.dpadUp = std::make_unique<PovMapper>(EPovDirection::Up),
.dpadDown = std::make_unique<PovMapper>(EPovDirection::Down),
.dpadLeft = std::make_unique<PovMapper>(EPovDirection::Left),
.dpadRight = std::make_unique<PovMapper>(EPovDirection::Right),
.triggerLT = std::make_unique<AxisMapper>(EAxis::Z, AxisMapper::EDirection::Positive),
.triggerRT = std::make_unique<AxisMapper>(EAxis::Z, AxisMapper::EDirection::Negative),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B7),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B8),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B9),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B10)
})
};
}
}
| 61.668966 | 184 | 0.576269 |
7d57ea775a493ae0c3d98bd36ba96118ff0b9eb7 | 1,434 | cpp | C++ | code/engine.vc2008/xrGame/autosave_manager.cpp | Rikoshet-234/xray-oxygen | eaac3fa4780639152684f3251b8b4452abb8e439 | [
"Apache-2.0"
] | 7 | 2018-03-27T12:36:07.000Z | 2020-06-26T11:31:52.000Z | code/engine.vc2008/xrGame/autosave_manager.cpp | Rikoshet-234/xray-oxygen | eaac3fa4780639152684f3251b8b4452abb8e439 | [
"Apache-2.0"
] | 2 | 2018-05-26T23:17:14.000Z | 2019-04-14T18:33:27.000Z | code/engine.vc2008/xrGame/autosave_manager.cpp | Rikoshet-234/xray-oxygen | eaac3fa4780639152684f3251b8b4452abb8e439 | [
"Apache-2.0"
] | 5 | 2020-10-18T11:55:26.000Z | 2022-03-28T07:21:35.000Z | ////////////////////////////////////////////////////////////////////////////
// Module : autosave_manager.cpp
// Created : 04.11.2004
// Modified : 04.11.2004
// Author : Dmitriy Iassenev
// Description : Autosave manager
////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "autosave_manager.h"
#include "../xrEngine/date_time.h"
#include "ai_space.h"
#include "level.h"
#include "xrMessages.h"
#include "UIGame.h"
#include "Actor.h"
extern LPCSTR alife_section;
CAutosaveManager::CAutosaveManager()
{
u32 hours, minutes, seconds;
LPCSTR section = alife_section;
sscanf(pSettings->r_string(section, "autosave_interval"), "%d:%d:%d", &hours, &minutes, &seconds);
m_autosave_interval = (u32)generate_time(1, 1, 1, hours, minutes, seconds);
m_last_autosave_time = Device.dwTimeGlobal;
sscanf(pSettings->r_string(section, "delay_autosave_interval"), "%d:%d:%d", &hours, &minutes, &seconds);
m_delay_autosave_interval = (u32)generate_time(1, 1, 1, hours, minutes, seconds);
m_not_ready_count = 0;
shedule.t_min = 5000;
shedule.t_max = 5000;
shedule_register();
}
CAutosaveManager::~CAutosaveManager()
{
shedule_unregister();
}
float CAutosaveManager::shedule_Scale()
{
return (.5f);
}
void CAutosaveManager::shedule_Update(u32 dt)
{
inherited::shedule_Update(dt);
}
void CAutosaveManager::on_game_loaded()
{
m_last_autosave_time = Device.dwTimeGlobal;
} | 25.157895 | 105 | 0.656206 |
7d5a2e1d415c9db70ec9fbe0cbcce50dcf3b9933 | 12,540 | cpp | C++ | test/validators/validators_factory_test.cpp | itzaayush/jwt-cpp | d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763 | [
"MIT"
] | 102 | 2016-09-02T03:57:05.000Z | 2022-03-22T12:23:59.000Z | test/validators/validators_factory_test.cpp | itzaayush/jwt-cpp | d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763 | [
"MIT"
] | 41 | 2017-01-26T14:57:40.000Z | 2020-10-16T11:28:49.000Z | test/validators/validators_factory_test.cpp | itzaayush/jwt-cpp | d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763 | [
"MIT"
] | 55 | 2017-02-11T22:27:14.000Z | 2022-03-31T08:29:22.000Z | #include <fstream>
#include <memory>
#include <string>
#include "./constants.h"
#include "gtest/gtest.h"
#include "jwt/hmacvalidator.h"
#include "jwt/jwt.h"
#include "jwt/messagevalidatorfactory.h"
#include "jwt/nonevalidator.h"
#include "jwt/rsavalidator.h"
// Test for the various validators.
TEST(parse_test, proper_hmac) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << hmacs[i] << "\" : { \"secret\" : \"safe!\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.str().c_str(), valid->toJson().c_str());
EXPECT_STREQ(hmacs[i], valid->algorithm().c_str());
}
}
TEST(parse_signer_test, proper_hmac) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << hmacs[i] << "\" : { \"secret\" : \"safe!\" } }";
validator_ptr valid(MessageValidatorFactory::BuildSigner(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.str().c_str(), valid->toJson().c_str());
EXPECT_STREQ(hmacs[i], valid->algorithm().c_str());
}
}
TEST(parse_test, can_use_validator) {
std::string json = "{ \"HS256\" : { \"secret\" : \"secret\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json));
std::string strtoken =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
"eyJzdWIiOiJzdWJqZWN0IiwiZXhwIjoxNDM3NDMzMzk3fQ."
"VGPkHXap_i2zwUCxr7dsjBq7Nnx83h5dNGjzuifjpx8";
::json header, payload;
std::tie(header, payload) = JWT::Decode(strtoken, valid.get());
EXPECT_FALSE(header.empty());
EXPECT_FALSE(payload.empty());
}
// Test for the various validators.
TEST(parse_test, proper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
TEST(parse_signer_test, rsa_missing_file) {
std::string json =
"{ \"RS256\" : { \"public\" : { \"fromfile\" : null } } }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), nlohmann::json::type_error);
}
// Test for the various validators.
TEST(parse_signer_test, proper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\", \"private\" : \""
"-----BEGIN RSA PRIVATE KEY-----\\n"
"MIIEowIBAAKCAQEA4SWe3cgEULKiz2wP+"
"fYqN2TxEx6DiL4rvyqZfl0CFpVMH7wC\\n"
"ZqvglxOMtUzpdO7USdlFmyOEjtH1tioll9EAg6DMs0QrLgBj7U0XHRHeJcRrbYx"
"m\\n"
"HqtmtRxjEmLBpClJoYaJ2fEdeaVcV5D1+kWMIRLM1q3RNafb1Q62nwSyojgX09/"
"X\\n"
"+lWtkuX4NPwnn5NW13uhLyO96bANWMzPhYewwCsY7s7HCscNEhVTLQF0UmtYMgp"
"n\\n"
"kzrR9aibtmCZhf58ebn0VjtoYu3JzhzmvUK+"
"E3OZb0xp3e2f464owRIvWTlTte9h\\n"
"kDnkNKYoqY7fF/"
"adwb8xDNZEAeYAwE0jC2tE3QIDAQABAoIBAQCsLgATba5XJHW8\\n"
"GNETAL2CRXDThUdkIMMF3AcsiuZY7O4dasOPTyxffPTjhaEX6rlwjHdd0EjEjC7"
"T\\n"
"k+HR+2TgRO2mvqAi+utwg78EXTC9QzxAt9k05TGTmdTuL5YU+/"
"oyS9hKUsmOyPYY\\n"
"hWSHc/5ZIK6EEsNmvCszAaCJdadCxCF9r/jTkT2iWVtV1Zrh7+Z/"
"azX+wWSBIcEW\\n"
"Lbk6MGCt2z7mWGla4x7ToxhYWBhRdDxZ0R3VzG05e1Yjn1q2U5uxsSdBAPAISge"
"D\\n"
"7LpnwMs9NcjGnVO2cUHfK1fL7tLpMlqTsyflEyvFuN2+WatY7eaFeI/"
"jRBb3ezYF\\n"
"IcNZD8eBAoGBAPnhgL1ZhpDZRJ+M/CjV0KQmbzoMyt5B38cDJ0VNZG/"
"CObCMKwvI\\n"
"kMisBwFZEyS1oiV2Lt//8tLDnrlvxQrKQLmEzI5kCbuh3EUiG/tMF4VmKB4+JR/"
"2\\n"
"TNsHCqeNuKmVjy+"
"SYNkHDfO5MbdNBSSXaV4GuA1L3evzwTNOij39C8ThAoGBAOap\\n"
"D7XOigmuGMeOiFcivtGmCuOKfS8ZqTV2tKBcu3kv8F9CeqAFp/Qznxn/"
"M8oi91VN\\n"
"rdDwkH9aClXXSjaj2FpWHCU+hQJUbzucClOf0VgExYsdwNwEDaVrwRbo+"
"fCzt3Fy\\n"
"IdChwV7AO9sSggcGWbavbCU7F/h1g/BLHx/"
"njYN9AoGAdQIDJqclO+6BE7UQ3o5A\\n"
"hJz6uFQFKs3t22K+oNT8kth/6wu3nGzuXwkuvpLXQ/"
"lJVAFjMcDIE6lGSc7slYDf\\n"
"jf+BSavOYu4IFtdCAwo+eVi8sGypNa4/"
"jtBdTNgwADjoM353myiSf+3YOdz264t6\\n"
"62x6Ar/"
"jyvj5Hu1IDn7PZAECgYAdoYw+G8lJ0w6l3B6Rqwn+Xqk5b9oDCfXdw2ES\\n"
"1LbUq57ibeTY18EqstL2gP1DM1i4oaD5nV3CrmtzeZO0DzpE6Jj3A+"
"AMW5JqgvIk\\n"
"qfw3pW1HIMxctzyVipEkg0tQa5XeQf4sEguIQ4Os8eS4SE2QFVr8MWoz5czMOqp"
"F\\n"
"6/YW9QKBgERgOD3W9BcecygPNZfGZSZRVF0j5LT0PDgKr/"
"02CIPu2mo+2ej9GmBP\\n"
"PnLXbe/R9SG8p2+Yh2ZfXn7FlXfr9a7MkzQWR/rpmxlDyzAyaJaI/"
"vCBP+KknzPo\\n"
"zBJNQZl5S6qKrqr0ypYs6ekAQ5MEe3twWWyXG2y1QgeMIs3BTnJ1\\n"
"-----END RSA PRIVATE KEY-----"
"\" } }";
validator_ptr valid(MessageValidatorFactory::BuildSigner(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
// Test for the various validators.
TEST(parse_test, improper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJK3ZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json.str()),
std::logic_error);
}
}
// Test for the various validators.
TEST(parse_test, proper_rsa_from_file) {
std::ofstream out("/tmp/test.key");
out << "-----BEGIN PUBLIC KEY-----\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskObb\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\n"
"-----END PUBLIC KEY-----";
out.close();
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << rs[i]
<< "\" : { \"public\" : { \"fromfile\" : \"/tmp/test.key\" } } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
// Test for the various validators.
TEST(parse_test, parse_set) {
std::string json =
"{ \"set\" : [ "
"{ \"HS256\" : { \"secret\" : \"safe\" } }, "
"{ \"HS512\" : { \"secret\" : \"supersafe\" } }"
" ] }";
validator_ptr valid(MessageValidatorFactory::Build(json));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.c_str(), valid->toJson().c_str());
EXPECT_TRUE(valid->Accepts({{"alg", "HS256"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS384"}}));
EXPECT_TRUE(valid->Accepts({{"alg", "HS512"}}));
}
TEST(parse_test, parse_kid) {
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"HS256\" : { \"secret\" : \"key1\" } }, "
"\"key2\" : { \"HS256\" : { \"secret\" : \"key2\" } }, "
"\"key3\" : { \"HS256\" : { \"secret\" : \"key3\" } } "
"} }";
validator_ptr valid(MessageValidatorFactory::Build(json));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.c_str(), valid->toJson().c_str());
EXPECT_TRUE(valid->Accepts({{"alg", "HS256"}, {"kid", "key1"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS256"}, {"kid", "key5"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS256"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS512"}, {"kid", "key1"}}));
}
TEST(parse_test, accepts_multiple_types) {
// do not have to be of the same type..
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"HS256\" : { \"secret\" : \"key1\" } }, "
"\"key3\" : { \"HS512\" : { \"secret\" : \"key3\" } } "
"} }";
ASSERT_NO_THROW(std::unique_ptr<MessageValidator>(MessageValidatorFactory::Build(json)));
}
TEST(parse_test, rsa_not_in_pem_format) {
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"RS256\" : { \"public\" : \"key1\" } }, "
"\"key2\" : { \"RS256\" : { \"public\" : \"key2\" } }, "
"\"key3\" : { \"RS256\" : { \"public\" : \"key3\" } } "
"} }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, non_existing) {
std::string json = "{ \"HS253\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, too_many_properties) {
std::string json =
"{ \"HS256\" : { \"secret\" : \"safe!\" }, \"FOO\" : \"BAR\" }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_signer, too_many_properties) {
std::string json =
"{ \"HS256\" : { \"secret\" : \"safe!\" }, \"FOO\" : \"BAR\" }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), std::logic_error);
}
TEST(parse_signer, non_existing_signer) {
std::string json = "{ \"HS252\" : { \"secret\" : \"safe!\" }}";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), std::logic_error);
}
TEST(parse_test, non_secret) {
std::string json = "{ \"HS256\" : { \"without_secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, bad_json) {
std::string json = "{ { \"HS256\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), nlohmann::json::parse_error);
}
TEST(parse_signer_test, bad_json) {
std::string json = "{ { \"HS256\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), nlohmann::json::parse_error);
}
void roundtrip(MessageValidator *validator) {
std::string json = validator->toJson();
validator_ptr msg(MessageValidatorFactory::Build(json));
EXPECT_STREQ(json.c_str(), msg->toJson().c_str());
}
void roundtrip_signer(MessageSigner *signer) {
std::string json = signer->toJson();
validator_ptr msg(MessageValidatorFactory::BuildSigner(json));
EXPECT_STREQ(json.c_str(), msg->toJson().c_str());
}
TEST(parse, round_trip_none) {
NoneValidator msg;
roundtrip(&msg);
}
TEST(parse_signer, round_trip_none) {
NoneValidator msg;
roundtrip_signer(&msg);
}
TEST(parse, round_trip_hs256) {
HS256Validator msg("secret");
roundtrip(&msg);
}
TEST(parse, round_trip_hs384) {
HS384Validator msg("secret");
roundtrip(&msg);
}
TEST(parse, round_trip_hs512) {
HS512Validator msg("secret");
roundtrip(&msg);
}
TEST(parse_signer, round_trip_hs256) {
HS256Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_hs384) {
HS384Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_hs512) {
HS512Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse, round_trip_rs256) {
RS256Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse, round_trip_rs384) {
RS384Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse, round_trip_rs512) {
RS512Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse_signer, round_trip_rs256) {
RS256Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_rs384) {
RS384Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_rs512) {
RS512Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
| 35.625 | 93 | 0.589394 |
7d5d6898d50e1481b8849485887fa8d1a9f5aa9c | 6,065 | cpp | C++ | tengine/tools/toyviewer.cpp | BSVino/Digitanks | 1bd1ed115493bce22001ae6684b70b8fcf135db0 | [
"BSD-4-Clause"
] | 5 | 2015-07-03T18:42:32.000Z | 2017-08-25T10:28:12.000Z | tengine/tools/toyviewer.cpp | BSVino/Digitanks | 1bd1ed115493bce22001ae6684b70b8fcf135db0 | [
"BSD-4-Clause"
] | null | null | null | tengine/tools/toyviewer.cpp | BSVino/Digitanks | 1bd1ed115493bce22001ae6684b70b8fcf135db0 | [
"BSD-4-Clause"
] | null | null | null | #include "toyviewer.h"
#include <tinker_platform.h>
#include <files.h>
#include <glgui/rootpanel.h>
#include <glgui/menu.h>
#include <glgui/filedialog.h>
#include <glgui/checkbox.h>
#include <models/models.h>
#include <tinker/application.h>
#include <renderer/game_renderingcontext.h>
#include <renderer/game_renderer.h>
#include <game/gameserver.h>
#include <tinker/keys.h>
#include <ui/gamewindow.h>
#include <toys/toy.h>
#include "workbench.h"
REGISTER_WORKBENCH_TOOL(ToyViewer);
CToyPreviewPanel::CToyPreviewPanel()
{
SetBackgroundColor(Color(0, 0, 0, 150));
SetBorder(glgui::CPanel::BT_SOME);
m_pInfo = new glgui::CLabel("", "sans-serif", 16);
AddControl(m_pInfo);
m_pShowPhysicsLabel = new glgui::CLabel("Show physics:", "sans-serif", 10);
m_pShowPhysicsLabel->SetAlign(glgui::CLabel::TA_TOPLEFT);
AddControl(m_pShowPhysicsLabel);
m_pShowPhysics = new glgui::CCheckBox();
AddControl(m_pShowPhysics);
}
void CToyPreviewPanel::Layout()
{
float flWidth = glgui::CRootPanel::Get()->GetWidth();
float flHeight = glgui::CRootPanel::Get()->GetHeight();
float flMenuBarBottom = glgui::CRootPanel::Get()->GetMenuBar()->GetBottom();
float flCurrLeft = 20;
float flCurrTop = flMenuBarBottom + 10;
SetDimensions(flCurrLeft, flCurrTop, 200, flHeight-30-flMenuBarBottom);
tstring sFilename = ToyViewer()->GetToyPreview();
tstring sAbsoluteGamePath = FindAbsolutePath(".");
tstring sAbsoluteFilename = FindAbsolutePath(sFilename);
if (sAbsoluteFilename.find(sAbsoluteGamePath) == 0)
sFilename = ToForwardSlashes(sAbsoluteFilename.substr(sAbsoluteGamePath.length()));
m_pInfo->SetText(sFilename);
m_pInfo->SetPos(0, 15);
m_pInfo->SetSize(GetWidth(), 25);
m_pShowPhysicsLabel->Layout_AlignTop(m_pInfo);
m_pShowPhysicsLabel->SetWidth(10);
m_pShowPhysicsLabel->SetHeight(1);
m_pShowPhysicsLabel->EnsureTextFits();
m_pShowPhysicsLabel->Layout_FullWidth();
m_pShowPhysics->SetTop(m_pShowPhysicsLabel->GetTop()+12);
m_pShowPhysics->SetLeft(m_pShowPhysicsLabel->GetLeft());
BaseClass::Layout();
}
CToyViewer* CToyViewer::s_pToyViewer = nullptr;
CToyViewer::CToyViewer()
{
s_pToyViewer = this;
m_pToyPreviewPanel = new CToyPreviewPanel();
m_pToyPreviewPanel->SetVisible(false);
glgui::CRootPanel::Get()->AddControl(m_pToyPreviewPanel);
m_iToyPreview = ~0;
m_bRotatingPreview = false;
m_angPreview = EAngle(-20, 20, 0);
m_flPreviewDistance = 10;
}
CToyViewer::~CToyViewer()
{
}
void CToyViewer::Activate()
{
Layout();
if (!m_sToyPreview.length() || m_iToyPreview == ~0)
ChooseToyCallback("");
BaseClass::Activate();
}
void CToyViewer::Deactivate()
{
BaseClass::Deactivate();
m_pToyPreviewPanel->SetVisible(false);
}
void CToyViewer::Layout()
{
m_pToyPreviewPanel->SetVisible(false);
if (m_iToyPreview != ~0)
m_pToyPreviewPanel->SetVisible(true);
SetupMenu();
}
void CToyViewer::SetupMenu()
{
GetFileMenu()->ClearSubmenus();
GetFileMenu()->AddSubmenu("Open", this, ChooseToy);
}
void CToyViewer::RenderScene()
{
CModel* pModel = CModelLibrary::GetModel(m_iToyPreview);
if (m_iToyPreview != ~0)
{
TAssert(pModel);
if (!pModel)
m_iToyPreview = ~0;
}
GameServer()->GetRenderer()->SetRenderingTransparent(false);
if (m_iToyPreview != ~0 && pModel)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
if (!c.GetActiveFrameBuffer())
c.UseFrameBuffer(GameServer()->GetRenderer()->GetSceneBuffer());
c.SetColor(Color(255, 255, 255));
c.RenderModel(m_iToyPreview);
if (m_pToyPreviewPanel->m_pShowPhysics->GetState() && pModel->m_pToy)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.ClearDepth();
c.UseProgram("model");
c.SetUniform("bDiffuse", false);
c.SetColor(Color(0, 100, 155, (int)(255*0.3f)));
c.SetBlend(BLEND_ALPHA);
c.SetUniform("vecColor", Color(0, 100, 155, (char)(255*0.3f)));
for (size_t i = 0; i < pModel->m_pToy->GetPhysicsNumBoxes(); i++)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.Transform(pModel->m_pToy->GetPhysicsBox(i).GetMatrix4x4());
c.RenderWireBox(CToy::s_aabbBoxDimensions);
}
if (pModel->m_pToy->GetPhysicsNumTris())
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.BeginRenderVertexArray();
c.SetPositionBuffer(pModel->m_pToy->GetPhysicsVerts());
c.EndRenderVertexArrayTriangles(pModel->m_pToy->GetPhysicsNumTris(), pModel->m_pToy->GetPhysicsTris());
}
// Reset for other stuff.
c.SetUniform("bDiffuse", true);
c.SetUniform("vecColor", Color(255, 255, 255, 255));
}
}
}
void CToyViewer::ChooseToyCallback(const tstring& sArgs)
{
glgui::CFileDialog::ShowOpenDialog(".", ".toy", this, OpenToy);
}
void CToyViewer::OpenToyCallback(const tstring& sArgs)
{
tstring sGamePath = GetRelativePath(sArgs, ".");
CModelLibrary::ReleaseModel(m_iToyPreview);
m_iToyPreview = CModelLibrary::AddModel(sGamePath);
if (m_iToyPreview != ~0)
{
m_sToyPreview = sGamePath;
m_flPreviewDistance = CModelLibrary::GetModel(m_iToyPreview)->m_aabbVisBoundingBox.Size().Length()*2;
}
Layout();
}
bool CToyViewer::MouseInput(int iButton, tinker_mouse_state_t iState)
{
if (iButton == TINKER_KEY_MOUSE_LEFT)
{
m_bRotatingPreview = (iState == TINKER_MOUSE_PRESSED);
return true;
}
return false;
}
void CToyViewer::MouseMotion(int x, int y)
{
if (m_bRotatingPreview)
{
int lx, ly;
if (GameWindow()->GetLastMouse(lx, ly))
{
m_angPreview.y -= (float)(x-lx);
m_angPreview.p -= (float)(y-ly);
}
}
}
void CToyViewer::MouseWheel(int x, int y)
{
if (y > 0)
{
for (int i = 0; i < y; i++)
m_flPreviewDistance *= 0.9f;
}
else if (y < 0)
{
for (int i = 0; i < -y; i++)
m_flPreviewDistance *= 1.1f;
}
}
TVector CToyViewer::GetCameraPosition()
{
if (m_iToyPreview == ~0)
return TVector(0, 0, 0);
CModel* pMesh = CModelLibrary::GetModel(m_iToyPreview);
if (!pMesh)
return TVector(0, 0, 0);
return pMesh->m_aabbVisBoundingBox.Center() - AngleVector(m_angPreview)*m_flPreviewDistance;
}
Vector CToyViewer::GetCameraDirection()
{
return AngleVector(m_angPreview);
}
| 23.060837 | 107 | 0.716076 |
7d5f50a48f7e26b4301ed55a2c8703c9ffafe22b | 2,428 | cpp | C++ | SiteData.cpp | RCjig/pw_manager | ed4da0ebccb6ab20813598ecf5731f0411f274e6 | [
"Apache-2.0"
] | null | null | null | SiteData.cpp | RCjig/pw_manager | ed4da0ebccb6ab20813598ecf5731f0411f274e6 | [
"Apache-2.0"
] | null | null | null | SiteData.cpp | RCjig/pw_manager | ed4da0ebccb6ab20813598ecf5731f0411f274e6 | [
"Apache-2.0"
] | null | null | null | #include "SiteData.h"
#include <ios>
#include <iostream>
using namespace std;
static int callback(void * used, int argc, char ** argv, char ** szColName) {
// set pointer structs values
select_wrapper * encSelect = (select_wrapper *) used;
encSelect->password = string(argv[0]);
// get rid of warning
if (0 > 1)
cout << encSelect;
return 0;
}
string SiteData::getPassword(char key) {
// decrypt passowrd using XOR cipher backwards
string password = "";
for (unsigned int i = 0; i < encPass.size(); i++) {
password += encPass[i] ^ (int(key) + i) % 255;
}
return password;
}
string SiteData::encodePassword(string password, char key) {
// encrypt passowrd using XOR cipher
string encryptPW = "";
for (unsigned int i = 0; i < password.size(); i++) {
encryptPW += password[i] ^ (int(key) + i) % 255;
}
return encryptPW;
}
void SiteData::insertPass(sqlite3 * db) {
// check if database exists
if (!db) {
return;
}
// create prepared statement
sqlite3_stmt * stmt;
const char * pzTest;
const char * szSQL;
string insert = "INSERT INTO passwords (id, website, user, password) values (?, ?, ?, ?)";
szSQL = insert.c_str();
int rc = sqlite3_prepare(db, szSQL, strlen(szSQL), &stmt, &pzTest);
if (rc == SQLITE_OK) {
// prepare params and bind to prepared statement
const char * websiteStmt = site.c_str();
const char * userStmt = user.c_str();
const char * passwordStmt = encPass.c_str();
sqlite3_bind_null(stmt, 1);
sqlite3_bind_text(stmt, 2, websiteStmt, strlen(websiteStmt), 0);
sqlite3_bind_text(stmt, 3, userStmt, strlen(userStmt), 0);
sqlite3_bind_text(stmt, 4, passwordStmt, strlen(passwordStmt), 0);
// execute
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
}
void SiteData::selectPass(sqlite3 * db) {
// check if database exists
if (!db) {
return;
}
// create prepared statement
char * szErrMsg = 0;
const char * pSQL;
string select = "SELECT password FROM passwords WHERE website = '" + site +
"' AND user = '" + user + "'";
pSQL = select.c_str();
// use struct to obtain select data
select_wrapper result;
int rc = sqlite3_exec(db, pSQL, callback, &result, &szErrMsg);
// check for error else set encrypted password
if (rc != SQLITE_OK) {
cerr << "Error: " << szErrMsg << endl;
sqlite3_free(szErrMsg);
} else {
encPass = result.password;
}
}
| 25.291667 | 92 | 0.645387 |
7d5f54a7c49337653bb4f4e20ceed3b0b7ae30ed | 6,300 | cpp | C++ | src/orbital/graphics/Graphics.cpp | JohannesMP/orbital | 9dca53deb6989fbe4c5171c4e9517c2e548ea3fa | [
"MIT"
] | null | null | null | src/orbital/graphics/Graphics.cpp | JohannesMP/orbital | 9dca53deb6989fbe4c5171c4e9517c2e548ea3fa | [
"MIT"
] | null | null | null | src/orbital/graphics/Graphics.cpp | JohannesMP/orbital | 9dca53deb6989fbe4c5171c4e9517c2e548ea3fa | [
"MIT"
] | 1 | 2018-10-23T23:53:00.000Z | 2018-10-23T23:53:00.000Z | //
// Created by jim on 24.01.18.
//
#include "Graphics.h"
#include <glm/gtx/matrix_transform_2d.hpp>
#include <orbital/math/elementary.h>
#include <orbital/common/convert.h>
Graphics::Graphics(
size_t const rows,
size_t cols
)
{
if (0 == rows)
{
throw std::runtime_error{"graphics cannot have 0 rows"};
}
if (0 == cols)
{
cols = static_cast<size_t>(rows / charRatio());
}
mScanlines.resize(rows);
for (auto &scanline : mScanlines)
{
scanline.resize(cols);
}
clear();
// Span over whole viewport
mProjection = glm::scale(mat{1}, {cols / 2.0, rows / 2.0});
// Origin should sit in the center
mProjection = glm::translate(mProjection, {1, 1});
// Y-Axis should point upwards
mProjection = glm::scale(mProjection, {1, -1});
// Scale against viewport distort
mProjection = glm::scale(mProjection, {rows / static_cast<Decimal>(cols) / charRatio(), 1});
push();
updateTransform();
}
void
Graphics::clear()
{
for (auto &scanline : mScanlines)
{
std::fill(scanline.begin(), scanline.end(), ' ');
}
}
void
Graphics::pixel(
WorldVector const &worldVector,
char const c
)
{
FramebufferVector vec = mapToFramebuffer(worldVector);
if (!withinFramebufferBounds(vec))
{
return;
}
char &target = framebufferPixel(FramebufferLocation{vec});
if (mOverwrite || (!mOverwrite && ' ' == target))
{
target = c;
}
}
void
Graphics::label(
WorldVector const &worldVector,
std::string_view const &text
)
{
auto vec = mapToFramebuffer(worldVector);
if (!withinFramebufferBounds(vec))
{
return;
}
FramebufferLocation loc{vec};
// If text length exceeds scanline length from a given column,
// the text must be trimmed to a smaller size to avoid:
auto span = std::min(text.length(), columns() - loc.x);
if (mOverwrite)
{
// Simply copy the whole text into framebuffer:
std::copy(text.begin(), text.begin() + span, mScanlines[loc.y].begin() + loc.x);
}
else
{
for (int i = 0; i < span; i++)
{
char &target = framebufferPixel(loc);
if (' ' == target)
{
target = text[i];
}
}
}
}
FramebufferVector
Graphics::mapToFramebuffer(
WorldVector const &vec
)
{
return mTransform * vec3{vec, 1.0};
}
Graphics::WorldVector
Graphics::mapToWorld(
FramebufferVector const &vec
)
{
return glm::inverse(mTransform) * vec3{vec, 1.0};
}
void
Graphics::border()
{
for (std::string &scanline : mScanlines)
{
scanline.front() = scanline.back() = '|';
}
std::fill(mScanlines.front().begin() + 1, mScanlines.front().end() - 1, '-');
std::fill(mScanlines.back().begin() + 1, mScanlines.back().end() - 1, '-');
mScanlines.front().front() = '+';
mScanlines.front().back() = '+';
mScanlines.back().front() = '+';
mScanlines.back().back() = '+';
}
void
Graphics::translate(
WorldVector const &v
)
{
mTransformStack.back().translate(v);
updateTransform();
}
void
Graphics::scale(
Decimal const s
)
{
mTransformStack.back().scale(s);
updateTransform();
}
void
Graphics::rotate(
Radian<Decimal> const theta
)
{
mTransformStack.back().rotate(theta);
updateTransform();
}
void
Graphics::updateTransform()
{
mat view{1};
for (auto transform : mTransformStack)
{
view *= transform.transformation();
}
mTransform = mProjection * view;
}
std::size_t
Graphics::columns() const
{
return static_cast<int>(mScanlines[0].length());
}
void
Graphics::resetTransform()
{
mTransformStack.back().reset();
updateTransform();
}
void
Graphics::present()
{
for (auto &scanline : mScanlines)
{
std::cout << scanline << '\n';
}
std::cout << std::flush;
}
bool
Graphics::withinFramebufferBounds(
const FramebufferVector &v
) const
{
return v.y >= 0 && v.y < rows() && v.x >= 0 && v.x < columns();
}
void
Graphics::push()
{
mTransformStack.emplace_back();
}
void
Graphics::pop()
{
mTransformStack.pop_back();
updateTransform();
}
mat const &
Graphics::transformation()
{
return mTransform;
}
void
Graphics::ellipse(const Ellipse<Decimal> &ellipse)
{
// Skip ellipse rendering if the viewport is completely contained by the ellipse shape,
// i.e. no lines are visible anyway.
vec ll = mapToWorld({0, rows() - 1});
vec ur = mapToWorld({columns() - 1, 0});
if (ellipse.contains(Rectangle<Decimal>{ll, ur}))
{
return;
}
// Since the stepper calculates the pixel distance based on vector subtraction and *not* on ellipse arc length,
// the ellipse must be divided into 4 quarters
stepper(ellipse, 0_pi, 0.5_pi);
stepper(ellipse, 0.5_pi, 1_pi);
stepper(ellipse, 1_pi, 1.5_pi);
stepper(ellipse, 1.5_pi, 2_pi);
}
void
Graphics::stepper(
const Ellipse<Decimal> &ellipse,
Radian<Decimal> const ts,
Radian<Decimal> const te
)
{
// Calculate distance the painted pixels of the start and end arc would have within the framebuffer:
auto const vs = convert<WorldVector>(ellipse.point(ts));
auto const ve = convert<WorldVector>(ellipse.point(te));
Decimal const d = vectorDistance(mapToFramebuffer(ve), mapToFramebuffer(vs));
// 1.4142... is the distance between to diagonal pixels:
if (1.5 < d)
{
// Distance between painted pixels in framebuffers spans over at least one pixel,
// continue stepping in smaller steps:
Radian<Decimal> const ta = average(ts, te);
stepper(ellipse, ts, ta);
stepper(ellipse, ta, te);
}
else
{
// Paint pixel:
pixel(vs, '+');
}
}
void
Graphics::overwrite(
bool const b
)
{
mOverwrite = b;
}
std::size_t
Graphics::rows() const
{
return static_cast<int>(mScanlines.size());
}
char &
Graphics::framebufferPixel(
const FramebufferLocation &loc
)
{
return mScanlines.at(loc.y).at(loc.x);
}
char const &
Graphics::framebufferPixel(
FramebufferLocation const &loc
) const
{
return mScanlines.at(loc.y).at(loc.x);
}
| 20.257235 | 115 | 0.61 |
7d661387415c9fd340937d5049995710e681adb0 | 2,017 | inl | C++ | Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl | liliilli/DianYing | 6e19f67e5d932e346a0ce63a648bed1a04ef618e | [
"MIT"
] | 4 | 2019-03-17T19:46:54.000Z | 2019-12-09T20:11:01.000Z | Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl | liliilli/DianYing | 6e19f67e5d932e346a0ce63a648bed1a04ef618e | [
"MIT"
] | 11 | 2019-06-09T13:53:27.000Z | 2020-02-09T09:47:28.000Z | Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl | liliilli/DianYing | 6e19f67e5d932e346a0ce63a648bed1a04ef618e | [
"MIT"
] | 1 | 2019-06-04T15:20:18.000Z | 2019-06-04T15:20:18.000Z | #pragma once
///
/// MIT License
/// Copyright (c) 2018-2019 Jongmin Yun
///
/// 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.
///
namespace dy::math
{
template <typename TLeft, typename TRight, typename = void>
struct GetBiggerType_T;
template <typename TLeft, typename TRight>
struct GetBiggerType_T<
TLeft, TRight,
std::enable_if_t<kCategoryOf<TLeft> == kCategoryOf<TRight>>> final
{
static constexpr auto kCategory = kCategoryOf<TLeft>;
static constexpr auto kLeftSize = sizeof(TLeft) * 8;
static constexpr auto kRightSize = sizeof(TRight) * 8;
static constexpr auto kBiggerSize = kLeftSize > kRightSize ? kLeftSize : kRightSize;
using Type = typename GetCoverableTypeOf<kCategory, kBiggerSize>::Type;
};
template <typename TLeftType, typename TRightType>
struct GetBiggerType_T<
TLeftType, TRightType,
std::enable_if_t<
(kCategoryOf<TLeftType> == EValueCategory::Real)
^ (kCategoryOf<TRightType> == EValueCategory::Real)>> final
{
static constexpr EValueCategory kLeftCategory = kCategoryOf<TLeftType>;
static constexpr EValueCategory kRightCategory = kCategoryOf<TRightType>;
static constexpr auto kLeftSize = sizeof(TLeftType) * 8;
static constexpr auto kRightSize = sizeof(TRightType) * 8;
static constexpr auto kBiggerSize = kLeftSize > kRightSize ? kLeftSize : kRightSize;
using Type = std::conditional_t<
kLeftCategory == EValueCategory::Real,
typename GetCoverableTypeOf<kLeftCategory, kBiggerSize>::Type,
typename GetCoverableTypeOf<kRightCategory, kBiggerSize>::Type>;
};
} /// ::dy::math namespace | 38.056604 | 86 | 0.752603 |
de094bae004ab2fc038364a3977bd8bbea023726 | 622 | cpp | C++ | Qt/EARC/app/EARC/App/draganddroplabel.cpp | argama147/zetprogratv | fbe0b7f4390df5ce581e11860d5f6142cdb3fdb7 | [
"MIT"
] | 1 | 2022-03-22T17:46:39.000Z | 2022-03-22T17:46:39.000Z | Qt/EARC/app/EARC/App/draganddroplabel.cpp | argama147/zetprogratv | fbe0b7f4390df5ce581e11860d5f6142cdb3fdb7 | [
"MIT"
] | 15 | 2022-02-20T05:10:23.000Z | 2022-03-26T23:49:32.000Z | Qt/EARC/app/EARC/App/draganddroplabel.cpp | argama147/zetprogratv | fbe0b7f4390df5ce581e11860d5f6142cdb3fdb7 | [
"MIT"
] | null | null | null | #include "draganddroplabel.h"
#include <QDropEvent>
#include <QMimeData>
DragAndDropLabel::DragAndDropLabel(QWidget *parent)
: QLabel(parent)
{
setAcceptDrops(true);
}
void DragAndDropLabel::dragEnterEvent(QDragEnterEvent *event)
{
Q_ASSERT(event);
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
}
void DragAndDropLabel::dropEvent(QDropEvent *event)
{
Q_ASSERT(event);
QStringList pathList;
for (auto &url : event->mimeData()->urls()) {
pathList << url.toLocalFile();
}
emit sendFilePathList(pathList);
setText(pathList.join("\n"));
}
| 20.064516 | 61 | 0.673633 |
de097b69e3439a94ca773bf913638ce2add4e97a | 115,226 | cpp | C++ | Source/Decoda/Decoda/LuaInject/LuaDll.cpp | KoSukeWork/BabeLua | 0904f8ba15174fcfe88d75e37349c4f4f15403ef | [
"MIT"
] | null | null | null | Source/Decoda/Decoda/LuaInject/LuaDll.cpp | KoSukeWork/BabeLua | 0904f8ba15174fcfe88d75e37349c4f4f15403ef | [
"MIT"
] | null | null | null | Source/Decoda/Decoda/LuaInject/LuaDll.cpp | KoSukeWork/BabeLua | 0904f8ba15174fcfe88d75e37349c4f4f15403ef | [
"MIT"
] | 1 | 2020-12-07T13:47:47.000Z | 2020-12-07T13:47:47.000Z | /*
Decoda
Copyright (C) 2007-2013 Unknown Worlds Entertainment, Inc.
This file is part of Decoda.
Decoda 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.
Decoda 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 Decoda. If not, see <http://www.gnu.org/licenses/>.
*/
#include "LuaDll.h"
#include "Hook.h"
#include "DebugBackend.h"
#include "StdCall.h"
#include "CriticalSection.h"
#include "CriticalSectionLock.h"
#include "DebugHelp.h"
#include <windows.h>
#include <tlhelp32.h>
#include <psapi.h>
#include <windows.h>
#include <malloc.h>
#include <assert.h>
#include <set>
#include <hash_map>
#include <hash_set>
// Macro for convenient pointer addition.
// Essentially treats the last two parameters as DWORDs. The first
// parameter is used to typecast the result to the appropriate pointer type.
#define MAKE_PTR(cast, ptr, addValue ) (cast)( (DWORD)(ptr)+(DWORD)(addValue))
// When this is defined, additional information about what's going on will be
// output for debugging.
//#define VERBOSE
//#define LOG
typedef const char* (__stdcall *lua_Reader_stdcall) (lua_State*, void*, size_t*);
typedef void (__stdcall *lua_Hook_stdcall) (lua_State*, lua_Debug*);
typedef lua_State* (*lua_open_cdecl_t) (int stacksize);
typedef lua_State* (*lua_open_500_cdecl_t) ();
typedef lua_State* (*lua_newstate_cdecl_t) (lua_Alloc, void*);
typedef void (*lua_close_cdecl_t) (lua_State*);
typedef lua_State* (*lua_newthread_cdecl_t) (lua_State*);
typedef int (*lua_error_cdecl_t) (lua_State*);
typedef int (*lua_sethook_cdecl_t) (lua_State*, lua_Hook, int, int);
typedef int (*lua_gethookmask_cdecl_t) (lua_State*);
typedef int (*lua_getinfo_cdecl_t) (lua_State*, const char*, lua_Debug* ar);
typedef void (*lua_remove_cdecl_t) (lua_State*, int);
typedef void (*lua_settable_cdecl_t) (lua_State*, int);
typedef void (*lua_gettable_cdecl_t) (lua_State*, int);
typedef void (*lua_rawget_cdecl_t) (lua_State *L, int idx);
typedef void (*lua_rawgeti_cdecl_t) (lua_State *L, int idx, int n);
typedef void (*lua_rawset_cdecl_t) (lua_State *L, int idx);
typedef void (*lua_pushstring_cdecl_t) (lua_State*, const char*);
typedef void (*lua_pushlstring_cdecl_t) (lua_State*, const char*, size_t);
typedef int (*lua_type_cdecl_t) (lua_State*, int);
typedef const char* (*lua_typename_cdecl_t) (lua_State*, int);
typedef void (*lua_settop_cdecl_t) (lua_State*, int);
typedef const char* (*lua_getlocal_cdecl_t) (lua_State*, const lua_Debug*, int);
typedef const char* (*lua_setlocal_cdecl_t) (lua_State*, const lua_Debug*, int);
typedef int (*lua_getstack_cdecl_t) (lua_State*, int, lua_Debug*);
typedef void (*lua_insert_cdecl_t) (lua_State*, int);
typedef void (*lua_pushnil_cdecl_t) (lua_State*);
typedef void (*lua_pushcclosure_cdecl_t) (lua_State*, lua_CFunction, int);
typedef void (*lua_pushvalue_cdecl_t) (lua_State*, int);
typedef void (*lua_pushinteger_cdecl_t) (lua_State*, int);
typedef void (*lua_pushnumber_cdecl_t) (lua_State*, lua_Number);
typedef const char* (*lua_tostring_cdecl_t) (lua_State*, int);
typedef const char* (*lua_tolstring_cdecl_t) (lua_State*, int, size_t*);
typedef int (*lua_toboolean_cdecl_t) (lua_State*, int);
typedef int (*lua_tointeger_cdecl_t) (lua_State*, int);
typedef lua_Integer (*lua_tointegerx_cdecl_t) (lua_State*, int, int*);
typedef lua_CFunction (*lua_tocfunction_cdecl_t) (lua_State*, int);
typedef lua_Number (*lua_tonumber_cdecl_t) (lua_State*, int);
typedef lua_Number (*lua_tonumberx_cdecl_t) (lua_State*, int, int*);
typedef void* (*lua_touserdata_cdecl_t) (lua_State*, int);
typedef int (*lua_gettop_cdecl_t) (lua_State*);
typedef int (*lua_load_cdecl_t) (lua_State*, lua_Reader, void*, const char *chunkname);
typedef void (*lua_call_cdecl_t) (lua_State*, int, int);
typedef void (*lua_callk_cdecl_t) (lua_State*, int, int, int, lua_CFunction);
typedef int (*lua_pcall_cdecl_t) (lua_State*, int, int, int);
typedef int (*lua_pcallk_cdecl_t) (lua_State*, int, int, int, int, lua_CFunction);
typedef void (*lua_newtable_cdecl_t) (lua_State*);
typedef void (*lua_createtable_cdecl_t) (lua_State*, int, int);
typedef int (*lua_next_cdecl_t) (lua_State*, int);
typedef int (*lua_rawequal_cdecl_t) (lua_State *L, int idx1, int idx2);
typedef int (*lua_getmetatable_cdecl_t) (lua_State*, int objindex);
typedef int (*lua_setmetatable_cdecl_t) (lua_State*, int objindex);
typedef int (*luaL_ref_cdecl_t) (lua_State *L, int t);
typedef void (*luaL_unref_cdecl_t) (lua_State *L, int t, int ref);
typedef int (*luaL_newmetatable_cdecl_t) (lua_State *L, const char *tname);
typedef int (*luaL_loadbuffer_cdecl_t) (lua_State *L, const char *buff, size_t sz, const char *name);
typedef int (*luaL_loadfile_cdecl_t) (lua_State *L, const char *fileName);
typedef const lua_WChar* (*lua_towstring_cdecl_t) (lua_State *L, int index);
typedef int (*lua_iswstring_cdecl_t) (lua_State *L, int index);
typedef const char* (*lua_getupvalue_cdecl_t) (lua_State *L, int funcindex, int n);
typedef const char* (*lua_setupvalue_cdecl_t) (lua_State *L, int funcindex, int n);
typedef void (*lua_getfenv_cdecl_t) (lua_State *L, int index);
typedef int (*lua_setfenv_cdecl_t) (lua_State *L, int index);
typedef void (*lua_pushlightuserdata_cdecl_t)(lua_State *L, void *p);
typedef int (*lua_cpcall_cdecl_t) (lua_State *L, lua_CFunction func, void *ud);
typedef int (*lua_pushthread_cdecl_t) (lua_State *L);
typedef void * (*lua_newuserdata_cdecl_t) (lua_State *L, size_t size);
typedef lua_State* (*luaL_newstate_cdecl_t) ();
typedef int (*lua_checkstack_cdecl_t) (lua_State* L, int extra);
typedef lua_State* (__stdcall *lua_open_stdcall_t) (int stacksize);
typedef lua_State* (__stdcall *lua_open_500_stdcall_t) ();
typedef lua_State* (__stdcall *lua_newstate_stdcall_t) (lua_Alloc, void*);
typedef void (__stdcall *lua_close_stdcall_t) (lua_State*);
typedef lua_State* (__stdcall *lua_newthread_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_error_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_sethook_stdcall_t) (lua_State*, lua_Hook_stdcall, int, int);
typedef int (__stdcall *lua_gethookmaskstdcall_t) (lua_State*);
typedef int (__stdcall *lua_getinfo_stdcall_t) (lua_State*, const char*, lua_Debug* ar);
typedef void (__stdcall *lua_remove_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_settable_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_gettable_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_rawget_stdcall_t) (lua_State *L, int idx);
typedef void (__stdcall *lua_rawgeti_stdcall_t) (lua_State *L, int idx, int n);
typedef void (__stdcall *lua_rawset_stdcall_t) (lua_State *L, int idx);
typedef void (__stdcall *lua_pushstring_stdcall_t) (lua_State*, const char*);
typedef void (__stdcall *lua_pushlstring_stdcall_t) (lua_State*, const char*, size_t);
typedef int (__stdcall *lua_type_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_typename_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_settop_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_getlocal_stdcall_t) (lua_State*, const lua_Debug*, int);
typedef const char* (__stdcall *lua_setlocal_stdcall_t) (lua_State*, const lua_Debug*, int);
typedef int (__stdcall *lua_getstack_stdcall_t) (lua_State*, int, lua_Debug*);
typedef void (__stdcall *lua_insert_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushnil_stdcall_t) (lua_State*);
typedef void (__stdcall *lua_pushcclosure_stdcall_t) (lua_State*, lua_CFunction, int);
typedef void (__stdcall *lua_pushvalue_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushinteger_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushnumber_stdcall_t) (lua_State*, lua_Number);
typedef const char* (__stdcall *lua_tostring_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_tolstring_stdcall_t) (lua_State*, int, size_t*);
typedef int (__stdcall *lua_toboolean_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_tointeger_stdcall_t) (lua_State*, int);
typedef lua_Integer (__stdcall *lua_tointegerx_stdcall_t) (lua_State*, int, int*);
typedef lua_CFunction (__stdcall *lua_tocfunction_stdcall_t) (lua_State*, int);
typedef lua_Number (__stdcall *lua_tonumber_stdcall_t) (lua_State*, int);
typedef lua_Number (__stdcall *lua_tonumberx_stdcall_t) (lua_State*, int, int*);
typedef void* (__stdcall *lua_touserdata_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_gettop_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_load_stdcall_t) (lua_State*, lua_Reader_stdcall, void*, const char *chunkname);
typedef void (__stdcall *lua_call_stdcall_t) (lua_State*, int, int);
typedef void (__stdcall *lua_callk_stdcall_t) (lua_State*, int, int, int, lua_CFunction);
typedef int (__stdcall *lua_pcall_stdcall_t) (lua_State*, int, int, int);
typedef int (__stdcall *lua_pcallk_stdcall_t) (lua_State*, int, int, int, int, lua_CFunction);
typedef void (__stdcall *lua_newtable_stdcall_t) (lua_State*);
typedef void (__stdcall *lua_createtable_stdcall_t) (lua_State*, int, int);
typedef int (__stdcall *lua_next_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_rawequal_stdcall_t) (lua_State *L, int idx1, int idx2);
typedef int (__stdcall *lua_getmetatable_stdcall_t) (lua_State*, int objindex);
typedef int (__stdcall *lua_setmetatable_stdcall_t) (lua_State*, int objindex);
typedef int (__stdcall *luaL_ref_stdcall_t) (lua_State *L, int t);
typedef void (__stdcall *luaL_unref_stdcall_t) (lua_State *L, int t, int ref);
typedef int (__stdcall *luaL_newmetatable_stdcall_t) (lua_State *L, const char *tname);
typedef int (__stdcall *luaL_loadbuffer_stdcall_t) (lua_State *L, const char *buff, size_t sz, const char *name);
typedef int (__stdcall *luaL_loadfile_stdcall_t) (lua_State *L, const char *fileName);
typedef const lua_WChar* (__stdcall *lua_towstring_stdcall_t) (lua_State *L, int index);
typedef int (__stdcall *lua_iswstring_stdcall_t) (lua_State *L, int index);
typedef const char* (__stdcall *lua_getupvalue_stdcall_t) (lua_State *L, int funcindex, int n);
typedef const char* (__stdcall *lua_setupvalue_stdcall_t) (lua_State *L, int funcindex, int n);
typedef void (__stdcall *lua_getfenv_stdcall_t) (lua_State *L, int index);
typedef int (__stdcall *lua_setfenv_stdcall_t) (lua_State *L, int index);
typedef void (__stdcall *lua_pushlightuserdata_stdcall_t)(lua_State *L, void *p);
typedef int (__stdcall *lua_cpcall_stdcall_t) (lua_State *L, lua_CFunction func, void *ud);
typedef int (__stdcall *lua_pushthread_stdcall_t) (lua_State *L);
typedef void * (__stdcall *lua_newuserdata_stdcall_t) (lua_State *L, size_t size);
typedef lua_State* (__stdcall *luaL_newstate_stdcall_t) ();
typedef int (__stdcall *lua_checkstack_stdcall_t) (lua_State* L, int extra);
typedef HMODULE (WINAPI *LoadLibraryExW_t) (LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags);
typedef ULONG (WINAPI *LdrLockLoaderLock_t) (ULONG flags, PULONG disposition, PULONG cookie);
typedef LONG (WINAPI *LdrUnlockLoaderLock_t) (ULONG flags, ULONG cookie);
/**
* Structure that holds pointers to all of the Lua API functions.
*/
struct LuaInterface
{
int version; // One of 401, 500, 510
bool finishedLoading;
bool stdcall;
// Use these instead of the LUA_* constants in lua.h. The value of these
// change depending on the version of Lua we're using.
int registryIndex;
int globalsIndex;
// cdecl functions.
lua_open_cdecl_t lua_open_dll_cdecl;
lua_open_500_cdecl_t lua_open_500_dll_cdecl;
lua_newstate_cdecl_t lua_newstate_dll_cdecl;
lua_close_cdecl_t lua_close_dll_cdecl;
lua_newthread_cdecl_t lua_newthread_dll_cdecl;
lua_error_cdecl_t lua_error_dll_cdecl;
lua_gettop_cdecl_t lua_gettop_dll_cdecl;
lua_sethook_cdecl_t lua_sethook_dll_cdecl;
lua_gethookmask_cdecl_t lua_gethookmask_dll_cdecl;
lua_getinfo_cdecl_t lua_getinfo_dll_cdecl;
lua_remove_cdecl_t lua_remove_dll_cdecl;
lua_settable_cdecl_t lua_settable_dll_cdecl;
lua_gettable_cdecl_t lua_gettable_dll_cdecl;
lua_rawget_cdecl_t lua_rawget_dll_cdecl;
lua_rawgeti_cdecl_t lua_rawgeti_dll_cdecl;
lua_rawset_cdecl_t lua_rawset_dll_cdecl;
lua_pushstring_cdecl_t lua_pushstring_dll_cdecl;
lua_pushlstring_cdecl_t lua_pushlstring_dll_cdecl;
lua_type_cdecl_t lua_type_dll_cdecl;
lua_typename_cdecl_t lua_typename_dll_cdecl;
lua_settop_cdecl_t lua_settop_dll_cdecl;
lua_getlocal_cdecl_t lua_getlocal_dll_cdecl;
lua_setlocal_cdecl_t lua_setlocal_dll_cdecl;
lua_getstack_cdecl_t lua_getstack_dll_cdecl;
lua_insert_cdecl_t lua_insert_dll_cdecl;
lua_pushnil_cdecl_t lua_pushnil_dll_cdecl;
lua_pushvalue_cdecl_t lua_pushvalue_dll_cdecl;
lua_pushinteger_cdecl_t lua_pushinteger_dll_cdecl;
lua_pushnumber_cdecl_t lua_pushnumber_dll_cdecl;
lua_pushcclosure_cdecl_t lua_pushcclosure_dll_cdecl;
lua_tostring_cdecl_t lua_tostring_dll_cdecl;
lua_tolstring_cdecl_t lua_tolstring_dll_cdecl;
lua_toboolean_cdecl_t lua_toboolean_dll_cdecl;
lua_tointeger_cdecl_t lua_tointeger_dll_cdecl;
lua_tointegerx_cdecl_t lua_tointegerx_dll_cdecl;
lua_tocfunction_cdecl_t lua_tocfunction_dll_cdecl;
lua_tonumber_cdecl_t lua_tonumber_dll_cdecl;
lua_tonumberx_cdecl_t lua_tonumberx_dll_cdecl;
lua_touserdata_cdecl_t lua_touserdata_dll_cdecl;
lua_load_cdecl_t lua_load_dll_cdecl;
lua_call_cdecl_t lua_call_dll_cdecl;
lua_callk_cdecl_t lua_callk_dll_cdecl;
lua_pcall_cdecl_t lua_pcall_dll_cdecl;
lua_pcallk_cdecl_t lua_pcallk_dll_cdecl;
lua_newtable_cdecl_t lua_newtable_dll_cdecl;
lua_createtable_cdecl_t lua_createtable_dll_cdecl;
lua_next_cdecl_t lua_next_dll_cdecl;
lua_rawequal_cdecl_t lua_rawequal_dll_cdecl;
lua_getmetatable_cdecl_t lua_getmetatable_dll_cdecl;
lua_setmetatable_cdecl_t lua_setmetatable_dll_cdecl;
luaL_ref_cdecl_t luaL_ref_dll_cdecl;
luaL_unref_cdecl_t luaL_unref_dll_cdecl;
luaL_newmetatable_cdecl_t luaL_newmetatable_dll_cdecl;
luaL_loadbuffer_cdecl_t luaL_loadbuffer_dll_cdecl;
luaL_loadfile_cdecl_t luaL_loadfile_dll_cdecl;
lua_towstring_cdecl_t lua_towstring_dll_cdecl;
lua_iswstring_cdecl_t lua_iswstring_dll_cdecl;
lua_getupvalue_cdecl_t lua_getupvalue_dll_cdecl;
lua_setupvalue_cdecl_t lua_setupvalue_dll_cdecl;
lua_getfenv_cdecl_t lua_getfenv_dll_cdecl;
lua_setfenv_cdecl_t lua_setfenv_dll_cdecl;
lua_pushlightuserdata_cdecl_t lua_pushlightuserdata_dll_cdecl;
lua_cpcall_cdecl_t lua_cpcall_dll_cdecl;
lua_pushthread_cdecl_t lua_pushthread_dll_cdecl;
lua_newuserdata_cdecl_t lua_newuserdata_dll_cdecl;
luaL_newstate_cdecl_t luaL_newstate_dll_cdecl;
lua_checkstack_cdecl_t lua_checkstack_dll_cdecl;
// stdcall functions.
lua_open_stdcall_t lua_open_dll_stdcall;
lua_open_500_stdcall_t lua_open_500_dll_stdcall;
lua_newstate_stdcall_t lua_newstate_dll_stdcall;
lua_close_stdcall_t lua_close_dll_stdcall;
lua_newthread_stdcall_t lua_newthread_dll_stdcall;
lua_error_stdcall_t lua_error_dll_stdcall;
lua_gettop_stdcall_t lua_gettop_dll_stdcall;
lua_sethook_stdcall_t lua_sethook_dll_stdcall;
lua_gethookmaskstdcall_t lua_gethookmask_dll_stdcall;
lua_getinfo_stdcall_t lua_getinfo_dll_stdcall;
lua_remove_stdcall_t lua_remove_dll_stdcall;
lua_settable_stdcall_t lua_settable_dll_stdcall;
lua_gettable_stdcall_t lua_gettable_dll_stdcall;
lua_rawget_stdcall_t lua_rawget_dll_stdcall;
lua_rawgeti_stdcall_t lua_rawgeti_dll_stdcall;
lua_rawset_stdcall_t lua_rawset_dll_stdcall;
lua_pushstring_stdcall_t lua_pushstring_dll_stdcall;
lua_pushlstring_stdcall_t lua_pushlstring_dll_stdcall;
lua_type_stdcall_t lua_type_dll_stdcall;
lua_typename_stdcall_t lua_typename_dll_stdcall;
lua_settop_stdcall_t lua_settop_dll_stdcall;
lua_getlocal_stdcall_t lua_getlocal_dll_stdcall;
lua_setlocal_stdcall_t lua_setlocal_dll_stdcall;
lua_getstack_stdcall_t lua_getstack_dll_stdcall;
lua_insert_stdcall_t lua_insert_dll_stdcall;
lua_pushnil_stdcall_t lua_pushnil_dll_stdcall;
lua_pushvalue_stdcall_t lua_pushvalue_dll_stdcall;
lua_pushinteger_stdcall_t lua_pushinteger_dll_stdcall;
lua_pushnumber_stdcall_t lua_pushnumber_dll_stdcall;
lua_pushcclosure_stdcall_t lua_pushcclosure_dll_stdcall;
lua_tostring_stdcall_t lua_tostring_dll_stdcall;
lua_tolstring_stdcall_t lua_tolstring_dll_stdcall;
lua_toboolean_stdcall_t lua_toboolean_dll_stdcall;
lua_tointeger_stdcall_t lua_tointeger_dll_stdcall;
lua_tointegerx_stdcall_t lua_tointegerx_dll_stdcall;
lua_tocfunction_stdcall_t lua_tocfunction_dll_stdcall;
lua_tonumber_stdcall_t lua_tonumber_dll_stdcall;
lua_tonumberx_stdcall_t lua_tonumberx_dll_stdcall;
lua_touserdata_stdcall_t lua_touserdata_dll_stdcall;
lua_load_stdcall_t lua_load_dll_stdcall;
lua_call_stdcall_t lua_call_dll_stdcall;
lua_callk_stdcall_t lua_callk_dll_stdcall;
lua_pcall_stdcall_t lua_pcall_dll_stdcall;
lua_pcallk_stdcall_t lua_pcallk_dll_stdcall;
lua_newtable_stdcall_t lua_newtable_dll_stdcall;
lua_createtable_stdcall_t lua_createtable_dll_stdcall;
lua_next_stdcall_t lua_next_dll_stdcall;
lua_rawequal_stdcall_t lua_rawequal_dll_stdcall;
lua_getmetatable_stdcall_t lua_getmetatable_dll_stdcall;
lua_setmetatable_stdcall_t lua_setmetatable_dll_stdcall;
luaL_ref_stdcall_t luaL_ref_dll_stdcall;
luaL_unref_stdcall_t luaL_unref_dll_stdcall;
luaL_newmetatable_stdcall_t luaL_newmetatable_dll_stdcall;
luaL_loadbuffer_stdcall_t luaL_loadbuffer_dll_stdcall;
luaL_loadfile_stdcall_t luaL_loadfile_dll_stdcall;
lua_towstring_stdcall_t lua_towstring_dll_stdcall;
lua_iswstring_stdcall_t lua_iswstring_dll_stdcall;
lua_getupvalue_stdcall_t lua_getupvalue_dll_stdcall;
lua_setupvalue_stdcall_t lua_setupvalue_dll_stdcall;
lua_getfenv_stdcall_t lua_getfenv_dll_stdcall;
lua_setfenv_stdcall_t lua_setfenv_dll_stdcall;
lua_pushlightuserdata_stdcall_t lua_pushlightuserdata_dll_stdcall;
lua_cpcall_stdcall_t lua_cpcall_dll_stdcall;
lua_pushthread_stdcall_t lua_pushthread_dll_stdcall;
lua_newuserdata_stdcall_t lua_newuserdata_dll_stdcall;
luaL_newstate_stdcall_t luaL_newstate_dll_stdcall;
lua_checkstack_stdcall_t lua_checkstack_dll_stdcall;
lua_CFunction DecodaOutput;
lua_CFunction CPCallHandler;
lua_Hook HookHandler;
};
struct CPCallHandlerArgs
{
lua_CFunction_dll function;
void* data;
};
/**
* This macro outputs the prolog code for a naked intercept function. It
* should be the first code in the function.
*/
#define INTERCEPT_PROLOG() \
__asm \
{ \
__asm push ebp \
__asm mov ebp, esp \
__asm sub esp, __LOCAL_SIZE \
}
/**
* This macro outputs the epilog code for a naked intercept function. It
* should be the last code in the function. argsSize is the number of
* bytes for the argments to the function (not including the the api parameter).
* The return from the function should be stored in the "result" variable, and
* the "stdcall" bool variable determines if the function was called using the
* stdcall or cdecl calling convention.
*/
#define INTERCEPT_EPILOG(argsSize) \
__asm \
{ \
__asm mov eax, result \
__asm cmp stdcall, 0 \
__asm mov esp, ebp \
__asm pop ebp \
__asm jne stdcall_ret \
__asm ret 4 \
__asm stdcall_ret: \
__asm ret (4 + argsSize) \
}
/**
* This macro outputs the epilog code for a naked intercept function that doesn't
* have a return value. It should be the last code in the function. argsSize is the
* number of bytes for the argments to the function (not including the the api
* parameter). The "stdcall" bool variable determines if the function was called using
* the stdcall or cdecl calling convention.
*/
#define INTERCEPT_EPILOG_NO_RETURN(argsSize) \
__asm \
{ \
__asm cmp stdcall, 0 \
__asm mov esp, ebp \
__asm pop ebp \
__asm jne stdcall_ret \
__asm ret 4 \
__asm stdcall_ret: \
__asm ret (4 + argsSize) \
}
LoadLibraryExW_t LoadLibraryExW_dll = NULL;
LdrLockLoaderLock_t LdrLockLoaderLock_dll = NULL;
LdrUnlockLoaderLock_t LdrUnlockLoaderLock_dll = NULL;
bool g_loadedLuaFunctions = false;
std::set<std::string> g_loadedModules;
CriticalSection g_loadedModulesCriticalSection;
std::vector<LuaInterface> g_interfaces;
stdext::hash_map<void*, void*> g_hookedFunctionMap;
stdext::hash_set<std::string> g_warnedAboutLua; // Indivates that we've warned the module contains Lua functions but none were loaded.
stdext::hash_set<std::string> g_warnedAboutPdb; // Indicates that we've warned about a module having a mismatched PDB.
bool g_warnedAboutThreads = false;
bool g_warnedAboutJit = false;
std::string g_symbolsDirectory;
static DWORD g_disableInterceptIndex = 0;
bool g_initializedDebugHelp = false;
/**
* Function called after a library has been loaded by the host application.
* We use this to check for the Lua dll.
*/
void PostLoadLibrary(HMODULE hModule);
/**
* Data structure passed into the MemoryReader function.
*/
struct Memory
{
const char* buffer;
size_t size;
};
/**
* lua_Reader function used to read from a memory buffer.
*/
const char* MemoryReader_cdecl(lua_State* L, void* data, size_t* size)
{
Memory* memory = static_cast<Memory*>(data);
if (memory->size > 0)
{
*size = memory->size;
memory->size = 0;
return memory->buffer;
}
else
{
return NULL;
}
}
/**
* lua_Reader function used to read from a memory buffer.
*/
const char* __stdcall MemoryReader_stdcall(lua_State* L, void* data, size_t* size)
{
Memory* memory = static_cast<Memory*>(data);
if (memory->size > 0)
{
*size = memory->size;
memory->size = 0;
return memory->buffer;
}
else
{
return NULL;
}
}
#pragma auto_inline(off)
int DecodaOutputWorker(unsigned long api, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
const char* message = lua_tostring_dll(api, L, 1);
// DebugBackend::Get().Message(message);
std::string outputMessage = "[LUA print] ";
outputMessage += message;
DebugBackend::Get().Message(outputMessage.c_str());
return 0;
}
#pragma auto_inline()
__declspec(naked) int DecodaOutput(unsigned long api, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
result = DecodaOutputWorker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
#pragma auto_inline(off)
int CPCallHandlerWorker(unsigned long api, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
CPCallHandlerArgs args = *static_cast<CPCallHandlerArgs*>(lua_touserdata_dll(api, L, 1));
// Remove the old args and put the new one on the stack.
lua_pop_dll(api, L, 1);
lua_pushlightuserdata_dll(api, L, args.data);
return args.function(api, L);
}
#pragma auto_inline()
__declspec(naked) int CPCallHandler(unsigned long api, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
result = CPCallHandlerWorker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
int lua_cpcall_dll(unsigned long api, lua_State *L, lua_CFunction_dll func, void *udn)
{
CPCallHandlerArgs args;
args.function = func;
args.data = udn;
return lua_cpcall_dll(api, L, g_interfaces[api].CPCallHandler, &args);
}
#pragma auto_inline(off)
void HookHandlerWorker(unsigned long api, lua_State* L, lua_Debug* ar, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
return DebugBackend::Get().HookCallback(api, L, ar);
}
#pragma auto_inline()
__declspec(naked) void HookHandler(unsigned long api, lua_State* L, lua_Debug* ar)
{
bool stdcall;
INTERCEPT_PROLOG()
HookHandlerWorker(api, L, ar, stdcall);
INTERCEPT_EPILOG_NO_RETURN(8)
}
void SetHookMode(unsigned long api, lua_State* L, HookMode mode)
{
if(mode == HookMode_None)
{
lua_sethook_dll(api, L, NULL, 0, 0);
}
else
{
int mask;
switch (mode)
{
case HookMode_CallsOnly:
mask = LUA_MASKCALL;
break;
case HookMode_CallsAndReturns:
mask = LUA_MASKCALL|LUA_MASKRET;
break;
case HookMode_Full:
mask = LUA_MASKCALL|LUA_MASKRET|LUA_MASKLINE;
break;
}
lua_sethook_dll(api, L, g_interfaces[api].HookHandler, mask, 0);
}
}
int lua_gethookmask(unsigned long api, lua_State *L)
{
if (g_interfaces[api].lua_gethookmask_dll_cdecl != NULL)
{
return g_interfaces[api].lua_gethookmask_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_gethookmask_dll_stdcall(L);
}
}
HookMode GetHookMode(unsigned long api, lua_State* L)
{
int mask = lua_gethookmask(api, L);
if(mask == 0)
{
return HookMode_None;
}
else if(mask == (LUA_MASKCALL))
{
return HookMode_CallsOnly;
}
else if(mask == (LUA_MASKCALL|LUA_MASKRET))
{
return HookMode_CallsAndReturns;
}
else
{
return HookMode_Full;
}
}
bool lua_pushthread_dll(unsigned long api, lua_State *L)
{
// These structures are taken out of the Lua 5.0 source code.
union lua_Value_500
{
void* gc;
void* p;
lua_Number n;
int b;
};
struct lua_TObject_500
{
int tt;
lua_Value_500 value;
};
struct lua_State_500
{
void* next;
unsigned char tt;
unsigned char marked;
lua_TObject_500* top;
};
#pragma pack(1)
union lua_Value_500_pack1
{
void* gc;
void* p;
lua_Number n;
int b;
};
struct lua_TObject_500_pack1
{
int tt;
lua_Value_500_pack1 value;
};
struct lua_State_500_pack1
{
void* next;
unsigned char tt;
unsigned char marked;
lua_TObject_500_pack1* top;
};
#pragma pack()
if (g_interfaces[api].lua_pushthread_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushthread_dll_cdecl(L);
return true;
}
else if (g_interfaces[api].lua_pushthread_dll_stdcall != NULL)
{
g_interfaces[api].lua_pushthread_dll_stdcall(L);
return true;
}
else
{
// The actual push thread function doesn't exist (probably Lua 5.0), so
// emulate it. The lua_pushthread function just pushes the state onto the
// stack and sets the type to LUA_TTHREAD. We use the pushlightuserdata
// function which basically does the same thing, except we need to modify the
// type of the object on the top of the stack.
lua_pushlightuserdata_dll(api, L, L);
// Check that the thing we think is pointing to the top of the stack actually
// is so that we don't overwrite something in memory.
bool success = false;
// If the structures are laid out differently in the implementation of Lua
// we might get crashes, so we wrap the access in a try block.
__try
{
lua_State_500* S = reinterpret_cast<lua_State_500*>(L);
lua_TObject_500* top = S->top - 1;
if (top->tt == LUA_TLIGHTUSERDATA && top->value.p == L)
{
top->tt = LUA_TTHREAD;
top->value.gc = L;
success = true;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
if (!success)
{
// The unpacked version didn't work out right, so try the version with no alignment.
__try
{
lua_State_500_pack1* S = reinterpret_cast<lua_State_500_pack1*>(L);
lua_TObject_500_pack1* top = S->top - 1;
if (top->tt == LUA_TLIGHTUSERDATA && top->value.p == L)
{
top->tt = LUA_TTHREAD;
top->value.gc = L;
success = true;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
}
if (!success)
{
lua_pop_dll(api, L, 1);
if (!g_warnedAboutThreads)
{
DebugBackend::Get().Message("Warning 1006: lua_pushthread could not be emulated due to modifications to Lua. Coroutines may be unstable", MessageType_Warning);
g_warnedAboutThreads = true;
}
}
return success;
}
}
void* lua_newuserdata_dll(unsigned long api, lua_State *L, size_t size)
{
if (g_interfaces[api].lua_newuserdata_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newuserdata_dll_cdecl(L, size);
}
else
{
return g_interfaces[api].lua_newuserdata_dll_stdcall(L, size);
}
}
void EnableIntercepts(bool enableIntercepts)
{
int value = reinterpret_cast<int>(TlsGetValue(g_disableInterceptIndex));
if (enableIntercepts)
{
--value;
}
else
{
++value;
}
TlsSetValue(g_disableInterceptIndex, reinterpret_cast<LPVOID>(value));
}
bool GetAreInterceptsEnabled()
{
int value = reinterpret_cast<int>(TlsGetValue(g_disableInterceptIndex));
return value <= 0;
}
void RegisterDebugLibrary(unsigned long api, lua_State* L)
{
lua_register_dll(api, L, "decoda_output", g_interfaces[api].DecodaOutput);
}
int GetGlobalsIndex(unsigned long api)
{
return g_interfaces[api].globalsIndex;
}
int GetRegistryIndex(unsigned long api)
{
return g_interfaces[api].registryIndex;
}
int lua_abs_index_dll(unsigned long api, lua_State* L, int i)
{
if (i > 0 || i <= GetRegistryIndex(api))
{
return i;
}
else
{
return lua_gettop_dll(api, L) + i + 1;
}
}
int lua_upvalueindex_dll(unsigned long api, int i)
{
return GetGlobalsIndex(api) - i;
}
void lua_setglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_setfield_dll(api, L, GetGlobalsIndex(api), s);
}
void lua_getglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_getfield_dll(api, L, GetGlobalsIndex(api), s);
}
void lua_rawgetglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_pushstring_dll(api, L, s);
lua_rawget_dll(api, L, GetGlobalsIndex(api));
}
lua_State* lua_newstate_dll(unsigned long api, lua_Alloc f, void* ud)
{
if (g_interfaces[api].lua_newstate_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newstate_dll_cdecl(f, ud);
}
else if (g_interfaces[api].lua_newstate_dll_stdcall != NULL)
{
return g_interfaces[api].lua_newstate_dll_stdcall(f, ud);
}
// This is an older version of Lua that doesn't support lua_newstate, so emulate it
// with lua_open.
if (g_interfaces[api].lua_open_500_dll_cdecl != NULL)
{
return g_interfaces[api].lua_open_500_dll_cdecl();
}
else if (g_interfaces[api].lua_open_500_dll_stdcall != NULL)
{
return g_interfaces[api].lua_open_500_dll_stdcall();
}
else if (g_interfaces[api].lua_open_dll_cdecl != NULL)
{
return g_interfaces[api].lua_open_dll_cdecl(0);
}
else if (g_interfaces[api].lua_open_dll_stdcall != NULL)
{
return g_interfaces[api].lua_open_dll_stdcall(0);
}
assert(0);
return NULL;
}
void lua_close_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_close_dll_cdecl != NULL)
{
g_interfaces[api].lua_close_dll_cdecl(L);
}
else
{
g_interfaces[api].lua_close_dll_stdcall(L);
}
}
lua_State* lua_newthread_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_newthread_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newthread_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_newthread_dll_stdcall(L);
}
}
int lua_error_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_error_dll_cdecl != NULL)
{
return g_interfaces[api].lua_error_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_error_dll_stdcall(L);
}
}
int lua_sethook_dll(unsigned long api, lua_State* L, lua_Hook f, int mask, int count)
{
if (g_interfaces[api].lua_sethook_dll_cdecl != NULL)
{
return g_interfaces[api].lua_sethook_dll_cdecl(L, f, mask, count);
}
else
{
return g_interfaces[api].lua_sethook_dll_stdcall(L, (lua_Hook_stdcall)f, mask, count);
}
}
int lua_getinfo_dll(unsigned long api, lua_State* L, const char* what, lua_Debug* ar)
{
if (g_interfaces[api].lua_getinfo_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getinfo_dll_cdecl(L, what, ar);
}
else
{
return g_interfaces[api].lua_getinfo_dll_stdcall(L, what, ar);
}
}
void lua_remove_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_remove_dll_cdecl != NULL)
{
g_interfaces[api].lua_remove_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_remove_dll_stdcall(L, index);
}
}
void lua_settable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_settable_dll_cdecl != NULL)
{
g_interfaces[api].lua_settable_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_settable_dll_stdcall(L, index);
}
}
void lua_gettable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_gettable_dll_cdecl != NULL)
{
g_interfaces[api].lua_gettable_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_gettable_dll_stdcall(L, index);
}
}
void lua_rawget_dll(unsigned long api, lua_State* L, int idx)
{
if (g_interfaces[api].lua_rawget_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawget_dll_cdecl(L, idx);
}
else
{
g_interfaces[api].lua_rawget_dll_stdcall(L, idx);
}
}
void lua_rawgeti_dll(unsigned long api, lua_State *L, int idx, int n)
{
if (g_interfaces[api].lua_rawgeti_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawgeti_dll_cdecl(L, idx, n);
}
else
{
g_interfaces[api].lua_rawgeti_dll_stdcall(L, idx, n);
}
}
void lua_rawset_dll(unsigned long api, lua_State* L, int idx)
{
if (g_interfaces[api].lua_rawset_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawset_dll_cdecl(L, idx);
}
else
{
g_interfaces[api].lua_rawset_dll_stdcall(L, idx);
}
}
void lua_pushstring_dll(unsigned long api, lua_State* L, const char* s)
{
if (g_interfaces[api].lua_pushstring_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushstring_dll_cdecl(L, s);
}
else
{
g_interfaces[api].lua_pushstring_dll_stdcall(L, s);
}
}
void lua_pushlstring_dll(unsigned long api, lua_State* L, const char* s, size_t len)
{
if (g_interfaces[api].lua_pushlstring_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushlstring_dll_cdecl(L, s, len);
}
else
{
g_interfaces[api].lua_pushlstring_dll_stdcall(L, s, len);
}
}
int lua_type_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_type_dll_cdecl != NULL)
{
return g_interfaces[api].lua_type_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_type_dll_stdcall(L, index);
}
}
const char* lua_typename_dll(unsigned long api, lua_State* L, int type)
{
if (g_interfaces[api].lua_typename_dll_cdecl != NULL)
{
return g_interfaces[api].lua_typename_dll_cdecl(L, type);
}
else
{
return g_interfaces[api].lua_typename_dll_stdcall(L, type);
}
}
int lua_checkstack_dll(unsigned long api, lua_State* L, int extra)
{
if (g_interfaces[api].lua_checkstack_dll_cdecl != NULL)
{
return g_interfaces[api].lua_checkstack_dll_cdecl(L, extra);
}
else
{
return g_interfaces[api].lua_checkstack_dll_stdcall(L, extra);
}
}
void lua_getfield_dll(unsigned long api, lua_State* L, int index, const char* k)
{
// Since Lua 4.0 doesn't include lua_getfield, we just emulate its
// behavior for simplicity.
index = lua_abs_index_dll(api, L, index);
lua_pushstring_dll(api, L, k);
lua_gettable_dll(api, L, index);
}
void lua_setfield_dll(unsigned long api, lua_State* L, int index, const char* k)
{
// Since Lua 4.0 doesn't include lua_setfield, we just emulate its
// behavior for simplicity.
index = lua_abs_index_dll(api, L, index);
lua_pushstring_dll(api, L, k);
lua_insert_dll(api, L, -2);
lua_settable_dll(api, L, index);
}
void lua_settop_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_settop_dll_cdecl != NULL)
{
g_interfaces[api].lua_settop_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_settop_dll_stdcall(L, index);
}
}
const char* lua_getlocal_dll(unsigned long api, lua_State* L, const lua_Debug* ar, int n)
{
if (g_interfaces[api].lua_getlocal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getlocal_dll_cdecl(L, ar, n);
}
else
{
return g_interfaces[api].lua_getlocal_dll_stdcall(L, ar, n);
}
}
const char* lua_setlocal_dll(unsigned long api, lua_State* L, const lua_Debug* ar, int n)
{
if (g_interfaces[api].lua_setlocal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setlocal_dll_cdecl(L, ar, n);
}
else
{
return g_interfaces[api].lua_setlocal_dll_stdcall(L, ar, n);
}
}
int lua_getstack_dll(unsigned long api, lua_State* L, int level, lua_Debug* ar)
{
if (g_interfaces[api].lua_getstack_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getstack_dll_cdecl(L, level, ar);
}
else
{
return g_interfaces[api].lua_getstack_dll_stdcall(L, level, ar);
}
}
void lua_insert_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_insert_dll_cdecl != NULL)
{
g_interfaces[api].lua_insert_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_insert_dll_stdcall(L, index);
}
}
void lua_pushnil_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_pushnil_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushnil_dll_cdecl(L);
}
else
{
g_interfaces[api].lua_pushnil_dll_stdcall(L);
}
}
void lua_pushcclosure_dll(unsigned long api, lua_State* L, lua_CFunction fn, int n)
{
if (g_interfaces[api].lua_pushcclosure_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushcclosure_dll_cdecl(L, fn, n);
}
else
{
g_interfaces[api].lua_pushcclosure_dll_stdcall(L, fn, n);
}
}
void lua_pushvalue_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_pushvalue_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushvalue_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_pushvalue_dll_stdcall(L, index);
}
}
void lua_pushnumber_dll(unsigned long api, lua_State* L, lua_Number value)
{
if (g_interfaces[api].lua_pushnumber_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushnumber_dll_cdecl(L, value);
}
else
{
g_interfaces[api].lua_pushnumber_dll_stdcall(L, value);
}
}
void lua_pushinteger_dll(unsigned long api, lua_State* L, int value)
{
if (g_interfaces[api].lua_pushinteger_dll_cdecl != NULL ||
g_interfaces[api].lua_pushinteger_dll_stdcall != NULL)
{
// Lua 5.0 version.
if (g_interfaces[api].lua_pushinteger_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pushinteger_dll_cdecl(L, value);
}
else
{
return g_interfaces[api].lua_pushinteger_dll_stdcall(L, value);
}
}
else
{
// Fallback to lua_pushnumber on Lua 4.0.
lua_pushnumber_dll(api, L, static_cast<lua_Number>(value));
}
}
void lua_pushlightuserdata_dll(unsigned long api, lua_State* L, void* p)
{
if (g_interfaces[api].lua_pushlightuserdata_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushlightuserdata_dll_cdecl(L, p);
}
else
{
g_interfaces[api].lua_pushlightuserdata_dll_stdcall(L, p);
}
}
const char* lua_tostring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL ||
g_interfaces[api].lua_tostring_dll_stdcall != NULL)
{
// Lua 4.0 implementation.
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tostring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tostring_dll_stdcall(L, index);
}
}
else
{
// Lua 5.0 version.
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tolstring_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tolstring_dll_stdcall(L, index, NULL);
}
}
}
const char* lua_tolstring_dll(unsigned long api, lua_State* L, int index, size_t* len)
{
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL ||
g_interfaces[api].lua_tolstring_dll_stdcall != NULL)
{
// Lua 5.0 version.
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tolstring_dll_cdecl(L, index, len);
}
else
{
return g_interfaces[api].lua_tolstring_dll_stdcall(L, index, len);
}
}
else
{
// Lua 4.0 implementation. lua_tolstring doesn't exist, so we just use lua_tostring
// and compute the length ourself. This means strings with embedded zeros doesn't work
// in Lua 4.0.
const char* string = NULL;
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL)
{
string = g_interfaces[api].lua_tostring_dll_cdecl(L, index);
}
else
{
string = g_interfaces[api].lua_tostring_dll_stdcall(L, index);
}
if (len)
{
if (string)
{
*len = strlen(string);
}
else
{
*len = 0;
}
}
return string;
}
}
int lua_toboolean_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_toboolean_dll_cdecl != NULL)
{
return g_interfaces[api].lua_toboolean_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_toboolean_dll_stdcall(L, index);
}
}
int lua_tointeger_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tointegerx_dll_cdecl != NULL ||
g_interfaces[api].lua_tointegerx_dll_stdcall != NULL)
{
// Lua 5.2 implementation.
if (g_interfaces[api].lua_tointegerx_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tointegerx_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tointegerx_dll_stdcall(L, index, NULL);
}
}
if (g_interfaces[api].lua_tointeger_dll_cdecl != NULL ||
g_interfaces[api].lua_tointeger_dll_stdcall != NULL)
{
// Lua 5.0 implementation.
if (g_interfaces[api].lua_tointeger_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tointeger_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tointeger_dll_stdcall(L, index);
}
}
else
{
// On Lua 4.0 fallback to lua_tonumber.
return static_cast<int>(lua_tonumber_dll(api, L, index));
}
}
lua_CFunction lua_tocfunction_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tocfunction_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tocfunction_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tocfunction_dll_stdcall(L, index);
}
}
lua_Number lua_tonumber_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tonumberx_dll_cdecl != NULL ||
g_interfaces[api].lua_tonumberx_dll_stdcall != NULL)
{
// Lua 5.2 implementation.
if (g_interfaces[api].lua_tonumberx_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tonumberx_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tonumberx_dll_stdcall(L, index, NULL);
}
}
// Lua 5.0 and earlier.
if (g_interfaces[api].lua_tonumber_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tonumber_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tonumber_dll_stdcall(L, index);
}
}
void* lua_touserdata_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_touserdata_dll_cdecl != NULL)
{
return g_interfaces[api].lua_touserdata_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_touserdata_dll_stdcall(L, index);
}
}
int lua_gettop_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_gettop_dll_cdecl != NULL)
{
return g_interfaces[api].lua_gettop_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_gettop_dll_stdcall(L);
}
}
int lua_loadbuffer_dll(unsigned long api, lua_State* L, const char* buffer, size_t size, const char* chunkname)
{
Memory memory;
memory.buffer = buffer;
memory.size = size;
if (g_interfaces[api].lua_load_dll_cdecl != NULL)
{
return g_interfaces[api].lua_load_dll_cdecl(L, MemoryReader_cdecl, &memory, chunkname);
}
else
{
return g_interfaces[api].lua_load_dll_stdcall(L, MemoryReader_stdcall, &memory, chunkname);
}
}
void lua_call_dll(unsigned long api, lua_State* L, int nargs, int nresults)
{
if (g_interfaces[api].lua_call_dll_cdecl != NULL)
{
return g_interfaces[api].lua_call_dll_cdecl(L, nargs, nresults);
}
else
{
return g_interfaces[api].lua_call_dll_stdcall(L, nargs, nresults);
}
}
int lua_pcallk_dll(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k)
{
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pcallk_dll_cdecl(L, nargs, nresults, errfunc, ctx, k);
}
else
{
return g_interfaces[api].lua_pcallk_dll_stdcall(L, nargs, nresults, errfunc, ctx, k);
}
}
int lua_pcall_dll(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc)
{
// Lua 5.2.
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL ||
g_interfaces[api].lua_pcallk_dll_stdcall != NULL)
{
return lua_pcallk_dll(api, L, nargs, nresults, errfunc, 0, NULL);
}
// Lua 5.1 and earlier.
if (g_interfaces[api].lua_pcall_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pcall_dll_cdecl(L, nargs, nresults, errfunc);
}
else
{
return g_interfaces[api].lua_pcall_dll_stdcall(L, nargs, nresults, errfunc);
}
}
void lua_newtable_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_newtable_dll_cdecl != NULL ||
g_interfaces[api].lua_newtable_dll_stdcall != NULL)
{
// Lua 4.0 implementation.
if (g_interfaces[api].lua_newtable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newtable_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_newtable_dll_stdcall(L);
}
}
else
{
// Lua 5.0 version.
if (g_interfaces[api].lua_createtable_dll_cdecl != NULL)
{
g_interfaces[api].lua_createtable_dll_cdecl(L, 0, 0);
}
else
{
g_interfaces[api].lua_createtable_dll_stdcall(L, 0, 0);
}
}
}
int lua_next_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_next_dll_cdecl != NULL)
{
return g_interfaces[api].lua_next_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_next_dll_stdcall(L, index);
}
}
int lua_rawequal_dll(unsigned long api, lua_State *L, int idx1, int idx2)
{
if (g_interfaces[api].lua_rawequal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_rawequal_dll_cdecl(L, idx1, idx2);
}
else
{
return g_interfaces[api].lua_rawequal_dll_stdcall(L, idx1, idx2);
}
}
int lua_getmetatable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_getmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getmetatable_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_getmetatable_dll_stdcall(L, index);
}
}
int lua_setmetatable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_setmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setmetatable_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_setmetatable_dll_stdcall(L, index);
}
}
int luaL_ref_dll(unsigned long api, lua_State *L, int t)
{
if (g_interfaces[api].luaL_ref_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_ref_dll_cdecl(L, t);
}
else if (g_interfaces[api].luaL_ref_dll_stdcall != NULL)
{
return g_interfaces[api].luaL_ref_dll_stdcall(L, t);
}
// We don't require that luaL_ref be present, so provide a suitable
// implementation if it's not.
return LUA_NOREF;
}
void luaL_unref_dll(unsigned long api, lua_State *L, int t, int ref)
{
if (g_interfaces[api].luaL_unref_dll_cdecl != NULL)
{
g_interfaces[api].luaL_unref_dll_cdecl(L, t, ref);
}
else if (g_interfaces[api].luaL_ref_dll_stdcall != NULL)
{
g_interfaces[api].luaL_unref_dll_stdcall(L, t, ref);
}
}
int luaL_newmetatable_dll(unsigned long api, lua_State *L, const char *tname)
{
if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_newmetatable_dll_cdecl(L, tname);
}
else
{
return g_interfaces[api].luaL_newmetatable_dll_stdcall(L, tname);
}
}
int luaL_loadbuffer_dll(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name)
{
if (g_interfaces[api].luaL_loadbuffer_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_loadbuffer_dll_cdecl(L, buff, sz, name);
}
else
{
return g_interfaces[api].luaL_loadbuffer_dll_stdcall(L, buff, sz, name);
}
}
int luaL_loadfile_dll(unsigned long api, lua_State* L, const char* fileName)
{
if (g_interfaces[api].luaL_loadfile_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_loadfile_dll_cdecl(L, fileName);
}
else
{
return g_interfaces[api].luaL_loadfile_dll_stdcall(L, fileName);
}
}
lua_State* luaL_newstate_dll(unsigned long api)
{
if (g_interfaces[api].luaL_newstate_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_newstate_dll_cdecl();
}
else
{
return g_interfaces[api].luaL_newstate_dll_stdcall();
}
}
const lua_WChar* lua_towstring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_towstring_dll_cdecl != NULL ||
g_interfaces[api].lua_towstring_dll_stdcall != NULL)
{
if (g_interfaces[api].lua_towstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_towstring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_towstring_dll_stdcall(L, index);
}
}
else
{
// The application is not using LuaPlus, so just return NULL.
return NULL;
}
}
int lua_iswstring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_iswstring_dll_cdecl != NULL ||
g_interfaces[api].lua_iswstring_dll_stdcall != NULL)
{
if (g_interfaces[api].lua_iswstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_iswstring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_iswstring_dll_stdcall(L, index);
}
}
else
{
// The application is not using LuaPlus, so just return 0.
return 0;
}
}
const char* lua_getupvalue_dll(unsigned long api, lua_State *L, int funcindex, int n)
{
if (g_interfaces[api].lua_getupvalue_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getupvalue_dll_cdecl(L, funcindex, n);
}
else
{
return g_interfaces[api].lua_getupvalue_dll_stdcall(L, funcindex, n);
}
}
const char* lua_setupvalue_dll(unsigned long api, lua_State *L, int funcindex, int n)
{
if (g_interfaces[api].lua_setupvalue_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setupvalue_dll_cdecl(L, funcindex, n);
}
else
{
return g_interfaces[api].lua_setupvalue_dll_stdcall(L, funcindex, n);
}
}
void lua_getfenv_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_getfenv_dll_cdecl != NULL)
{
g_interfaces[api].lua_getfenv_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_getfenv_dll_stdcall(L, index);
}
}
int lua_setfenv_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_setfenv_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setfenv_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_setfenv_dll_stdcall(L, index);
}
}
int lua_cpcall_dll(unsigned long api, lua_State *L, lua_CFunction func, void *ud)
{
if (g_interfaces[api].lua_cpcall_dll_cdecl != NULL)
{
return g_interfaces[api].lua_cpcall_dll_cdecl(L, func, ud);
}
else
{
return g_interfaces[api].lua_cpcall_dll_stdcall(L, func, ud);
}
}
HMODULE WINAPI LoadLibraryExW_intercept(LPCWSTR fileName, HANDLE hFile, DWORD dwFlags)
{
// We have to call the loader lock (if it is available) so that we don't get deadlocks
// in the case where Dll initialization acquires the loader lock and calls LoadLibrary
// while another thread is inside PostLoadLibrary.
ULONG cookie;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrLockLoaderLock_dll(0, 0, &cookie);
}
HMODULE hModule = LoadLibraryExW_dll(fileName, hFile, dwFlags);
if (hModule != NULL)
{
PostLoadLibrary(hModule);
}
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return hModule;
}
void FinishLoadingLua(unsigned long api, bool stdcall)
{
#define SET_STDCALL(function) \
if ( g_interfaces[api].function##_dll_cdecl != NULL) { \
g_interfaces[api].function##_dll_stdcall = reinterpret_cast<function##_stdcall_t>(g_interfaces[api].function##_dll_cdecl); \
g_interfaces[api].function##_dll_cdecl = NULL; \
}
if (g_interfaces[api].finishedLoading)
{
return;
}
g_interfaces[api].stdcall = stdcall;
if (stdcall)
{
SET_STDCALL(lua_newstate);
SET_STDCALL(lua_open);
SET_STDCALL(lua_open_500);
SET_STDCALL(lua_newstate);
SET_STDCALL(lua_newthread);
SET_STDCALL(lua_close);
SET_STDCALL(lua_error);
SET_STDCALL(lua_sethook);
SET_STDCALL(lua_getinfo);
SET_STDCALL(lua_remove);
SET_STDCALL(lua_settable);
SET_STDCALL(lua_gettable);
SET_STDCALL(lua_rawget);
SET_STDCALL(lua_rawgeti);
SET_STDCALL(lua_rawset);
SET_STDCALL(lua_pushstring);
SET_STDCALL(lua_pushlstring);
SET_STDCALL(lua_type);
SET_STDCALL(lua_typename);
SET_STDCALL(lua_settop);
SET_STDCALL(lua_gettop);
SET_STDCALL(lua_getlocal);
SET_STDCALL(lua_setlocal);
SET_STDCALL(lua_getstack);
SET_STDCALL(lua_insert);
SET_STDCALL(lua_pushnil);
SET_STDCALL(lua_pushvalue);
SET_STDCALL(lua_pushinteger);
SET_STDCALL(lua_pushnumber);
SET_STDCALL(lua_pushcclosure);
SET_STDCALL(lua_pushlightuserdata);
SET_STDCALL(lua_tostring);
SET_STDCALL(lua_tolstring);
SET_STDCALL(lua_toboolean);
SET_STDCALL(lua_tointeger);
SET_STDCALL(lua_tointegerx);
SET_STDCALL(lua_tocfunction);
SET_STDCALL(lua_tonumber);
SET_STDCALL(lua_tonumberx);
SET_STDCALL(lua_touserdata);
SET_STDCALL(lua_call);
SET_STDCALL(lua_callk);
SET_STDCALL(lua_pcall);
SET_STDCALL(lua_pcallk);
SET_STDCALL(lua_newtable);
SET_STDCALL(lua_createtable);
SET_STDCALL(lua_load);
SET_STDCALL(lua_next);
SET_STDCALL(lua_rawequal);
SET_STDCALL(lua_getmetatable);
SET_STDCALL(lua_setmetatable);
SET_STDCALL(luaL_ref);
SET_STDCALL(luaL_unref);
SET_STDCALL(luaL_newmetatable);
SET_STDCALL(luaL_loadbuffer);
SET_STDCALL(luaL_loadfile);
SET_STDCALL(lua_getupvalue);
SET_STDCALL(lua_setupvalue);
SET_STDCALL(lua_getfenv);
SET_STDCALL(lua_setfenv);
SET_STDCALL(lua_cpcall);
SET_STDCALL(lua_pushthread);
SET_STDCALL(lua_newuserdata);
SET_STDCALL(lua_pushthread);
SET_STDCALL(lua_checkstack);
}
g_interfaces[api].finishedLoading = true;
DebugBackend::Get().CreateApi(api);
}
#pragma auto_inline(off)
void lua_call_worker(unsigned long api, lua_State* L, int nargs, int nresults, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
int result;
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_call_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_call_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_call_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_call called with too few arguments on the stack", MessageType_Warning);
}
if (DebugBackend::Get().Call(api, L, nargs, nresults, 0))
{
lua_error_dll(api, L);
}
}
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_call_intercept(unsigned long api, lua_State* L, int nargs, int nresults)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_call_worker(api, L, nargs, nresults, stdcall);
INTERCEPT_EPILOG_NO_RETURN(12)
}
#pragma auto_inline(off)
void lua_callk_worker(unsigned long api, lua_State* L, int nargs, int nresults, int ctk, lua_CFunction k, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
int result;
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_callk_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void*)ctk, (void*)k, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_callk_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_callk_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_call called with too few arguments on the stack", MessageType_Warning);
}
if (DebugBackend::Get().Call(api, L, nargs, nresults, 0))
{
lua_error_dll(api, L);
}
}
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_callk_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int ctx, lua_CFunction k)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_callk_worker(api, L, nargs, nresults, ctx, k, stdcall);
INTERCEPT_EPILOG_NO_RETURN(20)
}
#pragma auto_inline(off)
int lua_pcall_worker(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_pcall_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void*)errfunc, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_pcall_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_pcall_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_pcall called with too few arguments on the stack", MessageType_Warning);
}
if (GetAreInterceptsEnabled())
{
result = DebugBackend::Get().Call(api, L, nargs, nresults, errfunc);
}
else
{
result = lua_pcall_dll(api, L, nargs, nresults, errfunc);
}
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_pcall_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_pcall_worker(api, L, nargs, nresults, errfunc, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int lua_pcallk_worker(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_pcall_dll_cdecl, (void*)L, (void*)nargs,
(void*)nresults, (void*)errfunc, (void*)ctx, (void*)k, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_pcallk_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_pcallk called with too few arguments on the stack", MessageType_Warning);
}
if (GetAreInterceptsEnabled())
{
result = DebugBackend::Get().Call(api, L, nargs, nresults, errfunc);
}
else
{
result = lua_pcallk_dll(api, L, nargs, nresults, errfunc, ctx, k);
}
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_pcallk_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_pcallk_worker(api, L, nargs, nresults, errfunc, ctx, k, stdcall);
INTERCEPT_EPILOG(24)
}
#pragma auto_inline(off)
lua_State* lua_newstate_worker(unsigned long api, lua_Alloc f, void* ud, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_newstate_dll_cdecl, (void*)f, ud, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_newstate_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_newstate_dll_cdecl(f, ud);
stdcall = false;
}
else if (g_interfaces[api].lua_newstate_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_newstate_dll_stdcall(f, ud);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_newstate_intercept(unsigned long api, lua_Alloc f, void* ud)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_newstate_worker(api, f, ud, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
lua_State* lua_newthread_worker(unsigned long api, lua_State* L, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_newthread_dll_cdecl, L, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_newthread_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_newthread_dll_cdecl(L);
stdcall = false;
}
else if (g_interfaces[api].lua_newthread_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_newthread_dll_stdcall(L);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_newthread_intercept(unsigned long api, lua_State* L)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_newthread_worker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
#pragma auto_inline(off)
lua_State* lua_open_worker(unsigned long api, int stacksize, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_open_dll_cdecl, (void*)stacksize, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_open_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_open_dll_cdecl(stacksize);
stdcall = false;
}
else if (g_interfaces[api].lua_open_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_open_dll_stdcall(stacksize);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
#pragma auto_inline(off)
lua_State* lua_open_500_worker(unsigned long api, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
// We can't test stdcall with the Lua 5.0 lua_open function since it doesn't
// take any arguments. To do the test, we create a dummy state and destroy it
// using the lua_close function to do the test.
lua_State* L = g_interfaces[api].lua_open_500_dll_cdecl();
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_close_dll_cdecl, (void*)L, (void**)&result);
FinishLoadingLua(api, stdcall);
}
if (g_interfaces[api].lua_open_500_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_open_500_dll_cdecl();
stdcall = false;
}
else if (g_interfaces[api].lua_open_500_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_open_500_dll_stdcall();
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_open_intercept(unsigned long api, int stacksize)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_open_worker(api, stacksize, stdcall);
INTERCEPT_EPILOG(4)
}
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_open_500_intercept(unsigned long api)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_open_500_worker(api, stdcall);
INTERCEPT_EPILOG(0)
}
#pragma auto_inline(off)
int lua_load_worker(unsigned long api, lua_State* L, lua_Reader reader, void* data, const char* name, bool& stdcall)
{
// If we haven't finished loading yet this will be wrong, but we'll fix it up
// when we access the reader function.
stdcall = (g_interfaces[api].lua_load_dll_stdcall != NULL);
// Read all of the data out of the reader and into a big buffer.
std::vector<char> buffer;
const char* chunk;
size_t chunkSize;
do
{
if (!g_interfaces[api].finishedLoading)
{
// In this case we must have attached the debugger so we're intercepting a lua_load
// function before we've initialized.
stdcall = GetIsStdCallConvention(reader, L, data, &chunkSize, (void**)&chunk);
FinishLoadingLua(api, stdcall);
}
else if (stdcall)
{
// We assume that since the lua_load function is stdcall the reader function is as well.
chunk = reinterpret_cast<lua_Reader_stdcall>(reader)(L, data, &chunkSize);
}
else
{
// We assume that since the lua_load function is cdecl the reader function is as well.
chunk = reader(L, data, &chunkSize);
}
// We allow the reader to return 0 for the chunk size since Lua supports
// that, although according to the manual it should return NULL to signal
// the end of the data.
if (chunk != NULL && chunkSize > 0)
{
buffer.insert(buffer.end(), chunk, chunk + chunkSize);
}
}
while (chunk != NULL && chunkSize > 0);
const char* source = NULL;
if (!buffer.empty())
{
source = &buffer[0];
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
// Disables JIT compilation if LuaJIT is being used. Otherwise we won't get hooks for
// this chunk.
if (DebugBackend::Get().EnableJit(api, L, false))
{
if (!g_warnedAboutJit)
{
DebugBackend::Get().Message("Warning 1007: Just-in-time compilation of Lua code disabled to allow debugging", MessageType_Warning);
g_warnedAboutJit = true;
}
}
int result = lua_loadbuffer_dll(api, L, source, buffer.size(), name);
if (!buffer.empty())
{
result = DebugBackend::Get().PostLoadScript(api, result, L, source, buffer.size(), name);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_load_intercept(unsigned long api, lua_State* L, lua_Reader reader, void* data, const char* name)
{
bool stdcall;
int result;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_load_worker(api, L, reader, data, name, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
void lua_close_worker(unsigned long api, lua_State* L, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_close_dll_cdecl, L, NULL);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_close_dll_cdecl != NULL)
{
g_interfaces[api].lua_close_dll_cdecl(L);
stdcall = false;
}
else if (g_interfaces[api].lua_close_dll_stdcall != NULL)
{
g_interfaces[api].lua_close_dll_stdcall(L);
stdcall = true;
}
DebugBackend::Get().DetachState(api, L);
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_close_intercept(unsigned long api, lua_State* L)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_close_worker(api, L, stdcall);
INTERCEPT_EPILOG_NO_RETURN(4)
}
#pragma auto_inline(off)
int luaL_newmetatable_worker(unsigned long api, lua_State *L, const char* tname, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_newmetatable_dll_cdecl, L, (void*)tname, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_newmetatable_dll_cdecl(L, tname);
stdcall = false;
}
else if (g_interfaces[api].luaL_newmetatable_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_newmetatable_dll_stdcall(L, tname);
stdcall = true;
}
if (result != 0)
{
// Only register if we haven't seen this name before.
DebugBackend::Get().RegisterClassName(api, L, tname, lua_gettop_dll(api, L));
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_newmetatable_intercept(unsigned long api, lua_State* L, const char* tname)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_newmetatable_worker(api, L, tname, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
int lua_sethook_worker(unsigned long api, lua_State *L, lua_Hook f, int mask, int count, bool& stdcall)
{
// Currently we're using the hook and can't let anyone else use it.
// What we should do is implement the lua hook on top of our existing hook.
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_sethook_dll_cdecl, L, f, (void*)mask, (void*)count, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].luaL_newmetatable_dll_stdcall != NULL)
{
stdcall = true;
}
// Note, the lua_hook call is currently bypassed.
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_sethook_intercept(unsigned long api, lua_State *L, lua_Hook f, int mask, int count)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_sethook_worker(api, L, f, mask, count, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int luaL_loadbuffer_worker(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name, bool& stdcall)
{
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_loadbuffer_dll_cdecl, L, (void*)buff, (void*)sz, (void*)name, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_loadbuffer_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_loadbuffer_dll_cdecl(L, buff, sz, name);
stdcall = false;
}
else if (g_interfaces[api].luaL_loadbuffer_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_loadbuffer_dll_stdcall(L, buff, sz, name);
stdcall = true;
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
return DebugBackend::Get().PostLoadScript(api, result, L, buff, sz, name);
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_loadbuffer_intercept(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_loadbuffer_worker(api, L, buff, sz, name, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int luaL_loadfile_worker(unsigned long api, lua_State *L, const char *fileName, bool& stdcall)
{
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_loadfile_dll_cdecl, L, (void*)fileName, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_loadfile_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_loadfile_dll_cdecl(L, fileName);
stdcall = false;
}
else if (g_interfaces[api].luaL_loadfile_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_loadfile_dll_stdcall(L, fileName);
stdcall = true;
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
// Load the file.
FILE* file = fopen(fileName, "rb");
if (file != NULL)
{
std::string name = "@";
name += fileName;
fseek(file, 0, SEEK_END);
unsigned int length = ftell(file);
char* buffer = new char[length];
fseek(file, 0, SEEK_SET);
fread(buffer, 1, length, file);
fclose(file);
result = DebugBackend::Get().PostLoadScript(api, result, L, buffer, length, name.c_str());
delete [] buffer;
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_loadfile_intercept(unsigned long api, lua_State *L, const char *fileName)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_loadfile_worker(api, L, fileName, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
lua_State* luaL_newstate_worker(unsigned long api, bool& stdcall)
{
lua_State* result = NULL;
if (g_interfaces[api].luaL_newstate_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_newstate_dll_cdecl();
}
else if (g_interfaces[api].luaL_newstate_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_newstate_dll_stdcall();
}
// Since we couldn't test if luaL_newstate was stdcall or cdecl (since it
// doesn't have any arguments), call another function. lua_gettop is a good
// choice since it has no side effects.
if (!g_interfaces[api].finishedLoading && result != NULL)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_gettop_dll_cdecl, result, NULL);
FinishLoadingLua(api, stdcall);
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* luaL_newstate_intercept(unsigned long api)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_newstate_worker(api, stdcall);
INTERCEPT_EPILOG(0)
}
std::string GetEnvironmentVariable(const std::string& name)
{
DWORD size = ::GetEnvironmentVariable(name.c_str(), NULL, 0);
std::string result;
if (size > 0)
{
char* buffer = new char[size];
buffer[0] = 0;
GetEnvironmentVariable(name.c_str(), buffer, size);
result = buffer;
delete [] buffer;
}
return result;
}
std::string GetApplicationDirectory()
{
char fileName[_MAX_PATH];
GetModuleFileNameEx(GetCurrentProcess(), NULL, fileName, _MAX_PATH);
char* term = strrchr(fileName, '\\');
if (term != NULL)
{
*term = 0;
}
return fileName;
}
bool LoadLuaFunctions(const stdext::hash_map<std::string, DWORD64>& symbols, HANDLE hProcess)
{
#define GET_FUNCTION_OPTIONAL(function) \
{ \
stdext::hash_map<std::string, DWORD64>::const_iterator iterator = symbols.find(#function); \
if (iterator != symbols.end()) \
{ \
luaInterface.function##_dll_cdecl = reinterpret_cast<function##_cdecl_t>(iterator->second); \
} \
}
#define GET_FUNCTION(function) \
GET_FUNCTION_OPTIONAL(function) \
if (luaInterface.function##_dll_cdecl == NULL) \
{ \
if (report) \
{ \
DebugBackend::Get().Message("Warning 1004: Couldn't hook Lua function '" #function "'", MessageType_Warning); \
} \
return false; \
}
#define HOOK_FUNCTION(function) \
if (luaInterface.function##_dll_cdecl != NULL) \
{ \
void* original = luaInterface.function##_dll_cdecl; \
luaInterface.function##_dll_cdecl = (function##_cdecl_t)(HookFunction(original, function##_intercept, api)); \
}
LuaInterface luaInterface = { 0 };
luaInterface.finishedLoading = false;
luaInterface.stdcall = false;
unsigned long api = g_interfaces.size();
bool report = false;
// Check if the lua_tag function exists. This function is only in Lua 4.0 and not in Lua 5.0.
// This helps us differentiate between those two versions.
luaInterface.registryIndex = 0;
luaInterface.globalsIndex = 0;
if (symbols.find("lua_tag") != symbols.end())
{
luaInterface.version = 401;
}
else
{
if (symbols.find("lua_open") != symbols.end())
{
luaInterface.version = 500;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10001;
}
else if (symbols.find("lua_callk") != symbols.end())
{
luaInterface.version = 520;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10001;
}
else
{
luaInterface.version = 510;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10002;
}
}
// Only present in Lua 4.0 and Lua 5.0 (not 5.1)
GET_FUNCTION_OPTIONAL(lua_open);
if (luaInterface.lua_open_dll_cdecl == NULL)
{
GET_FUNCTION(lua_newstate);
}
// Start reporting errors about functions we couldn't hook.
report = true;
GET_FUNCTION(lua_newthread);
GET_FUNCTION(lua_close);
GET_FUNCTION(lua_error);
GET_FUNCTION(lua_sethook);
GET_FUNCTION(lua_getinfo);
GET_FUNCTION(lua_remove);
GET_FUNCTION(lua_settable);
GET_FUNCTION(lua_gettable);
GET_FUNCTION(lua_rawget);
GET_FUNCTION(lua_rawgeti);
GET_FUNCTION(lua_rawset);
GET_FUNCTION(lua_pushstring);
GET_FUNCTION(lua_pushlstring);
GET_FUNCTION(lua_type);
GET_FUNCTION(lua_typename);
GET_FUNCTION(lua_settop);
GET_FUNCTION(lua_gettop);
GET_FUNCTION(lua_getlocal);
GET_FUNCTION(lua_setlocal);
GET_FUNCTION(lua_getstack);
GET_FUNCTION(lua_insert);
GET_FUNCTION(lua_pushnil);
GET_FUNCTION(lua_pushvalue);
GET_FUNCTION(lua_pushcclosure);
GET_FUNCTION(lua_pushnumber);
GET_FUNCTION(lua_pushlightuserdata);
GET_FUNCTION(lua_checkstack);
GET_FUNCTION(lua_gethookmask);
// Only present in Lua 5.1 (*number funtions used in Lua 4.0)
GET_FUNCTION_OPTIONAL(lua_pushinteger);
GET_FUNCTION_OPTIONAL(lua_tointeger);
GET_FUNCTION_OPTIONAL(lua_tointegerx);
// Only present in Lua 4.0 and 5.0 (exists as a macro in Lua 5.1)
GET_FUNCTION_OPTIONAL(lua_tostring);
if (luaInterface.lua_tostring_dll_cdecl == NULL)
{
GET_FUNCTION(lua_tolstring);
}
GET_FUNCTION_OPTIONAL(lua_tonumberx);
if (luaInterface.lua_tonumberx_dll_cdecl == NULL)
{
// If the Lua 5.2 tonumber isn't present, require the previous version.
GET_FUNCTION(lua_tonumber);
}
GET_FUNCTION(lua_toboolean);
GET_FUNCTION(lua_tocfunction);
GET_FUNCTION(lua_touserdata);
// Exists as a macro in Lua 5.2
GET_FUNCTION_OPTIONAL(lua_callk);
if (luaInterface.lua_callk_dll_cdecl == NULL)
{
GET_FUNCTION(lua_call);
}
// Exists as a macro in Lua 5.2
GET_FUNCTION_OPTIONAL(lua_pcallk);
if (luaInterface.lua_pcallk_dll_cdecl == NULL)
{
GET_FUNCTION(lua_pcall);
}
// Only present in Lua 4.0 and 5.0 (exists as a macro in Lua 5.1)
GET_FUNCTION_OPTIONAL(lua_newtable);
if (luaInterface.lua_newtable_dll_cdecl == NULL)
{
GET_FUNCTION(lua_createtable);
}
GET_FUNCTION(lua_load);
GET_FUNCTION(lua_next);
GET_FUNCTION(lua_rawequal);
GET_FUNCTION(lua_getmetatable);
GET_FUNCTION(lua_setmetatable);
GET_FUNCTION_OPTIONAL(luaL_ref);
GET_FUNCTION_OPTIONAL(luaL_unref);
GET_FUNCTION(luaL_newmetatable);
GET_FUNCTION(lua_getupvalue);
GET_FUNCTION(lua_setupvalue);
// We don't currently need these.
GET_FUNCTION_OPTIONAL(lua_getfenv);
GET_FUNCTION_OPTIONAL(lua_setfenv);
GET_FUNCTION_OPTIONAL(lua_cpcall);
if (luaInterface.version >= 510)
{
GET_FUNCTION(lua_pushthread);
}
else
{
// This function doesn't exist in Lua 5.0, so make it optional.
GET_FUNCTION_OPTIONAL(lua_pushthread);
}
GET_FUNCTION(lua_newuserdata);
// This function isn't strictly necessary. We only hook it
// in case the base function was inlined.
GET_FUNCTION_OPTIONAL(luaL_newstate);
GET_FUNCTION_OPTIONAL(luaL_loadbuffer);
GET_FUNCTION_OPTIONAL(luaL_loadfile);
// These functions only exists in LuaPlus.
GET_FUNCTION_OPTIONAL(lua_towstring);
GET_FUNCTION_OPTIONAL(lua_iswstring);
// Hook the functions we need to intercept calls to.
if (luaInterface.version == 500)
{
luaInterface.lua_open_500_dll_cdecl = reinterpret_cast<lua_open_500_cdecl_t>(luaInterface.lua_open_dll_cdecl);
luaInterface.lua_open_dll_cdecl = NULL;
}
HOOK_FUNCTION(lua_open);
HOOK_FUNCTION(lua_open_500);
HOOK_FUNCTION(lua_newstate);
HOOK_FUNCTION(lua_close);
HOOK_FUNCTION(lua_newthread);
HOOK_FUNCTION(lua_pcall);
HOOK_FUNCTION(lua_pcallk);
HOOK_FUNCTION(lua_call);
HOOK_FUNCTION(lua_callk);
HOOK_FUNCTION(lua_load);
HOOK_FUNCTION(luaL_newmetatable);
HOOK_FUNCTION(lua_sethook);
HOOK_FUNCTION(luaL_loadbuffer);
HOOK_FUNCTION(luaL_loadfile);
HOOK_FUNCTION(luaL_newstate);
#ifdef VERBOSE
DebugBackend::Get().Message("Found all necessary Lua functions");
#endif
// Setup our API.
luaInterface.DecodaOutput = (lua_CFunction)InstanceFunction(DecodaOutput, api);
luaInterface.CPCallHandler = (lua_CFunction)InstanceFunction(CPCallHandler, api);
luaInterface.HookHandler = (lua_Hook)InstanceFunction(HookHandler, api);
g_interfaces.push_back( luaInterface );
if (!g_loadedLuaFunctions)
{
DebugBackend::Get().Message("Debugger attached to process");
g_loadedLuaFunctions = true;
}
return true;
}
static PIMAGE_NT_HEADERS PEHeaderFromHModule(HMODULE hModule)
{
PIMAGE_NT_HEADERS pNTHeader = 0;
__try
{
if ( PIMAGE_DOS_HEADER(hModule)->e_magic != IMAGE_DOS_SIGNATURE )
__leave;
pNTHeader = PIMAGE_NT_HEADERS(PBYTE(hModule)
+ PIMAGE_DOS_HEADER(hModule)->e_lfanew);
if ( pNTHeader->Signature != IMAGE_NT_SIGNATURE )
pNTHeader = 0;
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
}
return pNTHeader;
}
/**
* Gets a list of the files that are imported by a module.
*/
bool GetModuleImports(HANDLE hProcess, HMODULE hModule, std::vector<std::string>& imports)
{
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule( hModule );
if ( !pExeNTHdr )
{
return false;
}
DWORD importRVA = pExeNTHdr->OptionalHeader.DataDirectory
[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
if ( !importRVA )
{
return false;
}
// Convert imports RVA to a usable pointer
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = MAKE_PTR( PIMAGE_IMPORT_DESCRIPTOR,
hModule, importRVA );
// Iterate through each import descriptor, and redirect if appropriate
while ( pImportDesc->FirstThunk )
{
PSTR pszImportModuleName = MAKE_PTR( PSTR, hModule, pImportDesc->Name);
imports.push_back(pszImportModuleName);
pImportDesc++; // Advance to next import descriptor
}
return true;
}
bool GetFileExists(const char* fileName)
{
return GetFileAttributes(fileName) != INVALID_FILE_ATTRIBUTES;
}
void ReplaceExtension(char fileName[_MAX_PATH], const char* extension)
{
char* start = strrchr(fileName, '.');
if (start == NULL)
{
strcat(fileName, extension);
}
else
{
strcpy(start + 1, extension);
}
}
void GetFileTitle(const char* fileName, char fileTitle[_MAX_PATH])
{
const char* slash1 = strrchr(fileName, '\\');
const char* slash2 = strrchr(fileName, '/');
const char* pathEnd = max(slash1, slash2);
if (pathEnd == NULL)
{
// There's no path so the whole thing is the file title.
strcpy(fileTitle, fileName);
}
else
{
strcpy(fileTitle, pathEnd + 1);
}
}
void GetFilePath(const char* fileName, char path[_MAX_PATH])
{
const char* slash1 = strrchr(fileName, '\\');
const char* slash2 = strrchr(fileName, '/');
const char* pathEnd = max(slash1, slash2);
if (pathEnd == NULL)
{
// There's no path on the file name.
path[0] = 0;
}
else
{
size_t length = pathEnd - fileName + 1;
memcpy(path, fileName, length);
path[length] = 0;
}
}
bool LocateSymbolFile(const IMAGEHLP_MODULE64& moduleInfo, char fileName[_MAX_PATH])
{
// The search order for symbol files is described here:
// http://msdn2.microsoft.com/en-us/library/ms680689.aspx
// This function doesn't currently support the full spec.
const char* imageFileName = moduleInfo.LoadedImageName;
// First check the absolute path specified in the CodeView data.
if (GetFileExists(moduleInfo.CVData))
{
strncpy(fileName, moduleInfo.CVData, _MAX_PATH);
return true;
}
char symbolTitle[_MAX_PATH];
GetFileTitle(moduleInfo.CVData, symbolTitle);
// Now check in the same directory as the image.
char imagePath[_MAX_PATH];
GetFilePath(imageFileName, imagePath);
strcat(imagePath, symbolTitle);
if (GetFileExists(imagePath))
{
strncpy(fileName, imagePath, _MAX_PATH);
return true;
}
return false;
}
BOOL CALLBACK GatherSymbolsCallback(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
stdext::hash_map<std::string, DWORD64>* symbols = reinterpret_cast<stdext::hash_map<std::string, DWORD64>*>(UserContext);
if (pSymInfo != NULL && pSymInfo->Name != NULL)
{
symbols->insert(std::make_pair(pSymInfo->Name, pSymInfo->Address));
}
return TRUE;
}
BOOL CALLBACK FindSymbolsCallback(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
bool* found = reinterpret_cast<bool*>(UserContext);
*found = true;
return FALSE;
}
bool ScanForSignature(DWORD64 start, DWORD64 length, const char* signature)
{
unsigned int signatureLength = strlen(signature);
for (DWORD64 i = start; i < start + length - signatureLength; ++i)
{
void* p = reinterpret_cast<void*>(i);
// Check that we have read access to the data. For some reason under Windows
// Vista part of the DLL is not accessible (possibly some sort of new delay
// loading mechanism for DLLs?)
if (IsBadReadPtr(reinterpret_cast<LPCSTR>(p), signatureLength))
{
break;
}
if (memcmp(p, signature, signatureLength) == 0)
{
return true;
}
}
return false;
}
void LoadSymbolsRecursively(std::set<std::string>& loadedModules, stdext::hash_map<std::string, DWORD64>& symbols, HANDLE hProcess, HMODULE hModule)
{
assert(hModule != NULL);
char moduleName[_MAX_PATH];
GetModuleBaseName(hProcess, hModule, moduleName, _MAX_PATH);
if (loadedModules.find(moduleName) == loadedModules.end())
{
// Record that we've loaded this module so that we don't
// try to load it again.
loadedModules.insert(moduleName);
MODULEINFO moduleInfo = { 0 };
GetModuleInformation(hProcess, hModule, &moduleInfo, sizeof(moduleInfo));
char moduleFileName[_MAX_PATH];
GetModuleFileNameEx(hProcess, hModule, moduleFileName, _MAX_PATH);
DWORD64 base = SymLoadModule64_dll(hProcess, NULL, moduleFileName, moduleName, (DWORD64)moduleInfo.lpBaseOfDll, moduleInfo.SizeOfImage);
#ifdef VERBOSE
char message[1024];
_snprintf(message, 1024, "Examining '%s' %s\n", moduleName, base ? "(symbols loaded)" : "");
DebugBackend::Get().Log(message);
#endif
// Check to see if there was a symbol file we failed to load (usually
// becase it didn't match the version of the module).
IMAGEHLP_MODULE64 module;
memset(&module, 0, sizeof(module));
module.SizeOfStruct = sizeof(module);
BOOL result = SymGetModuleInfo64_dll(hProcess, base, &module);
if (result && module.SymType == SymNone)
{
// No symbols were found. Check to see if the module file name + ".pdb"
// exists, since the symbol file and/or module names may have been renamed.
char pdbFileName[_MAX_PATH];
strcpy(pdbFileName, moduleFileName);
ReplaceExtension(pdbFileName, "pdb");
if (GetFileExists(pdbFileName))
{
SymUnloadModule64_dll(hProcess, base);
base = SymLoadModule64_dll(hProcess, NULL, pdbFileName, moduleName, (DWORD64)moduleInfo.lpBaseOfDll, moduleInfo.SizeOfImage);
if (base != 0)
{
result = SymGetModuleInfo64_dll(hProcess, base, &module);
}
else
{
result = FALSE;
}
}
}
if (result)
{
// Check to see if we've already warned about this module.
if (g_warnedAboutPdb.find(moduleFileName) == g_warnedAboutPdb.end())
{
if (strlen(module.CVData) > 0 && (module.SymType == SymExport || module.SymType == SymNone))
{
char symbolFileName[_MAX_PATH];
if (LocateSymbolFile(module, symbolFileName))
{
char message[1024];
_snprintf(message, 1024, "Warning 1002: Symbol file '%s' located but it does not match module '%s'", symbolFileName, moduleFileName);
DebugBackend::Get().Message(message, MessageType_Warning);
}
// Remember that we've checked on this file, so no need to check again.
g_warnedAboutPdb.insert(moduleFileName);
}
}
}
if (base != 0)
{
// SymFromName is really slow, so we gather up our own list of the symbols that we
// can index much faster.
SymEnumSymbols_dll(hProcess, base, "lua*", GatherSymbolsCallback, reinterpret_cast<PVOID>(&symbols));
}
// Check to see if the module contains the Lua signature but we didn't find any Lua functions.
if (g_warnedAboutLua.find(moduleFileName) == g_warnedAboutLua.end())
{
// Check to see if this module contains any Lua functions loaded from the symbols.
bool foundLuaFunctions = false;
if (base != 0)
{
SymEnumSymbols_dll(hProcess, base, "lua_*", FindSymbolsCallback, &foundLuaFunctions);
}
if (!foundLuaFunctions)
{
// Check to see if this module contains a string from the Lua source code. If it's there, it probably
// means this module has Lua compiled into it.
bool luaFile = ScanForSignature((DWORD64)hModule, moduleInfo.SizeOfImage, "$Lua:");
if (luaFile)
{
char message[1024];
_snprintf(message, 1024, "Warning 1001: '%s' appears to contain Lua functions however no Lua functions could located with the symbolic information", moduleFileName);
DebugBackend::Get().Message(message, MessageType_Warning);
}
}
// Remember that we've checked on this file, so no need to check again.
g_warnedAboutLua.insert(moduleFileName);
}
// Get the imports for the module. These are loaded before we're able to hook
// LoadLibrary for the module.
std::vector<std::string> imports;
GetModuleImports(hProcess, hModule, imports);
for (unsigned int i = 0; i < imports.size(); ++i)
{
HMODULE hImportModule = GetModuleHandle(imports[i].c_str());
// Sometimes the import module comes back NULL, which means that for some reason
// it wasn't loaded. Perhaps these are delay loaded and we'll catch them later?
if (hImportModule != NULL)
{
LoadSymbolsRecursively(loadedModules, symbols, hProcess, hImportModule);
}
}
}
}
BOOL CALLBACK SymbolCallbackFunction(HANDLE hProcess, ULONG code, ULONG64 data, ULONG64 UserContext)
{
if (code == CBA_DEBUG_INFO)
{
DebugBackend::Get().Message(reinterpret_cast<char*>(data));
}
return TRUE;
}
void PostLoadLibrary(HMODULE hModule)
{
extern HINSTANCE g_hInstance;
if (hModule == g_hInstance)
{
// Don't investigate ourself.
return;
}
HANDLE hProcess = GetCurrentProcess();
char moduleName[_MAX_PATH];
GetModuleBaseName(hProcess, hModule, moduleName, _MAX_PATH);
CriticalSectionLock lock(g_loadedModulesCriticalSection);
if (g_loadedModules.find(moduleName) == g_loadedModules.end())
{
// Record that we've loaded this module so that we don't
// try to load it again.
g_loadedModules.insert(moduleName);
if (!g_initializedDebugHelp)
{
if (!SymInitialize_dll(hProcess, g_symbolsDirectory.c_str(), FALSE))
{
return;
}
g_initializedDebugHelp = true;
}
//SymSetOptions(SYMOPT_DEBUG);
std::set<std::string> loadedModules;
stdext::hash_map<std::string, DWORD64> symbols;
LoadSymbolsRecursively(loadedModules, symbols, hProcess, hModule);
LoadLuaFunctions(symbols, hProcess);
//SymCleanup_dll(hProcess);
//hProcess = NULL;
}
}
void HookLoadLibrary()
{
HMODULE hModuleKernel = GetModuleHandle("kernel32.dll");
if (hModuleKernel != NULL)
{
// LoadLibraryExW is called by the other LoadLibrary functions, so we
// only need to hook it.
LoadLibraryExW_dll = (LoadLibraryExW_t) HookFunction( GetProcAddress(hModuleKernel, "LoadLibraryExW"), LoadLibraryExW_intercept);
}
// These NTDLL functions are undocumented and don't exist in Windows 2000.
HMODULE hModuleNt = GetModuleHandle("ntdll.dll");
if (hModuleNt != NULL)
{
LdrLockLoaderLock_dll = (LdrLockLoaderLock_t) GetProcAddress(hModuleNt, "LdrLockLoaderLock");
LdrUnlockLoaderLock_dll = (LdrUnlockLoaderLock_t) GetProcAddress(hModuleNt, "LdrUnlockLoaderLock");
}
}
bool InstallLuaHooker(HINSTANCE hInstance, const char* symbolsDirectory)
{
// Load the dbghelp functions. We have to do this dynamically since the
// older version of dbghelp that ships with Windows doesn't successfully
// load the symbols from PDBs. We can't simply include our new DLL since
// it needs to be in the directory for the application we're *debugging*
// since this DLL is injected.
if (!LoadDebugHelp(hInstance))
{
return false;
}
g_symbolsDirectory = symbolsDirectory;
// Add the "standard" stuff to the symbols directory search path.
g_symbolsDirectory += ";" + GetApplicationDirectory();
g_symbolsDirectory += ";" + GetEnvironmentVariable("_NT_SYMBOL_PATH");
g_symbolsDirectory += ";" + GetEnvironmentVariable("_NT_ALTERNATE_SYMBOL_PATH");
// Hook LoadLibrary* functions so that we can intercept those calls and search
// for Lua functions.
HookLoadLibrary();
// Avoid deadlock if a new DLL is loaded during this function.
ULONG cookie;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrLockLoaderLock_dll(0, 0, &cookie);
}
// Process all of the loaded modules.
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);
if (hSnapshot == NULL)
{
// If for some reason we couldn't take a snapshot, just load the
// main module. This shouldn't ever happen, but we do it just in
// case.
HMODULE hModule = GetModuleHandle(NULL);
PostLoadLibrary(hModule);
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return true;
}
MODULEENTRY32 module;
module.dwSize = sizeof(MODULEENTRY32);
BOOL moreModules = Module32First(hSnapshot, &module);
while (moreModules)
{
PostLoadLibrary(module.hModule);
moreModules = Module32Next(hSnapshot, &module);
}
CloseHandle(hSnapshot);
hSnapshot = NULL;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return true;
}
bool GetIsLuaLoaded()
{
return g_loadedLuaFunctions;
}
bool GetIsStdCall(unsigned long api)
{
return g_interfaces[api].stdcall;
}
struct CFunctionArgs
{
unsigned long api;
lua_CFunction_dll function;
};
#pragma auto_inline(off)
int CFunctionHandlerWorker(CFunctionArgs* args, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[args->api].stdcall;
return args->function(args->api, L);
}
#pragma auto_inline()
__declspec(naked) int CFunctionHandler(CFunctionArgs* args, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
stdcall = false;
result = CFunctionHandlerWorker(args, L, stdcall);
INTERCEPT_EPILOG(4)
}
lua_CFunction CreateCFunction(unsigned long api, lua_CFunction_dll function)
{
// This is never deallocated, but it doesn't really matter since we never
// destroy these functions.
CFunctionArgs* args = new CFunctionArgs;
args->api = api;
args->function = function;
return (lua_CFunction)InstanceFunction(CFunctionHandler, reinterpret_cast<unsigned long>(args));
} | 31.534209 | 185 | 0.63523 |
de0b01b7a122dc6a5665f7aa8c2ea7043f687258 | 1,065 | cpp | C++ | backends/mysql/factory.cpp | staticlibs/lookaside_soci | b3326cff7d4cf2dc122179eb8b988f2521944550 | [
"BSL-1.0"
] | null | null | null | backends/mysql/factory.cpp | staticlibs/lookaside_soci | b3326cff7d4cf2dc122179eb8b988f2521944550 | [
"BSL-1.0"
] | null | null | null | backends/mysql/factory.cpp | staticlibs/lookaside_soci | b3326cff7d4cf2dc122179eb8b988f2521944550 | [
"BSL-1.0"
] | null | null | null | //
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// MySQL backend copyright (C) 2006 Pawel Aleksander Fedorynski
// 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)
//
#define SOCI_MYSQL_SOURCE
#include "soci-mysql.h"
#include <backend-loader.h>
#include <ciso646>
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace soci;
using namespace soci::details;
// concrete factory for MySQL concrete strategies
mysql_session_backend * mysql_backend_factory::make_session(
connection_parameters const & parameters) const
{
return new mysql_session_backend(parameters);
}
mysql_backend_factory const soci::mysql;
extern "C"
{
// for dynamic backend loading
SOCI_MYSQL_DECL backend_factory const * factory_mysql()
{
return &soci::mysql;
}
SOCI_MYSQL_DECL void register_factory_mysql()
{
soci::dynamic_backends::register_backend("mysql", soci::mysql);
}
} // extern "C"
| 23.152174 | 68 | 0.728638 |
de12667519ef6601b38b263514b401342e376889 | 384 | cpp | C++ | CP-Algorithms/Algebra/3_Number-theoretic functions/N_2_spoj_DIVSUM - Divisor Summation.cpp | Sowmik23/All-Codes | 212ef0d940fa84624bb2972a257768a830a709a3 | [
"MIT"
] | 5 | 2021-02-14T17:48:21.000Z | 2022-01-24T14:29:44.000Z | CP-Algorithms/Algebra/3_Number-theoretic functions/N_2_spoj_DIVSUM - Divisor Summation.cpp | Sowmik23/All-Codes | 212ef0d940fa84624bb2972a257768a830a709a3 | [
"MIT"
] | null | null | null | CP-Algorithms/Algebra/3_Number-theoretic functions/N_2_spoj_DIVSUM - Divisor Summation.cpp | Sowmik23/All-Codes | 212ef0d940fa84624bb2972a257768a830a709a3 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mx = 5e6+1;
ll ans[mx];
void D(int n){
ll sum = 0;
for(int i=1;i*i<=n;i++){
if(n%i==0){
sum+=i;
if(n/i!=i) sum+=(n/i);
}
}
ans[n] =sum;
}
int main(){
int t, n;
scanf("%d", &t);
while(t--){
scanf("%d", &n);
if(ans[n]==0) D(n);
printf("%lld\n", ans[n]-n);
}
return 0;
}
| 10.666667 | 29 | 0.484375 |
de1512531606f78f11f625dbbea6669b2579e2e4 | 1,843 | cpp | C++ | CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp | Zemurin/CK2ToEU4 | f28971fb877497cc4117689d1600a8721466c365 | [
"MIT"
] | 3 | 2020-05-06T21:50:00.000Z | 2022-03-15T19:16:19.000Z | CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp | Zemurin/CK2ToEU4 | f28971fb877497cc4117689d1600a8721466c365 | [
"MIT"
] | 3 | 2022-02-01T19:35:02.000Z | 2022-03-02T17:34:16.000Z | CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp | Zemurin/CK2ToEU4 | f28971fb877497cc4117689d1600a8721466c365 | [
"MIT"
] | 1 | 2020-05-06T21:50:04.000Z | 2020-05-06T21:50:04.000Z | #include "BuildTriggerBuilder.h"
#include "CommonRegexes.h"
#include "ParserHelpers.h"
#include <iomanip>
mappers::BuildTriggerBuilder::BuildTriggerBuilder()
{
registerKeys();
clearRegisteredKeywords();
}
mappers::BuildTriggerBuilder::BuildTriggerBuilder(std::istream& theStream)
{
registerKeys();
parseStream(theStream);
clearRegisteredKeywords();
buildTrigger += "\n\t}";
}
void mappers::BuildTriggerBuilder::registerKeys()
{
registerKeyword("religious_groups", [this](const std::string& mods, std::istream& theStream) {
const auto& groups = commonItems::stringList(theStream).getStrings();
for (auto& group: groups)
{
buildTrigger += ("AND = {\n\t\t\t\treligion_group = " + group + "\n\t\t\t\thas_owner_religion = yes\n\t\t\t}\n\t\t");
}
});
registerKeyword("cultural_groups", [this](const std::string& mods, std::istream& theStream) {
const auto& groups = commonItems::stringList(theStream).getStrings();
for (auto& group: groups)
{
buildTrigger += ("AND = {\n\t\t\t\tculture_group = " + group + "\n\t\t\t\thas_owner_culture = yes\n\t\t\t}\n\t\t");
}
});
registerKeyword("cultural", [this](const std::string& mods, std::istream& theStream) {
cultural = commonItems::getString(theStream).find("yes") != std::string::npos;
});
registerKeyword("religious", [this](const std::string& mods, std::istream& theStream) {
religious = commonItems::getString(theStream).find("yes") != std::string::npos;
});
registerKeyword("other", [this](const std::string& mods, std::istream& theStream) {
auto tempInput = commonItems::stringOfItem(theStream).getString();
tempInput = tempInput.substr(tempInput.find('{') + 1, tempInput.length());
tempInput = tempInput.substr(0, tempInput.find_last_of('}'));
buildTrigger += tempInput;
});
registerRegex(commonItems::catchallRegex, commonItems::ignoreItem);
} | 37.612245 | 120 | 0.708627 |
de1762591476a9ae30810597e9db0c6e6f0d2d72 | 3,001 | hpp | C++ | include/paal/greedy/knapsack_unbounded_two_app.hpp | Kommeren/AA | e537b58d50e93d4a72709821b9ea413008970c6b | [
"BSL-1.0"
] | null | null | null | include/paal/greedy/knapsack_unbounded_two_app.hpp | Kommeren/AA | e537b58d50e93d4a72709821b9ea413008970c6b | [
"BSL-1.0"
] | null | null | null | include/paal/greedy/knapsack_unbounded_two_app.hpp | Kommeren/AA | e537b58d50e93d4a72709821b9ea413008970c6b | [
"BSL-1.0"
] | 1 | 2021-02-24T06:23:56.000Z | 2021-02-24T06:23:56.000Z | //=======================================================================
// Copyright (c) 2013 Piotr Wygocki
//
// 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)
//=======================================================================
/**
* @file knapsack_unbounded_two_app.hpp
* @brief
* @author Piotr Wygocki
* @version 1.0
* @date 2013-10-07
*/
#ifndef PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
#define PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
#include "paal/utils/accumulate_functors.hpp"
#include "paal/utils/type_functions.hpp"
#include "paal/greedy/knapsack/knapsack_greedy.hpp"
#include <boost/iterator/counting_iterator.hpp>
#include <boost/iterator/filter_iterator.hpp>
#include <type_traits>
#include <utility>
namespace paal {
namespace detail {
template <typename KnapsackData,
typename ObjectIter = typename KnapsackData::object_iter,
typename Size = typename KnapsackData::size,
typename Value = typename KnapsackData::value>
std::tuple<Value, Size,
std::pair<ObjectIter, unsigned>>
get_greedy_fill(KnapsackData knap_data, unbounded_tag) {
auto density = knap_data.get_density();
auto most_dense_iter = max_element_functor(
knap_data.get_objects(), density).base();
unsigned nr = knap_data.get_capacity() / knap_data.get_size(*most_dense_iter);
Value value_sum = Value(nr) * knap_data.get_value(*most_dense_iter);
Size size_sum = Size (nr) * knap_data.get_size (*most_dense_iter);
return std::make_tuple(value_sum, size_sum,
std::make_pair(most_dense_iter, nr));
}
template <typename ObjectsIterAndNr, typename OutputIter>
void greedy_to_output(ObjectsIterAndNr most_dense_iter_and_nr, OutputIter & out,
unbounded_tag) {
auto nr = most_dense_iter_and_nr.second;
auto most_dense_iter = most_dense_iter_and_nr.first;
for (unsigned i = 0; i < nr; ++i) {
*out = *most_dense_iter;
++out;
}
}
} //! detail
///this version of algorithm might permute, the input range
template <typename OutputIterator, typename Objects,
typename ObjectSizeFunctor, typename ObjectValueFunctor,
//this enable if assures that range can be permuted
typename std::enable_if<!detail::is_range_const<Objects>::value>::type * = nullptr>
typename detail::knapsack_base<Objects, ObjectSizeFunctor,
ObjectValueFunctor>::return_type
knapsack_unbounded_two_app(
Objects && objects,
typename detail::FunctorOnRangePValue<ObjectSizeFunctor, Objects> capacity,
OutputIterator out, ObjectValueFunctor value, ObjectSizeFunctor size) {
return detail::knapsack_general_two_app(
detail::make_knapsack_data(std::forward<Objects>(objects), capacity, size, value, out),
detail::unbounded_tag{});
}
} //! paal
#endif // PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
| 37.049383 | 99 | 0.682439 |
de186757d5f211e9eefcc8284dab4f7f0f29630d | 1,920 | hpp | C++ | include/clotho/cuda/sampling/random_sample_sequence.hpp | putnampp/clotho | 6dbfd82ef37b4265381cd78888cd6da8c61c68c2 | [
"ECL-2.0",
"Apache-2.0"
] | 3 | 2015-06-16T21:27:57.000Z | 2022-01-25T23:26:54.000Z | include/clotho/cuda/sampling/random_sample_sequence.hpp | putnampp/clotho | 6dbfd82ef37b4265381cd78888cd6da8c61c68c2 | [
"ECL-2.0",
"Apache-2.0"
] | 3 | 2015-06-16T21:12:42.000Z | 2015-06-23T12:41:00.000Z | include/clotho/cuda/sampling/random_sample_sequence.hpp | putnampp/clotho | 6dbfd82ef37b4265381cd78888cd6da8c61c68c2 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | // Copyright 2015 Patrick Putnam
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
#define RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
#include "clotho/cuda/sampling/random_sample_def.hpp"
#include "clotho/cuda/data_spaces/sequence_space/device_sequence_space.hpp"
#include "clotho/cuda/data_spaces/basic_data_space.hpp"
template < class StateType, class IntType, class IntType2 = unsigned int >
__global__ void random_sample( StateType * states
, device_sequence_space< IntType > * src
, unsigned int N
, basic_data_space< IntType2 > * index_space ) {
typedef StateType state_type;
unsigned int tid = threadIdx.y * blockDim.x + threadIdx.x;
state_type local_state = states[ tid ];
IntType2 M = src->seq_count;
if( tid == 0 ) {
_resize_space_impl( index_space, N );
}
__syncthreads();
unsigned int i = tid;
unsigned int * ids = index_space->data;
unsigned int tpb = blockDim.x * blockDim.y;
while( i < N ) {
float x = curand_uniform( &local_state );
IntType2 pidx = (IntType2)(x * M);
pidx = ((pidx >= M) ? 0 : pidx); // wrap around indexes
ids[ i ] = pidx;
i += tpb;
}
states[tid] = local_state;
}
#endif // RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
| 32.542373 | 80 | 0.657292 |
de1b873ac8cff20111a6c634b943f4765b8106c7 | 1,964 | hpp | C++ | modules/trustchain/include/Tanker/Trustchain/Actions/UserGroupAddition.hpp | TankerHQ/sdk-native | 5d9eb7c2048fdefae230590a3110e583f08c2c49 | [
"Apache-2.0"
] | 19 | 2018-12-05T12:18:02.000Z | 2021-07-13T07:33:22.000Z | modules/trustchain/include/Tanker/Trustchain/Actions/UserGroupAddition.hpp | TankerHQ/sdk-native | 5d9eb7c2048fdefae230590a3110e583f08c2c49 | [
"Apache-2.0"
] | 3 | 2020-03-16T15:52:06.000Z | 2020-08-01T11:14:30.000Z | modules/trustchain/include/Tanker/Trustchain/Actions/UserGroupAddition.hpp | TankerHQ/sdk-native | 5d9eb7c2048fdefae230590a3110e583f08c2c49 | [
"Apache-2.0"
] | 3 | 2020-01-07T09:55:32.000Z | 2020-08-01T01:29:28.000Z | #pragma once
#include <Tanker/Crypto/Hash.hpp>
#include <Tanker/Crypto/PrivateSignatureKey.hpp>
#include <Tanker/Crypto/Signature.hpp>
#include <Tanker/Serialization/SerializedSource.hpp>
#include <Tanker/Trustchain/Actions/Nature.hpp>
#include <Tanker/Trustchain/Actions/UserGroupAddition/v1.hpp>
#include <Tanker/Trustchain/Actions/UserGroupAddition/v2.hpp>
#include <Tanker/Trustchain/Actions/UserGroupAddition/v3.hpp>
#include <Tanker/Trustchain/GroupId.hpp>
#include <Tanker/Trustchain/Preprocessor/Actions/Json.hpp>
#include <Tanker/Trustchain/Preprocessor/Actions/Serialization.hpp>
#include <Tanker/Trustchain/Preprocessor/Actions/VariantImplementation.hpp>
#include <Tanker/Trustchain/UserId.hpp>
#include <boost/variant2/variant.hpp>
#include <nlohmann/json_fwd.hpp>
#include <cstddef>
#include <cstdint>
#include <utility>
#include <vector>
namespace Tanker
{
namespace Trustchain
{
namespace Actions
{
#define TANKER_TRUSTCHAIN_ACTIONS_USER_GROUP_ADDITION_ATTRIBUTES \
(trustchainId, TrustchainId), (groupId, GroupId), \
(previousGroupBlockHash, Crypto::Hash), \
(selfSignature, Crypto::Signature), (author, Crypto::Hash), \
(signature, Crypto::Signature)
class UserGroupAddition
{
TANKER_TRUSTCHAIN_ACTION_VARIANT_IMPLEMENTATION(
UserGroupAddition,
(UserGroupAddition1, UserGroupAddition2, UserGroupAddition3),
TANKER_TRUSTCHAIN_ACTIONS_USER_GROUP_ADDITION_ATTRIBUTES)
public:
using v1 = UserGroupAddition1;
using v2 = UserGroupAddition2;
using v3 = UserGroupAddition3;
Nature nature() const;
std::vector<std::uint8_t> signatureData() const;
};
// The nature is not present in the wired payload.
// Therefore there is no from_serialized overload for UserGroupAddition.
std::uint8_t* to_serialized(std::uint8_t*, UserGroupAddition const&);
std::size_t serialized_size(UserGroupAddition const&);
void to_json(nlohmann::json&, UserGroupAddition const&);
}
}
}
| 31.677419 | 75 | 0.775458 |
de1bc3d98cf3febde5e05f2ab8b3ce6f4fabfdc4 | 2,739 | cpp | C++ | src/ssd/NVM_Transaction_Flash.cpp | rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference | 61546ccbae3ecd4312757cb54ac9af5a0d01e9ae | [
"MIT"
] | null | null | null | src/ssd/NVM_Transaction_Flash.cpp | rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference | 61546ccbae3ecd4312757cb54ac9af5a0d01e9ae | [
"MIT"
] | null | null | null | src/ssd/NVM_Transaction_Flash.cpp | rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference | 61546ccbae3ecd4312757cb54ac9af5a0d01e9ae | [
"MIT"
] | null | null | null | #include "NVM_Transaction_Flash.h"
#include "assert.h"
namespace SSD_Components
{
NVM_Transaction_Flash::NVM_Transaction_Flash(
Transaction_Source_Type source,
Transaction_Type type,
stream_id_type stream_id,
unsigned int data_size_in_byte,
LPA_type lpa,
PPA_type ppa,
User_Request* user_request):
NVM_Transaction(
stream_id,
source,
type,
user_request),
Data_and_metadata_size_in_byte(data_size_in_byte),
Physical_address_determined(false),
FLIN_Barrier(false)
{
LPAs.push_back (lpa);
PPAs.push_back (ppa);
}
NVM_Transaction_Flash::NVM_Transaction_Flash(
Transaction_Source_Type source,
Transaction_Type type,
stream_id_type stream_id,
unsigned int data_size_in_byte,
LPA_type lpa,
PPA_type ppa,
const NVM::FlashMemory::Physical_Page_Address& address,
User_Request* user_request) :
NVM_Transaction(
stream_id,
source,
type,
user_request),
Data_and_metadata_size_in_byte(data_size_in_byte),
Address(address),
Physical_address_determined(false)
{
LPAs.push_back (lpa);
PPAs.push_back (ppa);
}
//FGM - LPAs
unsigned int NVM_Transaction_Flash::num_lpas ()
{
return LPAs.size ();
}
LPA_type NVM_Transaction_Flash::get_lpa ()
{
if (!LPAs.empty()) return LPAs[0];
}
LPA_type NVM_Transaction_Flash::get_lpa (int idx)
{
if (!LPAs.empty()) return LPAs[idx];
}
void NVM_Transaction_Flash::set_lpa (LPA_type lpa)
{
if (!LPAs.empty()) LPAs.push_back (lpa);
else LPAs[0] = lpa;
}
void NVM_Transaction_Flash::set_lpa (LPA_type lpa, int idx)
{
assert(LPAs.size() >= idx);
if (LPAs.empty()) LPAs.push_back(lpa);
else LPAs[idx] = lpa;
}
//FGM - PPAs
unsigned int NVM_Transaction_Flash::num_ppas ()
{
return PPAs.size ();
}
PPA_type NVM_Transaction_Flash::get_ppa ()
{
if (!PPAs.empty()) return PPAs[0];
}
PPA_type NVM_Transaction_Flash::get_ppa (int idx)
{
if (!PPAs.empty()) return PPAs[idx];
}
void NVM_Transaction_Flash::set_ppa (PPA_type ppa)
{
if (!PPAs.empty()) PPAs.push_back (ppa);
else PPAs[0] = ppa;
}
void NVM_Transaction_Flash::set_ppa (PPA_type ppa, int idx)
{
assert(PPAs.size() >= idx);
if (PPAs.empty()) PPAs.push_back (ppa);
else PPAs[idx] = ppa;
}
//FGM - LPAs for GC
void NVM_Transaction_Flash::replace_lpa(LPA_type lpa, int idx, int i)
{
assert(!LPAs.empty());
LPAs.erase ( LPAs.begin() + idx );
LPAs.insert( LPAs.begin()+ idx, lpa);
Waiting_LPAs.erase( Waiting_LPAs.begin() + i );
}
void NVM_Transaction_Flash:: set_waiting_lpas (LPA_type lpa)
{
Waiting_LPAs.push_back(lpa);
}
LPA_type NVM_Transaction_Flash:: get_waiting_lpas (int idx)
{
assert(!Waiting_LPAs.empty());
return Waiting_LPAs[idx];
}
}
| 22.08871 | 70 | 0.700256 |
de1cad88979b70e2929438d25bd08990d0b61807 | 571 | cpp | C++ | Hackerrank/Ice Cream Parlor.cpp | SurgicalSteel/Competitive-Programming | 3662b676de94796f717b25dc8d1b93c6851fb274 | [
"MIT"
] | 14 | 2016-02-11T09:26:13.000Z | 2022-03-27T01:14:29.000Z | Hackerrank/Ice Cream Parlor.cpp | SurgicalSteel/Competitive-Programming | 3662b676de94796f717b25dc8d1b93c6851fb274 | [
"MIT"
] | null | null | null | Hackerrank/Ice Cream Parlor.cpp | SurgicalSteel/Competitive-Programming | 3662b676de94796f717b25dc8d1b93c6851fb274 | [
"MIT"
] | 7 | 2016-10-25T19:29:35.000Z | 2021-12-05T18:31:39.000Z | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int tc,m,n,temp;
scanf("%d",&tc);
for(int i=0;i<tc;i++)
{
vector<int> v;
cin>>m>>n;
for(int x=0;x<n;x++)
{
cin>>temp;
v.push_back(temp);
}
for(int x=0;x<v.size();x++)
{
for(int y=x+1;y<v.size();y++)
{
if(v[x]+v[y]==m)
printf("%d %d\n",x+1,y+1);
}
}
}
return 0;
}
| 19.033333 | 42 | 0.401051 |
de1d06e0de9697325f3340fbd3fbeb80b7bd7893 | 499 | cpp | C++ | app/src/main/cpp/src/meshes/sphere.cpp | danielesteban/GLTest | 62f9e45adc1073d3d8ad5072266dc8a353f6e421 | [
"MIT"
] | 3 | 2018-01-01T14:27:29.000Z | 2019-01-20T03:14:41.000Z | app/src/main/cpp/src/meshes/sphere.cpp | danielesteban/GLTest | 62f9e45adc1073d3d8ad5072266dc8a353f6e421 | [
"MIT"
] | null | null | null | app/src/main/cpp/src/meshes/sphere.cpp | danielesteban/GLTest | 62f9e45adc1073d3d8ad5072266dc8a353f6e421 | [
"MIT"
] | null | null | null | #include "sphere.hpp"
void Sphere::init(btDiscreteDynamicsWorld *world, Model *model, const btVector3 position) {
Mesh::init(world, model, position, btQuaternion(0.0f, 0.0f, 0.0f, 1.0f), btScalar(5.0f));
albedo = glm::vec4(
(float) rand() / (float) RAND_MAX,
(float) rand() / (float) RAND_MAX,
(float) rand() / (float) RAND_MAX,
1.0f
);
}
void Sphere::render(const Camera *camera) {
glUniform4fv(model->shader->albedo, 1, glm::value_ptr(albedo));
Mesh::render(camera);
}
| 29.352941 | 91 | 0.661323 |
de1e25b54835b3689096547539a1649446d6c1eb | 1,464 | cpp | C++ | test/2pc.cpp | themighty1/emp-ag2pc | 18d8fd3965a749b5e994454bf0237ec2acb3019b | [
"MIT"
] | 18 | 2017-11-02T23:05:14.000Z | 2022-01-29T10:22:16.000Z | test/2pc.cpp | boltlabs-inc/emp-ag2pc | c5c38f212c5f51b71815071505c5430d2b1eb524 | [
"MIT"
] | 20 | 2017-12-18T07:34:59.000Z | 2021-12-08T04:31:06.000Z | test/2pc.cpp | boltlabs-inc/emp-ag2pc | c5c38f212c5f51b71815071505c5430d2b1eb524 | [
"MIT"
] | 19 | 2017-12-18T07:01:09.000Z | 2022-03-18T13:23:35.000Z | #include <emp-tool/emp-tool.h>
#include "2pc.h"
using namespace std;
using namespace emp;
const string circuit_file_location = macro_xstr(EMP_CIRCUIT_PATH);
static char out3[] = "92b404e556588ced6c1acd4ebf053f6809f73a93";//bafbc2c87c33322603f38e06c3e0f79c1f1b1475";
int main(int argc, char** argv) {
int port, party;
parse_party_and_port(argv, &party, &port);
NetIO* io = new NetIO(party==ALICE ? nullptr:IP, port);
io->set_nodelay();
string file = circuit_file_location+"/sha-1.txt";
CircuitFile cf(file.c_str());
auto t1 = clock_start();
C2PC twopc(io, party, &cf);
io->flush();
cout << "one time:\t"<<party<<"\t" <<time_from(t1)<<endl;
t1 = clock_start();
twopc.function_independent();
io->flush();
cout << "inde:\t"<<party<<"\t"<<time_from(t1)<<endl;
t1 = clock_start();
twopc.function_dependent();
io->flush();
cout << "dep:\t"<<party<<"\t"<<time_from(t1)<<endl;
bool in[512], out[512];
if(party == ALICE) {
in[0] = in[1] = true;
in[2] = in[3] = false;
} else {
in[0] = in[2] = true;
in[1] = in[3] = false;
}
for(int i = 0; i < 512; ++i)
in[i] = false;
t1 = clock_start();
twopc.online(in, out);
cout << "online:\t"<<party<<"\t"<<time_from(t1)<<endl;
if(party == BOB){
string res = "";
for(int i = 0; i < 160; ++i)
res += (out[i]?"1":"0");
// cout << hex_to_binary(string(out3))<<endl;
// cout << res<<endl;
cout << (res == hex_to_binary(string(out3))? "GOOD!":"BAD!")<<endl;
}
delete io;
return 0;
}
| 25.684211 | 108 | 0.623634 |
de20076bcede28ced3262762f5efb7d754b21b9f | 2,441 | cpp | C++ | ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp | emengdeath/acmcode | cc1b0e067464e754d125856004a991d6eb92a2cd | [
"MIT"
] | null | null | null | ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp | emengdeath/acmcode | cc1b0e067464e754d125856004a991d6eb92a2cd | [
"MIT"
] | null | null | null | ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp | emengdeath/acmcode | cc1b0e067464e754d125856004a991d6eb92a2cd | [
"MIT"
] | null | null | null | #include<iostream>
#include<algorithm>
#include<cstdio>
#define N 1000000
using namespace std;
int f[N][2],size[N];
int n,tot;
int g[N],d[N],a[N][4],fa[N],b[N];
struct node{
int x,l,r;
}c[N];
int sum;
void ins(int x,int y){
a[++sum][0]=y,a[sum][1]=g[x],g[x]=sum;
}
void dfs(int x){
size[x]=1;
for (int i=g[x];i;i=a[i][1])
dfs(a[i][0]),size[x]+=size[a[i][0]];
d[0]=0;
for (int i=g[x];i;i=a[i][1])
d[++d[0]]=i;
f[x][0]=f[x][1]=0;
while (d[0]){
int v=f[x][0];
int i=d[d[0]--];
if (f[a[i][0]][0]>=f[a[i][0]][1])a[i][2]=0;
else
a[i][2]=1;
f[x][0]=f[x][0]+max(f[a[i][0]][0],f[a[i][0]][1]);
if (f[x][1]+max(f[a[i][0]][0],f[a[i][0]][1])>=v+f[a[i][0]][0]+1){
if (f[a[i][0]][0]>=f[a[i][0]][1])
a[i][3]=0;
else
a[i][3]=1;
}else
a[i][3]=2;
f[x][1]=max(f[x][1]+max(f[a[i][0]][0],f[a[i][0]][1]),v+f[a[i][0]][0]+1);
}
}
void dfs1(int x,int y){
if (!g[x])return;
for (int i=g[x];i;i=a[i][1]){
if (y){
if (a[i][3]==0){
b[++b[0]]=a[i][0],dfs1(a[i][0],0);
}else
if (a[i][3]==1){
dfs1(a[i][0],1);
}else
y=0,dfs1(a[i][0],0);
}else{
if (a[i][2]==0)b[++b[0]]=a[i][0],dfs1(a[i][0],0);
else
dfs1(a[i][0],1);
}
}
}
bool cmp(const node&a,const node&b){
return a.r-a.l>b.r-b.l;
}
void update(int x,int y){
ins(x,y);
fa[y]=x;
}
int main(){
freopen("hidden.in","r",stdin);
freopen("hidden.out","w",stdout);
scanf("%d",&n);
for (int i=2;i<=n;i++){
scanf("%d",&fa[i]);
if (fa[i])
ins(fa[i],i);
}
c[++tot].x=1;
c[tot].l=b[0]+1;
dfs(1);
if (f[1][0]>=f[1][1])b[++b[0]]=1,dfs1(1,0);
else
dfs1(1,1);
c[tot].r=b[0];
for (int i=2;i<=n;i++)
if (!fa[i]){
dfs(i);
if (f[i][1]*2==size[i]){
update(1,i);
continue;
}
c[++tot].x=i;
c[tot].l=b[0]+1;
b[++b[0]]=i;
for (int j=g[i];j;j=a[j][1]){
dfs(a[j][0]);
if (f[a[j][0]][0]>=f[a[j][0]][1])b[++b[0]]=a[j][0],dfs1(a[j][0],0);
else
dfs1(a[j][0],1);
}
c[tot].r=b[0];
}
sort(c+2,c+tot+1,cmp);
int l=1;
d[0]=0;
for (int i=c[1].l;i<=c[1].r;i++)
d[++d[0]]=b[i];
for (int i=2;i<=tot;i++){
if (l<=d[0]){
update(d[l],c[i].x);
l++;
for (int j=c[i].l+1;j<=c[i].r;j++)
d[++d[0]]=b[j];
}else{
update(1,c[i].x);
d[++d[0]]=c[i].x;
swap(d[l],d[d[0]]);
for (int j=c[i].l+1;j<=c[i].r;j++)
d[++d[0]]=b[j];
}
}
dfs(1);
printf("%d\n",max(f[1][1],f[1][0]));
printf("%d",fa[2]);
for (int i=3;i<=n;i++)
printf(" %d",fa[i]);
return 0;
}
| 19.373016 | 74 | 0.436706 |
de24e400710212eb9a22f123a370205a326213a9 | 1,424 | cpp | C++ | src/States/Menu/MainMenu.cpp | BertilBraun/MyClone | 9573084e9a561b91995683ba016088174414a545 | [
"MIT"
] | 4 | 2019-01-10T18:39:53.000Z | 2022-01-15T21:38:28.000Z | src/States/Menu/MainMenu.cpp | BOTOrtwin/MyClone | 9573084e9a561b91995683ba016088174414a545 | [
"MIT"
] | 14 | 2018-09-30T21:48:35.000Z | 2018-10-05T08:46:40.000Z | src/States/Menu/MainMenu.cpp | BOTOrtwin/MyClone | 9573084e9a561b91995683ba016088174414a545 | [
"MIT"
] | 1 | 2019-12-23T19:35:54.000Z | 2019-12-23T19:35:54.000Z | #include "MainMenu.h"
#include "Utils/ToggleKey.h"
#include "Application.h"
#include "MenuWorldSelect.h"
MainMenu::MainMenu(Application& applic) :
StateBase(applic),
background(glm::vec2(0.5f, 0.5f), glm::vec2(1, 1), "GUI/background.jpg", (*app->getWindow()))
{
buttons.emplace_back(glm::vec2(0.5f, 0.4f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "PLAY", (*app->getWindow()), [&] { app->pushState<MenuWorldSelect>(*app); });
buttons.emplace_back(glm::vec2(0.5f, 0.5f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "OPTIONS NA", (*app->getWindow()));
buttons.emplace_back(glm::vec2(0.5f, 0.6f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "QUIT", (*app->getWindow()), [&] { app->popState(); });
}
MainMenu::~MainMenu()
{
}
void MainMenu::handleInput(float deltaTime, const Camera & camera)
{
}
void MainMenu::update(float deltaTime) {
for (Button& button : buttons)
button.pressed((*app->getWindow()));
}
void MainMenu::render(MasterRenderer & renderer) {
background.draw(renderer);
for (Button& button : buttons)
button.draw(renderer);
}
void MainMenu::onOpen() {
const sf::RenderWindow& window = (*app->getWindow());
sf::Mouse::setPosition(sf::Vector2i(sf::Vector2f(window.getSize()) / 2.0f), window);
app->turnOnMouse();
updateCamera = false;
}
void MainMenu::onResume() {
app->turnOnMouse();
updateCamera = false;
for (Button& button : buttons)
button.resetButton();
}
| 27.921569 | 172 | 0.67486 |
de27a6c8f9bbc73849ed220220a0e518f1332b0c | 10,225 | cpp | C++ | OpenGL3DRendering/src/Renderer/Renderer.cpp | Sarius587/OpenGL3DRendering | fb87593a2c36c473ae5665fba6f16cfb55461b21 | [
"Apache-2.0"
] | 1 | 2020-06-01T06:35:39.000Z | 2020-06-01T06:35:39.000Z | OpenGL3DRendering/src/Renderer/Renderer.cpp | Sarius587/OpenGL3DRendering | fb87593a2c36c473ae5665fba6f16cfb55461b21 | [
"Apache-2.0"
] | null | null | null | OpenGL3DRendering/src/Renderer/Renderer.cpp | Sarius587/OpenGL3DRendering | fb87593a2c36c473ae5665fba6f16cfb55461b21 | [
"Apache-2.0"
] | null | null | null | #include "oglpch.h"
#include "Renderer.h"
#include "RendererAPI.h"
#include "Framebuffer.h"
namespace OpenGLRendering {
struct MeshInfo
{
Ref<VertexArray> VertexArray;
Ref<Material> Material;
glm::mat4 ModelMatrix;
};
struct RendererData
{
Ref<Camera> Camera;
Ref<Cubemap> Cubemap;
Ref<Shader> PBRShaderTextured;
Ref<Shader> PBRShader;
Ref<Shader> CubemapShader;
Ref<Shader> ColorGradingShader;
Ref<Shader> InvertColorShader;
Ref<Framebuffer> MultisampleFramebuffer;
Ref<Framebuffer> IntermediateFramebuffer;
Ref<Framebuffer> FinalFramebuffer;
std::vector<MeshInfo> Meshes;
LightInfo LightInfo;
Ref<VertexArray> QuadVertexArray;
bool RenderedToFinalBuffer;
RendererStats Stats;
};
static RendererData s_RendererData;
void Renderer::Init()
{
s_RendererData.PBRShaderTextured = CreateRef<Shader>("src/Resources/ShaderSource/PBR/vertex_textured_pbr.glsl", "src/Resources/ShaderSource/PBR/fragment_textured_pbr.glsl");
s_RendererData.PBRShader = CreateRef<Shader>("src/Resources/ShaderSource/PBR/vertex_static_pbr.glsl", "src/Resources/ShaderSource/PBR/fragment_static_pbr.glsl");
s_RendererData.CubemapShader = CreateRef<Shader>("src/Resources/ShaderSource/Cubemap/background_vertex.glsl", "src/Resources/ShaderSource/Cubemap/background_fragment.glsl");
s_RendererData.ColorGradingShader = CreateRef<Shader>("src/Resources/ShaderSource/PostProcessing/color_grading_vertex.glsl", "src/Resources/ShaderSource/PostProcessing/color_grading_fragment.glsl");
s_RendererData.InvertColorShader = CreateRef<Shader>("src/Resources/ShaderSource/PostProcessing/color_invert_vertex.glsl", "src/Resources/ShaderSource/PostProcessing/color_invert_fragment.glsl");
float quadVertices[] =
{
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
};
uint32_t quadIndices[] =
{
0, 1, 2,
0, 2, 3,
};
s_RendererData.QuadVertexArray = CreateRef<VertexArray>();
Ref<VertexBuffer> vb = CreateRef<VertexBuffer>(quadVertices, 5 * 4 * 4);
vb->SetLayout(
{
{ ShaderDataType::Float3, "a_Position" },
{ ShaderDataType::Float2, "a_TexCoords" },
});
Ref<IndexBuffer> ib = CreateRef<IndexBuffer>(quadIndices, 6);
s_RendererData.QuadVertexArray->AddVertexBuffer(vb);
s_RendererData.QuadVertexArray->SetIndexBuffer(ib);
FramebufferSettings settings = { 1920, 1080, true, true, 8 };
s_RendererData.MultisampleFramebuffer = CreateRef<Framebuffer>(settings);
settings = { 1920, 1080 };
s_RendererData.IntermediateFramebuffer = CreateRef<Framebuffer>(settings);
s_RendererData.FinalFramebuffer = CreateRef<Framebuffer>(settings);
}
void Renderer::OnResize(uint32_t width, uint32_t height)
{
s_RendererData.MultisampleFramebuffer->Resize(width, height);
s_RendererData.IntermediateFramebuffer->Resize(width, height);
s_RendererData.FinalFramebuffer->Resize(width, height);
}
void Renderer::BeginScene(Ref<Camera>& camera, Ref<Cubemap>& cubemap, const LightInfo& lightInfo)
{
s_RendererData.Camera = camera;
s_RendererData.Cubemap = cubemap;
s_RendererData.LightInfo = lightInfo;
s_RendererData.Stats.VertexCount = 0;
s_RendererData.Stats.FaceCount = 0;
s_RendererData.Stats.DrawCalls = 0;
s_RendererData.RenderedToFinalBuffer = false;
}
void Renderer::EndScene()
{
s_RendererData.MultisampleFramebuffer->Bind();
RendererAPI::Clear();
s_RendererData.Cubemap->BindIrradianceMap(0);
s_RendererData.Cubemap->BindPrefilterMap(1);
s_RendererData.Cubemap->BindBrdfLutTexture(2);
for (const MeshInfo& mesh : s_RendererData.Meshes)
{
if (mesh.Material->IsUsingTextures())
{
s_RendererData.PBRShaderTextured->Bind();
s_RendererData.PBRShaderTextured->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.PBRShaderTextured->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.PBRShaderTextured->SetMat4("u_Model", mesh.ModelMatrix);
s_RendererData.PBRShaderTextured->SetFloat3("u_LightPos", s_RendererData.LightInfo.LightPos);
s_RendererData.PBRShaderTextured->SetFloat3("u_LightColor", s_RendererData.LightInfo.LightColor);
s_RendererData.PBRShaderTextured->SetFloat3("u_CameraPos", s_RendererData.Camera->GetPosition());
s_RendererData.PBRShaderTextured->SetInt("u_IrradianceMap", 0);
s_RendererData.PBRShaderTextured->SetInt("u_PrefilterMap", 1);
s_RendererData.PBRShaderTextured->SetInt("u_BrdfLutTexture", 2);
const std::unordered_map<TextureType, Ref<Texture2D>>& textures = mesh.Material->GetTextures();
if (textures.find(TextureType::ALBEDO) != textures.end())
{
textures.at(TextureType::ALBEDO)->Bind(3);
s_RendererData.PBRShaderTextured->SetInt("u_TextureAlbedo", 3);
}
if (textures.find(TextureType::NORMAL) != textures.end())
{
textures.at(TextureType::NORMAL)->Bind(4);
s_RendererData.PBRShaderTextured->SetInt("u_TextureNormal", 4);
}
if (textures.find(TextureType::METALLIC_SMOOTHNESS) != textures.end())
{
textures.at(TextureType::METALLIC_SMOOTHNESS)->Bind(5);
s_RendererData.PBRShaderTextured->SetInt("u_TextureMetallicSmooth", 5);
}
if (textures.find(TextureType::AMBIENT_OCCLUSION) != textures.end())
{
textures.at(TextureType::AMBIENT_OCCLUSION)->Bind(6);
s_RendererData.PBRShaderTextured->SetInt("u_TextureAmbient", 6);
}
RendererAPI::DrawIndexed(mesh.VertexArray, 0);
s_RendererData.Stats.DrawCalls += 1;
}
else
{
s_RendererData.PBRShader->Bind();
s_RendererData.PBRShader->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.PBRShader->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.PBRShader->SetMat4("u_Model", mesh.ModelMatrix);
s_RendererData.PBRShader->SetFloat3("u_LightPos", s_RendererData.LightInfo.LightPos);
s_RendererData.PBRShader->SetFloat3("u_LightColor", s_RendererData.LightInfo.LightColor);
s_RendererData.PBRShader->SetFloat3("u_CameraPos", s_RendererData.Camera->GetPosition());
s_RendererData.PBRShader->SetInt("u_IrradianceMap", 0);
s_RendererData.PBRShader->SetInt("u_PrefilterMap", 1);
s_RendererData.PBRShader->SetInt("u_BrdfLutTexture", 2);
s_RendererData.PBRShader->SetFloat3("u_Albedo", mesh.Material->GetAlbedo());
s_RendererData.PBRShader->SetFloat("u_Roughness", mesh.Material->GetRoughness());
s_RendererData.PBRShader->SetFloat("u_Metallic", mesh.Material->GetMetallic());
s_RendererData.PBRShader->SetFloat("u_Ambient", mesh.Material->GetAmbientOcclusion());
RendererAPI::DrawIndexed(mesh.VertexArray, 0);
s_RendererData.Stats.DrawCalls += 1;
}
}
s_RendererData.Cubemap->BindEnvironmentMap(0);
s_RendererData.CubemapShader->Bind();
s_RendererData.CubemapShader->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.CubemapShader->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.CubemapShader->SetInt("u_EnvironmentMap", 0);
RendererAPI::DrawIndexed(s_RendererData.Cubemap->GetVertexArray(), 0);
s_RendererData.Stats.DrawCalls += 1;
s_RendererData.Meshes.clear();
RendererAPI::BlitFramebuffer(s_RendererData.MultisampleFramebuffer, s_RendererData.IntermediateFramebuffer);
}
void Renderer::Submit(Ref<Mesh>& mesh, const glm::mat4& modelMatrix)
{
s_RendererData.Meshes.push_back({ mesh->GetVertexArray(), mesh->GetMaterial(), modelMatrix });
s_RendererData.Stats.VertexCount += mesh->GetVertexCount();
s_RendererData.Stats.FaceCount += mesh->GetFaceCount();
}
void Renderer::Submit(Ref<Model>& model, uint16_t lod, uint16_t meshesPerLod)
{
for (unsigned int i = lod * meshesPerLod; i < (lod + 1) * meshesPerLod && i < model->GetMeshes().size(); i++)
{
const Mesh& mesh = model->GetMeshes()[i];
s_RendererData.Meshes.push_back({ mesh.GetVertexArray(), mesh.GetMaterial(), model->GetModelMatrix() });
s_RendererData.Stats.VertexCount += mesh.GetVertexCount();
s_RendererData.Stats.FaceCount += mesh.GetFaceCount();
}
}
void Renderer::Submit(Ref<Model>& model)
{
for (const Mesh& mesh : model->GetMeshes())
{
s_RendererData.Meshes.push_back({ mesh.GetVertexArray(), mesh.GetMaterial(), model->GetModelMatrix() });
s_RendererData.Stats.VertexCount += mesh.GetVertexCount();
s_RendererData.Stats.FaceCount += mesh.GetFaceCount();
}
}
void Renderer::ColorGrade(const glm::vec4& color)
{
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.IntermediateFramebuffer->Bind();
else
s_RendererData.FinalFramebuffer->Bind();
RendererAPI::Clear();
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.FinalFramebuffer->BindColorTexture(0);
else
s_RendererData.IntermediateFramebuffer->BindColorTexture(0);
s_RendererData.ColorGradingShader->Bind();
s_RendererData.ColorGradingShader->SetInt("u_Frame", 0);
s_RendererData.ColorGradingShader->SetFloat4("u_GradingColor", color);
RendererAPI::DrawIndexed(s_RendererData.QuadVertexArray, 0);
s_RendererData.RenderedToFinalBuffer = !s_RendererData.RenderedToFinalBuffer;
s_RendererData.FinalFramebuffer->Unbind();
}
void Renderer::InvertColor()
{
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.IntermediateFramebuffer->Bind();
else
s_RendererData.FinalFramebuffer->Bind();
RendererAPI::Clear();
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.FinalFramebuffer->BindColorTexture(0);
else
s_RendererData.IntermediateFramebuffer->BindColorTexture(0);
s_RendererData.InvertColorShader->Bind();
s_RendererData.InvertColorShader->SetInt("u_Frame", 0);
RendererAPI::DrawIndexed(s_RendererData.QuadVertexArray, 0);
s_RendererData.RenderedToFinalBuffer = !s_RendererData.RenderedToFinalBuffer;
s_RendererData.FinalFramebuffer->Unbind();
}
const RendererStats& Renderer::GetStatistics()
{
return s_RendererData.Stats;
}
uint32_t Renderer::GetFrameTextureId()
{
return s_RendererData.RenderedToFinalBuffer ? s_RendererData.FinalFramebuffer->GetColorTextureId() : s_RendererData.IntermediateFramebuffer->GetColorTextureId();
}
} | 36.3879 | 200 | 0.757653 |
de286ab0d19051bab0a5d04bc312464b6ebeed79 | 2,106 | cpp | C++ | Codevita 2019/Given Three Digits Number/bit.cpp | gunjeetbawa10/Competition-Questions-Solutions | bbb257725b1d7635644023c067a918388354cdf5 | [
"Apache-2.0"
] | null | null | null | Codevita 2019/Given Three Digits Number/bit.cpp | gunjeetbawa10/Competition-Questions-Solutions | bbb257725b1d7635644023c067a918388354cdf5 | [
"Apache-2.0"
] | null | null | null | Codevita 2019/Given Three Digits Number/bit.cpp | gunjeetbawa10/Competition-Questions-Solutions | bbb257725b1d7635644023c067a918388354cdf5 | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <vector>
using namespace std;
vector<int> correctBitScores(vector<int>);
vector<int> bitScore(vector<int>);
int findPairs(vector<int>);
int main() {
int a, b;
int pairs = 0;
vector<int> vec;
vector<int> bitscore;
cout << "\nEnter count of nos: ";
cin >> a;
for (int i = 0; i < a; i++) {
cin >> b;
vec.push_back(b);
}
bitscore = bitScore(vec);
pairs = findPairs(bitscore);
cout << "Max pairs = " << pairs;
return 0;
}
vector<int> correctBitScores(vector<int> bis) {
int temp = 0;
for (size_t i = 0; i < bis.size(); i++) {
temp = bis[i];
int count = 0;
while (temp > 0) {
temp = temp / 10;
count++;
}
if (count > 2)
bis[i] = abs(100 - bis[i]);
}
return bis;
}
int findPairs(vector<int> vec) {
int count = 0;
vector<int> odd;
vector<int> even;
for (size_t i = 0; i < vec.size(); i++)
(i % 2 == 0 ? even.push_back(vec[i]) : odd.push_back(vec[i]));
for (size_t j = 0; j < odd.size(); j++)
for (size_t k = j + 1; k < odd.size(); k++) {
if (odd[j] / 10 == odd[k] / 10) {
count++;
odd.erase(odd.begin()+j);
}
}
for (size_t j = 0; j < even.size(); j++)
for (size_t k = j + 1; k < even.size(); k++) {
if (even[j] / 10 == even[k] / 10) {
count++;
even.erase(even.begin() + j);
}
}
return count;
}
vector<int> bitScore(vector<int> v) {
int temp = 0, rem = 0;
vector<int> bs;
for (size_t i = 0; i < v.size(); i++) {
int max = 0, min = 9;
temp = v[i];
while (temp > 0) {
rem = temp % 10;
if (min > rem)
min = rem;
if (max < rem)
max = rem;
temp = temp / 10;
}
int bscore = (max * 11) + (min * 7);
bs.push_back(bscore);
}
bs = correctBitScores(bs);
return bs;
}
| 22.645161 | 70 | 0.437322 |
de2e81e9973c5234f6acbefde666cdf584e596e1 | 6,211 | cc | C++ | src/STP.cc | VadimNvr/SDN_RunOS | 74df09f78f8672f144a283823b24de3106f8e419 | [
"Apache-2.0"
] | null | null | null | src/STP.cc | VadimNvr/SDN_RunOS | 74df09f78f8672f144a283823b24de3106f8e419 | [
"Apache-2.0"
] | null | null | null | src/STP.cc | VadimNvr/SDN_RunOS | 74df09f78f8672f144a283823b24de3106f8e419 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2015 Applied Research Center for Computer Networks
*
* 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 "STP.hh"
#include "Topology.hh"
REGISTER_APPLICATION(STP, {"switch-manager", "link-discovery", "topology", ""})
void SwitchSTP::computeSTP()
{
parent->computePathForSwitch(this->sw->id());
}
void SwitchSTP::resetBroadcast()
{
for (auto port : ports) {
if (port.second->to_switch)
unsetBroadcast(port.second->port_no);
}
}
void SwitchSTP::setSwitchPort(uint32_t port_no, uint64_t dpid)
{
ports.at(port_no)->to_switch = true;
ports.at(port_no)->nextSwitch = parent->switch_list[dpid];
}
void STP::init(Loader* loader, const Config& config)
{
QObject* ld = ILinkDiscovery::get(loader);
connect(ld, SIGNAL(linkDiscovered(switch_and_port, switch_and_port)),
this, SLOT(onLinkDiscovered(switch_and_port, switch_and_port)));
connect(ld, SIGNAL(linkBroken(switch_and_port, switch_and_port)),
this, SLOT(onLinkBroken(switch_and_port, switch_and_port)));
SwitchManager* sw = SwitchManager::get(loader);
connect(sw, &SwitchManager::switchDiscovered, this, &STP::onSwitchDiscovered);
connect(sw, &SwitchManager::switchDown, this, &STP::onSwitchDown);
topo = Topology::get(loader);
}
STPPorts STP::getSTP(uint64_t dpid)
{
std::vector<uint32_t> ports;
if (switch_list.count(dpid) == 0) {
return ports;
}
SwitchSTP* sw = switch_list[dpid];
if (!sw->computed) {
return ports;
}
for (auto port : sw->ports) {
if (port.second->broadcast)
ports.push_back(port.second->port_no);
}
return ports;
}
void STP::onLinkDiscovered(switch_and_port from, switch_and_port to)
{
if (switch_list.count(from.dpid) == 0)
return;
if (switch_list.count(to.dpid) == 0)
return;
SwitchSTP* sw = switch_list[from.dpid];
if (!sw->existsPort(from.port)) {
Port* port = new Port(from.port);
sw->ports[from.port] = port;
}
if (!sw->root)
sw->unsetBroadcast(from.port);
sw->setSwitchPort(from.port, to.dpid);
sw = switch_list[to.dpid];
if (!sw->existsPort(to.port)) {
Port* port = new Port(to.port);
sw->ports[to.port] = port;
}
if (!sw->root)
sw->unsetBroadcast(to.port);
sw->setSwitchPort(to.port, from.dpid);
// recompute pathes for all switches
for (auto ss : switch_list) {
if (!ss.second->root)
ss.second->computed = false;
}
}
void STP::onLinkBroken(switch_and_port from, switch_and_port to)
{
// recompute pathes for all switches
for (auto ss : switch_list) {
if (!ss.second->root)
ss.second->computed = false;
}
}
void STP::onSwitchDiscovered(Switch* dp)
{
SwitchSTP* sw;
if (switch_list.empty())
sw = new SwitchSTP(dp, this, true, true);
else
sw = new SwitchSTP(dp, this);
switch_list[dp->id()] = sw;
connect(dp, &Switch::portUp, this, &STP::onPortUp);
connect(sw->timer, SIGNAL(timeout()), sw, SLOT(computeSTP()));
sw->timer->start(POLL_TIMEOUT * 1000);
}
void STP::onSwitchDown(Switch* dp)
{
if (switch_list.count(dp->id()) > 0) {
SwitchSTP* sw = switch_list[dp->id()];
sw->timer->stop();
switch_list.erase(dp->id());
delete sw;
}
}
void STP::onPortUp(Switch *dp, of13::Port port)
{
if (switch_list.count(dp->id()) > 0) {
SwitchSTP* sw = switch_list[dp->id()];
if ( !sw->existsPort(port.port_no()) && port.port_no() < of13::OFPP_MAX ) {
Port* p = new Port(port.port_no());
sw->ports[port.port_no()] = p;
}
}
}
SwitchSTP* STP::findRoot()
{
for (auto it : switch_list) {
if (it.second->root)
return it.second;
}
return nullptr;
}
void STP::computePathForSwitch(uint64_t dpid)
{
static std::mutex compute;
if (!switch_list[dpid]->computed) {
SwitchSTP* root = findRoot();
if (root == nullptr) {
LOG(ERROR) << "Root switch not found!";
SwitchSTP* sw = switch_list[dpid];
sw->root = true;
sw->computed = true;
return;
}
SwitchSTP* sw = switch_list[dpid];
std::vector<uint32_t> old_broadcast = getSTP(dpid);
compute.lock();
sw->resetBroadcast();
data_link_route route = topo->computeRoute(dpid, root->sw->id());
if (route.size() > 0) {
uint32_t broadcast_port = route[0].port;
if (sw->existsPort(broadcast_port))
sw->setBroadcast(broadcast_port);
sw->nextSwitchToRoot = switch_list[route[1].dpid];
// getting broadcast port on second switch
data_link_route r_route = topo->computeRoute(route[1].dpid, dpid);
SwitchSTP* r_sw = switch_list[r_route[0].dpid];
uint32_t r_broadcast_port = r_route[0].port;
if (r_sw->existsPort(r_broadcast_port))
r_sw->setBroadcast(r_broadcast_port);
for (auto port : sw->ports) {
if (port.second->to_switch) {
if (port.second->nextSwitch->nextSwitchToRoot == sw) {
sw->setBroadcast(port.second->port_no);
}
}
}
if (getSTP(dpid).size() == old_broadcast.size())
sw->computed = true;
} else {
LOG(WARNING) << "Path between " << FORMAT_DPID << dpid
<< " and root switch " << FORMAT_DPID << root->sw->id() << " not found";
}
compute.unlock();
}
}
| 28.62212 | 88 | 0.596844 |
de31df2261416a611d50658fdd5be19ba732839f | 30,008 | hpp | C++ | src/libraries/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.hpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | src/libraries/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.hpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | src/libraries/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.hpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | /*---------------------------------------------------------------------------*\
Copyright (C) 2014 Applied CCM
Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of CAELUS.
CAELUS 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.
CAELUS 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 CAELUS. If not, see <http://www.gnu.org/licenses/>.
Class
CML::InjectionModel
Description
Templated injection model class.
The injection model nominally describes the parcel:
- position
- diameter
- velocity
In this case, the fullyDescribed() flag should be set to 0 (false). When
the parcel is then added to the cloud, the remaining properties are
populated using values supplied in the constant properties.
If, however, all of a parcel's properties are described in the model, the
fullDescribed() flag should be set to 1 (true).
\*---------------------------------------------------------------------------*/
#ifndef InjectionModel_H
#define InjectionModel_H
#include "IOdictionary.hpp"
#include "autoPtr.hpp"
#include "runTimeSelectionTables.hpp"
#include "CloudSubModelBase.hpp"
#include "vector.hpp"
#include "TimeDataEntry.hpp"
#include "mathematicalConstants.hpp"
#include "meshTools.hpp"
#include "volFields.hpp"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace CML
{
/*---------------------------------------------------------------------------*\
Class InjectionModel Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class InjectionModel
:
public CloudSubModelBase<CloudType>
{
public:
//- Convenience typedef for parcelType
typedef typename CloudType::parcelType parcelType;
// Enumerations
//- Parcel basis representation options
// i.e constant number of particles OR constant mass per parcel
enum parcelBasis
{
pbNumber,
pbMass,
pbFixed
};
protected:
// Protected data
// Global injection properties
//- Start of injection [s]
scalar SOI_;
//- Total volume of particles introduced by this injector [m^3]
// - scaled to ensure massTotal is achieved
scalar volumeTotal_;
//- Total mass to inject [kg]
scalar massTotal_;
//- Mass flow rate profile for steady calculations
TimeDataEntry<scalar> massFlowRate_;
//- Total mass injected to date [kg]
scalar massInjected_;
// Counters
//- Number of injections counter
label nInjections_;
//- Running counter of total number of parcels added
label parcelsAddedTotal_;
// Injection properties per Lagrangian time step
//- Parcel basis enumeration
parcelBasis parcelBasis_;
//- nParticle to assign to parcels when the 'fixed' basis
// is selected
scalar nParticleFixed_;
//- Continuous phase time at start of injection time step [s]
scalar time0_;
//- Time at start of injection time step [s]
scalar timeStep0_;
// Protected Member Functions
//- Additional flag to identify whether or not injection of parcelI is
// permitted
virtual bool validInjection(const label parcelI) = 0;
//- Determine properties for next time step/injection interval
virtual bool prepareForNextTimeStep
(
const scalar time,
label& newParcels,
scalar& newVolumeFraction
);
//- Find the cell that contains the supplied position
// Will modify position slightly towards the owner cell centroid to
// ensure that it lies in a cell and not edge/face
virtual bool findCellAtPosition
(
label& celli,
label& tetFacei,
label& tetPti,
vector& position,
bool errorOnNotFound = true
);
//- Set number of particles to inject given parcel properties
virtual scalar setNumberOfParticles
(
const label parcels,
const scalar volumeFraction,
const scalar diameter,
const scalar rho
);
//- Post injection checks
virtual void postInjectCheck
(
const label parcelsAdded,
const scalar massAdded
);
public:
//- Runtime type information
TypeName("injectionModel");
//- Declare runtime constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
InjectionModel,
dictionary,
(
const dictionary& dict,
CloudType& owner,
const word& modelType
),
(dict, owner, modelType)
);
// Constructors
//- Construct null from owner
InjectionModel(CloudType& owner);
//- Construct from dictionary
InjectionModel
(
const dictionary& dict,
CloudType& owner,
const word& modelName,
const word& modelType
);
//- Construct copy
InjectionModel(const InjectionModel<CloudType>& im);
//- Construct and return a clone
virtual autoPtr<InjectionModel<CloudType> > clone() const = 0;
//- Destructor
virtual ~InjectionModel();
// Selectors
//- Selector with lookup from dictionary
static autoPtr<InjectionModel<CloudType> > New
(
const dictionary& dict,
CloudType& owner
);
//- Selector with name and type
static autoPtr<InjectionModel<CloudType> > New
(
const dictionary& dict,
const word& modelName,
const word& modelType,
CloudType& owner
);
// Member Functions
// Mapping
//- Update mesh
virtual void updateMesh();
// Global information
//- Return the start-of-injection time
inline scalar timeStart() const;
//- Return the total volume to be injected across the event
inline scalar volumeTotal() const;
//- Return mass of particles to introduce
inline scalar massTotal() const;
//- Return mass of particles injected (cumulative)
inline scalar massInjected() const;
//- Return the end-of-injection time
virtual scalar timeEnd() const = 0;
//- Number of parcels to introduce relative to SOI
virtual label parcelsToInject
(
const scalar time0,
const scalar time1
) = 0;
//- Volume of parcels to introduce relative to SOI
virtual scalar volumeToInject
(
const scalar time0,
const scalar time1
) = 0;
//- Return the average parcel mass over the injection period
virtual scalar averageParcelMass();
// Counters
//- Return the number of injections
inline label nInjections() const;
//- Return the total number parcels added
inline label parcelsAddedTotal() const;
// Per-injection event functions
//- Main injection loop
template<class TrackCloudType>
void inject
(
TrackCloudType& cloud,
typename CloudType::parcelType::trackingData& td
);
//- Main injection loop - steady-state
template<class TrackCloudType>
void injectSteadyState
(
TrackCloudType& cloud,
typename CloudType::parcelType::trackingData& td,
const scalar trackTime
);
// Injection geometry
//- Set the injection position and owner cell, tetFace and tetPt
virtual void setPositionAndCell
(
const label parcelI,
const label nParcels,
const scalar time,
vector& position,
label& cellOwner,
label& tetFacei,
label& tetPti
) = 0;
//- Set the parcel properties
virtual void setProperties
(
const label parcelI,
const label nParcels,
const scalar time,
parcelType& parcel
) = 0;
//- Flag to identify whether model fully describes the parcel
virtual bool fullyDescribed() const = 0;
// I-O
//- Write injection info to stream
virtual void info(Ostream& os);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace CML
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeInjectionModel(CloudType) \
\
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug \
( \
InjectionModel<kinematicCloudType>, \
0 \
); \
\
defineTemplateRunTimeSelectionTable \
( \
InjectionModel<kinematicCloudType>, \
dictionary \
);
#define makeInjectionModelType(SS, CloudType) \
\
typedef CloudType::kinematicCloudType kinematicCloudType; \
defineNamedTemplateTypeNameAndDebug(SS<kinematicCloudType>, 0); \
\
CML::InjectionModel<kinematicCloudType>:: \
adddictionaryConstructorToTable<SS<kinematicCloudType> > \
add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::timeStart() const
{
return SOI_;
}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::volumeTotal() const
{
return volumeTotal_;
}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::massTotal() const
{
return massTotal_;
}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::massInjected() const
{
return massInjected_;
}
template<class CloudType>
CML::label CML::InjectionModel<CloudType>::nInjections() const
{
return nInjections_;
}
template<class CloudType>
CML::label CML::InjectionModel<CloudType>::parcelsAddedTotal() const
{
return parcelsAddedTotal_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace CML::constant::mathematical;
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class CloudType>
bool CML::InjectionModel<CloudType>::prepareForNextTimeStep
(
const scalar time,
label& newParcels,
scalar& newVolumeFraction
)
{
// Initialise values
newParcels = 0;
newVolumeFraction = 0.0;
bool validInjection = false;
// Return if not started injection event
if (time < SOI_)
{
timeStep0_ = time;
return validInjection;
}
// Make times relative to SOI
scalar t0 = timeStep0_ - SOI_;
scalar t1 = time - SOI_;
// Number of parcels to inject
newParcels = this->parcelsToInject(t0, t1);
// Volume of parcels to inject
newVolumeFraction =
this->volumeToInject(t0, t1)
/(volumeTotal_ + ROOTVSMALL);
if (newVolumeFraction > 0)
{
if (newParcels > 0)
{
timeStep0_ = time;
validInjection = true;
}
else
{
// Injection should have started, but not sufficient volume to
// produce (at least) 1 parcel - hold value of timeStep0_
validInjection = false;
}
}
else
{
timeStep0_ = time;
validInjection = false;
}
return validInjection;
}
template<class CloudType>
bool CML::InjectionModel<CloudType>::findCellAtPosition
(
label& celli,
label& tetFacei,
label& tetPti,
vector& position,
bool errorOnNotFound
)
{
const volVectorField& cellCentres = this->owner().mesh().C();
const vector p0 = position;
this->owner().mesh().findCellFacePt
(
position,
celli,
tetFacei,
tetPti
);
label proci = -1;
if (celli >= 0)
{
proci = Pstream::myProcNo();
}
reduce(proci, maxOp<label>());
// Ensure that only one processor attempts to insert this Parcel
if (proci != Pstream::myProcNo())
{
celli = -1;
tetFacei = -1;
tetPti = -1;
}
// Last chance - find nearest cell and try that one - the point is
// probably on an edge
if (proci == -1)
{
celli = this->owner().mesh().findNearestCell(position);
if (celli >= 0)
{
position += SMALL*(cellCentres[celli] - position);
this->owner().mesh().findCellFacePt
(
position,
celli,
tetFacei,
tetPti
);
if (celli > 0)
{
proci = Pstream::myProcNo();
}
}
reduce(proci, maxOp<label>());
if (proci != Pstream::myProcNo())
{
celli = -1;
tetFacei = -1;
tetPti = -1;
}
}
if (proci == -1)
{
if (errorOnNotFound)
{
FatalErrorInFunction
<< "Cannot find parcel injection cell. "
<< "Parcel position = " << p0 << nl
<< abort(FatalError);
}
else
{
return false;
}
}
return true;
}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::setNumberOfParticles
(
const label parcels,
const scalar volumeFraction,
const scalar diameter,
const scalar rho
)
{
scalar nP = 0.0;
switch (parcelBasis_)
{
case pbMass:
{
scalar volumep = pi/6.0*pow3(diameter);
scalar volumeTot = massTotal_/rho;
nP = volumeFraction*volumeTot/(parcels*volumep);
break;
}
case pbNumber:
{
nP = massTotal_/(rho*volumeTotal_);
break;
}
case pbFixed:
{
nP = nParticleFixed_;
break;
}
default:
{
nP = 0.0;
FatalErrorInFunction
<< "Unknown parcelBasis type" << nl
<< exit(FatalError);
}
}
return nP;
}
template<class CloudType>
void CML::InjectionModel<CloudType>::postInjectCheck
(
const label parcelsAdded,
const scalar massAdded
)
{
const label allParcelsAdded = returnReduce(parcelsAdded, sumOp<label>());
if (allParcelsAdded > 0)
{
Info<< nl
<< "Cloud: " << this->owner().name()
<< " injector: " << this->modelName() << nl
<< " Added " << allParcelsAdded << " new parcels" << nl << endl;
}
// Increment total number of parcels added
parcelsAddedTotal_ += allParcelsAdded;
// Increment total mass injected
massInjected_ += returnReduce(massAdded, sumOp<scalar>());
// Update time for start of next injection
time0_ = this->owner().db().time().value();
// Increment number of injections
nInjections_++;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
CML::InjectionModel<CloudType>::InjectionModel(CloudType& owner)
:
CloudSubModelBase<CloudType>(owner),
SOI_(0.0),
volumeTotal_(0.0),
massTotal_(0.0),
massFlowRate_(owner.db().time(), "massFlowRate"),
massInjected_(this->template getModelProperty<scalar>("massInjected")),
nInjections_(this->template getModelProperty<label>("nInjections")),
parcelsAddedTotal_
(
this->template getModelProperty<scalar>("parcelsAddedTotal")
),
parcelBasis_(pbNumber),
nParticleFixed_(0.0),
time0_(0.0),
timeStep0_(this->template getModelProperty<scalar>("timeStep0"))
{}
template<class CloudType>
CML::InjectionModel<CloudType>::InjectionModel
(
const dictionary& dict,
CloudType& owner,
const word& modelName,
const word& modelType
)
:
CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, modelType),
SOI_(0.0),
volumeTotal_(0.0),
massTotal_(0.0),
massFlowRate_(owner.db().time(), "massFlowRate"),
massInjected_(this->template getModelProperty<scalar>("massInjected")),
nInjections_(this->template getModelProperty<scalar>("nInjections")),
parcelsAddedTotal_
(
this->template getModelProperty<scalar>("parcelsAddedTotal")
),
parcelBasis_(pbNumber),
nParticleFixed_(0.0),
time0_(owner.db().time().value()),
timeStep0_(this->template getModelProperty<scalar>("timeStep0"))
{
// Provide some info
// - also serves to initialise mesh dimensions - needed for parallel runs
// due to lazy evaluation of valid mesh dimensions
Info<< " Constructing " << owner.mesh().nGeometricD() << "-D injection"
<< endl;
if (owner.solution().transient())
{
this->coeffDict().lookup("massTotal") >> massTotal_;
this->coeffDict().lookup("SOI") >> SOI_;
SOI_ = owner.db().time().userTimeToTime(SOI_);
}
else
{
massFlowRate_.reset(this->coeffDict());
massTotal_ = massFlowRate_.value(owner.db().time().value());
}
const word parcelBasisType = this->coeffDict().lookup("parcelBasisType");
if (parcelBasisType == "mass")
{
parcelBasis_ = pbMass;
}
else if (parcelBasisType == "number")
{
parcelBasis_ = pbNumber;
}
else if (parcelBasisType == "fixed")
{
parcelBasis_ = pbFixed;
Info<< " Choosing nParticle to be a fixed value, massTotal "
<< "variable now does not determine anything."
<< endl;
nParticleFixed_ = readScalar(this->coeffDict().lookup("nParticle"));
}
else
{
FatalErrorInFunction
<< "parcelBasisType must be either 'number', 'mass' or 'fixed'"
<< nl << exit(FatalError);
}
}
template<class CloudType>
CML::InjectionModel<CloudType>::InjectionModel
(
const InjectionModel<CloudType>& im
)
:
CloudSubModelBase<CloudType>(im),
SOI_(im.SOI_),
volumeTotal_(im.volumeTotal_),
massTotal_(im.massTotal_),
massFlowRate_(im.massFlowRate_),
massInjected_(im.massInjected_),
nInjections_(im.nInjections_),
parcelsAddedTotal_(im.parcelsAddedTotal_),
parcelBasis_(im.parcelBasis_),
nParticleFixed_(im.nParticleFixed_),
time0_(im.time0_),
timeStep0_(im.timeStep0_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
CML::InjectionModel<CloudType>::~InjectionModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void CML::InjectionModel<CloudType>::updateMesh()
{}
template<class CloudType>
CML::scalar CML::InjectionModel<CloudType>::averageParcelMass()
{
label nTotal = 0.0;
if (this->owner().solution().transient())
{
nTotal = parcelsToInject(0.0, timeEnd() - timeStart());
}
else
{
nTotal = parcelsToInject(0.0, 1.0);
}
return massTotal_/nTotal;
}
template<class CloudType>
template<class TrackCloudType>
void CML::InjectionModel<CloudType>::inject
(
TrackCloudType& cloud,
typename CloudType::parcelType::trackingData& td
)
{
if (!this->active())
{
return;
}
const scalar time = this->owner().db().time().value();
// Prepare for next time step
label parcelsAdded = 0;
scalar massAdded = 0.0;
label newParcels = 0;
scalar newVolumeFraction = 0.0;
if (prepareForNextTimeStep(time, newParcels, newVolumeFraction))
{
const scalar trackTime = this->owner().solution().trackTime();
const polyMesh& mesh = this->owner().mesh();
// Duration of injection period during this timestep
const scalar deltaT =
max(0.0, min(trackTime, min(time - SOI_, timeEnd() - time0_)));
// Pad injection time if injection starts during this timestep
const scalar padTime = max(0.0, SOI_ - time0_);
// Introduce new parcels linearly across carrier phase timestep
for (label parcelI = 0; parcelI < newParcels; parcelI++)
{
if (validInjection(parcelI))
{
// Calculate the pseudo time of injection for parcel 'parcelI'
scalar timeInj = time0_ + padTime + deltaT*parcelI/newParcels;
// Determine the injection position and owner cell,
// tetFace and tetPt
label celli = -1;
label tetFacei = -1;
label tetPti = -1;
vector pos = Zero;
setPositionAndCell
(
parcelI,
newParcels,
timeInj,
pos,
celli,
tetFacei,
tetPti
);
if (celli > -1)
{
// Lagrangian timestep
const scalar dt = time - timeInj;
// Apply corrections to position for 2-D cases
meshTools::constrainToMeshCentre(mesh, pos);
// Create a new parcel
parcelType* pPtr = new parcelType(mesh, pos, celli);
// Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr, dt);
// Assign new parcel properties in injection model
setProperties(parcelI, newParcels, timeInj, *pPtr);
// Check/set new parcel injection properties
cloud.checkParcelProperties(*pPtr, dt, fullyDescribed());
// Apply correction to velocity for 2-D cases
meshTools::constrainDirection
(
mesh,
mesh.solutionD(),
pPtr->U()
);
// Number of particles per parcel
pPtr->nParticle() =
setNumberOfParticles
(
newParcels,
newVolumeFraction,
pPtr->d(),
pPtr->rho()
);
parcelsAdded ++;
massAdded += pPtr->nParticle()*pPtr->mass();
if (pPtr->move(cloud, td, dt))
{
cloud.addParticle(pPtr);
}
else
{
delete pPtr;
}
}
}
}
}
postInjectCheck(parcelsAdded, massAdded);
}
template<class CloudType>
template<class TrackCloudType>
void CML::InjectionModel<CloudType>::injectSteadyState
(
TrackCloudType& cloud,
typename CloudType::parcelType::trackingData& td,
const scalar trackTime
)
{
if (!this->active())
{
return;
}
const polyMesh& mesh = this->owner().mesh();
massTotal_ = massFlowRate_.value(mesh.time().value());
// Reset counters
time0_ = 0.0;
label parcelsAdded = 0;
scalar massAdded = 0.0;
// Set number of new parcels to inject based on first second of injection
label newParcels = parcelsToInject(0.0, 1.0);
// Inject new parcels
for (label parcelI = 0; parcelI < newParcels; parcelI++)
{
// Volume to inject is split equally amongst all parcel streams
scalar newVolumeFraction = 1.0/scalar(newParcels);
// Determine the injection position and owner cell,
// tetFace and tetPt
label celli = -1;
label tetFacei = -1;
label tetPti = -1;
vector pos = Zero;
setPositionAndCell
(
parcelI,
newParcels,
0.0,
pos,
celli,
tetFacei,
tetPti
);
if (celli > -1)
{
// Apply corrections to position for 2-D cases
meshTools::constrainToMeshCentre(mesh, pos);
// Create a new parcel
parcelType* pPtr = new parcelType(mesh, pos, celli);
// Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr, 0.0);
// Assign new parcel properties in injection model
setProperties(parcelI, newParcels, 0.0, *pPtr);
// Check/set new parcel injection properties
cloud.checkParcelProperties(*pPtr, 0.0, fullyDescribed());
// Apply correction to velocity for 2-D cases
meshTools::constrainDirection(mesh, mesh.solutionD(), pPtr->U());
// Number of particles per parcel
pPtr->nParticle() =
setNumberOfParticles
(
1,
newVolumeFraction,
pPtr->d(),
pPtr->rho()
);
// Add the new parcel
cloud.addParticle(pPtr);
massAdded += pPtr->nParticle()*pPtr->mass();
parcelsAdded++;
}
}
postInjectCheck(parcelsAdded, massAdded);
}
template<class CloudType>
void CML::InjectionModel<CloudType>::info(Ostream& os)
{
os << " " << this->modelName() << ":" << nl
<< " number of parcels added = " << parcelsAddedTotal_ << nl
<< " mass introduced = " << massInjected_ << nl;
if (this->writeTime())
{
this->setModelProperty("massInjected", massInjected_);
this->setModelProperty("nInjections", nInjections_);
this->setModelProperty("parcelsAddedTotal", parcelsAddedTotal_);
this->setModelProperty("timeStep0", timeStep0_);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class CloudType>
CML::autoPtr<CML::InjectionModel<CloudType> >
CML::InjectionModel<CloudType>::New
(
const dictionary& dict,
CloudType& owner
)
{
const word modelType(dict.lookup("injectionModel"));
Info<< "Selecting injection model " << modelType << endl;
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown injection model type "
<< modelType << nl << nl
<< "Valid injection model types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError);
}
return autoPtr<InjectionModel<CloudType>>(cstrIter()(dict, owner));
}
template<class CloudType>
CML::autoPtr<CML::InjectionModel<CloudType> >
CML::InjectionModel<CloudType>::New
(
const dictionary& dict,
const word& modelName,
const word& modelType,
CloudType& owner
)
{
Info<< "Selecting injection model " << modelType << endl;
typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown injection model type "
<< modelType << nl << nl
<< "Valid injection model types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError);
}
return
autoPtr<InjectionModel<CloudType> >
(
cstrIter()
(
dict,
owner,
modelName
)
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
| 27.304823 | 80 | 0.532391 |
de3396e97f0d814930a807af6bb63b9a8a60cd56 | 427 | cpp | C++ | notes/examples/chapter09/indirectionOperator.cpp | jay3ss/co-sci-140 | 2751bd12bcd8a24bf15fba656e086f1b0615b4a9 | [
"BSD-3-Clause"
] | null | null | null | notes/examples/chapter09/indirectionOperator.cpp | jay3ss/co-sci-140 | 2751bd12bcd8a24bf15fba656e086f1b0615b4a9 | [
"BSD-3-Clause"
] | 1 | 2019-03-02T06:10:13.000Z | 2019-03-06T19:17:14.000Z | notes/examples/chapter09/indirectionOperator.cpp | jay3ss/co-sci-140 | 2751bd12bcd8a24bf15fba656e086f1b0615b4a9 | [
"BSD-3-Clause"
] | null | null | null | #include <iostream>
int main()
{
int x = 25;
int *ptr = nullptr;
ptr = &x;
std::cout << "Here is the value in x, printed twice:\n"
<< x << std::endl
<< *ptr << std::endl;
*ptr = 100;
std::cout << "Once again, here is the value in x:\n"
<< x << std::endl
<< *ptr << std::endl;
return 0;
} | 20.333333 | 60 | 0.386417 |
de34ff8b488ff7be459e0a16654816f1a8d561ff | 4,147 | cc | C++ | vos/gui/sub/gui/si_save/SiSaveAsCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | 16 | 2020-10-21T05:56:26.000Z | 2022-03-31T10:02:01.000Z | vos/gui/sub/gui/si_save/SiSaveAsCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | null | null | null | vos/gui/sub/gui/si_save/SiSaveAsCmd.cc | NASA-AMMOS/VICAR | 4504c1f558855d9c6eaef89f4460217aa4909f8e | [
"BSD-3-Clause"
] | 2 | 2021-03-09T01:51:08.000Z | 2021-03-23T00:23:24.000Z | ////////////////////////////////////////////////////////////
// SiSaveAsCmd.h: Saves the image according to the SiSaveCmdValue
// CmdValue passed in.
//
//!!!! NOTE: THIS IS A HACK CURRENTLY! The command derives from
//!!!! SiRunStretchScriptCmd, adding the SiSaveCmdValue parameters to
//!!!! the file, then running an *external* script to implement the
//!!!! save. It should be done internally, via save hooks in ImageData.
//
// In adition to the information included by SiRunStretchScriptCmd, the
// following information is passed:
//
// scriptVersion=1.2 replaces 1.1 from base class
// saveFilename="string" see below
// saveImageExtent=file how much to save: display, file, roi
// saveLutType=stretch whether to use stretch/pseudo tables
// (same values as lutType in parent)
// saveAsByte=1 0=retain data type (no stretch unless byte)
// 1=convert to byte (stretch/pseudo allowed)
// saveFileFormat="VICAR" file format to save in, currently VICAR or TIFF
//
// saveFilename follows the same rules as filename in SiRunScriptCmd,
// except that band numbers (in parens) are not allowed.
///////////////////////////////////////////////////////////
#include "SiSaveAsCmd.h"
#include "SiSaveCmdValue.h"
#include "XvicImage.h"
#include "ImageToReloadGlue.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
SiSaveAsCmd::SiSaveAsCmd(const char *name, int active, Widget xiw,
ImageData *image, const char *script,
Lut *sR, Lut *sG, Lut *sB, Lut *pR, Lut *pG, Lut *pB)
: SiRunStretchScriptCmd(name, active, xiw, image, script,
sR, sG, sB, pR, pG, pB)
{
// Empty
}
////////////////////////////////////////////////////////////
// Print the version string to the temp file. This function
// should be overridden by subclasses.
////////////////////////////////////////////////////////////
void SiSaveAsCmd::printVersionString(FILE *tfp)
{
fprintf(tfp, "scriptVersion=1.2\n");
}
////////////////////////////////////////////////////////////
// Print the contents to the temp file. This function could
// be overridden by subclasses, which should call this specific
// version to output the basic info.
////////////////////////////////////////////////////////////
void SiSaveAsCmd::printContents(FILE *tfp)
{
// Print basic values
SiRunStretchScriptCmd::printContents(tfp);
// Get extra values from CmdValue
SiSaveCmdValue *value = (SiSaveCmdValue *)_value;
if (value == NULL) {
fprintf(stderr, "No SiSaveCmdValue, internal error, file not saved!\n");
return;
}
if (strlen(value->filename_grn) == 0 && strlen(value->filename_blu) == 0)
fprintf(tfp, "saveFilename=\"%s\"\n", value->filename_red);
else
fprintf(tfp, "saveFilename=(\"%s\",\"%s\",\"%s\")\n",
value->filename_red, value->filename_grn, value->filename_blu);
switch (value->imageExtent) {
case SaveDisplayOnly:
fprintf(tfp, "saveImageExtent=display\n");
break;
case SaveEntireFile:
fprintf(tfp, "saveImageExtent=file\n");
break;
case SaveROI: // Not Implemented!!!!
fprintf(tfp, "saveImageExtent=roi\n");
break;
default:
break;
}
switch (value->lutType) {
case XvicRAW:
fprintf(tfp, "saveLutType=raw\n");
break;
case XvicSTRETCH:
fprintf(tfp, "saveLutType=stretch\n");
break;
case XvicPSEUDO:
fprintf(tfp, "saveLutType=pseudo\n");
break;
case XvicPSEUDO_ONLY:
fprintf(tfp, "saveLutType=pseudo_only\n");
break;
default:
break;
}
fprintf(tfp, "saveAsByte=%d\n", value->asByte ? 1 : 0);
fprintf(tfp, "saveFileFormat=%s\n", value->fileFormat);
}
////////////////////////////////////////////////////////////
// Delete the CmdValue object
////////////////////////////////////////////////////////////
void SiSaveAsCmd::freeValue(CmdValue value)
{
if (value)
delete (SiSaveCmdValue *)value;
}
| 31.9 | 78 | 0.565228 |
de373ff000311a4e3f0865cd47eb9259491d7c0b | 557 | hpp | C++ | src/view/cogbutton.hpp | severin-lemaignan/boxology | 08b592b315c0e7960ed5d7f8385f2702c0443013 | [
"MIT"
] | 9 | 2015-11-03T11:46:01.000Z | 2021-11-18T08:38:30.000Z | src/view/cogbutton.hpp | severin-lemaignan/boxology | 08b592b315c0e7960ed5d7f8385f2702c0443013 | [
"MIT"
] | 2 | 2016-04-11T16:24:23.000Z | 2017-04-06T14:19:31.000Z | src/view/cogbutton.hpp | severin-lemaignan/boxology | 08b592b315c0e7960ed5d7f8385f2702c0443013 | [
"MIT"
] | 4 | 2015-10-23T08:24:27.000Z | 2018-06-27T19:09:44.000Z | #ifndef LABEL_BUTTON_HPP
#define LABEL_BUTTON_HPP
#include <string>
#include <QPushButton>
#include <QMouseEvent>
#include <QColor>
#include "../label.hpp"
class CogButton : public QPushButton {
Q_OBJECT
public:
CogButton() = delete;
CogButton(Label label, QWidget *parent = 0);
// QColor color() const {return _color;}
// private slots:
void mousePressEvent(QMouseEvent *e);
signals:
void triggered(Label label);
private:
void setColor(const QColor &color);
Label _label;
};
#endif // LABEL_BUTTON_HPP
| 16.382353 | 48 | 0.685817 |
de3d6c360840d735ace846bbb9d1c860295da0f6 | 13,696 | cxx | C++ | ants/lib/LOCAL_getNeighborhoodMatrix.cxx | tfmoraes/ANTsPy | 4eeaa42548218b9699a7c7a2634cfc7a7350fb66 | [
"Apache-2.0"
] | 338 | 2017-09-01T06:47:54.000Z | 2022-03-31T12:11:46.000Z | ants/lib/LOCAL_getNeighborhoodMatrix.cxx | tfmoraes/ANTsPy | 4eeaa42548218b9699a7c7a2634cfc7a7350fb66 | [
"Apache-2.0"
] | 306 | 2017-08-30T20:05:07.000Z | 2022-03-31T16:20:44.000Z | ants/lib/LOCAL_getNeighborhoodMatrix.cxx | tfmoraes/ANTsPy | 4eeaa42548218b9699a7c7a2634cfc7a7350fb66 | [
"Apache-2.0"
] | 115 | 2017-09-08T11:53:17.000Z | 2022-03-27T05:53:39.000Z |
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <algorithm>
#include <vector>
#include <string>
#include <limits>
#include "itkAddImageFilter.h"
#include "itkDefaultConvertPixelTraits.h"
#include "itkMultiplyImageFilter.h"
#include "itkImage.h"
#include "itkVectorImage.h"
#include "itkImageBase.h"
#include "itkImageRegionConstIterator.h"
#include "itkImageRegionIterator.h"
#include "itkImageRegionIteratorWithIndex.h"
#include "itkNeighborhoodIterator.h"
#include "itkPermuteAxesImageFilter.h"
#include "itkCentralDifferenceImageFunction.h"
#include "itkContinuousIndex.h"
#include "vnl/vnl_matrix.h"
#include "vnl/vnl_vector.h"
#include "vnl/algo/vnl_determinant.h"
#include "LOCAL_antsImage.h"
namespace py = pybind11;
using namespace py::literals;
template< class PixelType , unsigned int Dimension >
py::dict getNeighborhoodMatrix( py::capsule ants_image,
py::capsule ants_mask,
std::vector<int> radius,
int physical,
int boundary,
int spatial,
int getgradient)
{
typedef double RealType;
typedef itk::Image<PixelType, Dimension> ImageType;
typedef typename ImageType::Pointer ImagePointerType;
typedef typename ImageType::IndexType IndexType;
typedef typename ImageType::PointType PointType;
typedef itk::CentralDifferenceImageFunction< ImageType, RealType > GradientCalculatorType;
typedef itk::CovariantVector<RealType, Dimension> CovariantVectorType;
ImagePointerType image = as< ImageType >( ants_image );
ImagePointerType mask = as< ImageType >( ants_mask );
//Rcpp::NumericVector radius( r_radius ) ;
//int physical = Rcpp::as<int>( r_physical );
//int boundary = Rcpp::as<int>( r_boundary );
//int spatial = Rcpp::as<int>( r_spatial );
//int getgradient = Rcpp::as<int>( r_gradient );
typename itk::NeighborhoodIterator<ImageType>::SizeType nSize;
unsigned long maxSize = 1;
for ( unsigned int i=0; i<Dimension; i++ )
{
maxSize *= ( 1 + 2*radius[i] );
nSize[i] = radius[i];
}
std::vector<double> pixelList;
pixelList.reserve(maxSize);
itk::ImageRegionIteratorWithIndex<ImageType> it( mask, mask->GetLargestPossibleRegion() ) ;
itk::NeighborhoodIterator<ImageType> nit( nSize, image, image->GetLargestPossibleRegion() ) ;
unsigned long nVoxels = 0;
while( !it.IsAtEnd() )
{
if ( it.Value() > 0 )
{
++nVoxels;
}
++it;
}
//Rcpp::NumericMatrix matrix(maxSize, nVoxels);
std::vector<std::vector<float> > matrix(maxSize, std::vector<float>(nVoxels));
if ( ( ! spatial ) && ( ! getgradient ) )
{
unsigned int col = 0;
it.GoToBegin();
while( !it.IsAtEnd() )
{
if ( it.Value() > 1.e-6 ) // use epsilon instead of zero
{
double mean = 0;
double count = 0;
for ( unsigned int row=0; row < nit.Size(); row++ )
{
IndexType idx = it.GetIndex() + nit.GetOffset(row);
// check boundary conditions
if ( mask->GetRequestedRegion().IsInside(idx) )
{
if ( mask->GetPixel(idx) > 0 ) // fully within boundaries
{
matrix[row][col] = nit.GetPixel(row);
mean += nit.GetPixel(row);
++count;
}
else
{
if ( boundary == 1 )
{
matrix[row][col] = nit.GetPixel(row);
}
else
{
matrix[row][col] = std::numeric_limits<double>::quiet_NaN();
}
}
}
else
{
matrix[row][col] = std::numeric_limits<double>::quiet_NaN();
}
}
if ( boundary == 2 )
{
mean /= count;
for ( unsigned int row=0; row < nit.Size(); row++ )
{
if ( matrix[row][col] != matrix[row][col] )
{
matrix[row][col] = mean;
}
}
}
++col;
}
++it;
++nit;
}
return py::dict("matrix"_a=matrix );
}
if ( ( ! spatial ) && ( getgradient ) )
{
typename GradientCalculatorType::Pointer
imageGradientCalculator = GradientCalculatorType::New();
imageGradientCalculator->SetInputImage( image );
// this will hold spatial locations of pixels or voxels
//Rcpp::NumericMatrix gradients( Dimension, nVoxels );
std::vector<std::vector<float> > gradients(Dimension, std::vector<float>(nVoxels));
unsigned int col = 0;
it.GoToBegin();
while( !it.IsAtEnd() )
{
if ( it.Value() > 1.e-6 ) // use epsilon instead of zero
{
double mean = 0;
double count = 0;
for ( unsigned int row=0; row < nit.Size(); row++ )
{
IndexType idx = it.GetIndex() + nit.GetOffset(row);
// check boundary conditions
if ( mask->GetRequestedRegion().IsInside(idx) )
{
if ( mask->GetPixel(idx) > 0 ) // fully within boundaries
{
matrix[row][col] = nit.GetPixel(row);
mean += nit.GetPixel(row);
++count;
if ( row == 0 )
{
CovariantVectorType gradient =
imageGradientCalculator->EvaluateAtIndex( it.GetIndex() );
for ( unsigned int dd = 0; dd < Dimension; dd++ )
gradients[dd][col] = gradient[ dd ];
}
}
else
{
if ( boundary == 1 )
{
matrix[row][col] = nit.GetPixel(row);
}
else
{
matrix[row][col] = std::numeric_limits<double>::quiet_NaN();
}
}
}
else
{
matrix[row][col] = std::numeric_limits<double>::quiet_NaN();
}
}
if ( boundary == 2 )
{
mean /= count;
for ( unsigned int row=0; row < nit.Size(); row++ )
{
if ( matrix[row][col] != matrix[row][col] )
{
matrix[row][col] = mean;
}
}
}
++col;
}
++it;
++nit;
}
//return Rcpp::List::create( Rcpp::Named("values") = matrix,
// Rcpp::Named("gradients") = gradients );
return py::dict("values"_a=matrix, "gradients"_a=gradients);
}
// if spatial and gradient, then just use spatial - no gradient ...
// this will hold spatial locations of pixels or voxels
//Rcpp::NumericMatrix indices(nVoxels, Dimension);
std::vector<std::vector<float> > indices(nVoxels, std::vector<float>(Dimension));
// Get relative offsets of neighborhood locations
//Rcpp::NumericMatrix offsets(nit.Size(), Dimension);
std::vector<std::vector<float> > offsets(nit.Size(), std::vector<float>(Dimension));
for ( unsigned int i=0; i < nit.Size(); i++ )
{
for ( unsigned int j=0; j<Dimension; j++)
{
offsets[i][j] = nit.GetOffset(i)[j];
if ( physical )
{
offsets[i][j] = offsets[i][j] * image->GetSpacing()[j];
}
}
}
unsigned int col = 0;
it.GoToBegin();
while( !it.IsAtEnd() )
{
if ( it.Value() > 0 )
{
PointType pt;
if ( physical )
{
image->TransformIndexToPhysicalPoint(it.GetIndex(), pt);
}
for ( unsigned int i=0; i < Dimension; i++)
{
if ( physical )
{
indices[col][i] = pt[i];
}
else
{
indices[col][i] = it.GetIndex()[i] + 1;
}
}
double mean = 0;
double count = 0;
for ( unsigned int row=0; row < nit.Size(); row++ )
{
IndexType idx = it.GetIndex() + nit.GetOffset(row);
// check boundary conditions
if ( mask->GetRequestedRegion().IsInside(idx) )
{
if ( mask->GetPixel(idx) > 0 ) // fully within boundaries
{
matrix[row][col] = nit.GetPixel(row);
mean += nit.GetPixel(row);
++count;
}
else
{
if ( boundary == 1 )
{
matrix[row][col] = nit.GetPixel(row);
}
else
{
matrix[row][col] = std::numeric_limits<double>::quiet_NaN();
}
}
}
else
{
matrix[row][col] = std::numeric_limits<double>::quiet_NaN();
}
}
if ( boundary == 2 )
{
mean /= count;
for ( unsigned int row=0; row < nit.Size(); row++ )
{
if ( matrix[row][col] != matrix[row][col] )
{
matrix[row][col] = mean;
}
}
}
++col;
}
++it;
++nit;
}
//return Rcpp::List::create( Rcpp::Named("values") = matrix,
// Rcpp::Named("indices") = indices,
// Rcpp::Named("offsets") = offsets );
return py::dict("values"_a=matrix, "indices"_a=indices, "offsets"_a=offsets);
}
template< class PixelType , unsigned int Dimension >
py::dict getNeighborhood( py::capsule ants_image,
std::vector<float> index,
std::vector<float> kernel,
std::vector<int> radius,
int physicalFlag )
{
typedef itk::Image<PixelType, Dimension> ImageType;
typedef typename ImageType::Pointer ImagePointerType;
typedef typename ImageType::RegionType RegionType;
typedef typename ImageType::IndexType IndexType;
ImagePointerType image = as< ImageType >( ants_image );
//Rcpp::NumericVector kernel( r_kernel );
//Rcpp::NumericVector radius( r_radius );
//Rcpp::NumericVector index( r_index );
//int physicalFlag = Rcpp::as<int>( physical );
unsigned long maxSize = 0;
std::vector<int> offsets;
for ( unsigned int i=0; i<kernel.size(); i++ )
{
if ( kernel[i] > 1.e-6 ) // use epsilon instead of zero
{
offsets.push_back(i);
++maxSize;
}
}
//Rcpp::NumericVector pixels(maxSize);
std::vector<float> pixels(maxSize);
std::vector<IndexType> indexList;
indexList.reserve(maxSize);
RegionType region;
typename itk::NeighborhoodIterator<ImageType>::SizeType nRadius;
for ( unsigned int i=0; i<Dimension; i++ )
{
nRadius[i] = radius[i];
region.SetSize(i, 1);
region.SetIndex(i, index[i]-1); // R-to-ITK index conversion
}
RegionType imageSize = image->GetLargestPossibleRegion();
itk::NeighborhoodIterator<ImageType> nit( nRadius, image, region );
unsigned int idx = 0;
for (unsigned int i = 0; i < offsets.size(); i++ )
{
//Rcpp::Rcout << nit.GetIndex(i) << ":" << offsets[i] << "=" << kernel[offsets[i]] << std::endl;
if ( kernel[offsets[i]] > 1e-6 )
{
if ( imageSize.IsInside( nit.GetIndex(offsets[i]) ) )
{
pixels[idx] = nit.GetPixel(offsets[i]);
}
else
{
pixels[idx] = 0.0;
}
indexList.push_back( nit.GetIndex(offsets[i]) );
++idx;
}
}
//Rcpp::NumericMatrix indices( pixels.size(), Dimension );
std::vector<std::vector<float> > indices(pixels.size(), std::vector<float>(Dimension));
for ( unsigned int i=0; i<pixels.size(); i++)
{
typename ImageType::PointType pt;
if ( physicalFlag )
{
image->TransformIndexToPhysicalPoint( indexList[i], pt );
}
for ( unsigned int j=0; j<Dimension; j++)
{
if ( !physicalFlag )
{
indices[i][j] = indexList[i][j] + 1; // ITK-to-R index conversion
}
else
{
indices[i][j] = pt[j];
}
}
}
//return Rcpp::List::create( Rcpp::Named("values") = pixels,
// Rcpp::Named("indices") = indices );
return py::dict("values"_a=pixels, "indices"_a=indices);
}
PYBIND11_MODULE(getNeighborhoodMatrix, m)
{
m.def("getNeighborhoodMatrixUC2", &getNeighborhoodMatrix<unsigned char,2>);
m.def("getNeighborhoodMatrixUC3", &getNeighborhoodMatrix<unsigned char,3>);
m.def("getNeighborhoodMatrixUC4", &getNeighborhoodMatrix<unsigned char,4>);
m.def("getNeighborhoodMatrixUI2", &getNeighborhoodMatrix<unsigned int,2>);
m.def("getNeighborhoodMatrixUI3", &getNeighborhoodMatrix<unsigned int,3>);
m.def("getNeighborhoodMatrixUI4", &getNeighborhoodMatrix<unsigned int,4>);
m.def("getNeighborhoodMatrixF2", &getNeighborhoodMatrix<float,2>);
m.def("getNeighborhoodMatrixF3", &getNeighborhoodMatrix<float,3>);
m.def("getNeighborhoodMatrixF4", &getNeighborhoodMatrix<float,4>);
m.def("getNeighborhoodUC2", &getNeighborhood<unsigned char,2>);
m.def("getNeighborhoodUC3", &getNeighborhood<unsigned char,3>);
m.def("getNeighborhoodUC4", &getNeighborhood<unsigned char,4>);
m.def("getNeighborhoodUI2", &getNeighborhood<unsigned int,2>);
m.def("getNeighborhoodUI3", &getNeighborhood<unsigned int,3>);
m.def("getNeighborhoodUI4", &getNeighborhood<unsigned int,4>);
m.def("getNeighborhoodF2", &getNeighborhood<float,2>);
m.def("getNeighborhoodF3", &getNeighborhood<float,3>);
m.def("getNeighborhoodF4", &getNeighborhood<float,4>);
}
| 30.035088 | 100 | 0.542932 |
de3d806a2ca4d876c343358a63de74ae59c8d1e9 | 1,096 | hpp | C++ | Octree/OctreeLeaf.hpp | kashinoleg/Octree | 3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5 | [
"ICU"
] | null | null | null | Octree/OctreeLeaf.hpp | kashinoleg/Octree | 3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5 | [
"ICU"
] | null | null | null | Octree/OctreeLeaf.hpp | kashinoleg/Octree | 3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5 | [
"ICU"
] | null | null | null | #pragma once
#include "OctreeArray.hpp"
#include "OctreeCell.hpp"
#include "OctreeBranch.hpp"
/**
* outer node implementation of an octree cell.stores pointers to items.
*/
namespace hxa {
class OctreeLeaf : public OctreeCell {
private:
OctreeArray<const void*> items_m;
public:
OctreeLeaf();
OctreeLeaf(const OctreeLeaf*const leafs[8]);
private:
explicit OctreeLeaf(const void* pItem);
public:
virtual ~OctreeLeaf();
OctreeLeaf(const OctreeLeaf&);
OctreeLeaf& operator=(const OctreeLeaf&);
virtual void insertItem(const OctreeData& thisData, OctreeCell*& pThis, const void* pItem, const OctreeAgentV& agent);
virtual bool removeItem(OctreeCell*& pThis, const void* pItem,
const int maxItemsPerCell, int& itemCount);
virtual void visit(const OctreeData& thisData, OctreeVisitorV& visitor) const;
virtual OctreeCell* clone() const;
virtual void getInfo(int& byteSize, int& leafCount, int& itemCount, int& maxDepth) const;
static void insertItemMaybeCreate(const OctreeData& cellData, OctreeCell*& pCell, const void* pItem, const OctreeAgentV& agent);
};
}
| 34.25 | 130 | 0.75365 |
de4019f479963529f9b3a6137e88af18a992c4cb | 10,017 | cpp | C++ | src/zNativeMayaTools/Helpers.cpp | zewt/zMayaTools | 9f7f43ab015e58cf25fc82f4ae1cdd424b5a52a1 | [
"MIT"
] | 73 | 2017-12-08T03:33:50.000Z | 2022-03-21T15:44:12.000Z | src/zNativeMayaTools/Helpers.cpp | zewt/zMayaTools | 9f7f43ab015e58cf25fc82f4ae1cdd424b5a52a1 | [
"MIT"
] | 4 | 2019-03-17T05:25:23.000Z | 2021-03-25T04:22:18.000Z | src/zNativeMayaTools/Helpers.cpp | zewt/zMayaTools | 9f7f43ab015e58cf25fc82f4ae1cdd424b5a52a1 | [
"MIT"
] | 10 | 2018-12-19T04:38:10.000Z | 2022-01-28T06:24:18.000Z | // Simple helpers that aren't specific to Maya.
#include "Helpers.h"
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
#include <fstream>
#include <exception>
#include <vector>
using namespace std;
string Helpers::vssprintf(const char *fmt, va_list va)
{
va_list va2 = va;
int size = vsnprintf(nullptr, 0, fmt, va2);
auto buf = (char *) alloca(size + 1);
vsnprintf(buf, size + 1, fmt, va);
return string(buf, size);
}
string Helpers::ssprintf(const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
return vssprintf(fmt, va);
}
wstring Helpers::vssprintf(const wchar_t *fmt, va_list va)
{
va_list va2 = va;
int size = _vsnwprintf(nullptr, 0, fmt, va2);
auto buf = (wchar_t *) alloca((size + 1)*sizeof(wchar_t));
_vsnwprintf(buf, size + 1, fmt, va);
return wstring(buf, size);
}
wstring Helpers::ssprintf(const wchar_t *fmt, ...)
{
va_list va;
va_start(va, fmt);
return vssprintf(fmt, va);
}
bool Helpers::endsWith(const wstring &s, const wstring &suffix)
{
if(s.size() < suffix.size())
return false;
return s.compare(s.size() - suffix.size(), suffix.size(), suffix) == 0;
}
void Helpers::split(const string &source, char delimitor, vector<string> &result)
{
result.clear();
if(source.empty())
return;
size_t startpos = 0;
do {
size_t pos;
pos = source.find(delimitor, startpos);
if(pos == source.npos)
pos = source.size();
if(pos-startpos > 0)
{
const string AddRString = source.substr(startpos, pos-startpos);
result.push_back(AddRString);
}
startpos = pos+1;
} while (startpos <= source.size());
}
string Helpers::basename(const string &path)
{
size_t slash = path.find_last_of("/\\");
if(slash == string::npos)
return path;
else
return path.substr(slash + 1);
}
wstring Helpers::basename(const wstring &path)
{
size_t slash = path.find_last_of(L"/\\");
if(slash == string::npos)
return path;
else
return path.substr(slash + 1);
}
wstring Helpers::dirname(const wstring &path)
{
size_t slash = path.find_last_of(L"/\\");
if(slash == wstring::npos)
return path;
else
return path.substr(0, slash);
}
string Helpers::extension(const string &path)
{
size_t pos = path.rfind('.');
if(pos == string::npos)
return "";
return path.substr(pos+1);
}
wstring Helpers::extension(const wstring &path)
{
size_t pos = path.rfind(L'.');
if(pos == wstring::npos)
return L"";
return path.substr(pos+1);
}
void Helpers::replaceString(string &s, const string &src, const string &dst)
{
if(src.empty())
return;
size_t pos = 0;
while(1)
{
pos = s.find(src, pos);
if(pos == string::npos)
break;
s.replace(s.begin()+pos, s.begin()+pos+src.size(), dst.begin(), dst.end());
pos += dst.size();
}
}
void Helpers::replaceString(wstring &s, const wstring &src, const wstring &dst)
{
if(src.empty())
return;
size_t pos = 0;
while(1)
{
pos = s.find(src, pos);
if(pos == string::npos)
break;
s.replace(s.begin()+pos, s.begin()+pos+src.size(), dst.begin(), dst.end());
pos += dst.size();
}
}
string Helpers::lowercase(const string &s)
{
string result = s;
for(char &c: result)
c = tolower(c);
return result;
}
wstring Helpers::lowercase(const wstring &s)
{
wstring result = s;
for(wchar_t &c: result)
c = towlower(c);
return result;
}
#include <windows.h>
string Helpers::getWinError(int err)
{
if(err == -1)
err = GetLastError();
char *buf = NULL;
if(!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, err, 0, (LPSTR) &buf, 0, NULL))
return "Error retrieving error";
string result(buf);
LocalFree(buf);
// Why does FormatMessage put newlines at the end of error messages?
while(result.size() > 1 && (result[result.size()-1] == '\r' || result[result.size()-1] == '\n'))
result.erase(result.size()-1);
return result;
}
wstring Helpers::getThisDLLPath()
{
HMODULE handle = NULL;
if(!GetModuleHandleExW(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPWSTR) getThisDLLPath, &handle))
{
throw exception((string("GetModuleHandleExW failed: ") + getWinError()).c_str());
}
wchar_t path[MAX_PATH*2];
if(!GetModuleFileNameW(handle, path, sizeof(path)))
{
throw exception((string("GetModuleFileNameW failed: ") + getWinError()).c_str());
}
return path;
}
std::wstring Helpers::getTopPluginPath()
{
wstring dllPath = getThisDLLPath();
if(dllPath.empty())
return L"";
// dllPath should be dir/plug-ins/bin/version/plugin.mll. Remove the last four
// components to get to the install directory.
for(int i = 0; i < 4; ++i)
dllPath = dirname(dllPath);
return dllPath;
}
string Helpers::wstringToString(const wstring &s)
{
// Get the size.
int size = WideCharToMultiByte(CP_ACP,
0,
s.data(), (int) s.size(),
NULL, 0,
0, NULL);
string result(size, 0);
WideCharToMultiByte(CP_ACP,
0,
s.data(), (int) s.size(),
const_cast<char *>(result.data()), size,
0, NULL);
return result;
}
wstring Helpers::stringToWstring(const string &s)
{
// Get the size.
int size = MultiByteToWideChar(CP_ACP,
0,
s.data(), (int) s.size(),
NULL, 0);
wstring result(size, 0);
MultiByteToWideChar(CP_ACP,
0,
s.data(), (int) s.size(),
const_cast<wchar_t *>(result.data()), size);
return result;
}
void Helpers::getFilesInDirectory(wstring path, vector<wstring> &filenames, bool includePath)
{
// if(path.size() > 0 && path.Right(1) == "/")
// path.erase(path.size() - 1);
WIN32_FIND_DATAW fd;
HANDLE hFind = FindFirstFileW((path + L"/*").c_str(), &fd);
if( hFind == INVALID_HANDLE_VALUE )
return;
do {
if(!wcscmp(fd.cFileName, L".") || !wcscmp(fd.cFileName, L".."))
continue;
wstring filename = fd.cFileName;
if(includePath)
filename = path + L"/" + filename;
filenames.push_back(filename);
} while(FindNextFile(hFind, &fd));
FindClose(hFind);
}
double Helpers::getTime()
{
#if 1
static LARGE_INTEGER freq = {0};
if(freq.QuadPart == 0)
QueryPerformanceFrequency(&freq);
LARGE_INTEGER cnt;
QueryPerformanceCounter(&cnt);
return cnt.QuadPart / double(freq.QuadPart);
#else
return GetTickCount() / 1000.0;
#endif
}
std::wstring Helpers::getTempPath()
{
wchar_t tempPath[MAX_PATH+1];
int length = GetTempPathW(MAX_PATH+1, tempPath);
return wstring(tempPath, length);
}
string Helpers::readFile(wstring path)
{
try {
ifstream f;
f.exceptions(std::ifstream::failbit | std::ifstream::badbit);
f.open(path, ios::in | ios::binary);
f.seekg(0, ios_base::end);
int size = (int) f.tellg();
f.seekg(0, ios_base::beg);
string result(size, 0);
f.read((char *) result.data(), size);
return result;
} catch(ifstream::failure e) {
throw StringException(ssprintf("Error reading %s: %s", wstringToString(path).c_str(), strerror(errno)));
}
}
void Helpers::writeFile(wstring path, string data)
{
ofstream f(path, ios::out | ios::binary | ios::trunc);
f.write(data.data(), data.size());
f.flush();
if(!f)
throw exception((string("Couldn't write ") + wstringToString(path)).c_str());
}
string Helpers::SubstituteString(string filenamePattern, map<string,string> replacements)
{
for(auto it: replacements)
{
string keyword = lowercase(it.first);
string lowercasePattern = string("<") + lowercase(keyword) + ">";
while(1)
{
size_t pos = lowercase(filenamePattern).find(lowercasePattern);
if(pos == string::npos)
break;
string newPattern;
newPattern += filenamePattern.substr(0, pos); // string before the keyword
newPattern += it.second;
newPattern += filenamePattern.substr(pos + lowercasePattern.size()); // string after the keyword
filenamePattern = newPattern;
}
}
return filenamePattern;
}
float Helpers::linearToSRGB(float value)
{
if(value > 0.0031308f)
return 1.055f * (powf(value, (1.0f / 2.4f))) - 0.055f;
else
return 12.92f * value;
}
double Helpers::getFileModificationTime(wstring path)
{
HANDLE file = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if(file == INVALID_HANDLE_VALUE)
return 0;
FILETIME writeTime;
bool result = GetFileTime(file, nullptr, nullptr, &writeTime);
CloseHandle(file);
if(!result)
return 0;
uint64_t ticks = uint64_t(writeTime.dwHighDateTime) << 32 | writeTime.dwLowDateTime;
return ticks / 100000000.0;
}
string Helpers::escapeMel(const string &s)
{
string result;
for(char c: s)
{
if(c == '"')
result.append("\\\"");
else if(c == '\\')
result.append("\\\\");
else if(c == '\n')
result.append("\\n");
else if(c == '\t')
result.append("\\t");
else
result.append(1, c);
}
return result;
}
Helpers::HResultException::HResultException(HRESULT hr_, std::string caller):
exception(formatMessage(hr_, caller).c_str()),
hr(hr_)
{
}
string Helpers::HResultException::formatMessage(HRESULT hr, std::string caller)
{
string result = Helpers::getWinError(hr);
if(!caller.empty())
result = caller + ": " + result;
return result;
}
| 24.313107 | 118 | 0.597784 |
de432f1072702f047a9ff38adc61b3285afe52ba | 412 | hpp | C++ | src/Generator.hpp | ageorgiev97/yat | 293adda152025d7c7bfbb2e982aa9d2ff5a461d9 | [
"Apache-2.0"
] | 1 | 2019-12-11T21:50:13.000Z | 2019-12-11T21:50:13.000Z | src/Generator.hpp | ageorgiev97/yat | 293adda152025d7c7bfbb2e982aa9d2ff5a461d9 | [
"Apache-2.0"
] | 4 | 2019-11-30T21:55:18.000Z | 2019-11-30T23:00:08.000Z | src/Generator.hpp | ageorgiev97/yat | 293adda152025d7c7bfbb2e982aa9d2ff5a461d9 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <memory>
#include <unordered_map>
#include "Llvm.hpp"
#include "Expressions.hpp"
#include "Statements.hpp"
#include "Scope.hpp"
#include "Function.hpp"
namespace yat
{
extern llvm::LLVMContext GlobalContext;
extern std::unique_ptr<llvm::Module> GlobalModule;
extern std::unordered_map<std::string, Function> functions;
void GenerateCode(Statement const& expression);
} | 19.619048 | 63 | 0.742718 |
de43e22d76b73a49cbfe76e8f08efcf00e7cedbe | 3,766 | cpp | C++ | python/src/distance/edge_edge.cpp | ipc-sim/ipc-toolk | 81873d0288810e30166d871419da4104329860e3 | [
"MIT"
] | 61 | 2020-08-04T21:08:25.000Z | 2022-02-25T02:24:31.000Z | python/src/distance/edge_edge.cpp | dbelgrod/ipc-toolkit | 0b7ca9b5f867db63bd68dd02ce54a9d00b0fc337 | [
"MIT"
] | 2 | 2020-10-12T05:54:40.000Z | 2021-10-10T18:39:30.000Z | python/src/distance/edge_edge.cpp | dbelgrod/ipc-toolkit | 0b7ca9b5f867db63bd68dd02ce54a9d00b0fc337 | [
"MIT"
] | 7 | 2020-11-26T12:47:38.000Z | 2022-03-25T04:55:49.000Z | #include <pybind11/pybind11.h>
#include <pybind11/eigen.h>
#include <ipc/distance/distance_type.hpp>
#include <ipc/distance/edge_edge.hpp>
#include "../utils.hpp"
namespace py = pybind11;
using namespace ipc;
void define_edge_edge_distance_functions(py::module_& m)
{
m.def(
"edge_edge_distance",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
if (dtype == nullptr) {
return edge_edge_distance(ea0, ea1, eb0, eb1);
} else {
return edge_edge_distance(ea0, ea1, eb0, eb1, *dtype);
}
},
R"ipc_Qu8mg5v7(
Compute the distance between a two lines segments in 3D.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) edge-edge distance type to compute
Returns:
The distance between the two edges.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
m.def(
"edge_edge_distance_gradient",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
Vector<double, 12> grad;
if (dtype == nullptr) {
edge_edge_distance_gradient(ea0, ea1, eb0, eb1, grad);
} else {
edge_edge_distance_gradient(ea0, ea1, eb0, eb1, *dtype, grad);
}
return grad;
},
R"ipc_Qu8mg5v7(
Compute the gradient of the distance between a two lines segments.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) point edge distance type to compute
Returns:
The gradient of the distance wrt ea0, ea1, eb0, and eb1.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
m.def(
"edge_edge_distance_hessian",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
Eigen::Matrix<double, 12, 12> hess;
if (dtype == nullptr) {
edge_edge_distance_hessian(ea0, ea1, eb0, eb1, hess);
} else {
edge_edge_distance_hessian(ea0, ea1, eb0, eb1, *dtype, hess);
}
return hess;
},
R"ipc_Qu8mg5v7(
Compute the hessian of the distance between a two lines segments.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) point edge distance type to compute
Returns:
The hessian of the distance wrt ea0, ea1, eb0, and eb1.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
}
| 34.87037 | 78 | 0.568508 |
de453dff328feddf3b3e01648695ad3c1c04d789 | 8,250 | cc | C++ | tests/unit/bcache_test.cc | pombredanne/forestdb | 37c787a7a6947a876d8609a3f70840b5da19b728 | [
"Apache-2.0"
] | 992 | 2015-02-28T11:55:28.000Z | 2022-03-28T03:17:50.000Z | tests/unit/bcache_test.cc | pombredanne/forestdb | 37c787a7a6947a876d8609a3f70840b5da19b728 | [
"Apache-2.0"
] | 16 | 2015-04-07T19:35:52.000Z | 2022-02-21T22:40:58.000Z | tests/unit/bcache_test.cc | pombredanne/forestdb | 37c787a7a6947a876d8609a3f70840b5da19b728 | [
"Apache-2.0"
] | 173 | 2015-03-04T13:17:41.000Z | 2022-03-28T13:17:55.000Z | /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
* Copyright 2010 Couchbase, 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "test.h"
#include "blockcache.h"
#include "filemgr.h"
#include "filemgr_ops.h"
#include "crc32.h"
#include "memleak.h"
void basic_test()
{
TEST_INIT();
FileMgr *file;
FileMgrConfig config(4096, 5, 1048576, 0, 0, FILEMGR_CREATE,
FDB_SEQTREE_NOT_USE, 0, 8, 0, FDB_ENCRYPTION_NONE,
0x00, 0, 0);
int i;
uint8_t buf[4096];
std::string fname("./bcache_testfile");
filemgr_open_result result = FileMgr::open(fname, get_filemgr_ops(),
&config, NULL);
file = result.file;
for (i=0;i<5;++i) {
file->alloc_FileMgr(NULL);
file->write_FileMgr(i, buf, NULL);
}
file->commit_FileMgr(true, NULL);
for (i=5;i<10;++i) {
file->alloc_FileMgr(NULL);
file->write_FileMgr(i, buf, NULL);
}
file->commit_FileMgr(true, NULL);
file->read_FileMgr(8, buf, NULL, true);
file->read_FileMgr(9, buf, NULL, true);
file->read_FileMgr(1, buf, NULL, true);
file->read_FileMgr(2, buf, NULL, true);
file->read_FileMgr(3, buf, NULL, true);
file->read_FileMgr(7, buf, NULL, true);
file->read_FileMgr(1, buf, NULL, true);
file->read_FileMgr(9, buf, NULL, true);
file->alloc_FileMgr(NULL);
file->write_FileMgr(10, buf, NULL);
TEST_RESULT("basic test");
}
void basic_test2()
{
TEST_INIT();
FileMgr *file;
FileMgrConfig config(4096, 5, 1048576, 0x0, 0, FILEMGR_CREATE,
FDB_SEQTREE_NOT_USE, 0, 8, 0, FDB_ENCRYPTION_NONE,
0x00, 0, 0);
int i;
uint8_t buf[4096];
std::string fname("./bcache_testfile");
int r;
r = system(SHELL_DEL " bcache_testfile");
(void)r;
filemgr_open_result result = FileMgr::open(fname, get_filemgr_ops(),
&config, NULL);
file = result.file;
for (i=0;i<5;++i) {
file->alloc_FileMgr(NULL);
file->write_FileMgr(i, buf, NULL);
}
for (i=5;i<10;++i) {
file->alloc_FileMgr(NULL);
file->write_FileMgr(i, buf, NULL);
}
file->commit_FileMgr(true, NULL);
FileMgr::close(file, true, NULL, NULL);
FileMgr::shutdown();
TEST_RESULT("basic test");
}
struct worker_args{
size_t n;
FileMgr *file;
size_t writer;
size_t nblocks;
size_t time_sec;
};
void * worker(void *voidargs)
{
uint8_t *buf = (uint8_t *)malloc(4096);
struct worker_args *args = (struct worker_args*)voidargs;
struct timeval ts_begin, ts_cur, ts_gap;
ssize_t ret;
bid_t bid;
uint32_t crc, crc_file;
uint64_t i, c, run_count=0;
TEST_INIT();
memset(buf, 0, 4096);
gettimeofday(&ts_begin, NULL);
while(1) {
bid = rand() % args->nblocks;
ret = BlockCacheManager::getInstance()->read(args->file, bid, buf);
if (ret <= 0) {
ret = args->file->getOps()->pread(args->file->getFopsHandle(), buf,
args->file->getBlockSize(),
bid * args->file->getBlockSize());
TEST_CHK(ret == (ssize_t)args->file->getBlockSize());
ret = BlockCacheManager::getInstance()->write(args->file, bid, buf,
BCACHE_REQ_CLEAN, false);
TEST_CHK(ret == (ssize_t)args->file->getBlockSize());
}
crc_file = crc32_8(buf, sizeof(uint64_t)*2, 0);
(void)crc_file;
memcpy(&i, buf, sizeof(i));
memcpy(&crc, buf + sizeof(uint64_t)*2, sizeof(crc));
// Disable checking the CRC value at this time as pread and pwrite are
// not thread-safe.
// TEST_CHK(crc == crc_file && i==bid);
//DBG("%d %d %d %x %x\n", (int)args->n, (int)i, (int)bid, (int)crc, (int)crc_file);
if (args->writer) {
memcpy(&c, buf+sizeof(i), sizeof(c));
c++;
memcpy(buf+sizeof(i), &c, sizeof(c));
crc = crc32_8(buf, sizeof(uint64_t)*2, 0);
memcpy(buf + sizeof(uint64_t)*2, &crc, sizeof(crc));
ret = BlockCacheManager::getInstance()->write(args->file, bid, buf,
BCACHE_REQ_DIRTY, true);
TEST_CHK(ret == (ssize_t)args->file->getBlockSize());
} else { // have some of the reader threads flush dirty immutable blocks
if (bid <= args->nblocks / 4) { // 25% probability
args->file->flushImmutable(NULL);
}
}
gettimeofday(&ts_cur, NULL);
ts_gap = _utime_gap(ts_begin, ts_cur);
if ((size_t)ts_gap.tv_sec >= args->time_sec) break;
run_count++;
}
free(buf);
thread_exit(0);
return NULL;
}
void multi_thread_test(int nblocks, int cachesize,
int blocksize, int time_sec,
int nwriters, int nreaders)
{
TEST_INIT();
FileMgr *file;
FileMgrConfig config(blocksize, cachesize, 1048576, 0x0, 0,
FILEMGR_CREATE, FDB_SEQTREE_NOT_USE, 0, 8, 0,
FDB_ENCRYPTION_NONE, 0x00, 0, 0);
int n = nwriters + nreaders;
uint64_t i, j;
uint32_t crc;
uint8_t *buf;
int r;
std::string fname("./bcache_testfile");
thread_t *tid = alca(thread_t, n);
struct worker_args *args = alca(struct worker_args, n);
void **ret = alca(void *, n);
r = system(SHELL_DEL " bcache_testfile");
(void)r;
memleak_start();
buf = (uint8_t *)malloc(4096);
memset(buf, 0, 4096);
filemgr_open_result result = FileMgr::open(fname, get_filemgr_ops(),
&config, NULL);
file = result.file;
for (i=0;i<(uint64_t)nblocks;++i) {
memcpy(buf, &i, sizeof(i));
j = 0;
memcpy(buf + sizeof(i), &j, sizeof(j));
crc = crc32_8(buf, sizeof(i) + sizeof(j), 0);
memcpy(buf + sizeof(i) + sizeof(j), &crc, sizeof(crc));
BlockCacheManager::getInstance()->write(file, (bid_t)i, buf,
BCACHE_REQ_DIRTY, false);
}
for (i=0;i<(uint64_t)n;++i){
args[i].n = i;
args[i].file = file;
args[i].writer = ((i<(uint64_t)nwriters)?(1):(0));
args[i].nblocks = nblocks;
args[i].time_sec = time_sec;
thread_create(&tid[i], worker, &args[i]);
}
DBG("wait for %d seconds..\n", time_sec);
for (i=0;i<(uint64_t)n;++i){
thread_join(tid[i], &ret[i]);
}
file->commit_FileMgr(true, NULL);
FileMgr::close(file, true, NULL, NULL);
FileMgr::shutdown();
free(buf);
memleak_end();
TEST_RESULT("multi thread test");
}
int main()
{
basic_test2();
#if !defined(THREAD_SANITIZER)
/**
* The following tests will be disabled when the code is run with
* thread sanitizer, because they point out a data race in writing/
* reading from a dirty block which will not happen in reality.
*
* The bcache partition lock is release iff a given dirty block has
* already been marked as immutable. These unit tests attempt to
* write to the same immutable block again causing this race. In
* reality, this won't happen as these operations go through
* FileMgr::read() and FileMgr::write().
*/
multi_thread_test(4, 1, 32, 20, 1, 7);
multi_thread_test(100, 1, 32, 10, 1, 7);
#endif
return 0;
}
| 30.783582 | 91 | 0.567879 |
de482e891dd8980943bd4795b5fc8ae7b524f6ad | 3,105 | cpp | C++ | integ/sync-interop/syncps-ind.cpp | yoursunny/ndn-ts | 1b8163ac43b2c2754a62e0724350ddb67714f095 | [
"0BSD"
] | null | null | null | integ/sync-interop/syncps-ind.cpp | yoursunny/ndn-ts | 1b8163ac43b2c2754a62e0724350ddb67714f095 | [
"0BSD"
] | null | null | null | integ/sync-interop/syncps-ind.cpp | yoursunny/ndn-ts | 1b8163ac43b2c2754a62e0724350ddb67714f095 | [
"0BSD"
] | null | null | null | #include "syncps.hpp"
#include <iostream>
/** @brief Timestamp naming convention (rev3). */
namespace Timestamp {
using TlvType = std::integral_constant<int, 0x38>;
inline uint64_t
now()
{
::timespec tp;
::clock_gettime(CLOCK_REALTIME, &tp);
return static_cast<uint64_t>(tp.tv_sec) * 1000000 + static_cast<uint64_t>(tp.tv_nsec) / 1000;
}
inline ndn::Name::Component
create(uint64_t v = now())
{
return ndn::Name::Component::fromNumber(v, ndn_NameComponentType_OTHER_CODE, TlvType::value);
}
inline uint64_t
parse(const ndn::Name::Component& comp)
{
if (comp.getType() == ndn_NameComponentType_OTHER_CODE &&
comp.getOtherTypeCode() == TlvType::value) {
return comp.toNumber();
}
return 0;
}
} // namespace Timestamp
int
main(int argc, char** argv)
{
INIT_LOGGERS();
log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getTrace());
// ndn::WireFormat::setDefaultWireFormat(ndn::Tlv0_3WireFormat::get());
if (argc != 4) {
std::cerr << "./demo SYNC-PREFIX SUB-PREFIX PUB-PREFIX" << std::endl;
return 2;
}
ndn::Name syncPrefix(argv[1]);
ndn::Name subPrefix(argv[2]);
ndn::Name pubPrefix(argv[3]);
ndn::KeyChain keyChain;
try {
keyChain.getDefaultCertificateName();
} catch (const ndn::Pib::Error&) {
keyChain.createIdentityV2("/operator");
}
ndn::ThreadsafeFace face;
face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
syncps::SyncPubsub sync(
face, syncPrefix,
[](const syncps::Publication& data) {
auto d = std::chrono::microseconds(
static_cast<int64_t>(Timestamp::now() - Timestamp::parse(data.getName()[-1])));
return d >= syncps::maxPubLifetime + syncps::maxClockSkew || d <= -syncps::maxClockSkew;
},
[](syncps::VPubPtr& ours, syncps::VPubPtr& others) mutable {
if (ours.empty()) {
return ours;
}
static const auto cmp = [](const syncps::PubPtr& a, const syncps::PubPtr& b) {
return Timestamp::parse(a->getName()[-1]) > Timestamp::parse(b->getName()[-1]);
};
std::sort(ours.begin(), ours.end(), cmp);
std::sort(others.begin(), others.end(), cmp);
std::copy(others.begin(), others.end(), std::back_inserter(ours));
return ours;
});
sync.subscribeTo(subPrefix, [](const syncps::Publication& data) {
std::cerr << "UPDATE " << data.getName() << std::endl;
});
ndn::scheduler::Scheduler sched(face.getIoService());
int seqNum = 0;
ndn::scheduler::EventCallback publish = [&]() {
ndn::Name name = pubPrefix;
name.append(std::to_string(++seqNum));
name.append(Timestamp::create());
std::cerr << "PUBLISH " << name << std::endl;
ndn::Data publication(name);
sync.publish(std::move(publication), [](const ndn::Data& pub, bool confirmed) {
std::cerr << (confirmed ? "CONFIRM " : "LOST ") << pub.getName() << std::endl;
});
float randTime = 0.0;
ndn::CryptoLite::generateRandomFloat(randTime);
sched.schedule(std::chrono::milliseconds(500 + static_cast<int>(200 * randTime)), publish);
};
publish();
face.getIoService().run();
}
| 30.441176 | 95 | 0.649919 |
de49013ba0bb5819c9de5d827f8a9f5731b10d95 | 1,843 | cpp | C++ | SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp | phoenixzz/VoronoiMapGen | 5afd852f8bb0212baba9d849178eb135f62df903 | [
"MIT"
] | 11 | 2017-03-03T03:31:15.000Z | 2019-03-01T17:09:12.000Z | SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp | phoenixzz/VoronoiMapGen | 5afd852f8bb0212baba9d849178eb135f62df903 | [
"MIT"
] | null | null | null | SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp | phoenixzz/VoronoiMapGen | 5afd852f8bb0212baba9d849178eb135f62df903 | [
"MIT"
] | 2 | 2017-03-03T03:31:17.000Z | 2021-05-27T21:50:43.000Z |
Emitter::Emitter() : Registerable(), Transformable(),
zone( &getDefaultZone() ),
full(true),
tank(-1),
flow(0.0f),
forceMin(0.0f),
forceMax(0.0f),
fraction( random(0.0f,1.0f) ),
active(true)
{}
Zone& Emitter::getDefaultZone()
{
static PointZone defaultZone;
return defaultZone;
}
void Emitter::registerChildren(bool registerAll)
{
Registerable::registerChildren(registerAll);
registerChild(zone, registerAll);
}
void Emitter::copyChildren(const Registerable& object, bool createBase)
{
const Emitter& emitter = dynamic_cast<const Emitter&>(object);
Registerable::copyChildren(emitter, createBase);
zone = dynamic_cast<Zone*>(copyChild(emitter.zone, createBase));
}
void Emitter::destroyChildren(bool keepChildren)
{
destroyChild(zone, keepChildren);
Registerable::destroyChildren(keepChildren);
}
Registerable* Emitter::findByName(const String& name)
{
Registerable* object = Registerable::findByName(name);
if (object != NULL)
return object;
return zone->findByName(name);
}
void Emitter::changeTank(int32 deltaTank)
{
if(tank >= 0)
{
tank += deltaTank;
if(tank < 0)
tank = 0;
}
}
void Emitter::changeFlow(float deltaFlow)
{
if(flow >= 0.0f)
{
flow += deltaFlow;
if(flow < 0.0f)
flow = 0.0f;
}
}
void Emitter::setZone(Zone* _zone, bool full)
{
decrementChildReference(this->zone);
incrementChildReference(_zone);
if(_zone == NULL)
_zone = &getDefaultZone();
this->zone = _zone;
this->full = full;
}
uint32 Emitter::updateNumber(float deltaTime)
{
int32 nbBorn;
if(flow < 0.0f)
{
nbBorn = jmax(0, tank);
tank = 0;
}
else if(tank != 0)
{
fraction += flow * deltaTime;
nbBorn = static_cast<int>(fraction);
if(tank >= 0)
{
nbBorn = jmin(tank, nbBorn);
tank -= nbBorn;
}
fraction -= nbBorn;
}
else
nbBorn = 0;
return static_cast<uint32>(nbBorn);
}
| 17.721154 | 71 | 0.689094 |
de4b3c28b3615706104c07e23521a23d4b51738b | 15,008 | cc | C++ | mysql-server/router/tests/helpers/router_test_helpers.cc | silenc3502/MYSQL-Arch-Doc-Summary | fcc6bb65f72a385b9f56debc9b2c00cee5914bae | [
"MIT"
] | null | null | null | mysql-server/router/tests/helpers/router_test_helpers.cc | silenc3502/MYSQL-Arch-Doc-Summary | fcc6bb65f72a385b9f56debc9b2c00cee5914bae | [
"MIT"
] | null | null | null | mysql-server/router/tests/helpers/router_test_helpers.cc | silenc3502/MYSQL-Arch-Doc-Summary | fcc6bb65f72a385b9f56debc9b2c00cee5914bae | [
"MIT"
] | null | null | null | /*
Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "router_test_helpers.h"
#include <cassert>
#include <cerrno>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <regex>
#include <stdexcept>
#include <thread>
#ifndef _WIN32
#include <sys/socket.h>
#include <unistd.h>
#else
#include <direct.h>
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#define getcwd _getcwd
#endif
#include "keyring/keyring_manager.h"
#include "my_inttypes.h" // ssize_t
#include "mysql/harness/filesystem.h"
#include "mysqlrouter/mysql_session.h"
#include "mysqlrouter/utils.h"
using mysql_harness::Path;
using namespace std::chrono_literals;
Path get_cmake_source_dir() {
Path result;
// PB2 specific source location
char *env_pb2workdir = std::getenv("PB2WORKDIR");
char *env_sourcename = std::getenv("SOURCENAME");
char *env_tmpdir = std::getenv("TMPDIR");
if ((env_pb2workdir && env_sourcename && env_tmpdir) &&
(strlen(env_pb2workdir) && strlen(env_tmpdir) &&
strlen(env_sourcename))) {
result = Path(env_tmpdir);
result.append(Path(env_sourcename));
if (result.exists()) {
return result;
}
}
char *env_value = std::getenv("CMAKE_SOURCE_DIR");
if (env_value == nullptr) {
// try a few places
result = Path(get_cwd()).join("..");
result = Path(result).real_path();
} else {
result = Path(env_value).real_path();
}
if (!result.join("src")
.join("router")
.join("src")
.join("router_app.cc")
.is_regular()) {
throw std::runtime_error(
"Source directory not available. Use CMAKE_SOURCE_DIR environment "
"variable; was " +
result.str());
}
return result;
}
Path get_envvar_path(const std::string &envvar, Path alternative = Path()) {
char *env_value = std::getenv(envvar.c_str());
Path result;
if (env_value == nullptr) {
result = alternative;
} else {
result = Path(env_value).real_path();
}
return result;
}
const std::string get_cwd() {
char buffer[FILENAME_MAX];
if (!getcwd(buffer, FILENAME_MAX)) {
throw std::runtime_error("getcwd failed: " + std::string(strerror(errno)));
}
return std::string(buffer);
}
const std::string change_cwd(std::string &dir) {
auto cwd = get_cwd();
#ifndef _WIN32
if (chdir(dir.c_str()) == -1) {
#else
if (!SetCurrentDirectory(dir.c_str())) {
#endif
throw std::runtime_error("chdir failed: " + mysqlrouter::get_last_error());
}
return cwd;
}
size_t read_bytes_with_timeout(int sockfd, void *buffer, size_t n_bytes,
uint64_t timeout_in_ms) {
// returns epoch time (aka unix time, etc), expressed in milliseconds
auto get_epoch_in_ms = []() -> uint64_t {
using namespace std::chrono;
time_point<system_clock> now = system_clock::now();
return static_cast<uint64_t>(
duration_cast<milliseconds>(now.time_since_epoch()).count());
};
// calculate deadline time
uint64_t now_in_ms = get_epoch_in_ms();
uint64_t deadline_epoch_in_ms = now_in_ms + timeout_in_ms;
// read until 1 of 3 things happen: enough bytes were read, we time out or
// read() fails
size_t bytes_read = 0;
while (true) {
#ifndef _WIN32
ssize_t res = read(sockfd, static_cast<char *>(buffer) + bytes_read,
n_bytes - bytes_read);
#else
WSASetLastError(0);
ssize_t res = recv(sockfd, static_cast<char *>(buffer) + bytes_read,
n_bytes - bytes_read, 0);
#endif
if (res == 0) { // reached EOF?
return bytes_read;
}
if (get_epoch_in_ms() > deadline_epoch_in_ms) {
throw std::runtime_error("read() timed out");
}
if (res == -1) {
#ifndef _WIN32
if (errno != EAGAIN) {
throw std::runtime_error(std::string("read() failed: ") +
strerror(errno));
}
#else
int err_code = WSAGetLastError();
if (err_code != 0) {
throw std::runtime_error("recv() failed with error: " +
get_last_error(err_code));
}
#endif
} else {
bytes_read += static_cast<size_t>(res);
if (bytes_read >= n_bytes) {
assert(bytes_read == n_bytes);
return bytes_read;
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
#ifdef _WIN32
std::string get_last_error(int err_code) {
char message[512];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_ALLOCATE_BUFFER,
nullptr, err_code, LANG_NEUTRAL, message, sizeof(message),
nullptr);
return std::string(message);
}
#endif
void init_windows_sockets() {
#ifdef _WIN32
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != 0) {
std::cerr << "WSAStartup() failed\n";
exit(1);
}
#endif
}
bool pattern_found(const std::string &s, const std::string &pattern) {
bool result = false;
try {
std::smatch m;
std::regex r(pattern);
result = std::regex_search(s, m, r);
} catch (const std::regex_error &e) {
std::cerr << ">" << e.what();
}
return result;
}
namespace {
#ifndef _WIN32
int close_socket(int sock) {
::shutdown(sock, SHUT_RDWR);
return close(sock);
}
#else
int close_socket(SOCKET sock) {
::shutdown(sock, SD_BOTH);
return closesocket(sock);
}
#endif
} // namespace
bool wait_for_port_ready(uint16_t port, std::chrono::milliseconds timeout,
const std::string &hostname) {
struct addrinfo hints, *ainfo;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
auto step_ms = 10ms;
// Valgrind needs way more time
if (getenv("WITH_VALGRIND")) {
timeout *= 10;
step_ms *= 10;
}
int status = getaddrinfo(hostname.c_str(), std::to_string(port).c_str(),
&hints, &ainfo);
if (status != 0) {
throw std::runtime_error(
std::string("wait_for_port_ready(): getaddrinfo() failed: ") +
gai_strerror(status));
}
std::shared_ptr<void> exit_freeaddrinfo(nullptr,
[&](void *) { freeaddrinfo(ainfo); });
const auto started = std::chrono::steady_clock::now();
do {
auto sock_id =
socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol);
if (sock_id < 0) {
throw std::runtime_error("wait_for_port_ready(): socket() failed: " +
std::to_string(mysqlrouter::get_socket_errno()));
}
std::shared_ptr<void> exit_close_socket(
nullptr, [&](void *) { close_socket(sock_id); });
#ifdef _WIN32
// On Windows if the port is not ready yet when we try the connect() first
// time it will block for 500ms (depends on the OS wide configuration) and
// retry again internally. Here we sleep for 100ms but will save this 500ms
// for most of the cases which is still a good deal
std::this_thread::sleep_for(100ms);
#endif
status = connect(sock_id, ainfo->ai_addr, ainfo->ai_addrlen);
if (status < 0) {
// if the address is not available, it is a client side problem.
#ifdef _WIN32
if (WSAGetLastError() == WSAEADDRNOTAVAIL) {
throw std::system_error(mysqlrouter::get_socket_errno(),
std::system_category());
}
#else
if (errno == EADDRNOTAVAIL) {
throw std::system_error(mysqlrouter::get_socket_errno(),
std::generic_category());
}
#endif
const auto step = std::min(timeout, step_ms);
std::this_thread::sleep_for(std::chrono::milliseconds(step));
timeout -= step;
}
} while (status < 0 && timeout > std::chrono::steady_clock::now() - started);
return status >= 0;
}
void init_keyring(std::map<std::string, std::string> &default_section,
const std::string &keyring_dir,
const std::string &user /*= "mysql_router1_user"*/,
const std::string &password /*= "root"*/) {
// init keyring
const std::string masterkey_file = Path(keyring_dir).join("master.key").str();
const std::string keyring_file = Path(keyring_dir).join("keyring").str();
mysql_harness::init_keyring(keyring_file, masterkey_file, true);
mysql_harness::Keyring *keyring = mysql_harness::get_keyring();
keyring->store(user, "password", password);
mysql_harness::flush_keyring();
mysql_harness::reset_keyring();
// add relevant config settings to [DEFAULT] section
default_section["keyring_path"] = keyring_file;
default_section["master_key_path"] = masterkey_file;
}
namespace {
bool real_find_in_file(
const std::string &file_path,
const std::function<bool(const std::string &)> &predicate,
std::ifstream &in_file, std::streampos &cur_pos) {
if (!in_file.is_open()) {
in_file.clear();
Path file(file_path);
in_file.open(file.c_str(), std::ifstream::in);
if (!in_file) {
throw std::runtime_error("Error opening file " + file.str());
}
cur_pos = in_file.tellg(); // initialize properly
} else {
// set current position to the end of what was already read
in_file.clear();
in_file.seekg(cur_pos);
}
std::string line;
while (std::getline(in_file, line)) {
cur_pos = in_file.tellg();
if (predicate(line)) {
return true;
}
}
return false;
}
} // namespace
bool find_in_file(const std::string &file_path,
const std::function<bool(const std::string &)> &predicate,
std::chrono::milliseconds sleep_time) {
const auto STEP = std::chrono::milliseconds(100);
std::ifstream in_file;
std::streampos cur_pos;
do {
try {
// This is proxy function to account for the fact that I/O can sometimes
// be slow.
if (real_find_in_file(file_path, predicate, in_file, cur_pos))
return true;
} catch (const std::runtime_error &) {
// report I/O error only on the last attempt
if (sleep_time == std::chrono::milliseconds(0)) {
std::cerr << " find_in_file() failed, giving up." << std::endl;
throw;
}
}
const auto sleep_for = std::min(STEP, sleep_time);
std::this_thread::sleep_for(sleep_for);
sleep_time -= sleep_for;
} while (sleep_time > std::chrono::milliseconds(0));
return false;
}
std::string get_file_output(const std::string &file_name,
const std::string &file_path,
bool throw_on_error /*=false*/) {
return get_file_output(file_path + "/" + file_name, throw_on_error);
}
std::string get_file_output(const std::string &file_name,
bool throw_on_error /*=false*/) {
Path file(file_name);
std::ifstream in_file;
in_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try {
in_file.open(file.c_str(), std::ifstream::in);
} catch (const std::exception &e) {
const std::string msg =
"Could not open file '" + file.str() + "' for reading: ";
if (throw_on_error)
throw std::runtime_error(msg + e.what());
else
return "<THIS ERROR COMES FROM TEST FRAMEWORK'S get_file_output(), IT IS "
"NOT PART OF PROCESS OUTPUT: " +
msg + e.what() + ">";
}
assert(in_file);
std::string result;
try {
result.assign((std::istreambuf_iterator<char>(in_file)),
std::istreambuf_iterator<char>());
} catch (const std::exception &e) {
const std::string msg = "Reading file '" + file.str() + "' failed: ";
if (throw_on_error)
throw std::runtime_error(msg + e.what());
else
return "<THIS ERROR COMES FROM TEST FRAMEWORK'S get_file_output(), IT IS "
"NOT PART OF PROCESS OUTPUT: " +
msg + e.what() + ">";
}
return result;
}
bool add_line_to_config_file(const std::string &config_path,
const std::string §ion_name,
const std::string &key, const std::string &value) {
std::ifstream config_stream{config_path};
if (!config_stream) return false;
std::vector<std::string> config;
std::string line;
bool found{false};
while (std::getline(config_stream, line)) {
config.push_back(line);
if (line == "[" + section_name + "]") {
config.push_back(key + "=" + value);
found = true;
}
}
config_stream.close();
if (!found) return false;
std::ofstream out_stream{config_path};
if (!out_stream) return false;
std::copy(std::begin(config), std::end(config),
std::ostream_iterator<std::string>(out_stream, "\n"));
out_stream.close();
return true;
}
void connect_client_and_query_port(unsigned router_port, std::string &out_port,
bool should_fail) {
using mysqlrouter::MySQLSession;
MySQLSession client;
if (should_fail) {
try {
client.connect("127.0.0.1", router_port, "username", "password", "", "");
} catch (const std::exception &exc) {
if (std::string(exc.what()).find("Error connecting to MySQL server") !=
std::string::npos) {
out_port = "";
return;
} else
throw;
}
throw std::runtime_error(
"connect_client_and_query_port: did not fail as expected");
} else {
client.connect("127.0.0.1", router_port, "username", "password", "", "");
}
std::unique_ptr<MySQLSession::ResultRow> result{
client.query_one("select @@port")};
if (nullptr == result.get()) {
throw std::runtime_error(
"connect_client_and_query_port: error querying the port");
}
if (1u != result->size()) {
throw std::runtime_error(
"connect_client_and_query_port: wrong number of columns returned " +
std::to_string(result->size()));
}
out_port = std::string((*result)[0]);
}
| 30.566191 | 80 | 0.63666 |
de4bb4c00d0cac29cdc3be2ad9870fa1e1ae63dc | 1,414 | hpp | C++ | src/meshInfo/geometry.hpp | guhanfeng/HSF | d2f091e990bb5a18473db0443872e37de6b6a83f | [
"Apache-2.0"
] | null | null | null | src/meshInfo/geometry.hpp | guhanfeng/HSF | d2f091e990bb5a18473db0443872e37de6b6a83f | [
"Apache-2.0"
] | null | null | null | src/meshInfo/geometry.hpp | guhanfeng/HSF | d2f091e990bb5a18473db0443872e37de6b6a83f | [
"Apache-2.0"
] | null | null | null | /**
* @file: compute.hpp
* @author: Liu Hongbin
* @brief:
* @date: 2019-11-28 10:39:09
* @last Modified by: lenovo
* @last Modified time: 2019-11-28 16:13:43
*/
#ifndef GEOMETRY_HPP
#define GEOMETRY_HPP
#include <cmath>
#include "utilities.hpp"
namespace HSF
{
// face area
scalar calculateQUADArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
scalar calculateTRIArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
scalar calculateFaceArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes);
// face normal vector
void calculateQUADNormVec(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, scalar* normVec);
void calculateFaceNormVec(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* normVec);
// face center coordinate
void calculateFaceCenter(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* center);
// cell volume
scalar calculateCellVol(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes);
scalar calculateHEXAVol(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
// cell center coordinate
void calculateCellCenter(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* center);
}
#endif | 27.72549 | 73 | 0.729137 |
de4bb71756df25a1b15b441b8fd5629db03b8d68 | 147 | cc | C++ | protobuf-cpp-3.2.0/src/google/protobuf/compiler/js/well_known_types_embed.cc | WatchBeam/ftl-photon | 93cbbc6fbaf5cbaa50dbf216bddacb1fc69b77e2 | [
"MIT"
] | 1,210 | 2020-08-18T07:57:36.000Z | 2022-03-31T15:06:05.000Z | protobuf-cpp-3.2.0/src/google/protobuf/compiler/js/well_known_types_embed.cc | WatchBeam/ftl-photon | 93cbbc6fbaf5cbaa50dbf216bddacb1fc69b77e2 | [
"MIT"
] | 37 | 2020-08-24T02:48:38.000Z | 2022-01-30T06:41:52.000Z | protobuf-cpp-3.2.0/src/google/protobuf/compiler/js/well_known_types_embed.cc | WatchBeam/ftl-photon | 93cbbc6fbaf5cbaa50dbf216bddacb1fc69b77e2 | [
"MIT"
] | 275 | 2020-08-18T08:35:16.000Z | 2022-03-31T15:06:07.000Z | #include <google/protobuf/compiler/js/well_known_types_embed.h>
struct FileToc well_known_types_js[] = {
{NULL, NULL} // Terminate the list.
};
| 29.4 | 63 | 0.748299 |
de4c177e70eb47fb3e186b53997edc25947c1045 | 3,455 | cpp | C++ | Laburi/Lab12/p2/lab11p2.cpp | teodutu/PA | 9abaf9f0ebbce8beac274edd672473a17575fe03 | [
"MIT"
] | 7 | 2019-02-12T15:14:12.000Z | 2020-05-05T13:48:52.000Z | Laburi/Lab12/p2/lab11p2.cpp | teodutu/PA | 9abaf9f0ebbce8beac274edd672473a17575fe03 | [
"MIT"
] | null | null | null | Laburi/Lab12/p2/lab11p2.cpp | teodutu/PA | 9abaf9f0ebbce8beac274edd672473a17575fe03 | [
"MIT"
] | 7 | 2020-03-22T09:46:19.000Z | 2021-03-11T20:53:19.000Z | #include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <set>
#include <queue>
#include <vector>
#include "State2.h"
class StateComparator {
public:
/* Determina algoritmul folosit. */
enum Algorithm {
AStar,
};
StateComparator(Algorithm algorithm)
: algorithm_(algorithm) { }
int f(State2* state) const{
/* f(n) = g(n) + h(n) */
/* g(n) = numarul de mutari din pozitia initiala */
switch(algorithm_) {
case AStar:
return state->distance() + state->approx_distance();
}
return 0;
}
bool operator() (State2* State1, State2* State2) const {
return f(State1) > f(State2);
}
private:
const Algorithm algorithm_;
};
bool is_explored(std::vector<State2*>& closed, State2& state) {
for (std::vector<State2*>::const_iterator it = closed.begin();
it != closed.end();
++it) {
if (state.has_same_state(**it)) {
return true;
}
}
return false;
}
void remove_state(std::vector<State2*>& closed, State2* state) {
auto it = std::find_if(closed.begin(), closed.end(), [state](State2* s) {
return state->has_same_state(*s);
});
if (it != closed.end()) {
closed.erase(it);
}
}
int main() {
State2* initial_State = new State2();
State2* solution_State = new State2();
initial_State->m_e = 3;
initial_State->m_v = 0;
initial_State->c_e = 3;
initial_State->c_v = 0;
initial_State->position = State2::E;
solution_State->m_e = 0;
solution_State->m_v = 3;
solution_State->c_e = 0;
solution_State->c_v = 3;
solution_State->position = State2::V;
std::cout << "initial point " << *initial_State << std::endl;
std::cout << "final point " << *solution_State << std::endl;
/* Pentru nodurile in curs de explorare, implementate ca o coada de
* prioritati. */
std::priority_queue<State2*, std::vector<State2*>, StateComparator> open(
StateComparator(StateComparator::AStar));
/* Initial doar nodul de start este in curs de explorare. */
initial_State->set_distance(0);
initial_State->set_parent(NULL);
open.push(initial_State);
/* Pentru nodurile care au fost deja expandate. */
std::vector<State2*> closed;
std::vector<State2*> next_states;
State2* crt_state;
/* Numar de pasi pana la solutie */
int steps = 0;
/*TODO: A* */
closed.emplace_back(initial_State);
open.emplace(initial_State);
while (!open.empty()) {
crt_state = open.top();
open.pop();
next_states.clear();
if (crt_state->has_same_state(*solution_State)) {
crt_state->print_path();
break;
}
crt_state->expand(next_states);
closed.emplace_back(crt_state);
for (State2* next_state : next_states) {
if (!is_explored(closed, *next_state)) {
// closed.emplace_back(next_state);
next_state->set_distance(crt_state->distance() + 1);
next_state->set_parent(crt_state);
open.emplace(next_state);
} else if (crt_state->distance() + 1 > next_state->distance()) {
remove_state(closed, next_state);
next_state->set_distance(crt_state->distance() + 1);
next_state->set_parent(crt_state);
open.emplace(next_state);
}
}
}
std::cout << "Numarul de pasi pana la solutie: " << steps << std::endl;
return 0;
}
| 25.592593 | 77 | 0.611288 |
de4dc80505f378ad0c688b4bd30bc1c4e8f56282 | 21,265 | cpp | C++ | hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp | RivuletStudio/vaa3d_tools | 58c267d4731df9a71e596200c45e9634aea8491c | [
"MIT"
] | null | null | null | hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp | RivuletStudio/vaa3d_tools | 58c267d4731df9a71e596200c45e9634aea8491c | [
"MIT"
] | 1 | 2016-12-03T05:33:13.000Z | 2016-12-03T05:33:13.000Z | hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp | RivuletStudio/vaa3d_tools | 58c267d4731df9a71e596200c45e9634aea8491c | [
"MIT"
] | null | null | null | /* mapping3D_swc_plugin.cpp
* This is a test plugin, you can use it as a demo.
* 2015-6-25 : by Zhi Zhou
*/
#include "v3d_message.h"
#include <vector>
#include "mapping3D_swc_plugin.h"
#include "openSWCDialog.h"
#include "../neurontracing_mip/my_surf_objs.h"
#include "../neurontracing_mip/smooth_curve.h"
#include "../neurontracing_mip/fastmarching_linker.h"
#include "../APP2_large_scale/readRawfile_func.h"
using namespace std;
Q_EXPORT_PLUGIN2(mapping3D_swc, mapping3D_swc);
QStringList mapping3D_swc::menulist() const
{
return QStringList()
<<tr("mapping")
<<tr("about");
}
QStringList mapping3D_swc::funclist() const
{
return QStringList()
<<tr("func1")
<<tr("help");
}
struct Point;
struct Point
{
double x,y,z,r;
V3DLONG type;
Point* p;
V3DLONG childNum;
};
typedef vector<Point*> Segment;
typedef vector<Point*> Tree;
bool map3Dfunc(NeuronTree nt,unsigned char * &data1d, V3DLONG N, V3DLONG M,V3DLONG P,vector<MyMarker*> & outswc_final);
bool map3Dfunc_raw(NeuronTree nt,string &image_name,vector<MyMarker*> & outswc_final);
void mapping3D_swc::domenu(const QString &menu_name, V3DPluginCallback2 &callback, QWidget *parent)
{
if (menu_name == tr("mapping"))
{
v3dhandle curwin = callback.currentImageWindow();
if (!curwin)
{
QMessageBox::information(0, "", "You don't have any image open in the main window.");
return;
}
Image4DSimple* p4DImage = callback.getImage(curwin);
if (!p4DImage)
{
QMessageBox::information(0, "", "The image pointer is invalid. Ensure your data is valid and try again!");
return;
}
unsigned char* data1d = p4DImage->getRawData();
V3DLONG pagesz = p4DImage->getTotalUnitNumberPerChannel();
QString image_name = callback.getImageName(curwin);
V3DLONG N = p4DImage->getXDim();
V3DLONG M = p4DImage->getYDim();
V3DLONG P = p4DImage->getZDim();
V3DLONG sc = p4DImage->getCDim();
// int mip_plane = 0;
OpenSWCDialog * openDlg = new OpenSWCDialog(0, &callback);
if (!openDlg->exec())
return;
NeuronTree nt = openDlg->nt;
vector<MyMarker*> outswc_final;
if(map3Dfunc(nt, data1d, N,M,P,outswc_final))
{
QString final_swc = openDlg->file_name + "_3D.swc"; ;
saveSWC_file(final_swc.toStdString(), outswc_final);
v3d_msg(QString("Now you can drag and drop the generated swc fle [%1] into Vaa3D.").arg(final_swc.toStdString().c_str()));
}
}
// V3DLONG siz = nt.listNeuron.size();
// Tree tree;
// for (V3DLONG i=0;i<siz;i++)
// {
// NeuronSWC s = nt.listNeuron[i];
// Point* pt = new Point;
// pt->x = s.x;
// pt->y = s.y;
// pt->z = s.z;
// pt->r = s.r;
// pt ->type = s.type;
// pt->p = NULL;
// pt->childNum = 0;
// tree.push_back(pt);
// }
// for (V3DLONG i=0;i<siz;i++)
// {
// if (nt.listNeuron[i].pn<0) continue;
// V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
// tree[i]->p = tree[pid];
// tree[pid]->childNum++;
// }
// vector<Segment*> seg_list;
// for (V3DLONG i=0;i<siz;i++)
// {
// if (tree[i]->childNum!=1)//tip or branch point
// {
// Segment* seg = new Segment;
// Point* cur = tree[i];
// do
// {
// seg->push_back(cur);
// cur = cur->p;
// }
// while(cur && cur->childNum==1);
// seg_list.push_back(seg);
// }
// }
// vector<MyMarker*> outswc;
// vector<MyMarker*> outswc_final;
// for (V3DLONG i=0;i<seg_list.size();i++)
// {
// vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
// nearpos_vec.clear();
// farpos_vec.clear();
// if(seg_list[i]->size() > 2)
// {
// for (V3DLONG j=0;j<seg_list[i]->size();j++)
// {
// Point* node = seg_list[i]->at(j);
// XYZ loc0_t, loc1_t;
// loc0_t = XYZ(node->x, node->y, node->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node->x, node->y, P-1); break;
// case 1: loc1_t = XYZ(node->x, M-1, node->z); break;
// case 2: loc1_t = XYZ(N-1, node->y, node->z); break;
// default:
// return;
// }
// XYZ loc0 = loc0_t;
// XYZ loc1 = loc1_t;
// nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
// farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
// }
// fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
// smooth_curve(outswc,5);
// for(V3DLONG d = 0; d <outswc.size(); d++)
// {
// outswc[d]->radius = 2;
// outswc[d]->type = 2;
// outswc_final.push_back(outswc[d]);
// }
// outswc.clear();
// }
// else if(seg_list[i]->size() == 2)
// {
// Point* node1 = seg_list[i]->at(0);
// Point* node2 = seg_list[i]->at(1);
// for (V3DLONG j=0;j<3;j++)
// {
// XYZ loc0_t, loc1_t;
// if(j ==0)
// {
// loc0_t = XYZ(node1->x, node1->y, node1->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node1->x, node1->y, P-1); break;
// case 1: loc1_t = XYZ(node1->x, M-1, node1->z); break;
// case 2: loc1_t = XYZ(N-1, node1->y, node1->z); break;
// default:
// return;
// }
// }
// else if(j ==1)
// {
// loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1); break;
// case 1: loc1_t = XYZ(0.5*(node1->x + node2->x), M-1, 0.5*(node1->z + node2->z)); break;
// case 2: loc1_t = XYZ(N-1, 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z)); break;
// default:
// return;
// }
// }
// else
// {
// loc0_t = XYZ(node2->x, node2->y, node2->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node2->x, node2->y, P-1); break;
// case 1: loc1_t = XYZ(node2->x, M-1, node2->z); break;
// case 2: loc1_t = XYZ(N-1, node2->y, node2->z); break;
// default:
// return;
// } }
// XYZ loc0 = loc0_t;
// XYZ loc1 = loc1_t;
// nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
// farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
// }
// fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
// smooth_curve(outswc,5);
// for(V3DLONG d = 0; d <outswc.size(); d++)
// {
// outswc[d]->radius = 2;
// outswc[d]->type = 2;
// outswc_final.push_back(outswc[d]);
// }
// outswc.clear();
// }
// }
else
{
v3d_msg(tr("This is a plugin to map 2D tracing back to 3D locations based on 3D image content..."
"Developed by Zhi Zhou, 2015-6-25"));
}
}
bool mapping3D_swc::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent)
{
vector<char*> infiles, inparas, outfiles;
if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p);
if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p);
if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p);
if (func_name == tr("mapping"))
{
if(infiles.size() != 2 && infiles.size() != 3)
{
cerr<<"Invalid input"<<endl;
return false;
}
string inimg_file = infiles[0];
string inswc_file = infiles[1];
string outswc_file = (infiles.size() == 3) ? infiles[2] : "";
if(outswc_file == "") outswc_file = inswc_file + "_3D.swc";
cout<<"inimg_file = "<<inimg_file<<endl;
cout<<"inswc_file = "<<inswc_file<<endl;
cout<<"outswc_file = "<<outswc_file<<endl;
// unsigned char * inimg1d = 0;
// V3DLONG in_sz[4];
// int datatype;
// simple_loadimage_wrapper(callback,const_cast<char *>(inimg_file.c_str()), inimg1d, in_sz, datatype);
// V3DLONG N = in_sz[0];
// V3DLONG M = in_sz[1];
// V3DLONG P = in_sz[2];
NeuronTree nt = readSWC_file(QString(inswc_file.c_str()));
vector<MyMarker*> outswc_final;
//if(map3Dfunc(nt, inimg1d, N,M,P,outswc_final))
if(map3Dfunc_raw(nt, inimg_file,outswc_final))
{
saveSWC_file(outswc_file, outswc_final);
v3d_msg(QString("Now you can drag and drop the generated swc fle [%1] into Vaa3D.").arg(outswc_file.c_str()),0);
}
// if(inimg1d) {delete []inimg1d; inimg1d=0;}
return true;
}
else if (func_name == tr("help"))
{
v3d_msg("To be implemented.");
}
else return false;
return true;
}
bool map3Dfunc(NeuronTree nt,unsigned char * &data1d, V3DLONG N, V3DLONG M,V3DLONG P,vector<MyMarker*> & outswc_final)
{
int mip_plane = 0;
V3DLONG siz = nt.listNeuron.size();
Tree tree;
for (V3DLONG i=0;i<siz;i++)
{
NeuronSWC s = nt.listNeuron[i];
Point* pt = new Point;
pt->x = s.x;
pt->y = s.y;
pt->z = s.z;
pt->r = s.r;
pt ->type = s.type;
pt->p = NULL;
pt->childNum = 0;
tree.push_back(pt);
}
for (V3DLONG i=0;i<siz;i++)
{
if (nt.listNeuron[i].pn<0) continue;
V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
tree[i]->p = tree[pid];
tree[pid]->childNum++;
}
vector<Segment*> seg_list;
for (V3DLONG i=0;i<siz;i++)
{
if (tree[i]->childNum!=1)//tip or branch point
{
Segment* seg = new Segment;
Point* cur = tree[i];
do
{
seg->push_back(cur);
cur = cur->p;
}
while(cur && cur->childNum==1);
seg_list.push_back(seg);
}
}
vector<MyMarker*> outswc;
for (V3DLONG i=0;i<seg_list.size();i++)
{
vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
nearpos_vec.clear();
farpos_vec.clear();
if(seg_list[i]->size() > 2)
{
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
XYZ loc0_t, loc1_t;
loc0_t = XYZ(node->x, node->y, node->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node->x, node->y, P-1); break;
case 1: loc1_t = XYZ(node->x, M-1, node->z); break;
case 2: loc1_t = XYZ(N-1, node->y, node->z); break;
default:
return false;
}
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc_final.push_back(outswc[d]);
}
outswc.clear();
}
else if(seg_list[i]->size() == 2)
{
Point* node1 = seg_list[i]->at(0);
Point* node2 = seg_list[i]->at(1);
for (V3DLONG j=0;j<3;j++)
{
XYZ loc0_t, loc1_t;
if(j ==0)
{
loc0_t = XYZ(node1->x, node1->y, node1->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node1->x, node1->y, P-1); break;
case 1: loc1_t = XYZ(node1->x, M-1, node1->z); break;
case 2: loc1_t = XYZ(N-1, node1->y, node1->z); break;
default:
return false;
}
}
else if(j ==1)
{
loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
switch (mip_plane)
{
case 0: loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1); break;
case 1: loc1_t = XYZ(0.5*(node1->x + node2->x), M-1, 0.5*(node1->z + node2->z)); break;
case 2: loc1_t = XYZ(N-1, 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z)); break;
default:
return false;
}
}
else
{
loc0_t = XYZ(node2->x, node2->y, node2->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node2->x, node2->y, P-1); break;
case 1: loc1_t = XYZ(node2->x, M-1, node2->z); break;
case 2: loc1_t = XYZ(N-1, node2->y, node2->z); break;
default:
return false;
} }
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc_final.push_back(outswc[d]);
}
outswc.clear();
}
}
return true;
}
bool map3Dfunc_raw(NeuronTree nt,string &image_name,vector<MyMarker*> & outswc_final)
{
V3DLONG siz = nt.listNeuron.size();
Tree tree;
for (V3DLONG i=0;i<siz;i++)
{
NeuronSWC s = nt.listNeuron[i];
Point* pt = new Point;
pt->x = s.x;
pt->y = s.y;
pt->z = s.z;
pt->r = s.r;
pt ->type = s.type;
pt->p = NULL;
pt->childNum = 0;
tree.push_back(pt);
}
for (V3DLONG i=0;i<siz;i++)
{
if (nt.listNeuron[i].pn<0) continue;
V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
tree[i]->p = tree[pid];
tree[pid]->childNum++;
}
vector<Segment*> seg_list;
for (V3DLONG i=0;i<siz;i++)
{
if (tree[i]->childNum!=1)//tip or branch point
{
Segment* seg = new Segment;
Point* cur = tree[i];
do
{
seg->push_back(cur);
cur = cur->p;
}
while(cur && cur->childNum==1);
seg_list.push_back(seg);
}
}
vector<MyMarker*> outswc;
unsigned char * data1d = 0;
V3DLONG *im3D_zz = 0;
V3DLONG *im3D_sz = 0;
int datatype;
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,0,0,0,1,1,1))
{
return false;
}
if(data1d) {delete []data1d; data1d = 0;}
V3DLONG N = im3D_zz[0];
V3DLONG M = im3D_zz[1];
V3DLONG P = im3D_zz[2];
for (V3DLONG i=0;i<seg_list.size();i++)
{
V3DLONG xb = N-1;
V3DLONG xe = 0;
V3DLONG yb = M-1;
V3DLONG ye = 0;
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
if(node->x < xb) xb = node->x;
if(node->x > xe) xe = node->x;
if(node->y < yb) yb = node->y;
if(node->y > ye) ye = node->y;
}
vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
nearpos_vec.clear();
farpos_vec.clear();
if(seg_list[i]->size() > 2)
{
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
XYZ loc0_t, loc1_t;
loc0_t = XYZ(node->x, node->y, node->z);
loc1_t = XYZ(node->x, node->y, P-1);
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x - xb, loc0.y - yb, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x - xb, loc1.y - yb, loc1.z));
}
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,xb,yb,0,xe+1,ye+1,P))
{
printf("can not load the region");
if(data1d) {delete []data1d; data1d = 0;}
return false;
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, xe-xb+1,ye-yb+1,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc[d]->x = outswc[d]->x + xb;
outswc[d]->y = outswc[d]->y + yb;
outswc_final.push_back(outswc[d]);
}
if(data1d) {delete []data1d; data1d = 0;}
outswc.clear();
}
else if(seg_list[i]->size() == 2)
{
Point* node1 = seg_list[i]->at(0);
Point* node2 = seg_list[i]->at(1);
for (V3DLONG j=0;j<3;j++)
{
XYZ loc0_t, loc1_t;
if(j ==0)
{
loc0_t = XYZ(node1->x, node1->y, node1->z);
loc1_t = XYZ(node1->x, node1->y, P-1);
}
else if(j ==1)
{
loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1);
}
else
{
loc0_t = XYZ(node2->x, node2->y, node2->z);
loc1_t = XYZ(node2->x, node2->y, P-1);
}
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x - xb, loc0.y - yb, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x - xb, loc1.y - yb, loc1.z));
}
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,xb,yb,0,xe+1,ye+1,P))
{
printf("can not load the region");
if(data1d) {delete []data1d; data1d = 0;}
return false;
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, xe-xb+1,ye-yb+1,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc[d]->x = outswc[d]->x + xb;
outswc[d]->y = outswc[d]->y + yb;
outswc_final.push_back(outswc[d]);
}
if(data1d) {delete []data1d; data1d = 0;}
outswc.clear();
}
}
return true;
}
| 33.541009 | 162 | 0.452104 |
de4df49971dab4e1d1dcbad2f659886611e8b928 | 4,998 | cpp | C++ | libs/numeric/interval/examples/io.cpp | cpp-pm/boost | 38c6c8c07f2fcc42d573b10807fef27ec14930f8 | [
"BSL-1.0"
] | 12,278 | 2015-01-29T17:11:33.000Z | 2022-03-31T21:12:00.000Z | libs/numeric/interval/examples/io.cpp | cpp-pm/boost | 38c6c8c07f2fcc42d573b10807fef27ec14930f8 | [
"BSL-1.0"
] | 9,469 | 2015-01-30T05:33:07.000Z | 2022-03-31T16:17:21.000Z | libs/numeric/interval/examples/io.cpp | cpp-pm/boost | 38c6c8c07f2fcc42d573b10807fef27ec14930f8 | [
"BSL-1.0"
] | 1,343 | 2017-12-08T19:47:19.000Z | 2022-03-26T11:31:36.000Z | /* Boost examples/io.cpp
* show some exampleso of i/o operators
* thanks to all the people who commented on this point, particularly on
* the Boost mailing-list
*
* Copyright 2003 Guillaume Melquiond
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or
* copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/numeric/interval.hpp>
#include <boost/io/ios_state.hpp>
#include <cmath>
#include <cassert>
namespace io_std {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "[]";
} else {
return stream << '[' << lower(value) << ',' << upper(value) << ']';
}
}
} // namespace io_std
namespace io_sngl {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "[]";
} else if (singleton(value)) {
return stream << '[' << lower(value) << ']';
} else {
return stream << '[' << lower(value) << ',' << upper(value) << ']';
}
}
} // namespace io_sngl
namespace io_wdth {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "nothing";
} else {
return stream << median(value) << " ± " << width(value) / 2;
}
}
} // namespace io_wdth
namespace io_prec {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "nothing";
} else if (singleton(value)) {
boost::io::ios_precision_saver state(stream, std::numeric_limits<T>::digits10);
return stream << lower(value);
} else if (zero_in(value)) {
return stream << "0~";
} else {
const T rel = width(value) / norm(value);
int range = - (int)std::log10(rel);
boost::io::ios_precision_saver state(stream, range);
return stream << median(value);
}
}
} // namespace io_prec
namespace io_wide {
template<class T, class Policies, class CharType, class CharTraits>
std::basic_ostream<CharType, CharTraits> &operator<<
(std::basic_ostream<CharType, CharTraits> &stream,
const boost::numeric::interval<T, Policies> &value)
{
if (empty(value)) {
return stream << "nothing";
} else if (singleton(value)) {
boost::io::ios_precision_saver state(stream, std::numeric_limits<T>::digits10);
return stream << lower(value);
} else if (zero_in(value)) {
return stream << "0~";
} else {
std::streamsize p = stream.precision();
// FIXME poor man's power of 10, only up to 1E-15
p = (p > 15) ? 15 : p - 1;
double eps = 1.0; for(; p > 0; --p) { eps /= 10; }
T eps2 = static_cast<T>(eps / 2) * norm(value);
boost::numeric::interval<T, Policies> r = widen(value, eps2);
return stream << '[' << lower(r) << ',' << upper(r) << ']';
}
}
} // namespace io_wide
template<class T, class Policies, class CharType, class CharTraits> inline
std::basic_istream<CharType, CharTraits> &operator>>
(std::basic_istream<CharType, CharTraits> &stream,
boost::numeric::interval<T, Policies> &value)
{
T l, u;
char c = 0;
stream >> c;
if (c == '[') {
stream >> l >> c;
if (c == ',') stream >> u >> c; else u = l;
if (c != ']') stream.setstate(stream.failbit);
} else {
stream.putback(c);
stream >> l;
u = l;
}
if (stream)
value.assign(l, u);
else
value = boost::numeric::interval<T, Policies>::empty();
return stream;
}
// Test program
#include <iostream>
int main()
{
using namespace boost;
using namespace numeric;
using namespace interval_lib;
typedef interval<double,
policies<rounded_math<double>,
checking_base<double> > > I;
I tab[] = { I::empty(), I(1,1), I(1,2), I(-1,1), I(12.34,12.35),
I(1234.56,1234.57), I(123456.78, 123456.79), I::empty() };
unsigned int len = sizeof(tab) / sizeof(I);
std::cout << "Enter an interval: (it will be the last shown)\n";
std::cin >> tab[len - 1];
for(unsigned int i = 0; i < len; ++i) {
{ using namespace io_std; std::cout << tab[i] << '\n'; }
{ using namespace io_sngl; std::cout << tab[i] << '\n'; }
{ using namespace io_wdth; std::cout << tab[i] << '\n'; }
{ using namespace io_prec; std::cout << tab[i] << '\n'; }
{ using namespace io_wide; std::cout << tab[i] << '\n'; }
std::cout << '\n';
}
}
| 28.890173 | 83 | 0.627251 |
de4f2c08e0ce27edb82f5bf71f7a60466fea9d61 | 3,530 | cpp | C++ | android-31/java/security/cert/CertificateFactory.cpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 12 | 2020-03-26T02:38:56.000Z | 2022-03-14T08:17:26.000Z | android-31/java/security/cert/CertificateFactory.cpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 1 | 2021-01-27T06:07:45.000Z | 2021-11-13T19:19:43.000Z | android-29/java/security/cert/CertificateFactory.cpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 3 | 2021-02-02T12:34:55.000Z | 2022-03-08T07:45:57.000Z | #include "../../io/InputStream.hpp"
#include "../../../JString.hpp"
#include "../Provider.hpp"
#include "./CRL.hpp"
#include "./CertPath.hpp"
#include "./Certificate.hpp"
#include "./CertificateFactorySpi.hpp"
#include "./CertificateFactory.hpp"
namespace java::security::cert
{
// Fields
// QJniObject forward
CertificateFactory::CertificateFactory(QJniObject obj) : JObject(obj) {}
// Constructors
// Methods
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>()
);
}
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0, JString arg1)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>(),
arg1.object<jstring>()
);
}
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0, java::security::Provider arg1)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;Ljava/security/Provider;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>(),
arg1.object()
);
}
java::security::cert::CRL CertificateFactory::generateCRL(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCRL",
"(Ljava/io/InputStream;)Ljava/security/cert/CRL;",
arg0.object()
);
}
JObject CertificateFactory::generateCRLs(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCRLs",
"(Ljava/io/InputStream;)Ljava/util/Collection;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/io/InputStream;)Ljava/security/cert/CertPath;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(JObject arg0) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/util/List;)Ljava/security/cert/CertPath;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(java::io::InputStream arg0, JString arg1) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/io/InputStream;Ljava/lang/String;)Ljava/security/cert/CertPath;",
arg0.object(),
arg1.object<jstring>()
);
}
java::security::cert::Certificate CertificateFactory::generateCertificate(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertificate",
"(Ljava/io/InputStream;)Ljava/security/cert/Certificate;",
arg0.object()
);
}
JObject CertificateFactory::generateCertificates(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertificates",
"(Ljava/io/InputStream;)Ljava/util/Collection;",
arg0.object()
);
}
JObject CertificateFactory::getCertPathEncodings() const
{
return callObjectMethod(
"getCertPathEncodings",
"()Ljava/util/Iterator;"
);
}
java::security::Provider CertificateFactory::getProvider() const
{
return callObjectMethod(
"getProvider",
"()Ljava/security/Provider;"
);
}
JString CertificateFactory::getType() const
{
return callObjectMethod(
"getType",
"()Ljava/lang/String;"
);
}
} // namespace java::security::cert
| 27.364341 | 118 | 0.724363 |
de53b158c280826d87aad3d27c95fcec1b745b1a | 4,999 | cc | C++ | modules/canbus/vehicle/wey/protocol/fail_241.cc | Shokoofeh/apollo | 71d6ea753b4595eb38cc54d6650c8de677b173df | [
"Apache-2.0"
] | 2 | 2019-02-21T05:52:59.000Z | 2019-07-27T03:24:16.000Z | modules/canbus/vehicle/wey/protocol/fail_241.cc | Shokoofeh/apollo | 71d6ea753b4595eb38cc54d6650c8de677b173df | [
"Apache-2.0"
] | null | null | null | modules/canbus/vehicle/wey/protocol/fail_241.cc | Shokoofeh/apollo | 71d6ea753b4595eb38cc54d6650c8de677b173df | [
"Apache-2.0"
] | 1 | 2021-12-03T23:30:00.000Z | 2021-12-03T23:30:00.000Z | /******************************************************************************
* Copyright 2019 The Apollo Authors. 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 "modules/canbus/vehicle/wey/protocol/fail_241.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"
namespace apollo {
namespace canbus {
namespace wey {
using ::apollo::drivers::canbus::Byte;
Fail241::Fail241() {}
const int32_t Fail241::ID = 0x241;
void Fail241::Parse(const std::uint8_t* bytes, int32_t length,
ChassisDetail* chassis) const {
chassis->mutable_wey()->mutable_fail_241()->
set_engfail(engfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_espfail(espfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_epbfail(epbfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_shiftfail(shiftfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_epsfail(epsfail(bytes, length));
}
// config detail: {'description': 'Engine Fail status', 'enum': {0:
// 'ENGFAIL_NO_FAIL', 1: 'ENGFAIL_FAIL'}, 'precision': 1.0, 'len': 1, 'name':
// 'engfail', 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]',
// 'bit': 7, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EngfailType Fail241::engfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(7, 1);
Fail_241::EngfailType ret = static_cast<Fail_241::EngfailType>(x);
return ret;
}
// config detail: {'description': 'ESP fault', 'enum': {0:'ESPFAIL_NO_FAILURE',
// 1: 'ESPFAIL_FAILURE'}, 'precision': 1.0, 'len': 1, 'name': 'espfail',
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 14,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EspfailType Fail241::espfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(6, 1);
Fail_241::EspfailType ret = static_cast<Fail_241::EspfailType>(x);
return ret;
}
// config detail: {'description': 'error indication of EPB system', 'enum': {0:
// 'EPBFAIL_UNDEFINED', 1: 'EPBFAIL_NO_ERROR', 2: 'EPBFAIL_ERROR', 3:
// 'EPBFAIL_DIAGNOSIS'}, 'precision': 1.0, 'len': 2, 'name': 'epbfail',
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]', 'bit': 35,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EpbfailType Fail241::epbfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(2, 2);
Fail_241::EpbfailType ret = static_cast<Fail_241::EpbfailType>(x);
return ret;
}
// config detail: {'description': 'Driver display failure messages', 'enum': {0:
// 'SHIFTFAIL_NO_FAIL', 1: 'SHIFTFAIL_TRANSMISSION_MALFUNCTION', 2:
// 'SHIFTFAIL_TRANSMISSION_P_ENGAGEMENT_FAULT', 3:
// 'SHIFTFAIL_TRANSMISSION_P_DISENGAGEMENT_FAULT', 4: 'SHIFTFAIL_RESERVED',
// 15: 'SHIFTFAIL_TRANSMISSION_LIMIT_FUNCTION'}, 'precision': 1.0, 'len': 4,
// 'name': 'shiftfail', 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|15]', 'bit': 31, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Fail_241::ShiftfailType Fail241::shiftfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 3);
int32_t x = t0.get_byte(4, 4);
Fail_241::ShiftfailType ret = static_cast<Fail_241::ShiftfailType>(x);
return ret;
}
// config detail: {'description': 'Electrical steering fail status', 'enum':
// {0: 'EPSFAIL_NO_FAULT', 1: 'EPSFAIL_FAULT'}, 'precision': 1.0, 'len': 1,
// 'name': 'epsfail', 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 21, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Fail_241::EpsfailType Fail241::epsfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(5, 1);
Fail_241::EpsfailType ret = static_cast<Fail_241::EpsfailType>(x);
return ret;
}
} // namespace wey
} // namespace canbus
} // namespace apollo
| 41.658333 | 80 | 0.625925 |
de576798f01f3efa2af2b716f5add56391ca2b8f | 951 | cpp | C++ | accelerator/stats/test/MonitorTest.cpp | Yeolar/accelerator | 04d36eac69490df9ae71c7cfd71481d83ca51914 | [
"Apache-2.0"
] | 2 | 2019-05-13T02:34:51.000Z | 2019-11-14T06:52:44.000Z | accelerator/stats/test/MonitorTest.cpp | Yeolar/accelerator | 04d36eac69490df9ae71c7cfd71481d83ca51914 | [
"Apache-2.0"
] | null | null | null | accelerator/stats/test/MonitorTest.cpp | Yeolar/accelerator | 04d36eac69490df9ae71c7cfd71481d83ca51914 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2018 Yeolar
*
* 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 <gtest/gtest.h>
#include "accelerator/stats/test/MonitorTest.h"
using namespace acc;
TEST(monitor, all) {
setupMonitor<TestMonitorKey>("", [](const MonitorBase::Data&) {});
ACCMON_CNT(TestMonitorKey, kTestCnt);
ACCMON_CNT(TestMonitorKey, kTestCnt);
ACCMON_ADD(TestMonitorKey, kTestAvg, 10);
ACCMON_ADD(TestMonitorKey, kTestAvg, 20);
}
| 28.818182 | 75 | 0.737119 |
de584d8d2205e07aa38d7dcf7a51f33f803960b8 | 4,690 | cpp | C++ | drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp | houtbrion/AusEx | fd74cbab4281da6ba4f285412f2d1f53f40206c9 | [
"Apache-1.1"
] | null | null | null | drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp | houtbrion/AusEx | fd74cbab4281da6ba4f285412f2d1f53f40206c9 | [
"Apache-1.1"
] | null | null | null | drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp | houtbrion/AusEx | fd74cbab4281da6ba4f285412f2d1f53f40206c9 | [
"Apache-1.1"
] | null | null | null | #include "AusExGroveI2cTouchSensor.h"
/*
*
*/
AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS(TwoWire *theWire, int32_t sensorID ){
_i2c_if=theWire;
_sensorID=sensorID;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::begin(uint32_t addr){
_i2c_addr=addr;
_i2c_if->begin();
mpr121Setup();
return true;
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::mpr121Setup() {
// Section A - Controls filtering when data is > baseline.
write(MHD_R, 0x01);
write(NHD_R, 0x01);
write(NCL_R, 0x00);
write(FDL_R, 0x00);
// Section B - Controls filtering when data is < baseline.
write(MHD_F, 0x01);
write(NHD_F, 0x01);
write(NCL_F, 0xFF);
write(FDL_F, 0x02);
// Section C - Sets touch and release thresholds for each electrode
write(ELE0_T, TOU_THRESH);
write(ELE0_R, REL_THRESH);
write(ELE1_T, TOU_THRESH);
write(ELE1_R, REL_THRESH);
write(ELE2_T, TOU_THRESH);
write(ELE2_R, REL_THRESH);
write(ELE3_T, TOU_THRESH);
write(ELE3_R, REL_THRESH);
write(ELE4_T, TOU_THRESH);
write(ELE4_R, REL_THRESH);
write(ELE5_T, TOU_THRESH);
write(ELE5_R, REL_THRESH);
write(ELE6_T, TOU_THRESH);
write(ELE6_R, REL_THRESH);
write(ELE7_T, TOU_THRESH);
write(ELE7_R, REL_THRESH);
write(ELE8_T, TOU_THRESH);
write(ELE8_R, REL_THRESH);
write(ELE9_T, TOU_THRESH);
write(ELE9_R, REL_THRESH);
write(ELE10_T, TOU_THRESH);
write(ELE10_R, REL_THRESH);
write(ELE11_T, TOU_THRESH);
write(ELE11_R, REL_THRESH);
// Section D
// Set the Filter Configuration
// Set ESI2
write(FIL_CFG, 0x04);
//set_register(0x5A,ATO_CFGU, 0xC9); // USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V mpr121Write(ATO_CFGL, 0x82); // LSL = 0.65*USL = 0x82 @3.3V
//set_register(0x5A,ATO_CFGL, 0x82); // Target = 0.9*USL = 0xB5 @3.3V
//set_register(0x5A,ATO_CFGT,0xb5);
//set_register(0x5A,ATO_CFG0, 0x1B);
// Section E
// Electrode Configuration
// Set ELE_CFG to 0x00 to return to standby mode
write(ELE_CFG, 0x0C); // Enables all 12 Electrodes
// Section F
// Enable Auto Config and auto Reconfig
//write(ATO_CFG0, 0x0B);
//write(ATO_CFGU, 0xC9); // USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V
//write(ATO_CFGL, 0x82); // LSL = 0.65*USL = 0x82 @3.3V
//write(ATO_CFGT, 0xB5); // Target = 0.9*USL = 0xB5 @3.3V
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::write(uint8_t _register, uint8_t _data)
{
//_i2c_addr->begin();
_i2c_if->beginTransmission(_i2c_addr);
_i2c_if->write(_register);
_i2c_if->write(_data);
_i2c_if->endTransmission();
}
int8_t AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::read(uint8_t _register)
{
int8_t data;
_i2c_if->beginTransmission(_i2c_addr);
_i2c_if->write(_register);
_i2c_if->endTransmission();
_i2c_if->requestFrom(_i2c_addr, 1);
if(_i2c_if->available() > 0){
data = _i2c_if->read();
}
_i2c_if->endTransmission();
return data;
}
int16_t AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::readLong()
{
uint8_t l,h;
_i2c_if->requestFrom(_i2c_addr, 2);
l = _i2c_if->read();
h = _i2c_if->read();
return (h << 8) | l;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getEvent(sensors_event_t* event){
/* Clear the event */
memset(event, 0, sizeof(sensors_event_t));
event->size = sizeof(sensors_event_t);
event->sensor_id = _sensorID;
event->type = AUSEX_GROVE_I2C_TOUCH_SENSOR_TYPE;
event->timestamp = millis();
/* Calculate the actual lux value */
event->AUSEX_GROVE_I2C_TOUCH_SENSOR_RETURN_VALUE = readLong();
return true;
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getSensor(sensor_t* sensor){
/* Clear the sensor_t object */
memset(sensor, 0, sizeof(sensor_t));
/* Insert the sensor name in the fixed length char array */
strncpy (sensor->name, AUSEX_GROVE_I2C_TOUCH_SENSOR_NAME , sizeof(sensor->name) - 1);
sensor->name[sizeof(sensor->name)- 1] = 0;
sensor->version = AUSEX_GROVE_I2C_TOUCH_SENSOR_LIBRARY_VERSION;
sensor->sensor_id = _sensorID;
sensor->type = AUSEX_GROVE_I2C_TOUCH_SENSOR_TYPE;
sensor->min_value = AUSEX_GROVE_I2C_TOUCH_SENSOR_MIN_VALUE;
sensor->max_value = AUSEX_GROVE_I2C_TOUCH_SENSOR_MAX_VALUE;
sensor->resolution = AUSEX_GROVE_I2C_TOUCH_SENSOR_RESOLUTION;
sensor->min_delay = AUSEX_GROVE_I2C_TOUCH_SENSOR_MIN_DELAY;
sensor->init_delay = AUSEX_GROVE_I2C_TOUCH_SENSOR_INIT_DELAY;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::enableAutoRange(bool enabled) {
return false;
}
int AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::setMode(int mode) {
return -1;
}
int AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getMode(void) {
return -1;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getTouchState(AUSEX_GROVE_I2C_TOUCH_SENSOR_VALUE_TYPE val, uint8_t num){
if(val & (1<<num)) return true;
return false;
}
| 30.258065 | 142 | 0.724733 |
de5b72aaeb5f997dd3537633617d4e1a3bcdc334 | 533 | hpp | C++ | src/include/XESystem.hpp | devxkh/FrankE | 72faca02759b54aaec842831f3c7a051e7cf5335 | [
"MIT"
] | 11 | 2017-01-17T15:02:25.000Z | 2020-11-27T16:54:42.000Z | src/include/XESystem.hpp | devxkh/FrankE | 72faca02759b54aaec842831f3c7a051e7cf5335 | [
"MIT"
] | 9 | 2016-10-23T20:15:38.000Z | 2018-02-06T11:23:17.000Z | src/include/XESystem.hpp | devxkh/FrankE | 72faca02759b54aaec842831f3c7a051e7cf5335 | [
"MIT"
] | 2 | 2019-08-29T10:23:51.000Z | 2020-04-03T06:08:34.000Z | #ifndef XE_INTERFACE_SYSTEM_HPP
#define XE_INTERFACE_SYSTEM_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
//#include <XESystem/gkDebugger.h>
#include <XESystem/SystemConfig.hpp>
//#include <ThirdParty/plog/Log.h>
//
//INITIALIZE_EASYLOGGINGPP
#endif // XE_INTERFACE_SYSTEM_HPP
////////////////////////////////////////////////////////////
/// \defgroup system System module
///
////////////////////////////////////////////////////////////
| 28.052632 | 60 | 0.420263 |
de5c5a7736c29df104cb288dff1dc23cc7a93454 | 1,294 | cpp | C++ | webrtc-jni/src/main/cpp/src/api/DataBufferFactory.cpp | hhgyu/webrtc-java | 572c3814c94a407cfacdee1e2bc898522063731f | [
"Apache-2.0"
] | 110 | 2019-12-25T11:54:02.000Z | 2022-03-16T06:27:05.000Z | webrtc-jni/src/main/cpp/src/api/DataBufferFactory.cpp | hhgyu/webrtc-java | 572c3814c94a407cfacdee1e2bc898522063731f | [
"Apache-2.0"
] | 54 | 2020-04-09T06:57:10.000Z | 2022-03-28T16:29:39.000Z | webrtc-jni/src/main/cpp/src/api/DataBufferFactory.cpp | internet-of-presence/webrtc-java | 26ab2091f962533288e2267a16980008d7008528 | [
"Apache-2.0"
] | 37 | 2019-12-26T10:12:11.000Z | 2022-03-10T18:06:23.000Z | /*
* Copyright 2019 Alex Andres
*
* 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 "api/DataBufferFactory.h"
#include "JavaUtils.h"
#include "JNI_WebRTC.h"
namespace jni
{
DataBufferFactory::DataBufferFactory(JNIEnv * env, const char * className) :
JavaFactory(env, className, "(" BYTE_BUFFER_SIG "Z)V")
{
}
JavaLocalRef<jobject> DataBufferFactory::create(JNIEnv * env, const webrtc::DataBuffer * dataBuffer)
{
jobject directBuffer = env->NewDirectByteBuffer(const_cast<char *>(dataBuffer->data.data<char>()), dataBuffer->data.size());
const jboolean isBinary = static_cast<jboolean>(dataBuffer->binary);
jobject object = env->NewObject(javaClass, javaCtor, directBuffer, isBinary);
ExceptionCheck(env);
return JavaLocalRef<jobject>(env, object);
}
} | 34.052632 | 126 | 0.742658 |
de5ce2395e0a1a352fadf0042b3eec426822b9f2 | 1,106 | hh | C++ | nel/src/memory.hh | jwebb68/nel | a5bfe9038921448da52cdeeba45984a54d79423c | [
"MIT"
] | null | null | null | nel/src/memory.hh | jwebb68/nel | a5bfe9038921448da52cdeeba45984a54d79423c | [
"MIT"
] | null | null | null | nel/src/memory.hh | jwebb68/nel | a5bfe9038921448da52cdeeba45984a54d79423c | [
"MIT"
] | null | null | null | #ifndef NEL_MEMORY_HH
#define NEL_MEMORY_HH
#include <cstdint> // uint8_t
#include <cstddef> // size_t
#include <utility> // std::move, std::swap
namespace nel {
void memcpy(uint8_t *const d, uint8_t const *const s, size_t const n) noexcept;
void memset(uint8_t *const d, uint8_t const s, size_t const n) noexcept;
void memmove(uint8_t *const d, uint8_t *const s, size_t const n) noexcept;
void memswap(uint8_t *const d, uint8_t *const s, size_t const n) noexcept;
template<typename T>
void memmove(T *d, T *s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = std::move(s[i]);
}
}
template<typename T>
void memcpy(T *const d, T const *const s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = s[i];
}
}
template<typename T>
void memset(T *const d, T const &s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = s;
}
}
template<typename T>
void memswap(T *const d, T *const s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
std::swap(*d, *s);
}
}
} // namespace nel
#endif//NEL_MEMORY_HH
| 20.109091 | 79 | 0.618445 |
de60633e2d2eb8f8099ed123e45c1e17d7d1892b | 227 | hpp | C++ | CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp | Electrux/CCPP-Code | 3c5e5b866cf050c11bced9651b112eb31dd2465d | [
"BSD-3-Clause"
] | 6 | 2019-08-29T23:31:17.000Z | 2021-11-14T20:35:47.000Z | CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp | Electrux/CCPP-Code | 3c5e5b866cf050c11bced9651b112eb31dd2465d | [
"BSD-3-Clause"
] | null | null | null | CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp | Electrux/CCPP-Code | 3c5e5b866cf050c11bced9651b112eb31dd2465d | [
"BSD-3-Clause"
] | 1 | 2019-09-01T12:22:58.000Z | 2019-09-01T12:22:58.000Z | #ifndef PROJECTFILEGENERATOR_HPP
#define PROJECTFILEGENERATOR_HPP
#include "ProjectData.hpp"
#include "FSFuncs.hpp"
#include "ConfigMgr.hpp"
int GenerateProjectFiles( ProjectData & data );
#endif // PROJECTFILEGENERATOR_HPP
| 20.636364 | 47 | 0.810573 |
de6207b4dcb7fcfddaae34e792c0b597dfc72b3a | 3,378 | hpp | C++ | include/RaZ/Math/MathUtils.hpp | Sausty/RaZ | 211cc1c0c4a7374520a3141fc069b7717e2e5e0f | [
"MIT"
] | null | null | null | include/RaZ/Math/MathUtils.hpp | Sausty/RaZ | 211cc1c0c4a7374520a3141fc069b7717e2e5e0f | [
"MIT"
] | null | null | null | include/RaZ/Math/MathUtils.hpp | Sausty/RaZ | 211cc1c0c4a7374520a3141fc069b7717e2e5e0f | [
"MIT"
] | null | null | null | #pragma once
#ifndef RAZ_MATHUTILS_HPP
#define RAZ_MATHUTILS_HPP
#include <algorithm>
#include <cassert>
#include <type_traits>
namespace Raz::MathUtils {
/// Computes the linear interpolation between two values, according to a coefficient.
/// \tparam T Type to compute the interpolation with.
/// \param min Minimum value (lower bound).
/// \param max Maximum value (upper bound).
/// \param coeff Coefficient between 0 (returns `min`) and 1 (returns `max`).
/// \return Computed linear interpolation between `min` and `max`.
template <typename T>
constexpr T interpolate(T min, T max, T coeff) noexcept {
static_assert(std::is_floating_point_v<T>, "Error: Interpolation type must be floating point.");
assert("Error: The interpolation coefficient must be between 0 & 1." && (coeff >= 0 && coeff <= 1));
return min * (1 - coeff) + max * coeff;
}
/// Computes the [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation) between two thresholds.
///
/// Any value below `minThresh` will return 0, and any above `maxThresh` will return 1. Between both thresholds, a smooth interpolation is performed.
///
/// 1.0 | |___
/// | .-~"|
/// | ,^ |
/// | / |
/// | / |
/// | / |
/// | ,v |
/// 0.0 ___|,.-" |
/// ^ ^
/// minThresh maxThresh
///
/// This is equivalent to [GLSL's smoothstep function](http://docs.gl/sl4/smoothstep).
/// \tparam T Type to compute the interpolation with.
/// \param minThresh Minimum threshold value.
/// \param maxThresh Maximum threshold value.
/// \param value Value to be interpolated.
/// \return 0 if `value` is lower than `minThresh`.
/// \return 1 if `value` is greater than `maxThresh`.
/// \return The interpolated value (between 0 & 1) otherwise.
template <typename T>
constexpr T smoothstep(T minThresh, T maxThresh, T value) noexcept {
assert("Error: The smoothstep's maximum threshold must be greater than the minimum one." && maxThresh > minThresh);
const T clampedVal = std::clamp((value - minThresh) / (maxThresh - minThresh), static_cast<T>(0), static_cast<T>(1));
return clampedVal * clampedVal * (3 - 2 * clampedVal);
}
/// Computes the [smootherstep](https://en.wikipedia.org/wiki/Smoothstep#Variations) between two thresholds.
/// This is Ken Perlin's smoothstep variation, which produces a slightly smoother smoothstep.
/// \tparam T Type to compute the interpolation with.
/// \param minThresh Minimum threshold value.
/// \param maxThresh Maximum threshold value.
/// \param value Value to be interpolated.
/// \return 0 if `value` is lower than `minThresh`.
/// \return 1 if `value` is greater than `maxThresh`.
/// \return The interpolated value (between 0 & 1) otherwise.
template <typename T>
constexpr T smootherstep(T minThresh, T maxThresh, T value) noexcept {
assert("Error: The smootherstep's maximum threshold must be greater than the minimum one." && maxThresh > minThresh);
const T clampedVal = std::clamp((value - minThresh) / (maxThresh - minThresh), static_cast<T>(0), static_cast<T>(1));
return clampedVal * clampedVal * clampedVal * (clampedVal * (clampedVal * 6 - 15) + 10);
}
} // namespace Raz::MathUtils
#endif // RAZ_MATHUTILS_HPP
| 43.87013 | 149 | 0.65897 |
de62423217435b714daacef3ad51497d1a4d690a | 3,286 | hpp | C++ | Axis.CommonLibrary/domain/elements/DoF.hpp | renato-yuzup/axis-fem | 2e8d325eb9c8e99285f513b4c1218ef53eb0ab22 | [
"MIT"
] | 2 | 2021-07-23T08:49:54.000Z | 2021-07-29T22:07:30.000Z | Axis.CommonLibrary/domain/elements/DoF.hpp | renato-yuzup/axis-fem | 2e8d325eb9c8e99285f513b4c1218ef53eb0ab22 | [
"MIT"
] | null | null | null | Axis.CommonLibrary/domain/elements/DoF.hpp | renato-yuzup/axis-fem | 2e8d325eb9c8e99285f513b4c1218ef53eb0ab22 | [
"MIT"
] | null | null | null | /// <summary>
/// Contains the definition for the class axis::domain::elements::DoF.
/// </summary>
/// <author>Renato T. Yamassaki</author>
#pragma once
#include "foundation/Axis.CommonLibrary.hpp"
#include "foundation/memory/pointer.hpp"
#include "nocopy.hpp"
namespace axis { namespace domain {
namespace boundary_conditions {
// a prototype
class AXISCOMMONLIBRARY_API BoundaryCondition;
}
namespace elements {
// another prototype
class AXISCOMMONLIBRARY_API Node;
/// <summary>
/// Represents a degree-of-freedom (DoF) that a node has. In other words, one possible
/// direction of movement of a node.
/// </summary>
class AXISCOMMONLIBRARY_API DoF
{
public:
typedef long id_type;
/**********************************************************************************************//**
* @fn :::DoF(id_type id, int localIndex, Node& node);
*
* @brief Creates a new degree-of-freedom.
*
* @author Renato T. Yamassaki
* @date 12 jun 2012
*
* @param id Numerical identifier which relates this
* dof with its position in a global matrix.
* @param localIndex Zero-based index of the dof in the node.
* @param [in,out] node The node to which this dof belongs.
**************************************************************************************************/
DoF(id_type id, int localIndex, const axis::foundation::memory::RelativePointer& node);
/// <summary>
/// Destroys this object.
/// </summary>
~DoF(void);
/// <summary>
/// Destroys this object.
/// </summary>
void Destroy(void) const;
/// <summary>
/// Returns the numerical identifier of this dof.
/// </summary>
id_type GetId(void) const;
int GetLocalIndex(void) const;
Node& GetParentNode(void);
const Node& GetParentNode(void) const;
/// <summary>
/// Returns if there is boundary condition applied to this dof.
/// </summary>
bool HasBoundaryConditionApplied(void) const;
/// <summary>
/// Return the boundary condition applied to this dof.
/// </summary>
axis::domain::boundary_conditions::BoundaryCondition& GetBoundaryCondition(void) const;
/// <summary>
/// Sets a new boundary condition applied to this dof.
/// </summary>
/// <param name="condition">The boundary condition to be applied to this dof.</param>
void SetBoundaryCondition(axis::domain::boundary_conditions::BoundaryCondition& condition);
/// <summary>
/// Sets a new boundary condition to this dof removing any applied before.
/// </summary>
/// <param name="condition">The boundary condition to be applied to this dof.</param>
void ReplaceBoundaryCondition(axis::domain::boundary_conditions::BoundaryCondition& condition);
/// <summary>
/// Removes any boundary condition applied to this dof.
/// </summary>
void RemoveBoundaryCondition(void);
static axis::foundation::memory::RelativePointer Create(
id_type id, int localIndex, const axis::foundation::memory::RelativePointer& node);
void *operator new(size_t bytes);
void operator delete(void *ptr);
void *operator new(size_t bytes, void *ptr);
void operator delete(void *, void *);
private:
id_type _id;
int _localIndex;
axis::domain::boundary_conditions::BoundaryCondition *_condition;
axis::foundation::memory::RelativePointer _parentNode;
DISALLOW_COPY_AND_ASSIGN(DoF);
};
} } }
| 30.146789 | 101 | 0.673767 |
de62e7a84d0185142b4b94cd7fa40b3d72c289f3 | 677 | cpp | C++ | model/mosesdecoder/moses/Syntax/S2T/PChart.cpp | saeedesm/UNMT_AH | cc171bf66933b5c0ad8a0ab87e57f7364312a7df | [
"Apache-2.0"
] | 3 | 2020-02-28T21:42:44.000Z | 2021-03-12T13:56:16.000Z | tools/mosesdecoder-master/moses/Syntax/S2T/PChart.cpp | Pangeamt/nectm | 6b84f048698f2530b9fdbb30695f2e2217c3fbfe | [
"Apache-2.0"
] | 2 | 2020-11-06T14:40:10.000Z | 2020-12-29T19:03:11.000Z | tools/mosesdecoder-master/moses/Syntax/S2T/PChart.cpp | Pangeamt/nectm | 6b84f048698f2530b9fdbb30695f2e2217c3fbfe | [
"Apache-2.0"
] | 2 | 2019-11-26T05:27:16.000Z | 2019-12-17T01:53:43.000Z | #include "PChart.h"
#include "moses/FactorCollection.h"
namespace Moses
{
namespace Syntax
{
namespace S2T
{
PChart::PChart(std::size_t width, bool maintainCompressedChart)
{
m_cells.resize(width);
for (std::size_t i = 0; i < width; ++i) {
m_cells[i].resize(width);
}
if (maintainCompressedChart) {
m_compressedChart = new CompressedChart(width);
for (CompressedChart::iterator p = m_compressedChart->begin();
p != m_compressedChart->end(); ++p) {
p->resize(FactorCollection::Instance().GetNumNonTerminals());
}
}
}
PChart::~PChart()
{
delete m_compressedChart;
}
} // namespace S2T
} // namespace Syntax
} // namespace Moses
| 19.342857 | 67 | 0.67356 |
de654ee37cfebeb17bfec97b1a696cd8a99c9e97 | 473 | cpp | C++ | cpp/zigzag_conversion.cpp | jieyaren/hello-world | 9fbc7d117b9aee98d748669646dd200c25a4122f | [
"WTFPL"
] | 3 | 2021-11-12T09:20:21.000Z | 2022-02-18T11:34:33.000Z | cpp/zigzag_conversion.cpp | jieyaren/hello-world | 9fbc7d117b9aee98d748669646dd200c25a4122f | [
"WTFPL"
] | 1 | 2019-05-15T10:55:59.000Z | 2019-05-15T10:56:31.000Z | cpp/zigzag_conversion.cpp | jieyaren/hello-world | 9fbc7d117b9aee98d748669646dd200c25a4122f | [
"WTFPL"
] | null | null | null | class Solution
{
public:
string convert(string s, int nRows)
{
if (nRows <= 1 || s.size() <= 1) return s;
string result;
for (int i = 0; i < nRows; i++)
{
for (int j = 0, index = i; index < s.size();j++, index = (2 * nRows - 2) * j + i)
{
result.append(1, s[index]);
if (i == 0 || i == nRows - 1) continue;
if (index + (nRows - i - 1) * 2 < s.size())
result.append(1, s[index + (nRows - i - 1) * 2]);
}
}
return result;
}
}; | 23.65 | 85 | 0.488372 |
de6621476f54d243bfc11625bbc9c7bc8ebcd59b | 95,558 | cc | C++ | fbench/src/grpcclient/third_party/googleapis/gens/google/actions/sdk/v2/interactionmodel/prompt/static_prompt.pb.cc | kashiish/vespa | 307de4bb24463d0f36cd8391a7b8df75bd0949b2 | [
"Apache-2.0"
] | null | null | null | fbench/src/grpcclient/third_party/googleapis/gens/google/actions/sdk/v2/interactionmodel/prompt/static_prompt.pb.cc | kashiish/vespa | 307de4bb24463d0f36cd8391a7b8df75bd0949b2 | [
"Apache-2.0"
] | null | null | null | fbench/src/grpcclient/third_party/googleapis/gens/google/actions/sdk/v2/interactionmodel/prompt/static_prompt.pb.cc | kashiish/vespa | 307de4bb24463d0f36cd8391a7b8df75bd0949b2 | [
"Apache-2.0"
] | null | null | null | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/actions/sdk/v2/interactionmodel/prompt/static_prompt.proto
#include "google/actions/sdk/v2/interactionmodel/prompt/static_prompt.pb.h"
#include <algorithm>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcanvas_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_StaticCanvasPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcanvas_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcontent_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<7> scc_info_StaticContentPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcontent_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5flink_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_StaticLinkPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5flink_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<2> scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<5> scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fsimple_5fprompt_2eproto ::google::protobuf::internal::SCCInfo<1> scc_info_StaticSimplePrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fsimple_5fprompt_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsuggestion_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_Suggestion_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsuggestion_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsurface_5fcapabilities_2eproto ::google::protobuf::internal::SCCInfo<0> scc_info_SurfaceCapabilities_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsurface_5fcapabilities_2eproto;
namespace google {
namespace actions {
namespace sdk {
namespace v2 {
namespace interactionmodel {
namespace prompt {
class StaticPrompt_StaticPromptCandidate_StaticPromptResponseDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StaticPrompt_StaticPromptCandidate_StaticPromptResponse> _instance;
} _StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_;
class StaticPrompt_StaticPromptCandidateDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StaticPrompt_StaticPromptCandidate> _instance;
} _StaticPrompt_StaticPromptCandidate_default_instance_;
class StaticPrompt_SelectorDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StaticPrompt_Selector> _instance;
} _StaticPrompt_Selector_default_instance_;
class StaticPromptDefaultTypeInternal {
public:
::google::protobuf::internal::ExplicitlyConstructed<StaticPrompt> _instance;
} _StaticPrompt_default_instance_;
} // namespace prompt
} // namespace interactionmodel
} // namespace v2
} // namespace sdk
} // namespace actions
} // namespace google
static void InitDefaultsStaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_;
new (ptr) ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<5> scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 5, InitDefaultsStaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto}, {
&scc_info_StaticSimplePrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fsimple_5fprompt_2eproto.base,
&scc_info_StaticContentPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcontent_5fprompt_2eproto.base,
&scc_info_Suggestion_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsuggestion_2eproto.base,
&scc_info_StaticLinkPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5flink_5fprompt_2eproto.base,
&scc_info_StaticCanvasPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcanvas_5fprompt_2eproto.base,}};
static void InitDefaultsStaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_default_instance_;
new (ptr) ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<2> scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 2, InitDefaultsStaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto}, {
&scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base,
&scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base,}};
static void InitDefaultsStaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_Selector_default_instance_;
new (ptr) ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<1> scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsStaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto}, {
&scc_info_SurfaceCapabilities_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsurface_5fcapabilities_2eproto.base,}};
static void InitDefaultsStaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_default_instance_;
new (ptr) ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt();
::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
}
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt::InitAsDefaultInstance();
}
::google::protobuf::internal::SCCInfo<1> scc_info_StaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto =
{{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsStaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto}, {
&scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base,}};
void InitDefaults_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
::google::protobuf::internal::InitSCC(&scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::google::protobuf::internal::InitSCC(&scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::google::protobuf::internal::InitSCC(&scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::google::protobuf::internal::InitSCC(&scc_info_StaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
}
::google::protobuf::Metadata file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[4];
constexpr ::google::protobuf::EnumDescriptor const** file_level_enum_descriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = nullptr;
constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = nullptr;
const ::google::protobuf::uint32 TableStruct_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, first_simple_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, content_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, last_simple_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, suggestions_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, link_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, override_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse, canvas_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate, selector_),
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate, prompt_response_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector, surface_capabilities_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt, candidates_),
};
static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse)},
{ 12, -1, sizeof(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate)},
{ 19, -1, sizeof(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector)},
{ 25, -1, sizeof(::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt)},
};
static ::google::protobuf::Message const * const file_default_instances[] = {
reinterpret_cast<const ::google::protobuf::Message*>(&::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_Selector_default_instance_),
reinterpret_cast<const ::google::protobuf::Message*>(&::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_default_instance_),
};
::google::protobuf::internal::AssignDescriptorsTable assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = {
{}, AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, "google/actions/sdk/v2/interactionmodel/prompt/static_prompt.proto", schemas,
file_default_instances, TableStruct_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto::offsets,
file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, 4, file_level_enum_descriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, file_level_service_descriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto,
};
const char descriptor_table_protodef_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[] =
"\nAgoogle/actions/sdk/v2/interactionmodel"
"/prompt/static_prompt.proto\022-google.acti"
"ons.sdk.v2.interactionmodel.prompt\032Pgoog"
"le/actions/sdk/v2/interactionmodel/promp"
"t/content/static_canvas_prompt.proto\032Qgo"
"ogle/actions/sdk/v2/interactionmodel/pro"
"mpt/content/static_content_prompt.proto\032"
"Ngoogle/actions/sdk/v2/interactionmodel/"
"prompt/content/static_link_prompt.proto\032"
"Hgoogle/actions/sdk/v2/interactionmodel/"
"prompt/static_simple_prompt.proto\032>googl"
"e/actions/sdk/v2/interactionmodel/prompt"
"/suggestion.proto\032Hgoogle/actions/sdk/v2"
"/interactionmodel/prompt/surface_capabil"
"ities.proto\032\037google/api/field_behavior.p"
"roto\"\234\010\n\014StaticPrompt\022e\n\ncandidates\030\001 \003("
"\0132Q.google.actions.sdk.v2.interactionmod"
"el.prompt.StaticPrompt.StaticPromptCandi"
"date\032\266\006\n\025StaticPromptCandidate\022[\n\010select"
"or\030\001 \001(\0132D.google.actions.sdk.v2.interac"
"tionmodel.prompt.StaticPrompt.SelectorB\003"
"\340A\001\022\177\n\017prompt_response\030\002 \001(\0132f.google.ac"
"tions.sdk.v2.interactionmodel.prompt.Sta"
"ticPrompt.StaticPromptCandidate.StaticPr"
"omptResponse\032\276\004\n\024StaticPromptResponse\022\\\n"
"\014first_simple\030\002 \001(\0132A.google.actions.sdk"
".v2.interactionmodel.prompt.StaticSimple"
"PromptB\003\340A\001\022X\n\007content\030\003 \001(\0132B.google.ac"
"tions.sdk.v2.interactionmodel.prompt.Sta"
"ticContentPromptB\003\340A\001\022[\n\013last_simple\030\004 \001"
"(\0132A.google.actions.sdk.v2.interactionmo"
"del.prompt.StaticSimplePromptB\003\340A\001\022S\n\013su"
"ggestions\030\005 \003(\01329.google.actions.sdk.v2."
"interactionmodel.prompt.SuggestionB\003\340A\001\022"
"R\n\004link\030\006 \001(\0132\?.google.actions.sdk.v2.in"
"teractionmodel.prompt.StaticLinkPromptB\003"
"\340A\001\022\025\n\010override\030\007 \001(\010B\003\340A\001\022Q\n\006canvas\030\010 \001"
"(\0132A.google.actions.sdk.v2.interactionmo"
"del.prompt.StaticCanvasPrompt\032l\n\010Selecto"
"r\022`\n\024surface_capabilities\030\001 \001(\0132B.google"
".actions.sdk.v2.interactionmodel.prompt."
"SurfaceCapabilitiesB\235\001\n1com.google.actio"
"ns.sdk.v2.interactionmodel.promptB\021Stati"
"cPromptProtoP\001ZSgoogle.golang.org/genpro"
"to/googleapis/actions/sdk/v2/interaction"
"model/prompt;promptb\006proto3"
;
::google::protobuf::internal::DescriptorTable descriptor_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = {
false, InitDefaults_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto,
descriptor_table_protodef_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto,
"google/actions/sdk/v2/interactionmodel/prompt/static_prompt.proto", &assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, 1827,
};
void AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto() {
static constexpr ::google::protobuf::internal::InitFunc deps[7] =
{
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcanvas_5fprompt_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5fcontent_5fprompt_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fcontent_2fstatic_5flink_5fprompt_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fsimple_5fprompt_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsuggestion_2eproto,
::AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fsurface_5fcapabilities_2eproto,
::AddDescriptors_google_2fapi_2ffield_5fbehavior_2eproto,
};
::google::protobuf::internal::AddDescriptors(&descriptor_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto, deps, 7);
}
// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto = []() { AddDescriptors_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto(); return true; }();
namespace google {
namespace actions {
namespace sdk {
namespace v2 {
namespace interactionmodel {
namespace prompt {
// ===================================================================
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::InitAsDefaultInstance() {
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->first_simple_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->content_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->last_simple_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->link_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_default_instance_._instance.get_mutable()->canvas_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt::internal_default_instance());
}
class StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters {
public:
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt& first_simple(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt& content(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt& last_simple(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt& link(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt& canvas(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg);
};
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::first_simple(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->first_simple_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::content(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->content_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::last_simple(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->last_simple_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::link(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->link_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt&
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::HasBitSetters::canvas(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* msg) {
return *msg->canvas_;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_first_simple() {
if (GetArenaNoVirtual() == nullptr && first_simple_ != nullptr) {
delete first_simple_;
}
first_simple_ = nullptr;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_content() {
if (GetArenaNoVirtual() == nullptr && content_ != nullptr) {
delete content_;
}
content_ = nullptr;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_last_simple() {
if (GetArenaNoVirtual() == nullptr && last_simple_ != nullptr) {
delete last_simple_;
}
last_simple_ = nullptr;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_suggestions() {
suggestions_.Clear();
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_link() {
if (GetArenaNoVirtual() == nullptr && link_ != nullptr) {
delete link_;
}
link_ = nullptr;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::clear_canvas() {
if (GetArenaNoVirtual() == nullptr && canvas_ != nullptr) {
delete canvas_;
}
canvas_ = nullptr;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kFirstSimpleFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kContentFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kLastSimpleFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kSuggestionsFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kLinkFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kOverrideFieldNumber;
const int StaticPrompt_StaticPromptCandidate_StaticPromptResponse::kCanvasFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::StaticPrompt_StaticPromptCandidate_StaticPromptResponse()
: ::google::protobuf::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
}
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::StaticPrompt_StaticPromptCandidate_StaticPromptResponse(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse& from)
: ::google::protobuf::Message(),
_internal_metadata_(nullptr),
suggestions_(from.suggestions_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.has_first_simple()) {
first_simple_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt(*from.first_simple_);
} else {
first_simple_ = nullptr;
}
if (from.has_content()) {
content_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt(*from.content_);
} else {
content_ = nullptr;
}
if (from.has_last_simple()) {
last_simple_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt(*from.last_simple_);
} else {
last_simple_ = nullptr;
}
if (from.has_link()) {
link_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt(*from.link_);
} else {
link_ = nullptr;
}
if (from.has_canvas()) {
canvas_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt(*from.canvas_);
} else {
canvas_ = nullptr;
}
override_ = from.override_;
// @@protoc_insertion_point(copy_constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::SharedCtor() {
::google::protobuf::internal::InitSCC(
&scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::memset(&first_simple_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&override_) -
reinterpret_cast<char*>(&first_simple_)) + sizeof(override_));
}
StaticPrompt_StaticPromptCandidate_StaticPromptResponse::~StaticPrompt_StaticPromptCandidate_StaticPromptResponse() {
// @@protoc_insertion_point(destructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
SharedDtor();
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::SharedDtor() {
if (this != internal_default_instance()) delete first_simple_;
if (this != internal_default_instance()) delete content_;
if (this != internal_default_instance()) delete last_simple_;
if (this != internal_default_instance()) delete link_;
if (this != internal_default_instance()) delete canvas_;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const StaticPrompt_StaticPromptCandidate_StaticPromptResponse& StaticPrompt_StaticPromptCandidate_StaticPromptResponse::default_instance() {
::google::protobuf::internal::InitSCC(&::scc_info_StaticPrompt_StaticPromptCandidate_StaticPromptResponse_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
return *internal_default_instance();
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::Clear() {
// @@protoc_insertion_point(message_clear_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
suggestions_.Clear();
if (GetArenaNoVirtual() == nullptr && first_simple_ != nullptr) {
delete first_simple_;
}
first_simple_ = nullptr;
if (GetArenaNoVirtual() == nullptr && content_ != nullptr) {
delete content_;
}
content_ = nullptr;
if (GetArenaNoVirtual() == nullptr && last_simple_ != nullptr) {
delete last_simple_;
}
last_simple_ = nullptr;
if (GetArenaNoVirtual() == nullptr && link_ != nullptr) {
delete link_;
}
link_ = nullptr;
if (GetArenaNoVirtual() == nullptr && canvas_ != nullptr) {
delete canvas_;
}
canvas_ = nullptr;
override_ = false;
_internal_metadata_.Clear();
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* StaticPrompt_StaticPromptCandidate_StaticPromptResponse::_InternalParse(const char* begin, const char* end, void* object,
::google::protobuf::internal::ParseContext* ctx) {
auto msg = static_cast<StaticPrompt_StaticPromptCandidate_StaticPromptResponse*>(object);
::google::protobuf::int32 size; (void)size;
int depth; (void)depth;
::google::protobuf::uint32 tag;
::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
auto ptr = begin;
while (ptr < end) {
ptr = ::google::protobuf::io::Parse32(ptr, &tag);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::_InternalParse;
object = msg->mutable_first_simple();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
case 3: {
if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt::_InternalParse;
object = msg->mutable_content();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
case 4: {
if (static_cast<::google::protobuf::uint8>(tag) != 34) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::_InternalParse;
object = msg->mutable_last_simple();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
case 5: {
if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
do {
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::Suggestion::_InternalParse;
object = msg->add_suggestions();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 42 && (ptr += 1));
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
case 6: {
if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt::_InternalParse;
object = msg->mutable_link();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
case 7: {
if (static_cast<::google::protobuf::uint8>(tag) != 56) goto handle_unusual;
msg->set_override(::google::protobuf::internal::ReadVarint(&ptr));
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
case 8: {
if (static_cast<::google::protobuf::uint8>(tag) != 66) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt::_InternalParse;
object = msg->mutable_canvas();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->EndGroup(tag);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
ptr = res.first;
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
if (res.second) return ptr;
}
} // switch
} // while
return ptr;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
}
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StaticPrompt_StaticPromptCandidate_StaticPromptResponse::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) == (18 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_first_simple()));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
case 3: {
if (static_cast< ::google::protobuf::uint8>(tag) == (26 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_content()));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
case 4: {
if (static_cast< ::google::protobuf::uint8>(tag) == (34 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_last_simple()));
} else {
goto handle_unusual;
}
break;
}
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
case 5: {
if (static_cast< ::google::protobuf::uint8>(tag) == (42 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, add_suggestions()));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
case 6: {
if (static_cast< ::google::protobuf::uint8>(tag) == (50 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_link()));
} else {
goto handle_unusual;
}
break;
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
case 7: {
if (static_cast< ::google::protobuf::uint8>(tag) == (56 & 0xFF)) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &override_)));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
case 8: {
if (static_cast< ::google::protobuf::uint8>(tag) == (66 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_canvas()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
return false;
#undef DO_
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_first_simple()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, HasBitSetters::first_simple(this), output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_content()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
3, HasBitSetters::content(this), output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_last_simple()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, HasBitSetters::last_simple(this), output);
}
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->suggestions_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
5,
this->suggestions(static_cast<int>(i)),
output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_link()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
6, HasBitSetters::link(this), output);
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
if (this->override() != 0) {
::google::protobuf::internal::WireFormatLite::WriteBool(7, this->override(), output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
if (this->has_canvas()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
8, HasBitSetters::canvas(this), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
}
::google::protobuf::uint8* StaticPrompt_StaticPromptCandidate_StaticPromptResponse::InternalSerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_first_simple()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
2, HasBitSetters::first_simple(this), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_content()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
3, HasBitSetters::content(this), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_last_simple()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
4, HasBitSetters::last_simple(this), target);
}
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->suggestions_size()); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
5, this->suggestions(static_cast<int>(i)), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_link()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
6, HasBitSetters::link(this), target);
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
if (this->override() != 0) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->override(), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
if (this->has_canvas()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
8, HasBitSetters::canvas(this), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
return target;
}
size_t StaticPrompt_StaticPromptCandidate_StaticPromptResponse::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .google.actions.sdk.v2.interactionmodel.prompt.Suggestion suggestions = 5 [(.google.api.field_behavior) = OPTIONAL];
{
unsigned int count = static_cast<unsigned int>(this->suggestions_size());
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSize(
this->suggestions(static_cast<int>(i)));
}
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt first_simple = 2 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_first_simple()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*first_simple_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticContentPrompt content = 3 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_content()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*content_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticSimplePrompt last_simple = 4 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_last_simple()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*last_simple_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticLinkPrompt link = 6 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_link()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*link_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticCanvasPrompt canvas = 8;
if (this->has_canvas()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*canvas_);
}
// bool override = 7 [(.google.api.field_behavior) = OPTIONAL];
if (this->override() != 0) {
total_size += 1 + 1;
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
GOOGLE_DCHECK_NE(&from, this);
const StaticPrompt_StaticPromptCandidate_StaticPromptResponse* source =
::google::protobuf::DynamicCastToGenerated<StaticPrompt_StaticPromptCandidate_StaticPromptResponse>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
MergeFrom(*source);
}
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::MergeFrom(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
suggestions_.MergeFrom(from.suggestions_);
if (from.has_first_simple()) {
mutable_first_simple()->::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::MergeFrom(from.first_simple());
}
if (from.has_content()) {
mutable_content()->::google::actions::sdk::v2::interactionmodel::prompt::StaticContentPrompt::MergeFrom(from.content());
}
if (from.has_last_simple()) {
mutable_last_simple()->::google::actions::sdk::v2::interactionmodel::prompt::StaticSimplePrompt::MergeFrom(from.last_simple());
}
if (from.has_link()) {
mutable_link()->::google::actions::sdk::v2::interactionmodel::prompt::StaticLinkPrompt::MergeFrom(from.link());
}
if (from.has_canvas()) {
mutable_canvas()->::google::actions::sdk::v2::interactionmodel::prompt::StaticCanvasPrompt::MergeFrom(from.canvas());
}
if (from.override() != 0) {
set_override(from.override());
}
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::CopyFrom(const StaticPrompt_StaticPromptCandidate_StaticPromptResponse& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StaticPrompt_StaticPromptCandidate_StaticPromptResponse::IsInitialized() const {
return true;
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::Swap(StaticPrompt_StaticPromptCandidate_StaticPromptResponse* other) {
if (other == this) return;
InternalSwap(other);
}
void StaticPrompt_StaticPromptCandidate_StaticPromptResponse::InternalSwap(StaticPrompt_StaticPromptCandidate_StaticPromptResponse* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
CastToBase(&suggestions_)->InternalSwap(CastToBase(&other->suggestions_));
swap(first_simple_, other->first_simple_);
swap(content_, other->content_);
swap(last_simple_, other->last_simple_);
swap(link_, other->link_);
swap(canvas_, other->canvas_);
swap(override_, other->override_);
}
::google::protobuf::Metadata StaticPrompt_StaticPromptCandidate_StaticPromptResponse::GetMetadata() const {
::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto);
return ::file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[kIndexInFileMessages];
}
// ===================================================================
void StaticPrompt_StaticPromptCandidate::InitAsDefaultInstance() {
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_default_instance_._instance.get_mutable()->selector_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector::internal_default_instance());
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_StaticPromptCandidate_default_instance_._instance.get_mutable()->prompt_response_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse*>(
::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse::internal_default_instance());
}
class StaticPrompt_StaticPromptCandidate::HasBitSetters {
public:
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector& selector(const StaticPrompt_StaticPromptCandidate* msg);
static const ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse& prompt_response(const StaticPrompt_StaticPromptCandidate* msg);
};
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector&
StaticPrompt_StaticPromptCandidate::HasBitSetters::selector(const StaticPrompt_StaticPromptCandidate* msg) {
return *msg->selector_;
}
const ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse&
StaticPrompt_StaticPromptCandidate::HasBitSetters::prompt_response(const StaticPrompt_StaticPromptCandidate* msg) {
return *msg->prompt_response_;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StaticPrompt_StaticPromptCandidate::kSelectorFieldNumber;
const int StaticPrompt_StaticPromptCandidate::kPromptResponseFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StaticPrompt_StaticPromptCandidate::StaticPrompt_StaticPromptCandidate()
: ::google::protobuf::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
}
StaticPrompt_StaticPromptCandidate::StaticPrompt_StaticPromptCandidate(const StaticPrompt_StaticPromptCandidate& from)
: ::google::protobuf::Message(),
_internal_metadata_(nullptr) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.has_selector()) {
selector_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector(*from.selector_);
} else {
selector_ = nullptr;
}
if (from.has_prompt_response()) {
prompt_response_ = new ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse(*from.prompt_response_);
} else {
prompt_response_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
}
void StaticPrompt_StaticPromptCandidate::SharedCtor() {
::google::protobuf::internal::InitSCC(
&scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
::memset(&selector_, 0, static_cast<size_t>(
reinterpret_cast<char*>(&prompt_response_) -
reinterpret_cast<char*>(&selector_)) + sizeof(prompt_response_));
}
StaticPrompt_StaticPromptCandidate::~StaticPrompt_StaticPromptCandidate() {
// @@protoc_insertion_point(destructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
SharedDtor();
}
void StaticPrompt_StaticPromptCandidate::SharedDtor() {
if (this != internal_default_instance()) delete selector_;
if (this != internal_default_instance()) delete prompt_response_;
}
void StaticPrompt_StaticPromptCandidate::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const StaticPrompt_StaticPromptCandidate& StaticPrompt_StaticPromptCandidate::default_instance() {
::google::protobuf::internal::InitSCC(&::scc_info_StaticPrompt_StaticPromptCandidate_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
return *internal_default_instance();
}
void StaticPrompt_StaticPromptCandidate::Clear() {
// @@protoc_insertion_point(message_clear_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
if (GetArenaNoVirtual() == nullptr && selector_ != nullptr) {
delete selector_;
}
selector_ = nullptr;
if (GetArenaNoVirtual() == nullptr && prompt_response_ != nullptr) {
delete prompt_response_;
}
prompt_response_ = nullptr;
_internal_metadata_.Clear();
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* StaticPrompt_StaticPromptCandidate::_InternalParse(const char* begin, const char* end, void* object,
::google::protobuf::internal::ParseContext* ctx) {
auto msg = static_cast<StaticPrompt_StaticPromptCandidate*>(object);
::google::protobuf::int32 size; (void)size;
int depth; (void)depth;
::google::protobuf::uint32 tag;
::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
auto ptr = begin;
while (ptr < end) {
ptr = ::google::protobuf::io::Parse32(ptr, &tag);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector::_InternalParse;
object = msg->mutable_selector();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
case 2: {
if (static_cast<::google::protobuf::uint8>(tag) != 18) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse::_InternalParse;
object = msg->mutable_prompt_response();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->EndGroup(tag);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
ptr = res.first;
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
if (res.second) return ptr;
}
} // switch
} // while
return ptr;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
}
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StaticPrompt_StaticPromptCandidate::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) == (10 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_selector()));
} else {
goto handle_unusual;
}
break;
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
case 2: {
if (static_cast< ::google::protobuf::uint8>(tag) == (18 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_prompt_response()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
return false;
#undef DO_
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void StaticPrompt_StaticPromptCandidate::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_selector()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, HasBitSetters::selector(this), output);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
if (this->has_prompt_response()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, HasBitSetters::prompt_response(this), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
}
::google::protobuf::uint8* StaticPrompt_StaticPromptCandidate::InternalSerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_selector()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
1, HasBitSetters::selector(this), target);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
if (this->has_prompt_response()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
2, HasBitSetters::prompt_response(this), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
return target;
}
size_t StaticPrompt_StaticPromptCandidate::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector selector = 1 [(.google.api.field_behavior) = OPTIONAL];
if (this->has_selector()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*selector_);
}
// .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate.StaticPromptResponse prompt_response = 2;
if (this->has_prompt_response()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*prompt_response_);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StaticPrompt_StaticPromptCandidate::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
GOOGLE_DCHECK_NE(&from, this);
const StaticPrompt_StaticPromptCandidate* source =
::google::protobuf::DynamicCastToGenerated<StaticPrompt_StaticPromptCandidate>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
MergeFrom(*source);
}
}
void StaticPrompt_StaticPromptCandidate::MergeFrom(const StaticPrompt_StaticPromptCandidate& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.has_selector()) {
mutable_selector()->::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector::MergeFrom(from.selector());
}
if (from.has_prompt_response()) {
mutable_prompt_response()->::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse::MergeFrom(from.prompt_response());
}
}
void StaticPrompt_StaticPromptCandidate::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StaticPrompt_StaticPromptCandidate::CopyFrom(const StaticPrompt_StaticPromptCandidate& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StaticPrompt_StaticPromptCandidate::IsInitialized() const {
return true;
}
void StaticPrompt_StaticPromptCandidate::Swap(StaticPrompt_StaticPromptCandidate* other) {
if (other == this) return;
InternalSwap(other);
}
void StaticPrompt_StaticPromptCandidate::InternalSwap(StaticPrompt_StaticPromptCandidate* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(selector_, other->selector_);
swap(prompt_response_, other->prompt_response_);
}
::google::protobuf::Metadata StaticPrompt_StaticPromptCandidate::GetMetadata() const {
::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto);
return ::file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[kIndexInFileMessages];
}
// ===================================================================
void StaticPrompt_Selector::InitAsDefaultInstance() {
::google::actions::sdk::v2::interactionmodel::prompt::_StaticPrompt_Selector_default_instance_._instance.get_mutable()->surface_capabilities_ = const_cast< ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities*>(
::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities::internal_default_instance());
}
class StaticPrompt_Selector::HasBitSetters {
public:
static const ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities& surface_capabilities(const StaticPrompt_Selector* msg);
};
const ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities&
StaticPrompt_Selector::HasBitSetters::surface_capabilities(const StaticPrompt_Selector* msg) {
return *msg->surface_capabilities_;
}
void StaticPrompt_Selector::clear_surface_capabilities() {
if (GetArenaNoVirtual() == nullptr && surface_capabilities_ != nullptr) {
delete surface_capabilities_;
}
surface_capabilities_ = nullptr;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StaticPrompt_Selector::kSurfaceCapabilitiesFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StaticPrompt_Selector::StaticPrompt_Selector()
: ::google::protobuf::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
}
StaticPrompt_Selector::StaticPrompt_Selector(const StaticPrompt_Selector& from)
: ::google::protobuf::Message(),
_internal_metadata_(nullptr) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
if (from.has_surface_capabilities()) {
surface_capabilities_ = new ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities(*from.surface_capabilities_);
} else {
surface_capabilities_ = nullptr;
}
// @@protoc_insertion_point(copy_constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
}
void StaticPrompt_Selector::SharedCtor() {
::google::protobuf::internal::InitSCC(
&scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
surface_capabilities_ = nullptr;
}
StaticPrompt_Selector::~StaticPrompt_Selector() {
// @@protoc_insertion_point(destructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
SharedDtor();
}
void StaticPrompt_Selector::SharedDtor() {
if (this != internal_default_instance()) delete surface_capabilities_;
}
void StaticPrompt_Selector::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const StaticPrompt_Selector& StaticPrompt_Selector::default_instance() {
::google::protobuf::internal::InitSCC(&::scc_info_StaticPrompt_Selector_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
return *internal_default_instance();
}
void StaticPrompt_Selector::Clear() {
// @@protoc_insertion_point(message_clear_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
if (GetArenaNoVirtual() == nullptr && surface_capabilities_ != nullptr) {
delete surface_capabilities_;
}
surface_capabilities_ = nullptr;
_internal_metadata_.Clear();
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* StaticPrompt_Selector::_InternalParse(const char* begin, const char* end, void* object,
::google::protobuf::internal::ParseContext* ctx) {
auto msg = static_cast<StaticPrompt_Selector*>(object);
::google::protobuf::int32 size; (void)size;
int depth; (void)depth;
::google::protobuf::uint32 tag;
::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
auto ptr = begin;
while (ptr < end) {
ptr = ::google::protobuf::io::Parse32(ptr, &tag);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities::_InternalParse;
object = msg->mutable_surface_capabilities();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
break;
}
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->EndGroup(tag);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
ptr = res.first;
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
if (res.second) return ptr;
}
} // switch
} // while
return ptr;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
}
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StaticPrompt_Selector::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) == (10 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, mutable_surface_capabilities()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
return false;
#undef DO_
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void StaticPrompt_Selector::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
if (this->has_surface_capabilities()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1, HasBitSetters::surface_capabilities(this), output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
}
::google::protobuf::uint8* StaticPrompt_Selector::InternalSerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
if (this->has_surface_capabilities()) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
1, HasBitSetters::surface_capabilities(this), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
return target;
}
size_t StaticPrompt_Selector::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// .google.actions.sdk.v2.interactionmodel.prompt.SurfaceCapabilities surface_capabilities = 1;
if (this->has_surface_capabilities()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSize(
*surface_capabilities_);
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StaticPrompt_Selector::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
GOOGLE_DCHECK_NE(&from, this);
const StaticPrompt_Selector* source =
::google::protobuf::DynamicCastToGenerated<StaticPrompt_Selector>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
MergeFrom(*source);
}
}
void StaticPrompt_Selector::MergeFrom(const StaticPrompt_Selector& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
if (from.has_surface_capabilities()) {
mutable_surface_capabilities()->::google::actions::sdk::v2::interactionmodel::prompt::SurfaceCapabilities::MergeFrom(from.surface_capabilities());
}
}
void StaticPrompt_Selector::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StaticPrompt_Selector::CopyFrom(const StaticPrompt_Selector& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.Selector)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StaticPrompt_Selector::IsInitialized() const {
return true;
}
void StaticPrompt_Selector::Swap(StaticPrompt_Selector* other) {
if (other == this) return;
InternalSwap(other);
}
void StaticPrompt_Selector::InternalSwap(StaticPrompt_Selector* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
swap(surface_capabilities_, other->surface_capabilities_);
}
::google::protobuf::Metadata StaticPrompt_Selector::GetMetadata() const {
::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto);
return ::file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[kIndexInFileMessages];
}
// ===================================================================
void StaticPrompt::InitAsDefaultInstance() {
}
class StaticPrompt::HasBitSetters {
public:
};
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int StaticPrompt::kCandidatesFieldNumber;
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
StaticPrompt::StaticPrompt()
: ::google::protobuf::Message(), _internal_metadata_(nullptr) {
SharedCtor();
// @@protoc_insertion_point(constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
}
StaticPrompt::StaticPrompt(const StaticPrompt& from)
: ::google::protobuf::Message(),
_internal_metadata_(nullptr),
candidates_(from.candidates_) {
_internal_metadata_.MergeFrom(from._internal_metadata_);
// @@protoc_insertion_point(copy_constructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
}
void StaticPrompt::SharedCtor() {
::google::protobuf::internal::InitSCC(
&scc_info_StaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
}
StaticPrompt::~StaticPrompt() {
// @@protoc_insertion_point(destructor:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
SharedDtor();
}
void StaticPrompt::SharedDtor() {
}
void StaticPrompt::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const StaticPrompt& StaticPrompt::default_instance() {
::google::protobuf::internal::InitSCC(&::scc_info_StaticPrompt_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto.base);
return *internal_default_instance();
}
void StaticPrompt::Clear() {
// @@protoc_insertion_point(message_clear_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
candidates_.Clear();
_internal_metadata_.Clear();
}
#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
const char* StaticPrompt::_InternalParse(const char* begin, const char* end, void* object,
::google::protobuf::internal::ParseContext* ctx) {
auto msg = static_cast<StaticPrompt*>(object);
::google::protobuf::int32 size; (void)size;
int depth; (void)depth;
::google::protobuf::uint32 tag;
::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
auto ptr = begin;
while (ptr < end) {
ptr = ::google::protobuf::io::Parse32(ptr, &tag);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
switch (tag >> 3) {
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
case 1: {
if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
do {
ptr = ::google::protobuf::io::ReadSize(ptr, &size);
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
parser_till_end = ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate::_InternalParse;
object = msg->add_candidates();
if (size > end - ptr) goto len_delim_till_end;
ptr += size;
GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
{parser_till_end, object}, ptr - size, ptr));
if (ptr >= end) break;
} while ((::google::protobuf::io::UnalignedLoad<::google::protobuf::uint64>(ptr) & 255) == 10 && (ptr += 1));
break;
}
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->EndGroup(tag);
return ptr;
}
auto res = UnknownFieldParse(tag, {_InternalParse, msg},
ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
ptr = res.first;
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
if (res.second) return ptr;
}
} // switch
} // while
return ptr;
len_delim_till_end:
return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
{parser_till_end, object}, size);
}
#else // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
bool StaticPrompt::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
::google::protobuf::uint32 tag;
// @@protoc_insertion_point(parse_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
for (;;) {
::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
tag = p.first;
if (!p.second) goto handle_unusual;
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
case 1: {
if (static_cast< ::google::protobuf::uint8>(tag) == (10 & 0xFF)) {
DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
input, add_candidates()));
} else {
goto handle_unusual;
}
break;
}
default: {
handle_unusual:
if (tag == 0) {
goto success;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, _internal_metadata_.mutable_unknown_fields()));
break;
}
}
}
success:
// @@protoc_insertion_point(parse_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
return true;
failure:
// @@protoc_insertion_point(parse_failure:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
return false;
#undef DO_
}
#endif // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
void StaticPrompt::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// @@protoc_insertion_point(serialize_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->candidates_size()); i < n; i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
1,
this->candidates(static_cast<int>(i)),
output);
}
if (_internal_metadata_.have_unknown_fields()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
_internal_metadata_.unknown_fields(), output);
}
// @@protoc_insertion_point(serialize_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
}
::google::protobuf::uint8* StaticPrompt::InternalSerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// @@protoc_insertion_point(serialize_to_array_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->candidates_size()); i < n; i++) {
target = ::google::protobuf::internal::WireFormatLite::
InternalWriteMessageToArray(
1, this->candidates(static_cast<int>(i)), target);
}
if (_internal_metadata_.have_unknown_fields()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields(), target);
}
// @@protoc_insertion_point(serialize_to_array_end:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
return target;
}
size_t StaticPrompt::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
size_t total_size = 0;
if (_internal_metadata_.have_unknown_fields()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
_internal_metadata_.unknown_fields());
}
::google::protobuf::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt.StaticPromptCandidate candidates = 1;
{
unsigned int count = static_cast<unsigned int>(this->candidates_size());
total_size += 1UL * count;
for (unsigned int i = 0; i < count; i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSize(
this->candidates(static_cast<int>(i)));
}
}
int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void StaticPrompt::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
GOOGLE_DCHECK_NE(&from, this);
const StaticPrompt* source =
::google::protobuf::DynamicCastToGenerated<StaticPrompt>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
MergeFrom(*source);
}
}
void StaticPrompt::MergeFrom(const StaticPrompt& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom(from._internal_metadata_);
::google::protobuf::uint32 cached_has_bits = 0;
(void) cached_has_bits;
candidates_.MergeFrom(from.candidates_);
}
void StaticPrompt::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void StaticPrompt::CopyFrom(const StaticPrompt& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:google.actions.sdk.v2.interactionmodel.prompt.StaticPrompt)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool StaticPrompt::IsInitialized() const {
return true;
}
void StaticPrompt::Swap(StaticPrompt* other) {
if (other == this) return;
InternalSwap(other);
}
void StaticPrompt::InternalSwap(StaticPrompt* other) {
using std::swap;
_internal_metadata_.Swap(&other->_internal_metadata_);
CastToBase(&candidates_)->InternalSwap(CastToBase(&other->candidates_));
}
::google::protobuf::Metadata StaticPrompt::GetMetadata() const {
::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto);
return ::file_level_metadata_google_2factions_2fsdk_2fv2_2finteractionmodel_2fprompt_2fstatic_5fprompt_2eproto[kIndexInFileMessages];
}
// @@protoc_insertion_point(namespace_scope)
} // namespace prompt
} // namespace interactionmodel
} // namespace v2
} // namespace sdk
} // namespace actions
} // namespace google
namespace google {
namespace protobuf {
template<> PROTOBUF_NOINLINE ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse* Arena::CreateMaybeMessage< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse >(Arena* arena) {
return Arena::CreateInternal< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate_StaticPromptResponse >(arena);
}
template<> PROTOBUF_NOINLINE ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate* Arena::CreateMaybeMessage< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate >(Arena* arena) {
return Arena::CreateInternal< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_StaticPromptCandidate >(arena);
}
template<> PROTOBUF_NOINLINE ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector* Arena::CreateMaybeMessage< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector >(Arena* arena) {
return Arena::CreateInternal< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt_Selector >(arena);
}
template<> PROTOBUF_NOINLINE ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt* Arena::CreateMaybeMessage< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt >(Arena* arena) {
return Arena::CreateInternal< ::google::actions::sdk::v2::interactionmodel::prompt::StaticPrompt >(arena);
}
} // namespace protobuf
} // namespace google
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 50.188025 | 332 | 0.761757 |
de66df5d745f37310b3cd581a149e17024a1f60e | 8,355 | cpp | C++ | net/ias/policy/dll_bld/request.cpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | net/ias/policy/dll_bld/request.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | net/ias/policy/dll_bld/request.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | ///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation.
//
// SYNOPSIS
//
// Defines the class Request.
//
///////////////////////////////////////////////////////////////////////////////
#include <polcypch.h>
#include <iasattr.h>
#include <sdoias.h>
#include <request.h>
#include <new>
PIASATTRIBUTE Request::findFirst(DWORD id) const throw ()
{
for (PIASATTRIBUTE* a = begin; a != end; ++a)
{
if ((*a)->dwId == id) { return *a; }
}
return NULL;
}
Request* Request::narrow(IUnknown* pUnk) throw ()
{
Request* request = NULL;
if (pUnk)
{
HRESULT hr = pUnk->QueryInterface(
__uuidof(Request),
(PVOID*)&request
);
if (SUCCEEDED(hr))
{
request->GetUnknown()->Release();
}
}
return request;
}
STDMETHODIMP Request::get_Source(IRequestSource** pVal)
{
if (*pVal = source) { source->AddRef(); }
return S_OK;
}
STDMETHODIMP Request::put_Source(IRequestSource* newVal)
{
if (source) { source->Release(); }
if (source = newVal) { source->AddRef(); }
return S_OK;
}
STDMETHODIMP Request::get_Protocol(IASPROTOCOL *pVal)
{
*pVal = protocol;
return S_OK;
}
STDMETHODIMP Request::put_Protocol(IASPROTOCOL newVal)
{
protocol = newVal;
return S_OK;
}
STDMETHODIMP Request::get_Request(LONG *pVal)
{
*pVal = (LONG)request;
return S_OK;
}
STDMETHODIMP Request::put_Request(LONG newVal)
{
request = (IASREQUEST)newVal;
return S_OK;
}
STDMETHODIMP Request::get_Response(LONG *pVal)
{
*pVal = (LONG)response;
return S_OK;
}
STDMETHODIMP Request::get_Reason(LONG *pVal)
{
*pVal = (LONG)reason;
return S_OK;
}
STDMETHODIMP Request::SetResponse(IASRESPONSE eResponse, LONG lReason)
{
response = eResponse;
reason = (IASREASON)lReason;
return S_OK;
}
STDMETHODIMP Request::ReturnToSource(IASREQUESTSTATUS eStatus)
{
return source ? source->OnRequestComplete(this, eStatus) : S_OK;
}
HRESULT Request::AddAttributes(
DWORD dwPosCount,
PATTRIBUTEPOSITION pPositions
)
{
if (!reserve(size() + dwPosCount))
{
return E_OUTOFMEMORY;
}
for ( ; dwPosCount; --dwPosCount, ++pPositions)
{
IASAttributeAddRef(pPositions->pAttribute);
*end++ = pPositions->pAttribute;
}
return S_OK;
}
HRESULT Request::RemoveAttributes(
DWORD dwPosCount,
PATTRIBUTEPOSITION pPositions
)
{
for ( ; dwPosCount; --dwPosCount, ++pPositions)
{
PIASATTRIBUTE* pos = find(pPositions->pAttribute);
if (pos != 0)
{
IASAttributeRelease(*pos);
--end;
memmove(pos, pos + 1, (end - pos) * sizeof(PIASATTRIBUTE));
}
}
return S_OK;
}
HRESULT Request::RemoveAttributesByType(
DWORD dwAttrIDCount,
DWORD *lpdwAttrIDs
)
{
for ( ; dwAttrIDCount; ++lpdwAttrIDs, --dwAttrIDCount)
{
for (PIASATTRIBUTE* i = begin; i != end; )
{
if ((*i)->dwId == *lpdwAttrIDs)
{
IASAttributeRelease(*i);
--end;
memmove(i, i + 1, (end - i) * sizeof(PIASATTRIBUTE));
}
else
{
++i;
}
}
}
return S_OK;
}
HRESULT Request::GetAttributeCount(
DWORD *lpdwCount
)
{
*lpdwCount = size();
return S_OK;
}
HRESULT Request::GetAttributes(
DWORD *lpdwPosCount,
PATTRIBUTEPOSITION pPositions,
DWORD dwAttrIDCount,
DWORD *lpdwAttrIDs
)
{
HRESULT hr = S_OK;
DWORD count = 0;
// End of the caller supplied array.
PATTRIBUTEPOSITION stop = pPositions + *lpdwPosCount;
// Next struct to be filled.
PATTRIBUTEPOSITION next = pPositions;
// Force at least one iteration of the for loop.
if (!lpdwAttrIDs) { dwAttrIDCount = 1; }
// Iterate through the desired attribute IDs.
for ( ; dwAttrIDCount; ++lpdwAttrIDs, --dwAttrIDCount)
{
// Iterate through the request's attribute collection.
for (PIASATTRIBUTE* i = begin; i != end; ++i)
{
// Did the caller ask for all the attributes ?
// If not, is this a match for one of the requested IDs ?
if (!lpdwAttrIDs || (*i)->dwId == *lpdwAttrIDs)
{
if (next)
{
if (next == stop)
{
*lpdwPosCount = count;
return HRESULT_FROM_WIN32(ERROR_MORE_DATA);
}
IASAttributeAddRef(next->pAttribute = *i);
++next;
}
++count;
}
}
}
*lpdwPosCount = count;
return hr;
}
STDMETHODIMP Request::InsertBefore(
PATTRIBUTEPOSITION newAttr,
PATTRIBUTEPOSITION refAttr
)
{
// Reserve space for the new attribute.
if (!reserve(size() + 1))
{
return E_OUTOFMEMORY;
}
// Find the position; if it doesn't exist we'll do a simple add.
PIASATTRIBUTE* pos = find(refAttr->pAttribute);
if (pos == 0)
{
return AddAttributes(1, newAttr);
}
// Move the existing attribute out of the way.
memmove(pos + 1, pos, (end - pos) * sizeof(PIASATTRIBUTE));
++end;
// Store the new attribute.
*pos = newAttr->pAttribute;
IASAttributeAddRef(*pos);
return S_OK;
}
STDMETHODIMP Request::Push(
ULONG64 State
)
{
const PULONG64 END_STATE = state + sizeof(state)/sizeof(state[0]);
if (topOfStack != END_STATE)
{
*topOfStack = State;
++topOfStack;
return S_OK;
}
return E_OUTOFMEMORY;
}
STDMETHODIMP Request::Pop(
ULONG64* pState
)
{
if (topOfStack != state)
{
--topOfStack;
*pState = *topOfStack;
return S_OK;
}
return E_FAIL;
}
STDMETHODIMP Request::Top(
ULONG64* pState
)
{
if (topOfStack != state)
{
*pState = *(topOfStack - 1);
return S_OK;
}
return E_FAIL;
}
Request::Request() throw ()
: source(NULL),
protocol(IAS_PROTOCOL_RADIUS),
request(IAS_REQUEST_ACCESS_REQUEST),
response(IAS_RESPONSE_INVALID),
reason(IAS_SUCCESS),
begin(NULL),
end(NULL),
capacity(NULL),
topOfStack(&state[0])
{
topOfStack = state;
}
Request::~Request() throw ()
{
for (PIASATTRIBUTE* i = begin; i != end; ++i)
{
IASAttributeRelease(*i);
}
delete[] begin;
if (source) { source->Release(); }
}
inline size_t Request::size() const throw ()
{
return end - begin;
}
bool Request::reserve(size_t newCapacity) throw ()
{
if (newCapacity <= capacity)
{
return true;
}
// Increase the capacity by at least 50% and never less than 32.
size_t minCapacity = (capacity > 21) ? (capacity * 3 / 2): 32;
// Is the requested capacity less than the minimum resize?
if (newCapacity < minCapacity)
{
newCapacity = minCapacity;
}
// Allocate the new array.
PIASATTRIBUTE* newArray = new (std::nothrow) PIASATTRIBUTE[newCapacity];
if (newArray == 0)
{
return false;
}
// Save the values in the old array.
memcpy(newArray, begin, size() * sizeof(PIASATTRIBUTE));
// Delete the old array.
delete[] begin;
// Update our pointers.
end = newArray + size();
begin = newArray;
capacity = newCapacity;
return true;
}
PIASATTRIBUTE* Request::find(IASATTRIBUTE* key) const throw ()
{
for (PIASATTRIBUTE* i = begin; i != end; ++i)
{
if (*i == key)
{
return i;
}
}
return 0;
}
| 21.589147 | 80 | 0.520766 |
de69117248769fece90923ed8a531e23e9866066 | 316 | cpp | C++ | atcoder/abc116/A.cpp | SashiRin/protrode | c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c | [
"MIT"
] | 1 | 2019-08-03T13:42:16.000Z | 2019-08-03T13:42:16.000Z | atcoder/abc116/A.cpp | SashiRin/protrode | c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c | [
"MIT"
] | null | null | null | atcoder/abc116/A.cpp | SashiRin/protrode | c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;
int main() {
vector<int> nums(3);
for (int i = 0; i < 3; ++i) {
cin >> nums[i];
}
sort(nums.begin(), nums.end());
cout << nums[0] * nums[1] / 2 << endl;
return 0;
}
| 18.588235 | 42 | 0.53481 |
de69d155868cb9b451780809dc5173551ad2facf | 1,188 | cpp | C++ | 洛谷/模拟/P1042.cpp | codehuanglei/- | 933a55b5c5a49163f12e0c39b4edfa9c4f01678f | [
"MIT"
] | null | null | null | 洛谷/模拟/P1042.cpp | codehuanglei/- | 933a55b5c5a49163f12e0c39b4edfa9c4f01678f | [
"MIT"
] | null | null | null | 洛谷/模拟/P1042.cpp | codehuanglei/- | 933a55b5c5a49163f12e0c39b4edfa9c4f01678f | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
const int MAX = 65535;
int arr[MAX] = {0};
char ch;
int main(){
for(int i = 1;cin >> ch && ch != 'E'; i++){
if(ch == 'W'){
arr[i] = 1;
}
if(ch == 'L'){
arr[i] = 2;
}
}
int w = 0, l = 0;
for(int i = 1; 1; i++){
if(arr[i] == 1){
w++;
}
if(arr[i] == 2){
l++;
}
if(arr[i] == 0){
cout<< w << ":" << l<<endl;
break;
}
if(w - l >= 2 || l - w >= 2){
if(w >= 11 || l >= 11){
cout<< w << ":"<< l << endl;
w = 0;
l = 0;
}
}
}
cout<< endl;
w = l = 0;
for(int i = 1; 1; i++){
if(arr[i] == 1){
w++;
}
if(arr[i] == 2){
l++;
}
if(arr[i] == 0){
cout<< w << ":" << l<<endl;
break;
}
if(w - l >= 2 || l - w >= 2){
if(w >= 21 || l >= 21){
cout<< w << ":"<< l << endl;
w = 0;
l = 0;
}
}
}
return 0;
} | 20.842105 | 47 | 0.244108 |
de6a14af5c852ebfe2b51977061ef15749adf264 | 1,662 | hpp | C++ | Source/wali/include/wali/LongestSaturatingPathSemiring.hpp | jusito/WALi-OpenNWA | 2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99 | [
"MIT"
] | 15 | 2015-03-07T17:25:57.000Z | 2022-02-04T20:17:00.000Z | Source/wali/include/wali/LongestSaturatingPathSemiring.hpp | jusito/WALi-OpenNWA | 2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99 | [
"MIT"
] | 1 | 2018-03-03T05:58:55.000Z | 2018-03-03T12:26:10.000Z | Source/wali/include/wali/LongestSaturatingPathSemiring.hpp | jusito/WALi-OpenNWA | 2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99 | [
"MIT"
] | 15 | 2015-09-25T17:44:35.000Z | 2021-07-18T18:25:38.000Z | #ifndef WALI_LONGESTSATURATING_PATH_SEMIRING_HPP
#define WALI_LONGESTSATURATING_PATH_SEMIRING_HPP
#include "wali/SemElem.hpp"
#include "wali/MergeFn.hpp"
#include "wali/ref_ptr.hpp"
#include "wali/Key.hpp"
#include <set>
namespace wali {
/// This is a funny domain. But maybe it'll be useful? I just use it for
/// testing.
///
/// The domain is {0, 1, 2, ...., big, bottom} for some 'big' (given in the
/// constructor). Extend is saturating addition strictly evaluated, combine
/// is maximum, semiring zero is bottom, and semiring one is distance 0.
class LongestSaturatingPathSemiring : public wali::SemElem
{
public:
//-----------------------------
// semiring one and zero
//-----------------------------
sem_elem_t one() const;
sem_elem_t zero() const;
//---------------------------------
// semiring operations
//---------------------------------
sem_elem_t extend( SemElem* rhs );
sem_elem_t combine( SemElem* rhs );
bool equal(SemElem *rhs) const;
bool containerLessThan(SemElem const * rhs) const;
//------------------------------------
// output
//------------------------------------
std::ostream & print(std::ostream &out) const;
unsigned int getNum() const;
size_t hash() const;
private:
unsigned int v;
unsigned int biggest;
public:
//---------------------
// Constructors
//---------------------
LongestSaturatingPathSemiring(unsigned int big) : v(0), biggest(big) { }
LongestSaturatingPathSemiring(unsigned int _v, unsigned int big) : v(_v), biggest(big) {}
};
}
#endif // REACH_SEMIRING
| 24.086957 | 93 | 0.561372 |
de6b176e78f826c786378659d8757f9f98fae5fa | 560 | cpp | C++ | Chapter_9/overloading_variadic_non-template.cpp | wagnerhsu/packt-CPP-Templates-Up-and-Running | 2dcede8bb155d609a1b8d9765bfd4167e3a57289 | [
"MIT"
] | null | null | null | Chapter_9/overloading_variadic_non-template.cpp | wagnerhsu/packt-CPP-Templates-Up-and-Running | 2dcede8bb155d609a1b8d9765bfd4167e3a57289 | [
"MIT"
] | null | null | null | Chapter_9/overloading_variadic_non-template.cpp | wagnerhsu/packt-CPP-Templates-Up-and-Running | 2dcede8bb155d609a1b8d9765bfd4167e3a57289 | [
"MIT"
] | null | null | null | #include <iostream>
void foo(int val1, int val2)
{
std::cout << "From non-template" << std::endl;
std::cout << val1 << " " << val2 << std::endl;
}
template<typename T>
void foo(T val1, T val2)
{
std::cout << "From non-variadic" << std::endl;
std::cout << val1 << " " << val2 << std::endl;
}
template<typename T, typename... rest>
void foo(T val, rest... argPack)
{
std::cout << "From variadic" << std::endl;
std::cout << val << std::endl;
foo(argPack...);
}
int main()
{
foo(10, 20);
foo(10, 20, 30, 40);
return 0;
}
| 19.310345 | 50 | 0.55 |
de6bec73380ead55000e692d1463d900d1472f4a | 12,254 | cc | C++ | src/trace_processor/args_table_unittest.cc | zakerinasab/perfetto | 7f86589d1522ce8bfc59f6b569ca52496a53eb79 | [
"Apache-2.0"
] | null | null | null | src/trace_processor/args_table_unittest.cc | zakerinasab/perfetto | 7f86589d1522ce8bfc59f6b569ca52496a53eb79 | [
"Apache-2.0"
] | null | null | null | src/trace_processor/args_table_unittest.cc | zakerinasab/perfetto | 7f86589d1522ce8bfc59f6b569ca52496a53eb79 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "src/trace_processor/args_table.h"
#include "src/trace_processor/sqlite/scoped_db.h"
#include "src/trace_processor/trace_processor_context.h"
#include "src/trace_processor/trace_storage.h"
#include "test/gtest_and_gmock.h"
namespace perfetto {
namespace trace_processor {
namespace {
class ArgsTableUnittest : public ::testing::Test {
public:
ArgsTableUnittest() {
sqlite3* db = nullptr;
PERFETTO_CHECK(sqlite3_initialize() == SQLITE_OK);
PERFETTO_CHECK(sqlite3_open(":memory:", &db) == SQLITE_OK);
db_.reset(db);
context_.storage.reset(new TraceStorage());
ArgsTable::RegisterTable(db_.get(), context_.storage.get());
}
void PrepareValidStatement(const std::string& sql) {
int size = static_cast<int>(sql.size());
sqlite3_stmt* stmt;
ASSERT_EQ(sqlite3_prepare_v2(*db_, sql.c_str(), size, &stmt, nullptr),
SQLITE_OK);
stmt_.reset(stmt);
}
const char* GetColumnAsText(int colId) {
return reinterpret_cast<const char*>(sqlite3_column_text(*stmt_, colId));
}
void AssertArgRowValues(int arg_set_id,
const char* flat_key,
const char* key,
base::Optional<int64_t> int_value,
base::Optional<const char*> string_value,
base::Optional<double> real_value);
protected:
TraceProcessorContext context_;
ScopedDb db_;
ScopedStmt stmt_;
};
// Test helper.
void ArgsTableUnittest::AssertArgRowValues(
int arg_set_id,
const char* flat_key,
const char* key,
base::Optional<int64_t> int_value,
base::Optional<const char*> string_value,
base::Optional<double> real_value) {
ASSERT_EQ(sqlite3_column_int(*stmt_, 0), arg_set_id);
ASSERT_STREQ(GetColumnAsText(1), flat_key);
ASSERT_STREQ(GetColumnAsText(2), key);
if (int_value.has_value()) {
ASSERT_EQ(sqlite3_column_int64(*stmt_, 3), int_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 3), SQLITE_NULL);
}
if (string_value.has_value()) {
ASSERT_STREQ(GetColumnAsText(4), string_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 4), SQLITE_NULL);
}
if (real_value.has_value()) {
ASSERT_DOUBLE_EQ(sqlite3_column_double(*stmt_, 5), real_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 5), SQLITE_NULL);
}
}
TEST_F(ArgsTableUnittest, IntValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const int kValue = 123;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Integer(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, kValue, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, StringValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const char kValue[] = "123";
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::String(context_.storage->InternString(kValue));
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, kValue, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, RealValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const double kValue = 0.123;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Real(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, base::nullopt, kValue);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, BoolValueTreatedAsInt) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const bool kValue = true;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Boolean(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
// Boolean returned in the "int_value" column, and is comparable to an integer
// literal.
PrepareValidStatement("SELECT * FROM args WHERE int_value = 1");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, kValue, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, PointerValueTreatedAsInt) {
static const uint64_t kSmallValue = 1ull << 30;
static const uint64_t kTopBitSetValue = 1ull << 63;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString("flat_key_small");
arg.key = context_.storage->InternString("key_small");
arg.value = Variadic::Pointer(kSmallValue);
TraceStorage::Args::Arg arg2;
arg2.flat_key = context_.storage->InternString("flat_key_large");
arg2.key = context_.storage->InternString("key_large");
arg2.value = Variadic::Pointer(kTopBitSetValue);
context_.storage->mutable_args()->AddArgSet({arg, arg2}, 0, 2);
// Pointer returned in the "int_value" column, as a signed 64 bit. And is
// comparable to an integer literal.
static const int64_t kExpectedSmallValue = static_cast<int64_t>(kSmallValue);
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedSmallValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_small", "key_small", kExpectedSmallValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
static const int64_t kExpectedTopBitSetValue =
static_cast<int64_t>(kTopBitSetValue); // negative
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedTopBitSetValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_large", "key_large", kExpectedTopBitSetValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, UintValueTreatedAsInt) {
static const uint64_t kSmallValue = 1ull << 30;
static const uint64_t kTopBitSetValue = 1ull << 63;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString("flat_key_small");
arg.key = context_.storage->InternString("key_small");
arg.value = Variadic::UnsignedInteger(kSmallValue);
TraceStorage::Args::Arg arg2;
arg2.flat_key = context_.storage->InternString("flat_key_large");
arg2.key = context_.storage->InternString("key_large");
arg2.value = Variadic::UnsignedInteger(kTopBitSetValue);
context_.storage->mutable_args()->AddArgSet({arg, arg2}, 0, 2);
// Unsigned returned in the "int_value" column, as a signed 64 bit. And is
// comparable to an integer literal.
static const int64_t kExpectedSmallValue = static_cast<int64_t>(kSmallValue);
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedSmallValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_small", "key_small", kExpectedSmallValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
static const int64_t kExpectedTopBitSetValue =
static_cast<int64_t>(kTopBitSetValue); // negative
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedTopBitSetValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_large", "key_large", kExpectedTopBitSetValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, IntegerLikeValuesSortByIntRepresentation) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
TraceStorage::Args::Arg bool_arg_true;
bool_arg_true.flat_key = context_.storage->InternString(kFlatKey);
bool_arg_true.key = context_.storage->InternString(kKey);
bool_arg_true.value = Variadic::Boolean(true);
TraceStorage::Args::Arg bool_arg_false;
bool_arg_false.flat_key = context_.storage->InternString(kFlatKey);
bool_arg_false.key = context_.storage->InternString(kKey);
bool_arg_false.value = Variadic::Boolean(false);
TraceStorage::Args::Arg pointer_arg_42;
pointer_arg_42.flat_key = context_.storage->InternString(kFlatKey);
pointer_arg_42.key = context_.storage->InternString(kKey);
pointer_arg_42.value = Variadic::Pointer(42);
TraceStorage::Args::Arg unsigned_arg_10;
unsigned_arg_10.flat_key = context_.storage->InternString(kFlatKey);
unsigned_arg_10.key = context_.storage->InternString(kKey);
unsigned_arg_10.value = Variadic::UnsignedInteger(10);
// treated as null by the int_value column
TraceStorage::Args::Arg string_arg;
string_arg.flat_key = context_.storage->InternString(kFlatKey);
string_arg.key = context_.storage->InternString(kKey);
string_arg.value =
Variadic::String(context_.storage->InternString("string_content"));
context_.storage->mutable_args()->AddArgSet(
{bool_arg_true, bool_arg_false, pointer_arg_42, unsigned_arg_10,
string_arg},
0, 5);
// Ascending sort by int representations:
// { null (string), 0 (false), 1 (true), 10, 42 }
PrepareValidStatement("SELECT * FROM args ORDER BY int_value ASC");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, "string_content",
base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 0, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 1, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 10, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 42, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
// Desceding order.
PrepareValidStatement("SELECT * FROM args ORDER BY int_value DESC");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 42, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 10, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 1, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 0, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, "string_content",
base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
} // namespace
} // namespace trace_processor
} // namespace perfetto
| 39.025478 | 80 | 0.71952 |
de6d301d3637b7189e571f714ed564941bae1ff9 | 127,143 | cpp | C++ | src/plugProjectKandoU/vsGameSection.cpp | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 33 | 2021-12-08T11:10:59.000Z | 2022-03-26T19:59:37.000Z | src/plugProjectKandoU/vsGameSection.cpp | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 6 | 2021-12-22T17:54:31.000Z | 2022-01-07T21:43:18.000Z | src/plugProjectKandoU/vsGameSection.cpp | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 2 | 2022-01-04T06:00:49.000Z | 2022-01-26T07:27:28.000Z | #include "Game/VsGameSection.h"
#include "types.h"
/*
Generated from dpostproc
.section .ctors, "wa" # 0x80472F00 - 0x804732C0
.4byte __sinit_vsGameSection_cpp
.section .rodata # 0x804732E0 - 0x8049E220
.global lbl_8047FF98
lbl_8047FF98:
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x56734761
.4byte 0x6D655365
.4byte 0x6374696F
.4byte 0x6E000000
.4byte 0x50534761
.4byte 0x6D652E68
.4byte 0x00000000
.global lbl_8047FFC0
lbl_8047FFC0:
.asciz "P2Assert"
.skip 3
.4byte 0x50535363
.4byte 0x656E652E
.4byte 0x68000000
.global lbl_8047FFD8
lbl_8047FFD8:
.4byte 0x63617665
.4byte 0x696E666F
.4byte 0x2E747874
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.global lbl_8047FFF4
lbl_8047FFF4:
.4byte 0x76734761
.4byte 0x6D655365
.4byte 0x6374696F
.4byte 0x6E2E6370
.4byte 0x70000000
.global lbl_80480008
lbl_80480008:
.4byte 0x7A616E6E
.4byte 0x656E6E0A
.4byte 0x00000000
.global lbl_80480014
lbl_80480014:
.4byte 0x2F757365
.4byte 0x722F4D61
.4byte 0x746F6261
.4byte 0x2F636861
.4byte 0x6C6C656E
.4byte 0x67652F6B
.4byte 0x6665732D
.4byte 0x73746167
.4byte 0x65732E74
.4byte 0x78740000
.global lbl_8048003C
lbl_8048003C:
.4byte 0x2F757365
.4byte 0x722F4D61
.4byte 0x746F6261
.4byte 0x2F636861
.4byte 0x6C6C656E
.4byte 0x67652F73
.4byte 0x74616765
.4byte 0x732E7478
.4byte 0x74000000
.global lbl_80480060
lbl_80480060:
.4byte 0x2F757365
.4byte 0x722F6162
.4byte 0x652F7673
.4byte 0x2F737461
.4byte 0x6765732E
.4byte 0x74787400
.global lbl_80480078
lbl_80480078:
.4byte 0x6F702D63
.4byte 0x2D6D6F72
.4byte 0x65000000
.4byte 0x6D6F7265
.4byte 0x2D796573
.4byte 0x00000000
.4byte 0x6D6F7265
.4byte 0x2D7A656E
.4byte 0x6B616900
.4byte 0x7330435F
.4byte 0x63765F65
.4byte 0x73636170
.4byte 0x65000000
.global lbl_804800AC
lbl_804800AC:
.4byte 0x7330335F
.4byte 0x6F72696D
.4byte 0x61646F77
.4byte 0x6E000000
.global lbl_804800BC
lbl_804800BC:
.4byte 0x63726561
.4byte 0x74654661
.4byte 0x6C6C5069
.4byte 0x6B6D696E
.4byte 0x73000000
.global lbl_804800D0
lbl_804800D0:
.4byte 0x6E6F2073
.4byte 0x70616365
.4byte 0x20666F72
.4byte 0x206E6577
.4byte 0x2079656C
.4byte 0x6C6F770A
.4byte 0x00000000
.global lbl_804800EC
lbl_804800EC:
.4byte 0x6E6F2065
.4byte 0x6E747279
.4byte 0x20666F72
.4byte 0x2070656C
.4byte 0x6C65740A
.4byte 0x00000000
.4byte 0x62697274
.4byte 0x68206661
.4byte 0x696C6564
.4byte 0x20210A00
.4byte 0x6F6F7375
.4byte 0x67692025
.4byte 0x640A0000
.4byte 0x25642070
.4byte 0x6C617965
.4byte 0x7249440A
.4byte 0x00000000
.4byte 0x25642074
.4byte 0x79706549
.4byte 0x440A0000
.4byte 0x41726745
.4byte 0x6E656D79
.4byte 0x54797065
.4byte 0x00000000
.4byte 0x50696B69
.4byte 0x496E6974
.4byte 0x41726700
.4byte 0x50656C6C
.4byte 0x6574496E
.4byte 0x69744172
.4byte 0x67000000
.section .data, "wa" # 0x8049E220 - 0x804EFC20
.global lbl_804B60E8
lbl_804B60E8:
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.global __vt__Q24Game20GameMessageVsUseCard
__vt__Q24Game20GameMessageVsUseCard:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game20GameMessageVsUseCardFPQ24Game13VsGameSection
.global __vt__Q24Game20GameMessageVsGotCard
__vt__Q24Game20GameMessageVsGotCard:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game20GameMessageVsGotCardFPQ24Game13VsGameSection
.global __vt__Q24Game23GameMessageVsPikminDead
__vt__Q24Game23GameMessageVsPikminDead:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game23GameMessageVsPikminDeadFPQ24Game13VsGameSection
.global __vt__Q24Game30GameMessageVsBirthTekiTreasure
__vt__Q24Game30GameMessageVsBirthTekiTreasure:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game30GameMessageVsBirthTekiTreasureFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessagePelletDead
__vt__Q24Game21GameMessagePelletDead:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessagePelletDeadFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessagePelletBorn
__vt__Q24Game21GameMessagePelletBorn:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessagePelletBornFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessageVsAddEnemy
__vt__Q24Game21GameMessageVsAddEnemy:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessageVsAddEnemyFPQ24Game13VsGameSection
.global __vt__Q24Game23GameMessageVsGetOtakara
__vt__Q24Game23GameMessageVsGetOtakara:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game23GameMessageVsGetOtakaraFPQ24Game13VsGameSection
.global __vt__Q24Game27GameMessageVsRedOrSuckStart
__vt__Q24Game27GameMessageVsRedOrSuckStart:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game27GameMessageVsRedOrSuckStartFPQ24Game13VsGameSection .global
__vt__Q24Game27GameMessageVsBattleFinished
__vt__Q24Game27GameMessageVsBattleFinished:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game27GameMessageVsBattleFinishedFPQ24Game13VsGameSection .global
__vt__Q24Game22GameMessageVsGetDoping
__vt__Q24Game22GameMessageVsGetDoping:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game22GameMessageVsGetDopingFPQ24Game13VsGameSection
.global "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"
"__vt__Q24Game36StateMachine<Q24Game13VsGameSection>":
.4byte 0
.4byte 0
.4byte
"init__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
"start__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.4byte
"exec__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
"transit__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.global __vt__Q24Game13VsGameSection
__vt__Q24Game13VsGameSection:
.4byte 0
.4byte 0
.4byte __dt__Q24Game13VsGameSectionFv
.4byte run__7SectionFv
.4byte update__7SectionFv
.4byte draw__7SectionFR8Graphics
.4byte init__Q24Game15BaseGameSectionFv
.4byte drawInit__7SectionFR8Graphics
.4byte
drawInit__Q24Game15BaseGameSectionFR8GraphicsQ27Section13EDrawInitMode .4byte
doExit__7SectionFv .4byte forceFinish__Q24Game15BaseGameSectionFv .4byte
forceReset__7SectionFv .4byte getCurrentSection__7SectionFv .4byte
doLoadingStart__7SectionFv .4byte doLoading__7SectionFv .4byte
doUpdate__Q24Game13VsGameSectionFv .4byte
doDraw__Q24Game13VsGameSectionFR8Graphics .4byte isFinishable__7SectionFv
.4byte initHIO__Q24Game14BaseHIOSectionFPQ24Game11HIORootNode
.4byte refreshHIO__Q24Game14BaseHIOSectionFv
.4byte sendMessage__Q24Game13VsGameSectionFRQ24Game11GameMessage
.4byte pre2dDraw__Q24Game13VsGameSectionFR8Graphics
.4byte getCurrFloor__Q24Game13VsGameSectionFv
.4byte isDevelopSection__Q24Game15BaseGameSectionFv
.4byte addChallengeScore__Q24Game13VsGameSectionFi
.4byte startMainBgm__Q24Game13VsGameSectionFv
.4byte section_fadeout__Q24Game13VsGameSectionFv
.4byte goNextFloor__Q24Game13VsGameSectionFPQ34Game8ItemHole4Item
.4byte goCave__Q24Game15BaseGameSectionFPQ34Game8ItemCave4Item
.4byte
goMainMap__Q24Game15BaseGameSectionFPQ34Game15ItemBigFountain4Item .4byte
getCaveID__Q24Game15BaseGameSectionFv .4byte
getCurrentCourseInfo__Q24Game15BaseGameSectionFv .4byte
challengeDisablePelplant__Q24Game13VsGameSectionFv .4byte
getCaveFilename__Q24Game13VsGameSectionFv .4byte
getEditorFilename__Q24Game13VsGameSectionFv .4byte
getVsEditNumber__Q24Game13VsGameSectionFv .4byte
openContainerWindow__Q24Game15BaseGameSectionFv .4byte
closeContainerWindow__Q24Game15BaseGameSectionFv .4byte
playMovie_firstexperience__Q24Game15BaseGameSectionFiPQ24Game8Creature .4byte
playMovie_bootup__Q24Game15BaseGameSectionFPQ24Game5Onyon .4byte
playMovie_helloPikmin__Q24Game15BaseGameSectionFPQ24Game4Piki .4byte
enableTimer__Q24Game15BaseGameSectionFfUl .4byte
disableTimer__Q24Game15BaseGameSectionFUl .4byte
getTimerType__Q24Game15BaseGameSectionFv .4byte
onMovieStart__Q24Game13VsGameSectionFPQ24Game11MovieConfigUlUl .4byte
onMovieDone__Q24Game13VsGameSectionFPQ24Game11MovieConfigUlUl .4byte
onMovieCommand__Q24Game15BaseGameSectionFi .4byte
startFadeout__Q24Game15BaseGameSectionFf .4byte
startFadein__Q24Game15BaseGameSectionFf .4byte
startFadeoutin__Q24Game15BaseGameSectionFf .4byte
startFadeblack__Q24Game15BaseGameSectionFv .4byte
startFadewhite__Q24Game15BaseGameSectionFv .4byte
gmOrimaDown__Q24Game13VsGameSectionFi .4byte
gmPikminZero__Q24Game13VsGameSectionFv .4byte
openCaveInMenu__Q24Game15BaseGameSectionFPQ34Game8ItemCave4Itemi .4byte
openCaveMoreMenu__Q24Game13VsGameSectionFPQ34Game8ItemHole4ItemP10Controller
.4byte
openKanketuMenu__Q24Game13VsGameSectionFPQ34Game15ItemBigFountain4ItemP10Controller
.4byte on_setCamController__Q24Game15BaseGameSectionFi
.4byte onTogglePlayer__Q24Game15BaseGameSectionFv
.4byte onPlayerJoin__Q24Game15BaseGameSectionFv
.4byte onInit__Q24Game13VsGameSectionFv
.4byte onUpdate__Q24Game15BaseGameSectionFv
.4byte initJ3D__Q24Game15BaseGameSectionFv
.4byte initViewports__Q24Game15BaseGameSectionFR8Graphics
.4byte initResources__Q24Game15BaseGameSectionFv
.4byte initGenerators__Q24Game15BaseGameSectionFv
.4byte initLights__Q24Game15BaseGameSectionFv
.4byte draw3D__Q24Game15BaseGameSectionFR8Graphics
.4byte draw2D__Q24Game15BaseGameSectionFR8Graphics
.4byte drawParticle__Q24Game15BaseGameSectionFR8Graphicsi
.4byte draw_Ogawa2D__Q24Game15BaseGameSectionFR8Graphics
.4byte do_drawOtakaraWindow__Q24Game15BaseGameSectionFR8Graphics
.4byte onSetupFloatMemory__Q24Game13VsGameSectionFv
.4byte postSetupFloatMemory__Q24Game13VsGameSectionFv
.4byte onSetSoundScene__Q24Game13VsGameSectionFv
.4byte onStartHeap__Q24Game15BaseGameSectionFv
.4byte onClearHeap__Q24Game13VsGameSectionFv
.4byte player2enabled__Q24Game13VsGameSectionFv
.global __vt__Q34Game6VsGame3FSM
__vt__Q34Game6VsGame3FSM:
.4byte 0
.4byte 0
.4byte init__Q34Game6VsGame3FSMFPQ24Game13VsGameSection
.4byte
"start__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.4byte
"exec__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
transit__Q34Game6VsGame3FSMFPQ24Game13VsGameSectioniPQ24Game8StateArg
.section .sbss # 0x80514D80 - 0x80516360
.global lbl_80515A88
lbl_80515A88:
.skip 0x4
.global lbl_80515A8C
lbl_80515A8C:
.skip 0x4
.global mRedWinCount__Q24Game13VsGameSection
mRedWinCount__Q24Game13VsGameSection:
.skip 0x4
.global mBlueWinCount__Q24Game13VsGameSection
mBlueWinCount__Q24Game13VsGameSection:
.skip 0x4
.global mDrawCount__Q24Game13VsGameSection
mDrawCount__Q24Game13VsGameSection:
.skip 0x8
.section .sdata2, "a" # 0x80516360 - 0x80520E40
.global lbl_805194A8
lbl_805194A8:
.4byte 0x00000000
.global lbl_805194AC
lbl_805194AC:
.float 0.5
.global lbl_805194B0
lbl_805194B0:
.4byte 0x72616E64
.4byte 0x6F6D0000
.global lbl_805194B8
lbl_805194B8:
.float 1.0
.4byte 0x00000000
.global lbl_805194C0
lbl_805194C0:
.4byte 0x40490000
.4byte 0x00000000
.global lbl_805194C8
lbl_805194C8:
.4byte 0x43300000
.4byte 0x80000000
.global lbl_805194D0
lbl_805194D0:
.4byte 0x6F702D6B
.4byte 0x6B000000
.global lbl_805194D8
lbl_805194D8:
.4byte 0x6D6F7265
.4byte 0x2D6E6F00
.global lbl_805194E0
lbl_805194E0:
.4byte 0x6B6B2D79
.4byte 0x65730000
.global lbl_805194E8
lbl_805194E8:
.4byte 0x6B6B2D6E
.4byte 0x6F000000
.global lbl_805194F0
lbl_805194F0:
.4byte 0x47000000
.global lbl_805194F4
lbl_805194F4:
.4byte 0x41700000
.global lbl_805194F8
lbl_805194F8:
.4byte 0x41F00000
.global lbl_805194FC
lbl_805194FC:
.4byte 0x40C90FDB
.global lbl_80519500
lbl_80519500:
.4byte 0x44408000
.global lbl_80519504
lbl_80519504:
.4byte 0x44548000
.global lbl_80519508
lbl_80519508:
.4byte 0x42F00000
.global lbl_8051950C
lbl_8051950C:
.4byte 0x43A2F983
.global lbl_80519510
lbl_80519510:
.4byte 0xC3A2F983
.global lbl_80519514
lbl_80519514:
.4byte 0x4528C000
.global lbl_80519518
lbl_80519518:
.4byte 0x43160000
.global lbl_8051951C
lbl_8051951C:
.4byte 0x41200000
.global lbl_80519520
lbl_80519520:
.4byte 0x41A00000
.global lbl_80519524
lbl_80519524:
.4byte 0x3E4CCCCD
.global lbl_80519528
lbl_80519528:
.4byte 0x3F4CCCCD
.global lbl_8051952C
lbl_8051952C:
.float 0.1
.global lbl_80519530
lbl_80519530:
.4byte 0xBDCCCCCD
.global lbl_80519534
lbl_80519534:
.4byte 0xBF000000
.global lbl_80519538
lbl_80519538:
.4byte 0xBF4CCCCD
.global lbl_8051953C
lbl_8051953C:
.4byte 0x3D50E560
.global lbl_80519540
lbl_80519540:
.4byte 0x3C23D70A
.global lbl_80519544
lbl_80519544:
.4byte 0x41C80000
.global lbl_80519548
lbl_80519548:
.4byte 0x3ECCCCCD
.global lbl_8051954C
lbl_8051954C:
.4byte 0x3F19999A
.global lbl_80519550
lbl_80519550:
.float 0.3
.global lbl_80519554
lbl_80519554:
.4byte 0x3F0CCCCD
.global lbl_80519558
lbl_80519558:
.4byte 0x3F666666
.global lbl_8051955C
lbl_8051955C:
.4byte 0x40000000
.global lbl_80519560
lbl_80519560:
.4byte 0x40400000
.4byte 0x00000000
.global lbl_80519568
lbl_80519568:
.4byte 0x43300000
.4byte 0x00000000
.global lbl_80519570
lbl_80519570:
.4byte 0x430C0000
.global lbl_80519574
lbl_80519574:
.4byte 0xC1200000
.global lbl_80519578
lbl_80519578:
.4byte 0xBF800000
.global lbl_8051957C
lbl_8051957C:
.4byte 0x40800000
.global lbl_80519580
lbl_80519580:
.float 0.25
.4byte 0x00000000
.section .sbss2, "", @nobits # 0x80520e40 - 0x80520ED8
.global lbl_80520E68
lbl_80520E68:
.skip 0x4
.global lbl_80520E6C
lbl_80520E6C:
.skip 0x4
.global lbl_80520E70
lbl_80520E70:
.skip 0x4
.global lbl_80520E74
lbl_80520E74:
.skip 0x4
.global lbl_80520E78
lbl_80520E78:
.skip 0x4
.global lbl_80520E7C
lbl_80520E7C:
.skip 0x4
*/
namespace Game {
/*
* --INFO--
* Address: 801C0DF8
* Size: 0000D0
*/
void VsGame::FSM::init(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
li r4, 5
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r3
bl "create__Q24Game36StateMachine<Q24Game13VsGameSection>Fi"
li r3, 0x44
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E2C
bl __ct__Q34Game6VsGame10TitleStateFv
mr r4, r3
lbl_801C0E2C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0xa4
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E4C
bl __ct__Q34Game6VsGame9LoadStateFv
mr r4, r3
lbl_801C0E4C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x28
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E6C
bl __ct__Q34Game6VsGame9GameStateFv
mr r4, r3
lbl_801C0E6C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x28
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E8C
bl __ct__Q34Game6VsGame7VSStateFv
mr r4, r3
lbl_801C0E8C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x3c
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0EAC
bl __ct__Q34Game6VsGame11ResultStateFv
mr r4, r3
lbl_801C0EAC:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 000038
*/
void VsGame::FSM::draw(Game::VsGameSection*, Graphics&)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C0EC8
* Size: 000004
*/
void VsGame::State::draw(Game::VsGameSection*, Graphics&) { }
/*
* --INFO--
* Address: 801C0ECC
* Size: 000020
*/
void VsGame::FSM::transit(Game::VsGameSection*, int, Game::StateArg*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
bl
"transit__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C0EEC
* Size: 0000FC
*/
VsGameSection::VsGameSection(JKRHeap*, bool)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r5
stw r30, 8(r1)
mr r30, r3
bl __ct__Q24Game15BaseGameSectionFP7JKRHeap
lis r4, __vt__Q24Game13VsGameSection@ha
addi r3, r30, 0x184
addi r0, r4, __vt__Q24Game13VsGameSection@l
stw r0, 0(r30)
bl __ct__16DvdThreadCommandFv
li r0, 0
addi r3, r30, 0x214
stb r0, 0x1f8(r30)
bl __ct__Q24Game13PikiContainerFv
addi r3, r30, 0x21c
bl __ct__Q24Game13PikiContainerFv
stb r31, 0x174(r30)
li r0, 1
lis r3, gGameConfig__4Game@ha
li r6, 0
stb r0, 0x205(r30)
li r5, -1
li r4, 2
li r0, -2
stw r6, 0x338(r30)
addi r3, r3, gGameConfig__4Game@l
stw r6, 0x340(r30)
stw r5, 0x34c(r30)
stw r4, 0x348(r30)
stw r4, 0x344(r30)
stw r6, 0x3d8(r30)
stw r6, 0x3d4(r30)
stw r6, 0x3e0(r30)
stw r6, 0x3dc(r30)
stw r0, 0x328(r30)
stw r6, 0x178(r30)
lwz r0, 0x278(r3)
cmpwi r0, 0
ble lbl_801C0FCC
slwi r31, r0, 0xa
li r3, 0x1c
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C0FB4
mr r4, r31
bl __ct__6VSFifoFUl
mr r0, r3
lbl_801C0FB4:
stw r0, 0x178(r30)
lwz r3, 0x178(r30)
bl becomeCurrent__6VSFifoFv
lwz r3, 0x178(r30)
lwz r3, 4(r3)
bl GXSetGPFifo
lbl_801C0FCC:
lwz r0, 0x14(r1)
mr r3, r30
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C0FE8
* Size: 0000CC
*/
VsGameSection::~VsGameSection(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
or. r30, r3, r3
beq lbl_801C1098
lis r3, __vt__Q24Game13VsGameSection@ha
addi r0, r3, __vt__Q24Game13VsGameSection@l
stw r0, 0(r30)
lwz r3, 0x178(r30)
cmplwi r3, 0
beq lbl_801C1064
lwz r3, 4(r3)
bl GXSaveCPUFifo
lbl_801C1028:
bl isGPActive__6VSFifoFv
clrlwi. r0, r3, 0x18
bne lbl_801C1028
bl GXDrawDone
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r4, 8(r3)
lwz r3, 4(r3)
mr r5, r4
bl GXInitFifoPtrs
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r3, 4(r3)
bl GXSetCPUFifo
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r3, 4(r3)
bl GXSetGPFifo
lbl_801C1064:
addic. r0, r30, 0x184
beq lbl_801C107C
addic. r3, r30, 0x1e0
beq lbl_801C107C
li r4, 0
bl __dt__10JSUPtrLinkFv
lbl_801C107C:
mr r3, r30
li r4, 0
bl __dt__Q24Game15BaseGameSectionFv
extsh. r0, r31
ble lbl_801C1098
mr r3, r30
bl __dl__FPv
lbl_801C1098:
lwz r0, 0x14(r1)
mr r3, r30
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
} // namespace Game
/*
* --INFO--
* Address: 801C10B4
* Size: 00005C
*/
void VSFifo::isGPActive()
{
/*
stwu r1, -0x10(r1)
mflr r0
addi r4, r13, mGpStatus__6VSFifo@sda21
addi r6, r13, mGpStatus__6VSFifo@sda21
stw r0, 0x14(r1)
addi r7, r13, mGpStatus__6VSFifo@sda21
addi r3, r13, mGpStatus__6VSFifo@sda21
addi r4, r4, 1
stw r31, 0xc(r1)
addi r31, r13, mGpStatus__6VSFifo@sda21
addi r31, r31, 2
addi r6, r6, 3
mr r5, r31
addi r7, r7, 4
bl GXGetGPStatus
lbz r0, 0(r31)
lwz r31, 0xc(r1)
cntlzw r0, r0
srwi r3, r0, 5
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
namespace Game {
/*
* --INFO--
* Address: 801C1110
* Size: 000034
*/
void VsGameSection::section_fadeout(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r4, r3
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x38(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1144
* Size: 000004
*/
void VsGame::State::on_section_fadeout(Game::VsGameSection*) { }
/*
* --INFO--
* Address: 801C1148
* Size: 000090
*/
void VsGameSection::startMainBgm(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
lis r3, lbl_8047FF98@ha
stw r0, 0x14(r1)
stw r31, 0xc(r1)
addi r31, r3, lbl_8047FF98@l
stw r30, 8(r1)
lwz r0, spSceneMgr__8PSSystem@sda21(r13)
cmplwi r0, 0
bne lbl_801C1184
addi r3, r31, 0x1c
addi r5, r31, 0x28
li r4, 0x1d3
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C1184:
lwz r30, spSceneMgr__8PSSystem@sda21(r13)
lwz r0, 4(r30)
cmplwi r0, 0
bne lbl_801C11A8
addi r3, r31, 0x34
addi r5, r31, 0x28
li r4, 0xc7
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C11A8:
lwz r3, 4(r30)
lwz r3, 4(r3)
lwz r12, 0(r3)
lwz r12, 0x1c(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C11D8
* Size: 00020C
*/
void VsGameSection::onInit(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
lfs f1, lbl_805194A8@sda21(r2)
stw r0, 0x14(r1)
lfs f0, lbl_805194AC@sda21(r2)
stw r31, 0xc(r1)
mr r31, r3
stfs f1, 0x350(r3)
stfs f0, 0x354(r3)
stfs f1, 0x1f4(r3)
stfs f1, 0x1f0(r3)
bl clearGetDopeCount__Q24Game13VsGameSectionFv
mr r3, r31
bl clearGetCherryCount__Q24Game13VsGameSectionFv
lbz r0, 0x174(r31)
cmplwi r0, 0
beq lbl_801C122C
lwz r3, gameSystem__4Game@sda21(r13)
li r0, 1
stw r0, 0x44(r3)
b lbl_801C1238
lbl_801C122C:
lwz r3, gameSystem__4Game@sda21(r13)
li r0, 2
stw r0, 0x44(r3)
lbl_801C1238:
lwz r4, gameSystem__4Game@sda21(r13)
li r5, 1
li r0, 0
lis r3, lbl_8047FFD8@ha
stb r5, 0x48(r4)
addi r4, r3, lbl_8047FFD8@l
addi r3, r31, 0x224
stb r0, 0x11c(r31)
stw r0, 0x1fc(r31)
stw r0, 0x3bc(r31)
stb r0, 0x204(r31)
crclr 6
bl sprintf
addi r3, r31, 0x2a4
addi r4, r2, lbl_805194B0@sda21
crclr 6
bl sprintf
mr r3, r31
bl setupFixMemory__Q24Game15BaseGameSectionFv
li r3, 0x94
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C129C
bl __ct__Q34Game13ChallengeGame9StageListFv
mr r0, r3
lbl_801C129C:
stw r0, 0x20c(r31)
mr r3, r31
lwz r4, 0x20c(r31)
bl addGenNode__Q24Game14BaseHIOSectionFP5CNode
li r3, 0xcc
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C12C4
bl __ct__Q34Game6VsGame9StageListFv
mr r0, r3
lbl_801C12C4:
stw r0, 0x210(r31)
mr r3, r31
lwz r4, 0x210(r31)
bl addGenNode__Q24Game14BaseHIOSectionFP5CNode
mr r3, r31
bl loadChallengeStageList__Q24Game13VsGameSectionFv
mr r3, r31
bl loadVsStageList__Q24Game13VsGameSectionFv
li r3, 0x1c
bl __nw__FUl
cmplwi r3, 0
beq lbl_801C1314
lis r5, "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"@ha
lis r4, __vt__Q34Game6VsGame3FSM@ha
addi r0, r5, "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"@l
li r5, -1
stw r0, 0(r3)
addi r0, r4, __vt__Q34Game6VsGame3FSM@l
stw r5, 0x18(r3)
stw r0, 0(r3)
lbl_801C1314:
stw r3, 0x17c(r31)
mr r4, r31
lwz r3, 0x17c(r31)
lwz r12, 0(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
mr r3, r31
bl initPlayData__Q24Game13VsGameSectionFv
lwz r3, 0x17c(r31)
mr r4, r31
li r5, 0
li r6, 0
lwz r12, 0(r3)
lwz r12, 0xc(r12)
mtctr r12
bctrl
li r0, 0
lfs f0, lbl_805194A8@sda21(r2)
stw r0, 0x324(r31)
li r3, 0x5c
stfs f0, 0x35c(r31)
stfs f0, 0x358(r31)
stfs f0, 0x374(r31)
stfs f0, 0x370(r31)
stfs f0, 0x364(r31)
stfs f0, 0x360(r31)
stfs f0, 0x36c(r31)
stfs f0, 0x368(r31)
stfs f0, 0x37c(r31)
stfs f0, 0x378(r31)
stw r0, 0x384(r31)
stw r0, 0x380(r31)
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C13AC
bl __ct__Q25Radar3MgrFv
mr r0, r3
lbl_801C13AC:
stw r0, mgr__5Radar@sda21(r13)
li r0, 0
stw r0, 0x388(r31)
stw r0, 0x38c(r31)
stw r0, 0x390(r31)
stw r0, 0x394(r31)
stw r0, 0x398(r31)
stw r0, 0x39c(r31)
stw r0, 0x3a0(r31)
lwz r31, 0xc(r1)
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C13E4
* Size: 000034
*/
void start__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSectioniPQ24Game8StateArg(void)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
li r0, 0
stw r0, 0x180(r4)
lwz r12, 0x0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1418
* Size: 000008
*/
void VsGameSection::getCurrFloor(void)
{
/*
lwz r3, 0x324(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C1420
* Size: 0001B8
*/
void VsGameSection::doUpdate(void)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stfd f31, 0x30(r1)
psq_st f31, 56(r1), 0, qr0
stw r31, 0x2c(r1)
stw r30, 0x28(r1)
stw r29, 0x24(r1)
mr r29, r3
lbz r0, 0x204(r3)
cmplwi r0, 0
beq lbl_801C1460
li r0, 0
li r3, 0
stb r0, 0x34(r29)
b lbl_801C15B4
lbl_801C1460:
lwz r3, 0x17c(r29)
mr r4, r29
lwz r12, 0(r3)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lwz r3, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r3)
cmpwi r0, 1
bne lbl_801C15B0
li r3, 1
bl getMapPikmins__Q24Game8GameStatFi
lwz r4, 0x344(r29)
addi r0, r4, -3
subf r31, r0, r3
li r3, 0
bl getMapPikmins__Q24Game8GameStatFi
lwz r4, 0x348(r29)
cmpwi r31, 0
addi r0, r4, -3
subf r30, r0, r3
bge lbl_801C14BC
li r31, 1
lbl_801C14BC:
cmpwi r30, 0
bge lbl_801C14C8
li r30, 1
lbl_801C14C8:
cmpwi r31, 0
beq lbl_801C14D8
cmpwi r30, 0
bne lbl_801C1500
lbl_801C14D8:
cmpwi r31, 0
bne lbl_801C14EC
lfs f0, lbl_805194B8@sda21(r2)
stfs f0, 0x354(r29)
b lbl_801C15B0
lbl_801C14EC:
cmpwi r30, 0
bne lbl_801C15B0
lfs f0, lbl_805194A8@sda21(r2)
stfs f0, 0x354(r29)
b lbl_801C15B0
lbl_801C1500:
cmpw r30, r31
ble lbl_801C1544
lis r3, 0x4330
xoris r4, r30, 0x8000
xoris r0, r31, 0x8000
stw r4, 0xc(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r3, 8(r1)
lfd f0, 8(r1)
stw r0, 0x14(r1)
fsubs f1, f0, f2
stw r3, 0x10(r1)
lfd f0, 0x10(r1)
fsubs f0, f0, f2
fdivs f0, f1, f0
stfs f0, 0x350(r29)
b lbl_801C157C
lbl_801C1544:
lis r3, 0x4330
xoris r4, r31, 0x8000
xoris r0, r30, 0x8000
stw r4, 0x14(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r3, 0x10(r1)
lfd f0, 0x10(r1)
stw r0, 0xc(r1)
fsubs f1, f0, f2
stw r3, 8(r1)
lfd f0, 8(r1)
fsubs f0, f0, f2
fdivs f0, f1, f0
stfs f0, 0x350(r29)
lbl_801C157C:
lfd f1, lbl_805194C0@sda21(r2)
bl log10
frsp f31, f1
lfs f1, 0x350(r29)
bl log10
frsp f0, f1
cmpw r31, r30
fdivs f0, f0, f31
stfs f0, 0x354(r29)
bge lbl_801C15B0
lfs f0, 0x354(r29)
fneg f0, f0
stfs f0, 0x354(r29)
lbl_801C15B0:
lbz r3, 0x34(r29)
lbl_801C15B4:
psq_l f31, 56(r1), 0, qr0
lwz r0, 0x44(r1)
lfd f31, 0x30(r1)
lwz r31, 0x2c(r1)
lwz r30, 0x28(r1)
lwz r29, 0x24(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C15D8
* Size: 00003C
*/
void VsGameSection::pre2dDraw(Graphics&)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
cmplwi r3, 0
beq lbl_801C1604
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lbl_801C1604:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1614
* Size: 000004
*/
void VsGame::State::pre2dDraw(Graphics&, Game::VsGameSection*) { }
/*
* --INFO--
* Address: 801C1618
* Size: 000050
*/
void VsGameSection::doDraw(Graphics&)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
lbz r0, 0x204(r3)
cmplwi r0, 0
bne lbl_801C1658
lwz r3, 0x180(r6)
cmplwi r3, 0
beq lbl_801C1658
lwz r12, 0(r3)
mr r4, r6
lwz r12, 0x20(r12)
mtctr r12
bctrl
lbl_801C1658:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1668
* Size: 0001DC
*/
void VsGameSection::onSetSoundScene(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r4, lbl_8047FF98@ha
stw r0, 0x64(r1)
stw r31, 0x5c(r1)
addi r31, r4, lbl_8047FF98@l
stw r30, 0x58(r1)
mr r30, r3
addi r3, r1, 8
bl __ct__Q26PSGame9SceneInfoFv
lis r5, __vt__Q26PSGame13CaveFloorInfo@ha
lis r3, 0x0000FFFF@ha
li r4, 0
li r0, 0xff
addi r5, r5, __vt__Q26PSGame13CaveFloorInfo@l
addi r3, r3, 0x0000FFFF@l
stw r5, 8(r1)
lwz r5, gameSystem__4Game@sda21(r13)
stw r4, 0x40(r1)
stw r4, 0x44(r1)
stb r4, 0x48(r1)
stw r3, 0x4c(r1)
stb r0, 0x50(r1)
stb r0, 0x51(r1)
lwz r0, 0x44(r5)
cmpwi r0, 2
beq lbl_801C16DC
cmpwi r0, 3
bne lbl_801C16E0
lbl_801C16DC:
li r4, 1
lbl_801C16E0:
clrlwi. r0, r4, 0x18
beq lbl_801C1714
li r0, 6
mr r3, r30
stb r0, 0xe(r1)
lwz r12, 0(r30)
lwz r12, 0x58(r12)
mtctr r12
bctrl
stb r3, 0x48(r1)
lwz r0, 0x338(r30)
stb r0, 0x51(r1)
b lbl_801C1724
lbl_801C1714:
li r0, 7
stb r0, 0xe(r1)
lwz r0, 0x340(r30)
stb r0, 0x48(r1)
lbl_801C1724:
lwz r4, mapMgr__4Game@sda21(r13)
li r3, 0
lwz r5, gameSystem__4Game@sda21(r13)
lwz r4, 0x2c(r4)
lwz r0, 0x22c(r4)
stw r0, 0x40(r1)
stw r3, 0x44(r1)
lwz r0, 0x44(r5)
cmpwi r0, 1
beq lbl_801C1754
cmpwi r0, 3
bne lbl_801C1758
lbl_801C1754:
li r3, 1
lbl_801C1758:
clrlwi. r0, r3, 0x18
bne lbl_801C1774
addi r3, r1, 8
li r4, 0
li r5, 1
bl
setStageFlag__Q26PSGame9SceneInfoFQ36PSGame9SceneInfo7FlagDefQ36PSGame9SceneInfo12FlagBitShift
b lbl_801C1784
lbl_801C1774:
addi r3, r1, 8
li r4, 1
li r5, 1
bl
setStageFlag__Q26PSGame9SceneInfoFQ36PSGame9SceneInfo7FlagDefQ36PSGame9SceneInfo12FlagBitShift
lbl_801C1784:
mr r3, r30
addi r4, r1, 8
bl setDefaultPSSceneInfo__Q24Game15BaseGameSectionFRQ26PSGame9SceneInfo lwz
r0, spSceneMgr__8PSSystem@sda21(r13) cmplwi r0, 0 bne lbl_801C17B0 addi
r3, r31, 0x1c addi r5, r31, 0x28 li r4, 0x1d3 crclr 6 bl
panic_f__12JUTExceptionFPCciPCce
lbl_801C17B0:
lwz r3, spSceneMgr__8PSSystem@sda21(r13)
addi r4, r1, 8
lwz r12, 0(r3)
lwz r12, 0xc(r12)
mtctr r12
bctrl
lwz r0, spSceneMgr__8PSSystem@sda21(r13)
cmplwi r0, 0
bne lbl_801C17E8
addi r3, r31, 0x1c
addi r5, r31, 0x28
li r4, 0x1d3
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C17E8:
lwz r30, spSceneMgr__8PSSystem@sda21(r13)
lwz r0, 4(r30)
cmplwi r0, 0
bne lbl_801C180C
addi r3, r31, 0x34
addi r5, r31, 0x28
li r4, 0xc7
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C180C:
lwz r3, 4(r30)
lwz r3, 4(r3)
lwz r12, 0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
lwz r3, naviMgr__4Game@sda21(r13)
bl createPSMDirectorUpdator__Q24Game7NaviMgrFv
lwz r0, 0x64(r1)
lwz r31, 0x5c(r1)
lwz r30, 0x58(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C1844
* Size: 00005C
*/
void VsGameSection::initPlayData(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r3, playData__4Game@sda21(r13)
bl reset__Q24Game8PlayDataFv
lwz r3, playData__4Game@sda21(r13)
li r4, 1
li r5, 1
bl setDevelopSetting__Q24Game8PlayDataFbb
lwz r4, naviMgr__4Game@sda21(r13)
lwz r3, playData__4Game@sda21(r13)
lwz r4, 0xc8(r4)
lfs f0, 0x9d0(r4)
stfs f0, 0x24(r3)
lwz r4, naviMgr__4Game@sda21(r13)
lwz r3, playData__4Game@sda21(r13)
lwz r4, 0xc8(r4)
lfs f0, 0x9d0(r4)
stfs f0, 0x28(r3)
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C18A0
* Size: 000168
*/
void VsGameSection::onSetupFloatMemory(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r4, lbl_8047FF98@ha
stw r0, 0x64(r1)
li r0, 0
stmw r26, 0x48(r1)
mr r26, r3
addi r31, r4, lbl_8047FF98@l
li r3, 0x28
stw r0, farmMgr__Q24Game4Farm@sda21(r13)
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C18DC
bl __ct__Q34Game6VsGame7TekiMgrFv
mr r0, r3
lbl_801C18DC:
stw r0, 0x32c(r26)
li r3, 0x114
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C1900
lwz r5, 0x32c(r26)
mr r4, r26
bl
__ct__Q34Game6VsGame7CardMgrFPQ24Game13VsGameSectionPQ34Game6VsGame7TekiMgr mr
r0, r3
lbl_801C1900:
stw r0, 0x330(r26)
lwz r3, 0x330(r26)
bl loadResource__Q34Game6VsGame7CardMgrFv
lwz r6, 0x50(r31)
lis r4, __vt__Q24Game15CreatureInitArg@ha
lwz r5, 0x54(r31)
lis r3, __vt__Q24Game13PelletInitArg@ha
lwz r0, 0x58(r31)
addi r30, r1, 0xc
stw r6, 0xc(r1)
addi r27, r4, __vt__Q24Game15CreatureInitArg@l
lwz r4, cBedamaRed__13VsOtakaraName@sda21(r13)
addi r28, r3, __vt__Q24Game13PelletInitArg@l
stw r5, 0x10(r1)
li r26, 0
lwz r3, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r0, 0x14(r1)
lwz r0, cBedamaYellow__13VsOtakaraName@sda21(r13)
stw r4, 0xc(r1)
stw r3, 0x10(r1)
stw r0, 0x14(r1)
lbl_801C1954:
stw r27, 0x18(r1)
li r7, 0
li r0, -1
li r6, 0xff
li r5, 1
stw r28, 0x18(r1)
lwz r3, 0(r30)
addi r4, r1, 8
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C19C0
addi r3, r31, 0x5c
addi r5, r31, 0x70
li r4, 0x388
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C19C0:
lha r3, 0x258(r29)
addi r4, r1, 0x18
lwz r0, 8(r1)
stw r3, 0x28(r1)
lwz r3, pelletMgr__4Game@sda21(r13)
lwz r5, 0x40(r29)
stw r5, 0x20(r1)
stb r0, 0x2e(r1)
bl setUse__Q24Game9PelletMgrFPQ24Game13PelletInitArg
addi r26, r26, 1
addi r30, r30, 4
cmpwi r26, 3
blt lbl_801C1954
lmw r26, 0x48(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C1A08
* Size: 0000A0
*/
void VsGameSection::postSetupFloatMemory(void)
{
/*
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
stw r31, 0x1c(r1)
mr r31, r3
lwz r4, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r4)
cmpwi r0, 1
bne lbl_801C1A8C
lfs f0, lbl_805194A8@sda21(r2)
li r0, 0
addi r4, r1, 8
stfs f0, 0x35c(r31)
stfs f0, 0x358(r31)
stw r0, 0x384(r31)
stw r0, 0x380(r31)
stfs f0, 8(r1)
stfs f0, 0xc(r1)
stfs f0, 0x10(r1)
bl "createRedBlueBedamas__Q24Game13VsGameSectionFR10Vector3<f>"
li r0, 0
mr r3, r31
stw r0, 0x388(r31)
li r4, 7
stw r0, 0x38c(r31)
stw r0, 0x390(r31)
stw r0, 0x394(r31)
stw r0, 0x398(r31)
stw r0, 0x39c(r31)
stw r0, 0x3a0(r31)
bl createYellowBedamas__Q24Game13VsGameSectionFi
mr r3, r31
bl initCardPellets__Q24Game13VsGameSectionFv
lbl_801C1A8C:
mr r3, r31
bl postSetupFloatMemory__Q24Game15BaseGameSectionFv
lwz r0, 0x24(r1)
lwz r31, 0x1c(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C1AA8
* Size: 000020
*/
void VsGameSection::onClearHeap(void)
{
/*
lwz r4, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r4)
cmpwi r0, 1
bnelr
li r0, 0
stw r0, 0x3d0(r3)
stw r0, 0x3cc(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C1AC8
* Size: 0000B0
*/
void VsGameSection::loadChallengeStageList(void)
{
/*
stwu r1, -0x440(r1)
mflr r0
lis r4, gGameConfig__4Game@ha
stw r0, 0x444(r1)
addi r5, r4, gGameConfig__4Game@l
li r0, 0
lis r4, lbl_8048003C@ha
stw r31, 0x43c(r1)
mr r31, r3
addi r3, r4, lbl_8048003C@l
stw r0, 8(r1)
lwz r0, 0x228(r5)
cmpwi r0, 0
beq lbl_801C1B08
lis r3, lbl_80480014@ha
addi r3, r3, lbl_80480014@l
lbl_801C1B08:
li r4, 0
li r5, 0
li r6, 0
li r7, 0
li r8, 2
li r9, 0
li r10, 0
bl
loadToMainRAM__12JKRDvdRipperFPCcPUc15JKRExpandSwitchUlP7JKRHeapQ212JKRDvdRipper15EAllocDirectionUlPiPUl
cmplwi r3, 0
beq lbl_801C1B64
mr r4, r3
addi r3, r1, 0x10
li r5, -1
bl __ct__9RamStreamFPvi
li r0, 1
cmpwi r0, 1
stw r0, 0x1c(r1)
bne lbl_801C1B58
li r0, 0
stw r0, 0x424(r1)
lbl_801C1B58:
lwz r3, 0x20c(r31)
addi r4, r1, 0x10
bl read__Q34Game13ChallengeGame9StageListFR6Stream
lbl_801C1B64:
lwz r0, 0x444(r1)
lwz r31, 0x43c(r1)
mtlr r0
addi r1, r1, 0x440
blr
*/
}
/*
* --INFO--
* Address: 801C1B78
* Size: 000098
*/
void VsGameSection::loadVsStageList(void)
{
/*
stwu r1, -0x440(r1)
mflr r0
lis r4, lbl_80480060@ha
li r5, 0
stw r0, 0x444(r1)
li r0, 0
li r6, 0
li r7, 0
stw r31, 0x43c(r1)
mr r31, r3
li r8, 2
li r9, 0
stw r0, 8(r1)
addi r0, r4, lbl_80480060@l
li r4, 0
li r10, 0
mr r3, r0
bl
loadToMainRAM__12JKRDvdRipperFPCcPUc15JKRExpandSwitchUlP7JKRHeapQ212JKRDvdRipper15EAllocDirectionUlPiPUl
cmplwi r3, 0
beq lbl_801C1BFC
mr r4, r3
addi r3, r1, 0x10
li r5, -1
bl __ct__9RamStreamFPvi
li r0, 1
cmpwi r0, 1
stw r0, 0x1c(r1)
bne lbl_801C1BF0
li r0, 0
stw r0, 0x424(r1)
lbl_801C1BF0:
lwz r3, 0x210(r31)
addi r4, r1, 0x10
bl read__Q34Game6VsGame9StageListFR6Stream
lbl_801C1BFC:
lwz r0, 0x444(r1)
lwz r31, 0x43c(r1)
mtlr r0
addi r1, r1, 0x440
blr
*/
}
/*
* --INFO--
* Address: 801C1C10
* Size: 000044
*/
void VsGameSection::gmOrimaDown(int)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
cmplwi r3, 0
beq lbl_801C1C44
lwz r12, 0(r3)
mr r4, r6
lwz r12, 0x28(r12)
mtctr r12
bctrl
lbl_801C1C44:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1C54
* Size: 000004
*/
void VsGame::State::onOrimaDown(Game::VsGameSection*, int) { }
/*
* --INFO--
* Address: 801C1C58
* Size: 000004
*/
void VsGameSection::gmPikminZero(void) { }
/*
* --INFO--
* Address: 801C1C5C
* Size: 00003C
*/
void VsGameSection::goNextFloor(Game::ItemHole::Item*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
mr r4, r6
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x34(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1C98
* Size: 000004
*/
void VsGame::State::onNextFloor(Game::VsGameSection*, Game::ItemHole::Item*) { }
/*
* --INFO--
* Address: 801C1C9C
* Size: 0001D8
*/
void VsGameSection::openCaveMoreMenu(Game::ItemHole::Item*, Controller*)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stw r31, 0x3c(r1)
mr r31, r4
stw r30, 0x38(r1)
mr r30, r3
mr r4, r30
stw r29, 0x34(r1)
mr r29, r5
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x3c(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C1E58
lwz r4, gameSystem__4Game@sda21(r13)
li r3, 0
lwz r0, 0x44(r4)
cmpwi r0, 1
beq lbl_801C1CFC
cmpwi r0, 3
bne lbl_801C1D00
lbl_801C1CFC:
li r3, 1
lbl_801C1D00:
clrlwi. r0, r3, 0x18
beq lbl_801C1D20
cmplwi r29, 0
beq lbl_801C1D20
lwz r3, gGame2DMgr__6Screen@sda21(r13)
mr r4, r29
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
b lbl_801C1D2C
lbl_801C1D20:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
lwz r4, 0x10c(r30)
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
lbl_801C1D2C:
lis r3, __vt__Q32og6Screen14DispMemberBase@ha
li r11, 0
addi r0, r3, __vt__Q32og6Screen14DispMemberBase@l
li r8, 1
lis r3, 0x745F3031@ha
lis r6, __vt__Q32og6Screen17DispMemberAnaDemo@ha
addi r7, r3, 0x745F3031@l
stw r0, 8(r1)
li r10, 0x18
li r9, 0x45
addi r0, r6, __vt__Q32og6Screen17DispMemberAnaDemo@l
stw r11, 0x28(r1)
lis r5, __vt__Q32og6Screen18DispMemberCaveMore@ha
lis r4, 0x32705F63@ha
stw r0, 8(r1)
addi r6, r5, __vt__Q32og6Screen18DispMemberCaveMore@l
addi r0, r4, 0x32705F63@l
li r5, 4
stw r10, 0x10(r1)
li r4, 0xa
lis r3, mePikis__Q24Game8GameStat@ha
stw r9, 0x14(r1)
stw r8, 0x18(r1)
stw r7, 0x20(r1)
stw r11, 0xc(r1)
stb r8, 0x27(r1)
stw r8, 0x1c(r1)
stb r11, 0x24(r1)
stb r11, 0x25(r1)
stw r6, 8(r1)
stb r11, 0x2c(r1)
stb r11, 0x2d(r1)
stw r11, 0x28(r1)
stw r5, 0x10(r1)
stw r5, 0x14(r1)
stw r4, 0x18(r1)
stw r0, 0x20(r1)
lwzu r12, mePikis__Q24Game8GameStat@l(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
or. r29, r3, r3
ble lbl_801C1E08
li r0, 1
li r3, -1
stb r0, 0x2c(r1)
bl getMapPikmins__Q24Game8GameStatFi
cmpw r29, r3
bne lbl_801C1DFC
li r0, 1
stb r0, 0x2d(r1)
b lbl_801C1E14
lbl_801C1DFC:
li r0, 0
stb r0, 0x2d(r1)
b lbl_801C1E14
lbl_801C1E08:
li r0, 0
stb r0, 0x2d(r1)
stb r0, 0x2c(r1)
lbl_801C1E14:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
addi r4, r1, 8
bl open_CaveMoreMenu__Q26Screen9Game2DMgrFRQ32og6Screen18DispMemberCaveMore
clrlwi. r0, r3, 0x18
beq lbl_801C1E58
stw r31, 0x1fc(r30)
lis r3, lbl_80480078@ha
addi r5, r3, lbl_80480078@l
li r4, 1
lwz r3, gameSystem__4Game@sda21(r13)
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lis r4, lbl_80480078@ha
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r4, lbl_80480078@l
li r4, 1
bl setMoviePause__Q24Game10GameSystemFbPc
lbl_801C1E58:
lwz r0, 0x44(r1)
lwz r31, 0x3c(r1)
lwz r30, 0x38(r1)
lwz r29, 0x34(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C1E74
* Size: 000008
*/
u32 VsGame::State::goingToCave(Game::VsGameSection*) { return 0x0; }
/*
* --INFO--
* Address: 801C1E7C
* Size: 0001B0
*/
void VsGameSection::openKanketuMenu(Game::ItemBigFountain::Item*, Controller*)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stw r31, 0x3c(r1)
mr r31, r4
stw r30, 0x38(r1)
mr r30, r3
li r3, 0
stw r29, 0x34(r1)
lwz r6, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r6)
cmpwi r0, 1
beq lbl_801C1EB8
cmpwi r0, 3
bne lbl_801C1EBC
lbl_801C1EB8:
li r3, 1
lbl_801C1EBC:
clrlwi. r0, r3, 0x18
beq lbl_801C1EDC
cmplwi r5, 0
beq lbl_801C1EDC
lwz r3, gGame2DMgr__6Screen@sda21(r13)
mr r4, r5
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
b lbl_801C1EE8
lbl_801C1EDC:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
lwz r4, 0x10c(r30)
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
lbl_801C1EE8:
lis r3, __vt__Q32og6Screen14DispMemberBase@ha
li r9, 0
addi r0, r3, __vt__Q32og6Screen14DispMemberBase@l
li r7, 1
lis r3, __vt__Q32og6Screen17DispMemberAnaDemo@ha
stw r0, 8(r1)
addi r5, r3, __vt__Q32og6Screen17DispMemberAnaDemo@l
li r0, 0x18
li r8, 0x45
stw r9, 0x28(r1)
lis r3, 0x745F3031@ha
lis r4, __vt__Q32og6Screen21DispMemberKanketuMenu@ha
addi r6, r3, 0x745F3031@l
stw r5, 8(r1)
addi r5, r4, __vt__Q32og6Screen21DispMemberKanketuMenu@l
li r4, 4
stw r0, 0x10(r1)
li r0, 0xa
lis r3, mePikis__Q24Game8GameStat@ha
stw r8, 0x14(r1)
stw r7, 0x18(r1)
stw r9, 0xc(r1)
stb r7, 0x27(r1)
stw r7, 0x1c(r1)
stw r6, 0x20(r1)
stb r9, 0x24(r1)
stb r9, 0x25(r1)
stw r5, 8(r1)
stb r9, 0x2c(r1)
stb r9, 0x2d(r1)
stb r9, 0x2e(r1)
stw r9, 0x28(r1)
stw r4, 0x10(r1)
stw r4, 0x14(r1)
stw r0, 0x18(r1)
lwzu r12, mePikis__Q24Game8GameStat@l(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
or. r29, r3, r3
ble lbl_801C1FBC
li r0, 1
li r3, -1
stb r0, 0x2c(r1)
bl getMapPikmins__Q24Game8GameStatFi
cmpw r29, r3
bne lbl_801C1FB0
li r0, 1
stb r0, 0x2d(r1)
b lbl_801C1FC8
lbl_801C1FB0:
li r0, 0
stb r0, 0x2d(r1)
b lbl_801C1FC8
lbl_801C1FBC:
li r0, 0
stb r0, 0x2d(r1)
stb r0, 0x2c(r1)
lbl_801C1FC8:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
addi r4, r1, 8
bl
open_ChallengeKanketuMenu__Q26Screen9Game2DMgrFRQ32og6Screen21DispMemberKanketuMenu
clrlwi. r0, r3, 0x18
beq lbl_801C2010
stw r31, 0x200(r30)
li r4, 1
addi r5, r2, lbl_805194D0@sda21
li r6, 3
lbz r0, 0x1f8(r30)
ori r0, r0, 4
stb r0, 0x1f8(r30)
lwz r3, gameSystem__4Game@sda21(r13)
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 1
addi r5, r2, lbl_805194D0@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbl_801C2010:
lwz r0, 0x44(r1)
lwz r31, 0x3c(r1)
lwz r30, 0x38(r1)
lwz r29, 0x34(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C202C
* Size: 000014
*/
void VsGameSection::clearCaveMenus(void)
{
/*
li r0, 0
stb r0, 0x1f8(r3)
stw r0, 0x1fc(r3)
stw r0, 0x200(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C2040
* Size: 0002A8
*/
void VsGameSection::updateCaveMenus(void)
{
/*
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stw r31, 0x4c(r1)
mr r31, r3
lis r3, lbl_8047FF98@ha
stw r30, 0x48(r1)
addi r30, r3, lbl_8047FF98@l
lbz r4, 0x1f8(r31)
rlwinm. r0, r4, 0, 0x1e, 0x1e
beq lbl_801C217C
lwz r3, gGame2DMgr__6Screen@sda21(r13)
bl check_CaveMoreMenu__Q26Screen9Game2DMgrFv
cmpwi r3, 2
beq lbl_801C2134
bge lbl_801C2090
cmpwi r3, 0
beq lbl_801C22CC
bge lbl_801C209C
b lbl_801C22CC
lbl_801C2090:
cmpwi r3, 4
bge lbl_801C22CC
b lbl_801C2168
lbl_801C209C:
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lfs f0, 0x2a0(r3)
li r4, 1
lwz r3, playData__4Game@sda21(r13)
stfs f0, 0x24(r3)
lwz r3, naviMgr__4Game@sda21(r13)
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lfs f0, 0x2a0(r3)
addi r5, r30, 0xec
lwz r3, playData__4Game@sda21(r13)
li r4, 0
li r6, 3
stfs f0, 0x28(r3)
lwz r3, gameSystem__4Game@sda21(r13)
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r30, 0xec
li r4, 0
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
mr r3, r31
rlwinm r0, r0, 0, 0x1f, 0x1d
stb r0, 0x1f8(r31)
lwz r12, 0(r31)
lwz r4, 0x1fc(r31)
lwz r12, 0x6c(r12)
mtctr r12
bctrl
li r3, 1
b lbl_801C22D0
lbl_801C2134:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194D8@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194D8@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
rlwinm r0, r0, 0, 0x1f, 0x1d
stb r0, 0x1f8(r31)
b lbl_801C22CC
lbl_801C2168:
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r30, 0xf8
li r4, 0
bl setMoviePause__Q24Game10GameSystemFbPc
b lbl_801C22CC
lbl_801C217C:
rlwinm. r0, r4, 0, 0x1d, 0x1d
beq lbl_801C22CC
lwz r3, gGame2DMgr__6Screen@sda21(r13)
bl check_KanketuMenu__Q26Screen9Game2DMgrFv
cmpwi r3, 2
beq lbl_801C229C
bge lbl_801C22CC
cmpwi r3, 0
beq lbl_801C22CC
bge lbl_801C21AC
b lbl_801C22CC
b lbl_801C22CC
lbl_801C21AC:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E0@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E0@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r3, 0x1f8(r31)
addi r4, r30, 0x104
lfs f0, lbl_805194A8@sda21(r2)
li r0, 0
rlwinm r5, r3, 0, 0x1e, 0x1c
addi r3, r1, 8
stb r5, 0x1f8(r31)
lwz r5, 0xc8(r31)
stw r4, 0x14(r1)
stw r0, 0x18(r1)
stw r5, 0x20(r1)
stfs f0, 0x2c(r1)
stfs f0, 0x30(r1)
stfs f0, 0x34(r1)
stfs f0, 0x38(r1)
stw r0, 0x3c(r1)
stw r0, 0x24(r1)
stw r0, 0x1c(r1)
stw r0, 0x40(r1)
stw r0, 0x28(r1)
stw r0, 0x44(r1)
lwz r4, 0x200(r31)
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f2, 8(r1)
lfs f1, 0xc(r1)
lfs f0, 0x10(r1)
stfs f2, 0x2c(r1)
stfs f1, 0x30(r1)
stfs f0, 0x34(r1)
lwz r3, 0x200(r31)
lwz r12, 0(r3)
lwz r12, 0x64(r12)
mtctr r12
bctrl
stfs f1, 0x38(r1)
li r4, 0
lwz r0, 0xcc(r31)
stw r0, 0x24(r1)
lwz r3, 0x200(r31)
bl movie_begin__Q24Game8CreatureFb
lwz r0, 0x200(r31)
addi r4, r1, 0x14
lwz r3, moviePlayer__4Game@sda21(r13)
stw r0, 0x194(r3)
lwz r3, moviePlayer__4Game@sda21(r13)
bl play__Q24Game11MoviePlayerFRQ24Game12MoviePlayArg
li r3, 1
b lbl_801C22D0
lbl_801C229C:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E8@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E8@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
rlwinm r0, r0, 0, 0x1e, 0x1c
stb r0, 0x1f8(r31)
lbl_801C22CC:
li r3, 0
lbl_801C22D0:
lwz r0, 0x54(r1)
lwz r31, 0x4c(r1)
lwz r30, 0x48(r1)
mtlr r0
addi r1, r1, 0x50
blr
*/
}
/*
* --INFO--
* Address: 801C22E8
* Size: 000008
*/
void ItemBigFountain::Item::getFaceDir(void)
{
/*
lfs f1, 0x1ec(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C22F0
* Size: 0000DC
*/
void VsGameSection::onMovieStart(Game::MovieConfig*, unsigned long, unsigned long)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
lis r7, 0x8048
stw r0, 0x24(r1)
stw r31, 0x1C(r1)
mr r31, r6
stw r30, 0x18(r1)
mr r30, r5
stw r29, 0x14(r1)
mr r29, r4
addi r4, r7, 0xAC
stw r28, 0x10(r1)
mr r28, r3
mr r3, r29
bl 0x26F5A4
lwz r4, -0x6C18(r13)
li r3, 0
lwz r0, 0x44(r4)
cmpwi r0, 0x1
beq- .loc_0x58
cmpwi r0, 0x3
bne- .loc_0x5C
.loc_0x58:
li r3, 0x1
.loc_0x5C:
rlwinm. r0,r3,0,24,31
beq- .loc_0x88
cmplwi r31, 0x1
bne- .loc_0x7C
mr r3, r28
li r4, 0x1
bl -0x74A4C
b .loc_0x88
.loc_0x7C:
mr r3, r28
li r4, 0
bl -0x74A5C
.loc_0x88:
mr r3, r28
bl -0x745F4
lwz r3, 0x180(r28)
cmplwi r3, 0
beq- .loc_0xBC
lwz r12, 0x0(r3)
mr r4, r28
mr r5, r29
mr r6, r30
lwz r12, 0x2C(r12)
mr r7, r31
mtctr r12
bctrl
.loc_0xBC:
lwz r0, 0x24(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C23CC
* Size: 000004
*/
void VsGame::State::onMovieStart(Game::VsGameSection*, Game::MovieConfig*, unsigned long, unsigned long) { }
/*
* --INFO--
* Address: 801C23D0
* Size: 000054
*/
void VsGameSection::onMovieDone(Game::MovieConfig*, unsigned long, unsigned long)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
mr r9, r3
mr r8, r4
stw r0, 0x14(r1)
mr r0, r5
mr r7, r6
lwz r3, 0x180(r3)
cmplwi r3, 0
beq- .loc_0x44
lwz r12, 0x0(r3)
mr r4, r9
mr r5, r8
mr r6, r0
lwz r12, 0x30(r12)
mtctr r12
bctrl
.loc_0x44:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2424
* Size: 000004
*/
void VsGame::State::onMovieDone(Game::VsGameSection*, Game::MovieConfig*, unsigned long, unsigned long) { }
/*
* --INFO--
* Address: 801C2428
* Size: 000434
*/
void VsGameSection::createFallPikmins(Game::PikiContainer&, int)
{
/*
stwu r1, -0x160(r1)
mflr r0
stw r0, 0x164(r1)
stfd f31, 0x150(r1)
psq_st f31, 344(r1), 0, qr0
stfd f30, 0x140(r1)
psq_st f30, 328(r1), 0, qr0
stfd f29, 0x130(r1)
psq_st f29, 312(r1), 0, qr0
stfd f28, 0x120(r1)
psq_st f28, 296(r1), 0, qr0
stfd f27, 0x110(r1)
psq_st f27, 280(r1), 0, qr0
stfd f26, 0x100(r1)
psq_st f26, 264(r1), 0, qr0
stfd f25, 0xf0(r1)
psq_st f25, 248(r1), 0, qr0
stfd f24, 0xe0(r1)
psq_st f24, 232(r1), 0, qr0
stfd f23, 0xd0(r1)
psq_st f23, 216(r1), 0, qr0
stfd f22, 0xc0(r1)
psq_st f22, 200(r1), 0, qr0
stfd f21, 0xb0(r1)
psq_st f21, 184(r1), 0, qr0
stfd f20, 0xa0(r1)
psq_st f20, 168(r1), 0, qr0
stmw r25, 0x84(r1)
lwz r3, mapMgr__4Game@sda21(r13)
mr r26, r4
addi r4, r1, 0x38
lwz r12, 4(r3)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lis r4, lbl_804800BC@ha
mr r3, r26
addi r4, r4, lbl_804800BC@l
bl dump__Q24Game13PikiContainerFPc
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
mr r0, r3
addi r3, r1, 8
mr r4, r0
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f2, 8(r1)
addi r4, r1, 0x38
lfs f1, 0xc(r1)
lfs f0, 0x10(r1)
stfs f2, 0x38(r1)
lwz r3, mapMgr__4Game@sda21(r13)
stfs f1, 0x3c(r1)
stfs f0, 0x40(r1)
lwz r12, 4(r3)
lwz r12, 0x28(r12)
mtctr r12
bctrl
lis r3, sincosTable___5JMath@ha
stfs f1, 0x3c(r1)
lfd f22, lbl_805194C8@sda21(r2)
addi r31, r3, sincosTable___5JMath@l
lfs f23, lbl_805194F0@sda21(r2)
li r29, 0
lfs f24, lbl_805194F8@sda21(r2)
lis r30, 0x4330
lfs f25, lbl_805194F4@sda21(r2)
lfs f26, lbl_805194FC@sda21(r2)
lfs f27, lbl_80519500@sda21(r2)
lfs f28, lbl_80519508@sda21(r2)
lfs f29, lbl_80519504@sda21(r2)
lfs f30, lbl_805194A8@sda21(r2)
lfs f31, lbl_8051950C@sda21(r2)
lbl_801C2564:
li r28, 0
lbl_801C2568:
li r27, 0
b lbl_801C27AC
lbl_801C2570:
bl rand
xoris r0, r3, 0x8000
stw r30, 0x48(r1)
stw r0, 0x4c(r1)
lfd f0, 0x48(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmadds f21, f24, f0, f25
bl rand
xoris r0, r3, 0x8000
stw r30, 0x50(r1)
stw r0, 0x54(r1)
lfd f0, 0x50(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmuls f20, f26, f0
bl rand
xoris r0, r3, 0x8000
stw r30, 0x58(r1)
fmr f1, f20
stw r0, 0x5c(r1)
fcmpo cr0, f20, f30
lfd f0, 0x58(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmadds f0, f28, f0, f29
fadds f2, f27, f0
bge lbl_801C25E4
fneg f1, f20
lbl_801C25E4:
fmuls f0, f1, f31
fcmpo cr0, f20, f30
fctiwz f0, f0
stfd f0, 0x60(r1)
lwz r0, 0x64(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r31, r0
lfs f0, 4(r3)
fmuls f1, f21, f0
bge lbl_801C2638
lfs f0, lbl_80519510@sda21(r2)
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fmuls f0, f20, f0
fctiwz f0, f0
stfd f0, 0x68(r1)
lwz r0, 0x6c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
fneg f0, f0
b lbl_801C2658
lbl_801C2638:
fmuls f0, f20, f31
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fctiwz f0, f0
stfd f0, 0x70(r1)
lwz r0, 0x74(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
lbl_801C2658:
fmuls f0, f21, f0
stfs f2, 0x30(r1)
lwz r3, pikiMgr__4Game@sda21(r13)
stfs f1, 0x34(r1)
stfs f0, 0x2c(r1)
lwz r12, 0(r3)
lwz r12, 0x7c(r12)
mtctr r12
bctrl
lfs f1, 0x2c(r1)
or. r25, r3, r3
lfs f0, 0x38(r1)
lfs f3, 0x30(r1)
fadds f4, f1, f0
lfs f2, 0x3c(r1)
lfs f1, 0x34(r1)
lfs f0, 0x40(r1)
fadds f2, f3, f2
stfs f4, 0x2c(r1)
fadds f0, f1, f0
stfs f2, 0x30(r1)
stfs f0, 0x34(r1)
beq lbl_801C27A8
lis r5, __vt__Q24Game15CreatureInitArg@ha
lis r4, __vt__Q24Game11PikiInitArg@ha
addi r0, r5, __vt__Q24Game15CreatureInitArg@l
li r5, 0xf
stw r0, 0x20(r1)
addi r6, r4, __vt__Q24Game11PikiInitArg@l
li r0, 0
addi r4, r1, 0x20
stw r6, 0x20(r1)
stw r5, 0x24(r1)
stw r0, 0x28(r1)
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x74(r1)
mr r3, r25
lfd f3, lbl_805194C8@sda21(r2)
addi r4, r1, 0x2c
stw r0, 0x70(r1)
li r5, 0
lfs f1, lbl_805194F0@sda21(r2)
lfd f2, 0x70(r1)
lfs f0, lbl_805194FC@sda21(r2)
fsubs f2, f2, f3
fdivs f1, f2, f1
fmuls f0, f0, f1
stfs f0, 0x1fc(r25)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
mr r3, r25
mr r4, r29
bl changeShape__Q24Game4PikiFi
mr r3, r25
mr r4, r28
bl changeHappa__Q24Game4PikiFi
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x6c(r1)
mr r3, r25
lfs f2, lbl_805194A8@sda21(r2)
addi r4, r1, 0x14
stw r0, 0x68(r1)
lfd f1, lbl_805194C8@sda21(r2)
lfd f0, 0x68(r1)
lfs f3, lbl_805194F0@sda21(r2)
fsubs f4, f0, f1
lfs f1, lbl_80519518@sda21(r2)
lfs f0, lbl_80519514@sda21(r2)
stfs f2, 0x14(r1)
fdivs f3, f4, f3
stfs f2, 0x1c(r1)
fnmadds f0, f1, f3, f0
stfs f0, 0x18(r1)
lwz r12, 0(r25)
lwz r12, 0x68(r12)
mtctr r12
bctrl
mr r3, r25
li r4, 0
bl movie_begin__Q24Game8CreatureFb
lbl_801C27A8:
addi r27, r27, 1
lbl_801C27AC:
mr r3, r26
mr r4, r29
mr r5, r28
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0(r3)
cmpw r27, r0
blt lbl_801C2570
addi r28, r28, 1
cmpwi r28, 3
blt lbl_801C2568
addi r29, r29, 1
cmpwi r29, 7
blt lbl_801C2564
mr r3, r26
bl clear__Q24Game13PikiContainerFv
psq_l f31, 344(r1), 0, qr0
lfd f31, 0x150(r1)
psq_l f30, 328(r1), 0, qr0
lfd f30, 0x140(r1)
psq_l f29, 312(r1), 0, qr0
lfd f29, 0x130(r1)
psq_l f28, 296(r1), 0, qr0
lfd f28, 0x120(r1)
psq_l f27, 280(r1), 0, qr0
lfd f27, 0x110(r1)
psq_l f26, 264(r1), 0, qr0
lfd f26, 0x100(r1)
psq_l f25, 248(r1), 0, qr0
lfd f25, 0xf0(r1)
psq_l f24, 232(r1), 0, qr0
lfd f24, 0xe0(r1)
psq_l f23, 216(r1), 0, qr0
lfd f23, 0xd0(r1)
psq_l f22, 200(r1), 0, qr0
lfd f22, 0xc0(r1)
psq_l f21, 184(r1), 0, qr0
lfd f21, 0xb0(r1)
psq_l f20, 168(r1), 0, qr0
lfd f20, 0xa0(r1)
lmw r25, 0x84(r1)
lwz r0, 0x164(r1)
mtlr r0
addi r1, r1, 0x160
blr
*/
}
/*
* --INFO--
* Address: 801C285C
* Size: 000564
*/
void VsGameSection::createVsPikmins(void)
{
/*
stwu r1, -0x1b0(r1)
mflr r0
stw r0, 0x1b4(r1)
stfd f31, 0x1a0(r1)
psq_st f31, 424(r1), 0, qr0
stfd f30, 0x190(r1)
psq_st f30, 408(r1), 0, qr0
stfd f29, 0x180(r1)
psq_st f29, 392(r1), 0, qr0
stfd f28, 0x170(r1)
psq_st f28, 376(r1), 0, qr0
stfd f27, 0x160(r1)
psq_st f27, 360(r1), 0, qr0
stfd f26, 0x150(r1)
psq_st f26, 344(r1), 0, qr0
stfd f25, 0x140(r1)
psq_st f25, 328(r1), 0, qr0
stfd f24, 0x130(r1)
psq_st f24, 312(r1), 0, qr0
stfd f23, 0x120(r1)
psq_st f23, 296(r1), 0, qr0
stfd f22, 0x110(r1)
psq_st f22, 280(r1), 0, qr0
stfd f21, 0x100(r1)
psq_st f21, 264(r1), 0, qr0
stfd f20, 0xf0(r1)
psq_st f20, 248(r1), 0, qr0
stfd f19, 0xe0(r1)
psq_st f19, 232(r1), 0, qr0
stfd f18, 0xd0(r1)
psq_st f18, 216(r1), 0, qr0
stfd f17, 0xc0(r1)
psq_st f17, 200(r1), 0, qr0
stfd f16, 0xb0(r1)
psq_st f16, 184(r1), 0, qr0
stmw r24, 0x90(r1)
mr r25, r3
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
li r4, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
or. r26, r3, r3
bne lbl_801C2920
lis r3, lbl_8047FFF4@ha
lis r5, lbl_8047FFC0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x545
addi r5, r5, lbl_8047FFC0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C2920:
mr r4, r26
addi r3, r1, 0x28
lwz r12, 0(r26)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f25, 0x28(r1)
li r4, 0
lfs f24, 0x2c(r1)
lfs f23, 0x30(r1)
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
bl getOnyon__Q34Game9ItemOnyon3MgrFi
or. r26, r3, r3
bne lbl_801C2974
lis r3, lbl_8047FFF4@ha
lis r5, lbl_8047FFC0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x54a
addi r5, r5, lbl_8047FFC0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C2974:
mr r4, r26
addi r3, r1, 0x1c
lwz r12, 0(r26)
lwz r12, 8(r12)
mtctr r12
bctrl
addi r29, r25, 0x214
lfs f22, 0x1c(r1)
lfs f21, 0x20(r1)
mr r3, r29
lfs f20, 0x24(r1)
bl clear__Q24Game13PikiContainerFv
mr r3, r29
li r4, 1
li r5, 0
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0x344(r25)
li r4, 0
li r5, 0
mulli r0, r0, 5
stw r0, 0(r3)
mr r3, r29
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0x348(r25)
li r28, 0
mulli r0, r0, 5
stw r0, 0(r3)
lbl_801C29E0:
cmpwi r28, 1
bne lbl_801C29F8
fmr f19, f25
fmr f18, f24
fmr f17, f23
b lbl_801C2A0C
lbl_801C29F8:
cmpwi r28, 0
bne lbl_801C2BD4
fmr f19, f22
fmr f18, f21
fmr f17, f20
lbl_801C2A0C:
lis r3, sincosTable___5JMath@ha
lfd f26, lbl_805194C8@sda21(r2)
lfs f27, lbl_805194F0@sda21(r2)
addi r31, r3, sincosTable___5JMath@l
lfs f28, lbl_8051951C@sda21(r2)
li r27, 0
lfs f29, lbl_805194FC@sda21(r2)
lis r30, 0x4330
lfs f30, lbl_805194A8@sda21(r2)
lfs f31, lbl_8051950C@sda21(r2)
lbl_801C2A34:
li r26, 0
b lbl_801C2BAC
lbl_801C2A3C:
bl rand
xoris r0, r3, 0x8000
stw r30, 0x68(r1)
stw r0, 0x6c(r1)
lfd f0, 0x68(r1)
fsubs f0, f0, f26
fdivs f0, f0, f27
fmuls f16, f28, f0
bl rand
xoris r0, r3, 0x8000
stw r30, 0x70(r1)
stw r0, 0x74(r1)
lfd f0, 0x70(r1)
fsubs f0, f0, f26
fdivs f0, f0, f27
fmuls f2, f29, f0
fmr f0, f2
fcmpo cr0, f2, f30
bge lbl_801C2A8C
fneg f0, f2
lbl_801C2A8C:
fmuls f0, f0, f31
fcmpo cr0, f2, f30
fctiwz f0, f0
stfd f0, 0x78(r1)
lwz r0, 0x7c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r31, r0
lfs f0, 4(r3)
fmuls f1, f16, f0
bge lbl_801C2AE0
lfs f0, lbl_80519510@sda21(r2)
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fmuls f0, f2, f0
fctiwz f0, f0
stfd f0, 0x80(r1)
lwz r0, 0x84(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
fneg f0, f0
b lbl_801C2B00
lbl_801C2AE0:
fmuls f0, f2, f31
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fctiwz f0, f0
stfd f0, 0x88(r1)
lwz r0, 0x8c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
lbl_801C2B00:
fmuls f0, f16, f0
stfs f30, 0x60(r1)
lwz r3, pikiMgr__4Game@sda21(r13)
stfs f1, 0x64(r1)
stfs f0, 0x5c(r1)
lwz r12, 0(r3)
lwz r12, 0x7c(r12)
mtctr r12
bctrl
lfs f2, 0x5c(r1)
or. r24, r3, r3
lfs f1, 0x60(r1)
lfs f0, 0x64(r1)
fadds f2, f2, f19
fadds f1, f1, f18
fadds f0, f0, f17
stfs f2, 0x5c(r1)
stfs f1, 0x60(r1)
stfs f0, 0x64(r1)
beq lbl_801C2BA8
lis r5, __vt__Q24Game15CreatureInitArg@ha
lis r4, __vt__Q24Game11PikiInitArg@ha
addi r0, r5, __vt__Q24Game15CreatureInitArg@l
li r5, -1
stw r0, 0x50(r1)
addi r6, r4, __vt__Q24Game11PikiInitArg@l
li r0, 0
addi r4, r1, 0x50
stw r6, 0x50(r1)
stw r5, 0x54(r1)
stw r0, 0x58(r1)
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
mr r3, r24
addi r4, r1, 0x5c
li r5, 0
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
mr r3, r24
mr r4, r28
bl changeShape__Q24Game4PikiFi
mr r3, r24
mr r4, r27
bl changeHappa__Q24Game4PikiFi
lbl_801C2BA8:
addi r26, r26, 1
lbl_801C2BAC:
mr r3, r29
mr r4, r28
mr r5, r27
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0(r3)
cmpw r26, r0
blt lbl_801C2A3C
addi r27, r27, 1
cmpwi r27, 3
blt lbl_801C2A34
lbl_801C2BD4:
addi r28, r28, 1
cmpwi r28, 7
blt lbl_801C29E0
lwz r3, lbl_80520E68@sda21(r2)
addi r26, r1, 8
lwz r0, lbl_80520E6C@sda21(r2)
li r24, 0
stw r3, 8(r1)
lwz r3, cBedamaRed__13VsOtakaraName@sda21(r13)
stw r0, 0xc(r1)
lwz r0, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r3, 8(r1)
stw r0, 0xc(r1)
lbl_801C2C08:
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
subfic r4, r24, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
mr r0, r3
addi r3, r1, 0x40
mr r27, r0
bl __ct__Q24Game14PelletIteratorFv
addi r3, r1, 0x40
bl first__Q24Game14PelletIteratorFv
b lbl_801C2CAC
lbl_801C2C30:
addi r3, r1, 0x40
bl __ml__Q24Game14PelletIteratorFv
mr r0, r3
lwz r3, 0(r26)
mr r28, r0
lwz r4, 0x35c(r28)
lwz r4, 0x40(r4)
bl strcmp
cmpwi r3, 0
bne lbl_801C2CA4
mr r4, r27
addi r3, r1, 0x10
bl getFlagSetPos__Q24Game5OnyonFv
lfs f2, 0x10(r1)
mr r3, r28
lfs f1, 0x14(r1)
lfs f0, 0x18(r1)
stfs f2, 0x34(r1)
stfs f1, 0x38(r1)
stfs f0, 0x3c(r1)
bl getCylinderHeight__Q24Game6PelletFv
lfs f2, lbl_805194AC@sda21(r2)
mr r3, r28
lfs f0, 0x38(r1)
addi r4, r1, 0x34
li r5, 0
fmadds f0, f2, f1, f0
stfs f0, 0x38(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lbl_801C2CA4:
addi r3, r1, 0x40
bl next__Q24Game14PelletIteratorFv
lbl_801C2CAC:
addi r3, r1, 0x40
bl isDone__Q24Game14PelletIteratorFv
clrlwi. r0, r3, 0x18
beq lbl_801C2C30
addi r24, r24, 1
addi r26, r26, 4
cmpwi r24, 2
blt lbl_801C2C08
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lwz r5, 0x33c(r25)
li r4, 1
lwz r0, 0x68(r5)
stw r0, 0x25c(r3)
lwz r5, 0x33c(r25)
lwz r0, 0x64(r5)
stw r0, 0x260(r3)
lwz r3, naviMgr__4Game@sda21(r13)
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lwz r4, 0x33c(r25)
lwz r0, 0x68(r4)
stw r0, 0x25c(r3)
lwz r4, 0x33c(r25)
lwz r0, 0x64(r4)
stw r0, 0x260(r3)
psq_l f31, 424(r1), 0, qr0
lfd f31, 0x1a0(r1)
psq_l f30, 408(r1), 0, qr0
lfd f30, 0x190(r1)
psq_l f29, 392(r1), 0, qr0
lfd f29, 0x180(r1)
psq_l f28, 376(r1), 0, qr0
lfd f28, 0x170(r1)
psq_l f27, 360(r1), 0, qr0
lfd f27, 0x160(r1)
psq_l f26, 344(r1), 0, qr0
lfd f26, 0x150(r1)
psq_l f25, 328(r1), 0, qr0
lfd f25, 0x140(r1)
psq_l f24, 312(r1), 0, qr0
lfd f24, 0x130(r1)
psq_l f23, 296(r1), 0, qr0
lfd f23, 0x120(r1)
psq_l f22, 280(r1), 0, qr0
lfd f22, 0x110(r1)
psq_l f21, 264(r1), 0, qr0
lfd f21, 0x100(r1)
psq_l f20, 248(r1), 0, qr0
lfd f20, 0xf0(r1)
psq_l f19, 232(r1), 0, qr0
lfd f19, 0xe0(r1)
psq_l f18, 216(r1), 0, qr0
lfd f18, 0xd0(r1)
psq_l f17, 200(r1), 0, qr0
lfd f17, 0xc0(r1)
psq_l f16, 184(r1), 0, qr0
lfd f16, 0xb0(r1)
lmw r24, 0x90(r1)
lwz r0, 0x1b4(r1)
mtlr r0
addi r1, r1, 0x1b0
blr
*/
}
/*
* --INFO--
* Address: 801C2DC0
* Size: 000010
*/
void VsGameSection::addChallengeScore(int)
{
/*
lwz r0, 0x3bc(r3)
add r0, r0, r4
stw r0, 0x3bc(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C2DD0
* Size: 00006C
*/
void VsGameSection::sendMessage(Game::GameMessage&)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
mr r3, r31
lwz r12, 0(r31)
mr r4, r30
lwz r12, 8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C2E24
mr r3, r31
mr r4, r30
lwz r12, 0(r31)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lbl_801C2E24:
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2E3C
* Size: 000040
*/
void GameMessageVsGetDoping::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
mr r3, r4
stw r0, 0x14(r1)
lwz r4, 4(r5)
lwz r5, 8(r5)
bl getGetDopeCount__Q24Game13VsGameSectionFii
lwz r4, 0(r3)
addi r0, r4, 1
stw r0, 0(r3)
li r3, 1
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2E7C
* Size: 00004C
*/
void GameMessageVsBattleFinished::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2EB4
mr r3, r0
lwz r5, 4(r5)
lwz r12, 0(r3)
li r6, 0
lwz r12, 0x40(r12)
mtctr r12
bctrl
lbl_801C2EB4:
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2EC8
* Size: 000004
*/
void VsGame::State::onBattleFinished(Game::VsGameSection*, int, bool) { }
/*
* --INFO--
* Address: 801C2ECC
* Size: 00004C
*/
void GameMessageVsRedOrSuckStart::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
stw r0, 0x14(r1)
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2F04
mr r3, r0
lwz r5, 4(r6)
lwz r12, 0(r3)
lbz r6, 8(r6)
lwz r12, 0x44(r12)
mtctr r12
bctrl
lbl_801C2F04:
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2F18
* Size: 000004
*/
void VsGame::State::onRedOrBlueSuckStart(Game::VsGameSection*, int, bool) { }
/*
* --INFO--
* Address: 801C2F1C
* Size: 0000B8
*/
void GameMessageVsGetOtakara::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2FB8
lwz r0, 4(r30)
slwi r0, r0, 2
add r4, r31, r0
lwz r3, 0x3d4(r4)
addi r0, r3, 1
stw r0, 0x3d4(r4)
lwz r3, 4(r30)
slwi r0, r3, 2
cntlzw r4, r3
add r3, r31, r0
lwz r0, 0x3d4(r3)
srwi r3, r4, 5
subfic r0, r0, 3
cntlzw r0, r0
srwi r4, r0, 5
bl PSSetLastBeedamaDirection__Fbb
lwz r5, 4(r30)
slwi r0, r5, 2
add r3, r31, r0
lwz r0, 0x3d4(r3)
cmpwi r0, 4
blt lbl_801C2FB8
lwz r3, 0x180(r31)
mr r4, r31
li r6, 1
lwz r12, 0(r3)
lwz r12, 0x40(r12)
mtctr r12
bctrl
lbl_801C2FB8:
lwz r0, 0x14(r1)
li r3, 1
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2FD4
* Size: 000034
*/
void GameMessageVsAddEnemy::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r3, 0x32c(r4)
lwz r4, 4(r5)
lwz r5, 8(r5)
bl entry__Q34Game6VsGame7TekiMgrFQ34Game11EnemyTypeID12EEnemyTypeIDi
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 0000A4
*/
void GameMessageVsBirthTeki::actVs(Game::VsGameSection*)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C3008
* Size: 000118
*/
void GameMessagePelletBorn::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r5, 4(r3)
lbz r0, 0x32c(r5)
cmplwi r0, 6
bne lbl_801C310C
lwz r0, 0x388(r4)
cmplw r0, r5
bne lbl_801C3038
li r3, 0
b lbl_801C3110
lbl_801C3038:
lwz r0, 0x38c(r4)
cmplw r0, r5
bne lbl_801C304C
li r3, 0
b lbl_801C3110
lbl_801C304C:
addi r3, r4, 8
lwz r0, 0x390(r4)
cmplw r0, r5
bne lbl_801C3064
li r3, 0
b lbl_801C3110
lbl_801C3064:
lwz r0, 0x38c(r3)
cmplw r0, r5
bne lbl_801C3078
li r3, 0
b lbl_801C3110
lbl_801C3078:
lwz r0, 0x390(r3)
cmplw r0, r5
bne lbl_801C308C
li r3, 0
b lbl_801C3110
lbl_801C308C:
lwz r0, 0x394(r3)
cmplw r0, r5
bne lbl_801C30A0
li r3, 0
b lbl_801C3110
lbl_801C30A0:
lwz r0, 0x398(r3)
cmplw r0, r5
bne lbl_801C30B4
li r3, 0
b lbl_801C3110
lbl_801C30B4:
li r0, 7
mr r3, r4
li r6, 0
mtctr r0
lbl_801C30C4:
lwz r0, 0x388(r3)
cmplwi r0, 0
bne lbl_801C30E4
slwi r0, r6, 2
li r3, 1
add r4, r4, r0
stw r5, 0x388(r4)
b lbl_801C3110
lbl_801C30E4:
addi r3, r3, 4
addi r6, r6, 1
bdnz lbl_801C30C4
lis r3, lbl_8047FFF4@ha
lis r5, lbl_804800D0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x638
addi r5, r5, lbl_804800D0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C310C:
li r3, 0
lbl_801C3110:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C3120
* Size: 00008C
*/
void GameMessagePelletDead::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r5, 4(r3)
lbz r0, 0x32c(r5)
cmplwi r0, 6
bne lbl_801C3198
li r0, 7
mr r3, r4
li r6, 0
mtctr r0
lbl_801C314C:
lwz r0, 0x388(r3)
cmplw r0, r5
bne lbl_801C3170
slwi r0, r6, 2
li r5, 0
add r4, r4, r0
li r3, 1
stw r5, 0x388(r4)
b lbl_801C319C
lbl_801C3170:
addi r3, r3, 4
addi r6, r6, 1
bdnz lbl_801C314C
lis r3, lbl_8047FFF4@ha
lis r5, lbl_804800EC@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x651
addi r5, r5, lbl_804800EC@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3198:
li r3, 0
lbl_801C319C:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C31AC
* Size: 000228
*/
void GameMessageVsBirthTekiTreasure::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0xb0(r1)
mflr r0
stw r0, 0xb4(r1)
stfd f31, 0xa0(r1)
psq_st f31, 168(r1), 0, qr0
stmw r26, 0x88(r1)
mr r30, r3
mr r31, r4
lfs f1, 4(r3)
addi r3, r1, 0x18
lfs f0, lbl_80519520@sda21(r2)
addi r4, r1, 8
stfs f1, 8(r1)
li r29, 0
li r28, 0
li r27, 0
lfs f1, 8(r30)
stfs f1, 0xc(r1)
lfs f1, 0xc(r30)
stfs f1, 0x10(r1)
stfs f0, 0x14(r1)
bl __ct__Q24Game15CellIteratorArgFRQ23Sys6Sphere
addi r3, r1, 0x38
addi r4, r1, 0x18
bl __ct__Q24Game12CellIteratorFRQ24Game15CellIteratorArg
addi r3, r1, 0x38
bl first__Q24Game12CellIteratorFv
b lbl_801C3284
lbl_801C321C:
addi r3, r1, 0x38
bl __ml__Q24Game12CellIteratorFv
lwz r12, 0(r3)
mr r26, r3
lwz r12, 0x18(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C327C
mr r3, r26
lwz r12, 0(r26)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C327C
lbz r0, 0x2b8(r26)
cmpwi r0, 1
bne lbl_801C3270
addi r28, r28, 1
b lbl_801C327C
lbl_801C3270:
cmpwi r0, 0
bne lbl_801C327C
addi r27, r27, 1
lbl_801C327C:
addi r3, r1, 0x38
bl next__Q24Game12CellIteratorFv
lbl_801C3284:
addi r3, r1, 0x38
bl isDone__Q24Game12CellIteratorFv
clrlwi. r0, r3, 0x18
beq lbl_801C321C
cmpw r27, r28
ble lbl_801C32A0
li r29, 1
lbl_801C32A0:
subfic r0, r29, 1
slwi r3, r29, 2
slwi r0, r0, 2
lfs f0, lbl_80519528@sda21(r2)
add r4, r31, r3
lfs f31, lbl_80519524@sda21(r2)
add r3, r31, r0
lfs f2, 0x370(r4)
lfs f1, 0x370(r3)
fsubs f2, f2, f1
fcmpo cr0, f2, f0
ble lbl_801C32E4
lwz r3, 0x10(r30)
fmr f31, f0
addi r0, r3, 2
stw r0, 0x10(r30)
b lbl_801C334C
lbl_801C32E4:
lfs f0, lbl_805194AC@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3304
lwz r3, 0x10(r30)
fmr f31, f0
addi r0, r3, 1
stw r0, 0x10(r30)
b lbl_801C334C
lbl_801C3304:
lfs f1, lbl_8051952C@sda21(r2)
fcmpo cr0, f2, f1
ble lbl_801C3314
b lbl_801C334C
lbl_801C3314:
lfs f0, lbl_80519530@sda21(r2)
fcmpo cr0, f2, f0
bgt lbl_801C334C
lfs f0, lbl_80519534@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3334
fmr f31, f1
b lbl_801C334C
lbl_801C3334:
lfs f0, lbl_80519538@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3348
lfs f31, lbl_8051953C@sda21(r2)
b lbl_801C334C
lbl_801C3348:
lfs f31, lbl_80519540@sda21(r2)
lbl_801C334C:
bl rand
xoris r4, r3, 0x8000
lis r0, 0x4330
stw r4, 0x84(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r0, 0x80(r1)
lfs f0, lbl_805194F0@sda21(r2)
lfd f1, 0x80(r1)
fsubs f1, f1, f2
fdivs f0, f1, f0
fcmpo cr0, f0, f31
bgt lbl_801C33B8
lwz r3, 0x32c(r31)
li r27, 0
lwz r3, 0x24(r3)
addi r26, r3, -1
b lbl_801C33A8
lbl_801C3390:
lwz r3, 0x32c(r31)
mr r4, r26
lbz r6, 0x14(r30)
addi r5, r30, 4
bl "birth__Q34Game6VsGame7TekiMgrFiR10Vector3<f>b"
addi r27, r27, 1
lbl_801C33A8:
lwz r0, 0x10(r30)
cmpw r27, r0
blt lbl_801C3390
li r3, 1
lbl_801C33B8:
psq_l f31, 168(r1), 0, qr0
lfd f31, 0xa0(r1)
lmw r26, 0x88(r1)
lwz r0, 0xb4(r1)
mtlr r0
addi r1, r1, 0xb0
blr
*/
}
/*
* --INFO--
* Address: 801C33D4
* Size: 00001C
*/
void GameMessageVsPikminDead::actVs(Game::VsGameSection*)
{
/*
li r0, 0
li r3, 1
stb r0, 0x205(r4)
lwz r5, 0x208(r4)
addi r0, r5, 1
stw r0, 0x208(r4)
blr
*/
}
/*
* --INFO--
* Address: 801C33F0
* Size: 00007C
*/
void GameMessageVsGotCard::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r0, 4(r3)
lwz r4, 0x330(r4)
mulli r3, r0, 0x70
addi r3, r3, 0x18
add r3, r4, r3
lbz r0, 0x18(r3)
cmplwi r0, 0
bne lbl_801C3444
lwz r3, 0x58(r3)
addis r0, r3, 0
cmplwi r0, 0xffff
beq lbl_801C3444
mr r3, r31
bl useCard__Q24Game13VsGameSectionFv
lbl_801C3444:
lwz r3, 0x330(r31)
lwz r4, 4(r30)
bl gotPlayerCard__Q34Game6VsGame7CardMgrFi
lwz r0, 0x14(r1)
li r3, 1
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C346C
* Size: 0000A8
*/
void GameMessageVsUseCard::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r3, 0x180(r4)
cmplwi r3, 0
beq lbl_801C34B4
lwz r12, 0(r3)
lwz r12, 0x48(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C34B4
li r3, 0
b lbl_801C34FC
lbl_801C34B4:
lis r3, gGameConfig__4Game@ha
addi r3, r3, gGameConfig__4Game@l
lwz r0, 0x1b8(r3)
cmpwi r0, 0
bne lbl_801C34EC
lwz r3, 0x330(r31)
lwz r4, 4(r30)
lwz r5, 0x32c(r31)
bl usePlayerCard__Q34Game6VsGame7CardMgrFiPQ34Game6VsGame7TekiMgr
clrlwi. r0, r3, 0x18
beq lbl_801C34F8
mr r3, r31
bl useCard__Q24Game13VsGameSectionFv
b lbl_801C34F8
lbl_801C34EC:
lwz r3, 0x330(r31)
lwz r4, 4(r30)
bl stopSlot__Q34Game6VsGame7CardMgrFi
lbl_801C34F8:
li r3, 1
lbl_801C34FC:
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C3514
* Size: 000008
*/
u32 VsGame::State::isCardUsable(Game::VsGameSection*) { return 0x0; }
/*
* --INFO--
* Address: ........
* Size: 000170
*/
void VsGameSection::createCardPellet(void)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C351C
* Size: 000010
*/
void setComeAlive__Q24Game49FixedSizePelletMgr<Game::PelletOtakara::Object> Fi(void)
{
/*
.loc_0x0:
lwz r3, 0x9C(r3)
li r0, 0
stbx r0, r3, r4
blr
*/
}
/*
* --INFO--
* Address: 801C352C
* Size: 000190
*/
void VsGameSection::initCardPellets(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
stw r0, 0x64(r1)
li r0, 0xa
stmw r27, 0x4c(r1)
mr r30, r3
stw r0, 0x3cc(r3)
lis r3, lbl_8047FF98@ha
addi r31, r3, lbl_8047FF98@l
lwz r0, 0x3cc(r30)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x3d0(r30)
lis r3, __vt__Q24Game15CreatureInitArg@ha
addi r0, r3, __vt__Q24Game15CreatureInitArg@l
li r7, 0
lis r3, __vt__Q24Game13PelletInitArg@ha
stw r0, 0x18(r1)
li r0, -1
li r6, 0xff
addi r3, r3, __vt__Q24Game13PelletInitArg@l
li r5, 1
stw r3, 0x18(r1)
addi r4, r1, 8
lwz r3, cCoin__13VsOtakaraName@sda21(r13)
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C35DC
addi r3, r31, 0x5c
addi r5, r31, 0x70
li r4, 0x704
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C35DC:
lha r4, 0x258(r29)
li r0, 1
lwz r3, 8(r1)
li r27, 0
stw r4, 0x28(r1)
li r28, 0
lwz r4, 0x40(r29)
stw r4, 0x20(r1)
stb r3, 0x2e(r1)
stw r0, 0x38(r1)
stw r0, 0x3c(r1)
b lbl_801C366C
lbl_801C360C:
lwz r3, pelletMgr__4Game@sda21(r13)
addi r4, r1, 0x18
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
or. r29, r3, r3
beq lbl_801C3650
lfs f0, lbl_805194A8@sda21(r2)
addi r4, r1, 0xc
li r5, 0
stfs f0, 0xc(r1)
stfs f0, 0x10(r1)
stfs f0, 0x14(r1)
lwz r6, 0x3d0(r30)
stwx r29, r6, r28
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lwz r3, 0x3d0(r30)
stwx r29, r3, r28
b lbl_801C3664
lbl_801C3650:
addi r3, r31, 0x5c
addi r5, r31, 0x16c
li r4, 0x715
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3664:
addi r28, r28, 4
addi r27, r27, 1
lbl_801C366C:
lwz r0, 0x3cc(r30)
cmpw r27, r0
blt lbl_801C360C
li r27, 0
li r28, 0
b lbl_801C369C
lbl_801C3684:
lwz r3, 0x3d0(r30)
li r4, 0
lwzx r3, r3, r28
bl kill__Q24Game8CreatureFPQ24Game15CreatureKillArg
addi r28, r28, 4
addi r27, r27, 1
lbl_801C369C:
lwz r0, 0x3cc(r30)
cmpw r27, r0
blt lbl_801C3684
lmw r27, 0x4c(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C36BC
* Size: 000014
*/
void VsGameSection::initCardGeneration(void)
{
/*
li r0, 0
lfs f0, lbl_80519544@sda21(r2)
stw r0, 0x3c4(r3)
stfs f0, 0x3c8(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C36D0
* Size: 0002D8
*/
void VsGameSection::updateCardGeneration(void)
{
/*
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stfd f31, 0x40(r1)
psq_st f31, 72(r1), 0, qr0
stfd f30, 0x30(r1)
psq_st f30, 56(r1), 0, qr0
stmw r27, 0x1c(r1)
mr r29, r3
lfs f4, lbl_80519524@sda21(r2)
lfs f3, 0x378(r3)
li r31, 0
lfs f2, 0x37c(r3)
li r30, 5
lfs f1, 0x370(r3)
lfs f0, 0x374(r3)
fsubs f2, f3, f2
lfs f31, lbl_80519548@sda21(r2)
fsubs f0, f1, f0
lfs f30, lbl_8051954C@sda21(r2)
fsubs f6, f2, f0
fabs f0, f6
frsp f5, f0
fcmpo cr0, f5, f4
blt lbl_801C37D8
fcmpo cr0, f4, f5
cror 2, 0, 2
mfcr r0
lis r3, 0x4330
rlwinm r0, r0, 3, 0x1f, 0x1f
stw r3, 0x10(r1)
lfd f3, lbl_80519568@sda21(r2)
stw r0, 0x14(r1)
lfd f0, 0x10(r1)
fsubs f0, f0, f3
fcmpo cr0, f0, f31
bge lbl_801C3778
lfs f31, lbl_80519550@sda21(r2)
li r30, 5
lfs f30, lbl_805194AC@sda21(r2)
li r31, 1
b lbl_801C37D8
lbl_801C3778:
fcmpo cr0, f31, f5
fmr f2, f31
cror 2, 0, 2
mfcr r0
stw r3, 0x10(r1)
rlwinm r0, r0, 3, 0x1f, 0x1f
lfs f0, lbl_80519528@sda21(r2)
stw r0, 0x14(r1)
lfd f1, 0x10(r1)
fsubs f1, f1, f3
fcmpo cr0, f1, f0
bge lbl_801C37BC
fmr f31, f4
li r30, 6
fmr f30, f2
li r31, 1
b lbl_801C37D8
lbl_801C37BC:
fcmpo cr0, f0, f5
cror 2, 0, 2
bne lbl_801C37D8
fmr f31, f4
li r30, 7
fmr f30, f2
li r31, 1
lbl_801C37D8:
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f6, f0
bge lbl_801C37F4
fmr f1, f31
lfs f0, lbl_805194B8@sda21(r2)
fsubs f31, f0, f30
fsubs f30, f0, f1
lbl_801C37F4:
clrlwi. r0, r31, 0x18
bne lbl_801C3894
lfs f2, 0x364(r29)
lfs f0, 0x360(r29)
lfs f1, lbl_805194AC@sda21(r2)
fsubs f3, f2, f0
lfs f0, lbl_8051952C@sda21(r2)
fmuls f3, f3, f1
fabs f2, f3
frsp f2, f2
fcmpo cr0, f2, f0
cror 2, 0, 2
beq lbl_801C3894
lfs f0, lbl_80519524@sda21(r2)
fcmpo cr0, f2, f0
bge lbl_801C3840
lfs f31, lbl_80519548@sda21(r2)
lfs f30, lbl_80519554@sda21(r2)
b lbl_801C3878
lbl_801C3840:
fcmpo cr0, f2, f1
bge lbl_801C3854
fmr f30, f1
lfs f31, lbl_80519548@sda21(r2)
b lbl_801C3878
lbl_801C3854:
lfs f0, lbl_805194B8@sda21(r2)
fcmpo cr0, f2, f0
bge lbl_801C3878
lfs f0, lbl_80519558@sda21(r2)
fmr f30, f1
lfs f31, lbl_80519550@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3878
li r30, 5
lbl_801C3878:
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f3, f0
bge lbl_801C3894
fmr f1, f31
lfs f0, lbl_805194B8@sda21(r2)
fsubs f31, f0, f30
fsubs f30, f0, f1
lbl_801C3894:
li r28, 0
li r27, 0
stw r28, 0x3c4(r29)
b lbl_801C38D8
lbl_801C38A4:
lwz r3, 0x3d0(r29)
lwzx r3, r3, r28
lwz r12, 0(r3)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C38D0
lwz r3, 0x3c4(r29)
addi r0, r3, 1
stw r0, 0x3c4(r29)
lbl_801C38D0:
addi r28, r28, 4
addi r27, r27, 1
lbl_801C38D8:
lwz r0, 0x3cc(r29)
cmpw r27, r0
blt lbl_801C38A4
lwz r3, 0x3c4(r29)
cmpwi r3, 4
blt lbl_801C3900
clrlwi. r0, r31, 0x18
beq lbl_801C3984
cmpw r3, r30
bge lbl_801C3984
lbl_801C3900:
lwz r3, sys@sda21(r13)
clrlwi. r0, r31, 0x18
lfs f2, 0x54(r3)
beq lbl_801C3918
lfs f0, lbl_8051955C@sda21(r2)
fmuls f2, f2, f0
lbl_801C3918:
lfs f1, 0x3c8(r29)
lfs f0, lbl_805194A8@sda21(r2)
fsubs f1, f1, f2
stfs f1, 0x3c8(r29)
lfs f1, 0x3c8(r29)
fcmpo cr0, f1, f0
cror 2, 0, 2
bne lbl_801C3984
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x14(r1)
mr r3, r29
lfd f3, lbl_805194C8@sda21(r2)
addi r4, r1, 8
stw r0, 0x10(r1)
lfs f2, lbl_805194F0@sda21(r2)
lfd f0, 0x10(r1)
lfs f1, lbl_80519560@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_8051951C@sda21(r2)
fdivs f2, f3, f2
fmadds f0, f1, f2, f0
stfs f0, 0x3c8(r29)
stfs f31, 8(r1)
stfs f30, 0xc(r1)
bl dropCard__Q24Game13VsGameSectionFRQ34Game13VsGameSection11DropCardArg
lbl_801C3984:
psq_l f31, 72(r1), 0, qr0
lfd f31, 0x40(r1)
psq_l f30, 56(r1), 0, qr0
lfd f30, 0x30(r1)
lmw r27, 0x1c(r1)
lwz r0, 0x54(r1)
mtlr r0
addi r1, r1, 0x50
blr
*/
}
/*
* --INFO--
* Address: 801C39A8
* Size: 000018
*/
void VsGameSection::useCard(void)
{
/*
lwz r4, 0x3c4(r3)
cmpwi r4, 0
blelr
addi r0, r4, -1
stw r0, 0x3c4(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C39C0
* Size: 0003F4
*/
void VsGameSection::dropCard(Game::VsGameSection::DropCardArg&)
{
/*
stwu r1, -0xf0(r1)
mflr r0
stw r0, 0xf4(r1)
stfd f31, 0xe0(r1)
psq_st f31, 232(r1), 0, qr0
stw r31, 0xdc(r1)
stw r30, 0xd8(r1)
stw r29, 0xd4(r1)
stw r28, 0xd0(r1)
mr r5, r4
mr r30, r3
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
addi r4, r1, 0x28
lfs f1, 0(r5)
lfs f2, 4(r5)
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFR10Vector3<f>ff"
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xac(r1)
lfd f3, lbl_805194C8@sda21(r2)
stw r0, 0xa8(r1)
lfs f1, lbl_805194F0@sda21(r2)
lfd f2, 0xa8(r1)
lfs f0, lbl_80519520@sda21(r2)
fsubs f2, f2, f3
fdivs f1, f2, f1
fmuls f31, f0, f1
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xb4(r1)
lfd f3, lbl_805194C8@sda21(r2)
stw r0, 0xb0(r1)
lfs f2, lbl_805194F0@sda21(r2)
lfd f0, 0xb0(r1)
lfs f1, lbl_805194FC@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_805194A8@sda21(r2)
fdivs f2, f3, f2
fmuls f3, f1, f2
fmr f1, f3
fcmpo cr0, f3, f0
bge lbl_801C3A74
fneg f1, f3
lbl_801C3A74:
lfs f2, lbl_8051950C@sda21(r2)
lis r3, sincosTable___5JMath@ha
lfs f0, lbl_805194A8@sda21(r2)
addi r4, r3, sincosTable___5JMath@l
fmuls f1, f1, f2
lfs f4, 0x28(r1)
fcmpo cr0, f3, f0
fctiwz f0, f1
stfd f0, 0xb8(r1)
lwz r0, 0xbc(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r4, r0
lfs f0, 4(r3)
fmuls f5, f31, f0
bge lbl_801C3AD4
lfs f0, lbl_80519510@sda21(r2)
fmuls f0, f3, f0
fctiwz f0, f0
stfd f0, 0xc0(r1)
lwz r0, 0xc4(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r4, r0
fneg f0, f0
b lbl_801C3AEC
lbl_801C3AD4:
fmuls f0, f3, f2
fctiwz f0, f0
stfd f0, 0xc8(r1)
lwz r0, 0xcc(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r4, r0
lbl_801C3AEC:
fmuls f3, f31, f0
li r7, 0
lfs f0, 0x30(r1)
li r0, -1
lis r3, __vt__Q24Game15CreatureInitArg@ha
lfs f2, 0x2c(r1)
lfs f1, lbl_805194A8@sda21(r2)
fadds f3, f4, f3
fadds f0, f0, f5
addi r4, r3, __vt__Q24Game15CreatureInitArg@l
fadds f1, f2, f1
lis r3, __vt__Q24Game13PelletInitArg@ha
li r6, 0xff
li r5, 1
stw r4, 0x4c(r1)
addi r8, r3, __vt__Q24Game13PelletInitArg@l
lwz r3, cCoin__13VsOtakaraName@sda21(r13)
addi r4, r1, 8
stfs f3, 0x28(r1)
stfs f1, 0x2c(r1)
stfs f0, 0x30(r1)
stw r8, 0x4c(r1)
stb r7, 0x68(r1)
sth r7, 0x60(r1)
stb r6, 0x62(r1)
stw r7, 0x64(r1)
stb r7, 0x63(r1)
stb r5, 0x50(r1)
stb r7, 0x69(r1)
stw r0, 0x70(r1)
stw r0, 0x6c(r1)
stb r7, 0x6a(r1)
stb r7, 0x6b(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r31, r3, r3
bne lbl_801C3B98
lis r3, lbl_8047FFF4@ha
lis r5, lbl_80480008@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x6df
addi r5, r5, lbl_80480008@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3B98:
lha r4, 0x258(r31)
li r29, 0
lwz r3, 8(r1)
li r0, 1
stw r4, 0x5c(r1)
mr r28, r29
lwz r4, 0x40(r31)
stw r4, 0x54(r1)
stb r3, 0x62(r1)
stb r0, 0x68(r1)
stw r0, 0x6c(r1)
stw r0, 0x70(r1)
b lbl_801C3C30
lbl_801C3BCC:
lwz r3, 0x3d0(r30)
lwzx r31, r3, r28
mr r3, r31
lwz r12, 0(r31)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C3C28
mr r3, r31
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C3C28
lwz r3, mgr__Q24Game13PelletOtakara@sda21(r13)
lwz r4, 0x440(r31)
lwz r12, 0(r3)
lwz r12, 0x4c(r12)
mtctr r12
bctrl
mr r3, r31
addi r4, r1, 0x4c
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
b lbl_801C3C40
lbl_801C3C28:
addi r28, r28, 4
addi r29, r29, 1
lbl_801C3C30:
lwz r0, 0x3cc(r30)
cmpw r29, r0
blt lbl_801C3BCC
li r31, 0
lbl_801C3C40:
cmplwi r31, 0
beq lbl_801C3D54
lfs f1, 0x2c(r1)
mr r3, r31
lfs f0, lbl_80519570@sda21(r2)
addi r4, r1, 0x28
li r5, 0
fadds f0, f1, f0
stfs f0, 0x2c(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lwz r5, 0x28(r1)
lis r6, __vt__Q23efx5TBase@ha
lwz r0, 0x2c(r1)
lis r3, __vt__Q23efx3Arg@ha
lwz r4, 0x30(r1)
addi r8, r6, __vt__Q23efx5TBase@l
stw r5, 0x10(r1)
addi r6, r3, __vt__Q23efx3Arg@l
lfs f0, lbl_805194B8@sda21(r2)
lis r5, __vt__Q23efx13TEnemyApsmoke@ha
stw r0, 0x14(r1)
lis r3, __vt__Q23efx12ArgEnemyType@ha
lfs f3, 0x10(r1)
li r0, 1
stw r4, 0x18(r1)
addi r7, r5, __vt__Q23efx13TEnemyApsmoke@l
lfs f2, 0x14(r1)
addi r5, r3, __vt__Q23efx12ArgEnemyType@l
stw r8, 0xc(r1)
addi r3, r1, 0xc
lfs f1, 0x18(r1)
addi r4, r1, 0x34
stw r6, 0x34(r1)
stw r7, 0xc(r1)
stfs f3, 0x38(r1)
stfs f2, 0x3c(r1)
stfs f1, 0x40(r1)
stw r5, 0x34(r1)
stw r0, 0x44(r1)
stfs f0, 0x48(r1)
bl create__Q23efx13TEnemyApsmokeFPQ23efx3Arg
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xcc(r1)
lis r3, "zero__10Vector3<f>"@ha
lfs f1, lbl_805194A8@sda21(r2)
addi r4, r3, "zero__10Vector3<f>"@l
stw r0, 0xc8(r1)
addi r3, r1, 0x74
lfd f3, lbl_805194C8@sda21(r2)
addi r5, r1, 0x1c
lfd f0, 0xc8(r1)
lfs f2, lbl_805194F0@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_805194FC@sda21(r2)
stfs f1, 0x1c(r1)
fdivs f2, f3, f2
stfs f1, 0x24(r1)
fmuls f0, f0, f2
stfs f0, 0x20(r1)
bl "makeTR__7MatrixfFR10Vector3<f>R10Vector3<f>"
mr r3, r31
addi r4, r1, 0x74
bl setOrientation__Q24Game6PelletFR7Matrixf
lwz r3, 0x3c4(r30)
addi r0, r3, 1
stw r0, 0x3c4(r30)
b lbl_801C3D8C
lbl_801C3D54:
li r29, 0
li r28, 0
b lbl_801C3D80
lbl_801C3D60:
lwz r3, 0x3d0(r30)
lwzx r3, r3, r28
lwz r12, 0(r3)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
addi r28, r28, 4
addi r29, r29, 1
lbl_801C3D80:
lwz r0, 0x3cc(r30)
cmpw r29, r0
blt lbl_801C3D60
lbl_801C3D8C:
psq_l f31, 232(r1), 0, qr0
lwz r0, 0xf4(r1)
lfd f31, 0xe0(r1)
lwz r31, 0xdc(r1)
lwz r30, 0xd8(r1)
lwz r29, 0xd4(r1)
lwz r28, 0xd0(r1)
mtlr r0
addi r1, r1, 0xf0
blr
*/
}
/*
* --INFO--
* Address: 801C3DB4
* Size: 0001AC
*/
void VsGameSection::createYellowBedamas(int)
{
/*
stwu r1, -0x2b0(r1)
mflr r0
stw r0, 0x2b4(r1)
stmw r27, 0x29c(r1)
mr r30, r3
lis r3, lbl_8047FF98@ha
mr r31, r4
addi r28, r3, lbl_8047FF98@l
lwz r5, 0x33c(r30)
cmplwi r5, 0
beq lbl_801C3DF8
lwz r31, 0xb0(r5)
cmpwi r31, 0
beq lbl_801C3F4C
cmpwi r31, 7
blt lbl_801C3DF8
li r31, 7
lbl_801C3DF8:
lis r3, __vt__Q24Game15CreatureInitArg@ha
li r7, 0
addi r4, r3, __vt__Q24Game15CreatureInitArg@l
li r0, -1
lis r3, __vt__Q24Game13PelletInitArg@ha
stw r4, 0x18(r1)
addi r3, r3, __vt__Q24Game13PelletInitArg@l
li r6, 0xff
li r5, 1
stw r3, 0x18(r1)
lwz r3, cBedamaYellow__13VsOtakaraName@sda21(r13)
addi r4, r1, 8
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C3E74
addi r3, r28, 0x5c
addi r5, r28, 0x70
li r4, 0x86a
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3E74:
lha r0, 0x258(r29)
cmpwi r31, 0x32
lwz r4, 8(r1)
li r3, 1
stw r0, 0x28(r1)
li r0, 8
lwz r5, 0x40(r29)
stw r5, 0x20(r1)
stb r4, 0x2e(r1)
stw r3, 0x38(r1)
stw r0, 0x3c(r1)
ble lbl_801C3EBC
mr r6, r31
addi r3, r28, 0x5c
addi r5, r28, 0x17c
li r4, 0x873
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3EBC:
lis r4, "__ct__10Vector3<f>Fv"@ha
addi r3, r1, 0x40
addi r4, r4, "__ct__10Vector3<f>Fv"@l
li r5, 0
li r6, 0xc
li r7, 0x32
bl __construct_array
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
mr r5, r31
lfs f1, lbl_80519548@sda21(r2)
addi r4, r1, 0x40
lfs f2, lbl_8051954C@sda21(r2)
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFP10Vector3<f>iff"
mr r29, r30
addi r28, r1, 0x40
li r27, 0
b lbl_801C3F44
lbl_801C3F00:
lwz r3, pelletMgr__4Game@sda21(r13)
addi r4, r1, 0x18
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
lfs f2, 0(r28)
mr r30, r3
lfs f1, 4(r28)
addi r4, r1, 0xc
lfs f0, 8(r28)
li r5, 0
stfs f2, 0xc(r1)
stfs f1, 0x10(r1)
stfs f0, 0x14(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
stw r30, 0x388(r29)
addi r28, r28, 0xc
addi r29, r29, 4
addi r27, r27, 1
lbl_801C3F44:
cmpw r27, r31
blt lbl_801C3F00
lbl_801C3F4C:
lmw r27, 0x29c(r1)
lwz r0, 0x2b4(r1)
mtlr r0
addi r1, r1, 0x2b0
blr
*/
}
} // namespace Game
/*
* --INFO--
* Address: 801C3F60
* Size: 00014C
*/
void createRedBlueBedamas__Q24Game13VsGameSectionFR10Vector3f(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r5, __vt__Q24Game15CreatureInitArg@ha
stw r0, 0x64(r1)
stmw r26, 0x48(r1)
mr r28, r3
addi r29, r1, 0xc
addi r30, r5, __vt__Q24Game15CreatureInitArg@l
li r27, 0
lwz r4, lbl_80520E70@sda21(r2)
lwz r0, lbl_80520E74@sda21(r2)
stw r4, 0xc(r1)
lis r4, __vt__Q24Game13PelletInitArg@ha
lwz r6, cBedamaRed__13VsOtakaraName@sda21(r13)
addi r31, r4, __vt__Q24Game13PelletInitArg@l
stw r0, 0x10(r1)
lwz r0, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r6, 0xc(r1)
stw r0, 0x10(r1)
lbl_801C3FAC:
stw r30, 0x20(r1)
li r7, 0
li r0, -1
li r6, 0xff
li r5, 1
stw r31, 0x20(r1)
lwz r3, 0(r29)
addi r4, r1, 8
stb r7, 0x3c(r1)
sth r7, 0x34(r1)
stb r6, 0x36(r1)
stw r7, 0x38(r1)
stb r7, 0x37(r1)
stb r5, 0x24(r1)
stb r7, 0x3d(r1)
stw r0, 0x44(r1)
stw r0, 0x40(r1)
stb r7, 0x3e(r1)
stb r7, 0x3f(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r26, r3, r3
bne lbl_801C4020
lis r3, lbl_8047FFF4@ha
lis r5, lbl_80480008@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x8a3
addi r5, r5, lbl_80480008@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C4020:
lha r3, 0x258(r26)
li r5, 1
lwz r6, 8(r1)
li r0, 8
stw r3, 0x30(r1)
addi r4, r1, 0x20
lwz r3, pelletMgr__4Game@sda21(r13)
lwz r7, 0x40(r26)
stw r7, 0x28(r1)
stb r6, 0x36(r1)
stw r5, 0x40(r1)
stw r0, 0x44(r1)
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
mr r0, r3
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
lfs f1, lbl_80519524@sda21(r2)
mr r26, r0
lfs f2, lbl_80519528@sda21(r2)
addi r4, r1, 0x14
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFR10Vector3<f>ff"
mr r3, r26
addi r4, r1, 0x14
li r5, 0
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
addi r27, r27, 1
stw r26, 0x380(r28)
cmpwi r27, 2
addi r29, r29, 4
addi r28, r28, 4
blt lbl_801C3FAC
lmw r26, 0x48(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
namespace Game {
/*
* --INFO--
* Address: 801C40AC
* Size: 000814
*/
void VsGameSection::calcVsScores(void)
{
/*
stwu r1, -0x180(r1)
mflr r0
stw r0, 0x184(r1)
stfd f31, 0x170(r1)
psq_st f31, 376(r1), 0, qr0
stfd f30, 0x160(r1)
psq_st f30, 360(r1), 0, qr0
stfd f29, 0x150(r1)
psq_st f29, 344(r1), 0, qr0
stmw r22, 0x128(r1)
mr r29, r3
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
li r4, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
stw r3, 0x18(r1)
li r4, 0
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
bl getOnyon__Q34Game9ItemOnyon3MgrFi
addi r31, r1, 0xa8
addi r30, r1, 0x8c
stw r3, 0x1c(r1)
mr r28, r29
mr r27, r31
mr r26, r30
mr r25, r3
li r24, 0
lbl_801C4114:
lwz r23, 0x388(r28)
cmplwi r23, 0
beq lbl_801C4308
mr r3, r23
lwz r12, 0(r23)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C4308
mr r3, r23
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C4308
mr r3, r23
li r22, -1
lwz r12, 0(r23)
lwz r12, 0x204(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C4194
lwz r0, 0x3d4(r23)
cmpwi r0, 1
beq lbl_801C4188
bge lbl_801C4194
cmpwi r0, 0
bge lbl_801C4190
b lbl_801C4194
lbl_801C4188:
li r22, 0
b lbl_801C4194
lbl_801C4190:
li r22, 1
lbl_801C4194:
mr r4, r23
addi r3, r1, 0x80
lwz r12, 0(r23)
lwz r12, 8(r12)
mtctr r12
bctrl
lwz r4, 0x18(r1)
addi r3, r1, 0x74
lfs f30, 0x80(r1)
lwz r12, 0(r4)
lfs f29, 0x88(r1)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x7c(r1)
lfs f1, 0x74(r1)
fsubs f3, f29, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f30, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4200
ble lbl_801C4204
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4204
lbl_801C4200:
fmr f31, f0
lbl_801C4204:
mr r4, r25
addi r3, r1, 0x68
lwz r12, 0(r25)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x70(r1)
lfs f1, 0x68(r1)
fsubs f3, f29, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f30, f1
fmuls f1, f3, f3
fmadds f3, f2, f2, f1
fcmpo cr0, f3, f0
ble lbl_801C4250
ble lbl_801C4254
frsqrte f0, f3
fmuls f3, f0, f3
b lbl_801C4254
lbl_801C4250:
fmr f3, f0
lbl_801C4254:
fadds f1, f31, f3
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f3, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
lwz r0, 0xb8(r23)
li r3, 0
fadds f0, f1, f0
cmplwi r0, 0
fdivs f3, f1, f0
beq lbl_801C4294
li r3, 1
lbl_801C4294:
clrlwi. r0, r3, 0x18
bne lbl_801C42E8
cmpwi r22, -1
bne lbl_801C42B8
lfs f0, lbl_805194B8@sda21(r2)
stfs f3, 0(r27)
fsubs f0, f0, f3
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42B8:
cmpwi r22, 0
bne lbl_801C42D0
lfs f0, lbl_805194A8@sda21(r2)
stfs f3, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42D0:
lfs f0, lbl_805194B8@sda21(r2)
lfs f1, lbl_805194A8@sda21(r2)
fsubs f0, f0, f3
stfs f1, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42E8:
lfs f0, lbl_805194B8@sda21(r2)
lfs f2, lbl_8051952C@sda21(r2)
fsubs f0, f0, f3
fmuls f1, f2, f3
fmuls f0, f2, f0
stfs f1, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C4308:
lfs f0, lbl_80519578@sda21(r2)
stfs f0, 0(r27)
stfs f0, 0(r26)
lbl_801C4314:
addi r24, r24, 1
addi r27, r27, 4
cmpwi r24, 7
addi r26, r26, 4
addi r28, r28, 4
blt lbl_801C4114
lfs f3, lbl_805194A8@sda21(r2)
mr r7, r29
lfd f4, lbl_805194C8@sda21(r2)
addi r8, r1, 0x10
lfs f2, lbl_8051957C@sda21(r2)
li r9, 0
lfs f1, lbl_80519580@sda21(r2)
lis r3, 0x4330
lbl_801C434C:
lwz r4, 0x3dc(r7)
li r0, 7
stw r3, 0x118(r1)
mr r5, r31
xoris r4, r4, 0x8000
mr r6, r30
stw r4, 0x11c(r1)
lfd f0, 0x118(r1)
fsubs f5, f0, f4
mtctr r0
lbl_801C4374:
cmpwi r9, 0
bne lbl_801C4390
lfs f0, 0(r5)
fcmpo cr0, f0, f3
cror 2, 1, 2
bne lbl_801C4390
fadds f5, f5, f0
lbl_801C4390:
cmpwi r9, 1
bne lbl_801C43AC
lfs f0, 0(r6)
fcmpo cr0, f0, f3
cror 2, 1, 2
bne lbl_801C43AC
fadds f5, f5, f0
lbl_801C43AC:
addi r5, r5, 4
addi r6, r6, 4
bdnz lbl_801C4374
fcmpo cr0, f5, f2
cror 2, 1, 2
bne lbl_801C43C8
fmr f5, f2
lbl_801C43C8:
fmuls f5, f5, f1
addi r9, r9, 1
cmpwi r9, 2
stfs f5, 0(r8)
lfs f0, 0(r8)
addi r8, r8, 4
stfs f0, 0x370(r7)
addi r7, r7, 4
blt lbl_801C434C
lwz r3, lbl_80520E78@sda21(r2)
mr r25, r29
lwz r0, lbl_80520E7C@sda21(r2)
addi r26, r1, 0x18
stw r3, 8(r1)
addi r27, r1, 8
li r22, 0
stw r0, 0xc(r1)
lbl_801C440C:
lwz r4, 0x380(r25)
lwz r23, 0(r26)
cmplwi r4, 0
beq lbl_801C451C
lwz r12, 0(r4)
addi r3, r1, 0x5c
lwz r12, 8(r12)
mtctr r12
bctrl
mr r4, r23
addi r3, r1, 0x50
lwz r12, 0(r23)
lfs f29, 0x5c(r1)
lwz r12, 8(r12)
lfs f30, 0x64(r1)
mtctr r12
bctrl
lfs f0, 0x58(r1)
lfs f1, 0x50(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4484
ble lbl_801C4488
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4488
lbl_801C4484:
fmr f31, f0
lbl_801C4488:
subfic r0, r22, 1
addi r4, r1, 0x18
slwi r0, r0, 2
addi r3, r1, 0x44
lwzx r4, r4, r0
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x4c(r1)
lfs f1, 0x44(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f1, f2, f2, f1
fcmpo cr0, f1, f0
ble lbl_801C44E0
ble lbl_801C44E4
frsqrte f0, f1
fmuls f1, f0, f1
b lbl_801C44E4
lbl_801C44E0:
fmr f1, f0
lbl_801C44E4:
fadds f1, f31, f1
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f31, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
fadds f0, f1, f0
fdivs f0, f1, f0
stfs f0, 0(r27)
lfs f0, 0(r27)
stfs f0, 0x378(r25)
lbl_801C451C:
addi r22, r22, 1
addi r26, r26, 4
cmpwi r22, 2
addi r27, r27, 4
addi r25, r25, 4
blt lbl_801C440C
lfs f3, 0x10(r1)
addi r28, r1, 0xec
lfs f0, 0x14(r1)
addi r30, r1, 0xc4
lfs f2, 8(r1)
mr r26, r28
fsubs f1, f3, f0
lfs f4, 0xc(r1)
fsubs f0, f0, f3
mr r27, r30
li r22, 0
li r25, 0
fsubs f1, f1, f2
fsubs f0, f0, f4
fadds f1, f4, f1
fadds f0, f2, f0
stfs f1, 0x358(r29)
stfs f0, 0x35c(r29)
lbl_801C457C:
lwz r3, 0x3d0(r29)
lwzx r23, r3, r25
mr r3, r23
lwz r12, 0(r23)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C476C
mr r3, r23
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C476C
mr r3, r23
li r24, -1
lwz r12, 0(r23)
lwz r12, 0x204(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C45F8
lwz r0, 0x3d4(r23)
cmpwi r0, 1
beq lbl_801C45EC
bge lbl_801C45F8
cmpwi r0, 0
bge lbl_801C45F4
b lbl_801C45F8
lbl_801C45EC:
li r24, 0
b lbl_801C45F8
lbl_801C45F4:
li r24, 1
lbl_801C45F8:
mr r4, r23
addi r3, r1, 0x38
lwz r12, 0(r23)
lwz r12, 8(r12)
mtctr r12
bctrl
lwz r4, 0x18(r1)
addi r3, r1, 0x2c
lfs f29, 0x38(r1)
lwz r12, 0(r4)
lfs f30, 0x40(r1)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x34(r1)
lfs f1, 0x2c(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4664
ble lbl_801C4668
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4668
lbl_801C4664:
fmr f31, f0
lbl_801C4668:
lwz r4, 0x1c(r1)
addi r3, r1, 0x20
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x28(r1)
lfs f1, 0x20(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f3, f2, f2, f1
fcmpo cr0, f3, f0
ble lbl_801C46B4
ble lbl_801C46B8
frsqrte f0, f3
fmuls f3, f0, f3
b lbl_801C46B8
lbl_801C46B4:
fmr f3, f0
lbl_801C46B8:
fadds f1, f31, f3
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f3, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
lwz r0, 0xb8(r23)
li r3, 0
fadds f0, f1, f0
cmplwi r0, 0
fdivs f3, f1, f0
beq lbl_801C46F8
li r3, 1
lbl_801C46F8:
clrlwi. r0, r3, 0x18
bne lbl_801C474C
cmpwi r24, -1
bne lbl_801C471C
lfs f0, lbl_805194B8@sda21(r2)
stfs f3, 0(r26)
fsubs f0, f0, f3
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C471C:
cmpwi r24, 0
bne lbl_801C4734
lfs f0, lbl_805194A8@sda21(r2)
stfs f3, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C4734:
lfs f0, lbl_805194B8@sda21(r2)
lfs f1, lbl_805194A8@sda21(r2)
fsubs f0, f0, f3
stfs f1, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C474C:
lfs f0, lbl_805194B8@sda21(r2)
lfs f2, lbl_8051952C@sda21(r2)
fsubs f0, f0, f3
fmuls f1, f2, f3
fmuls f0, f2, f0
stfs f1, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C476C:
lfs f0, lbl_80519578@sda21(r2)
stfs f0, 0(r26)
stfs f0, 0(r27)
lbl_801C4778:
addi r22, r22, 1
addi r26, r26, 4
cmpwi r22, 0xa
addi r27, r27, 4
addi r25, r25, 4
blt lbl_801C457C
lfs f1, lbl_805194A8@sda21(r2)
mr r5, r29
li r6, 0
lbl_801C479C:
fmr f3, f1
li r0, 5
mr r3, r28
mr r4, r30
stfs f1, 0x368(r5)
li r7, 0
mtctr r0
lbl_801C47B8:
cmpwi r6, 0
lfs f4, lbl_805194A8@sda21(r2)
bne lbl_801C47DC
lfs f0, 0(r3)
fcmpo cr0, f0, f4
cror 2, 1, 2
bne lbl_801C47DC
fadds f3, f3, f0
fmr f4, f0
lbl_801C47DC:
cmpwi r6, 1
bne lbl_801C4800
lfs f2, 0(r4)
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f2, f0
cror 2, 1, 2
bne lbl_801C4800
fadds f3, f3, f2
fmr f4, f2
lbl_801C4800:
lfs f0, 0x368(r5)
fcmpo cr0, f0, f4
cror 2, 0, 2
bne lbl_801C4814
stfs f4, 0x368(r5)
lbl_801C4814:
cmpwi r6, 0
lfs f4, lbl_805194A8@sda21(r2)
bne lbl_801C4838
lfs f0, 4(r3)
fcmpo cr0, f0, f4
cror 2, 1, 2
bne lbl_801C4838
fadds f3, f3, f0
fmr f4, f0
lbl_801C4838:
cmpwi r6, 1
bne lbl_801C485C
lfs f2, 4(r4)
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f2, f0
cror 2, 1, 2
bne lbl_801C485C
fadds f3, f3, f2
fmr f4, f2
lbl_801C485C:
lfs f0, 0x368(r5)
fcmpo cr0, f0, f4
cror 2, 0, 2
bne lbl_801C4870
stfs f4, 0x368(r5)
lbl_801C4870:
addi r3, r3, 8
addi r4, r4, 8
addi r7, r7, 1
bdnz lbl_801C47B8
addi r6, r6, 1
stfs f3, 0x360(r5)
cmpwi r6, 2
addi r5, r5, 4
blt lbl_801C479C
psq_l f31, 376(r1), 0, qr0
lfd f31, 0x170(r1)
psq_l f30, 360(r1), 0, qr0
lfd f30, 0x160(r1)
psq_l f29, 344(r1), 0, qr0
lfd f29, 0x150(r1)
lmw r22, 0x128(r1)
lwz r0, 0x184(r1)
mtlr r0
addi r1, r1, 0x180
blr
*/
}
/*
* --INFO--
* Address: 801C48C0
* Size: 000018
*/
void VsGameSection::clearGetDopeCount(void)
{
/*
li r0, 0
stw r0, 0x3b0(r3)
stw r0, 0x3ac(r3)
stw r0, 0x3a8(r3)
stw r0, 0x3a4(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C48D8
* Size: 0000D0
*/
void VsGameSection::getGetDopeCount(int, int)
{
/*
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
li r0, 0
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
mr r30, r5
stw r29, 0x14(r1)
or. r29, r4, r4
lis r4, lbl_8047FF98@ha
stw r28, 0x10(r1)
mr r28, r3
addi r31, r4, lbl_8047FF98@l
blt lbl_801C491C
cmpwi r29, 1
bgt lbl_801C491C
li r0, 1
lbl_801C491C:
clrlwi. r0, r0, 0x18
bne lbl_801C493C
mr r6, r29
addi r3, r31, 0x5c
addi r5, r31, 0x188
li r4, 0xa07
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C493C:
cmpwi r30, 0
li r0, 0
blt lbl_801C4954
cmpwi r30, 1
bgt lbl_801C4954
li r0, 1
lbl_801C4954:
clrlwi. r0, r0, 0x18
bne lbl_801C4974
mr r6, r30
addi r3, r31, 0x5c
addi r5, r31, 0x198
li r4, 0xa08
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C4974:
slwi r3, r29, 3
slwi r0, r30, 2
add r3, r3, r0
addi r3, r3, 0x3a4
add r3, r28, r3
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C49A8
* Size: 000010
*/
void VsGameSection::clearGetCherryCount(void)
{
/*
li r0, 0
stw r0, 0x3b8(r3)
stw r0, 0x3b4(r3)
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 00007C
*/
u32 VsGameSection::getGetCherryCount(int playerIndex)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C49B8
* Size: 000008
*/
bool VsGameSection::challengeDisablePelplant(void) { return false; }
/*
* --INFO--
* Address: 801C49C0
* Size: 000008
*/
bool VsGameSection::player2enabled(void) { return true; }
/*
* --INFO--
* Address: 801C49C8
* Size: 000008
*/
char* VsGameSection::getCaveFilename(void)
{
/*
addi r3, r3, 0x224
blr
*/
}
/*
* --INFO--
* Address: 801C49D0
* Size: 000008
*/
void VsGameSection::getEditorFilename(void)
{
/*
addi r3, r3, 0x2a4
blr
*/
}
/*
* --INFO--
* Address: 801C49D8
* Size: 000008
*/
void VsGameSection::getVsEditNumber(void)
{
/*
lwz r3, 0x328(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C49E0
* Size: 000004
*/
void init__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
} // namespace Game
/*
* --INFO--
* Address: 801C49E4
* Size: 000064
*/
void create__Q24Game36StateMachine<Game::VsGameSection> Fi(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
li r0, 0
stw r31, 0xc(r1)
mr r31, r3
stw r4, 0xc(r3)
stw r0, 8(r3)
lwz r0, 0xc(r3)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 4(r31)
lwz r0, 0xc(r31)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x10(r31)
lwz r0, 0xc(r31)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x14(r31)
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C4A48
* Size: 00009C
*/
void transit__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSectioniPQ24Game8StateArg(void)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
rlwinm r0,r5,2,0,29
stmw r27, 0xC(r1)
mr r27, r3
mr r28, r4
mr r29, r6
lwz r30, 0x180(r4)
lwz r3, 0x14(r3)
cmplwi r30, 0
lwzx r31, r3, r0
beq- .loc_0x50
mr r3, r30
lwz r12, 0x0(r30)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lwz r0, 0x4(r30)
stw r0, 0x18(r27)
.loc_0x50:
lwz r0, 0xC(r27)
cmpw r31, r0
blt- .loc_0x60
.loc_0x5C:
b .loc_0x5C
.loc_0x60:
lwz r3, 0x4(r27)
rlwinm r0,r31,2,0,29
mr r4, r28
mr r5, r29
lwzx r3, r3, r0
stw r3, 0x180(r28)
lwz r12, 0x0(r3)
lwz r12, 0x8(r12)
mtctr r12
bctrl
lmw r27, 0xC(r1)
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C4AE4
* Size: 000004
*/
void init__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSectionPQ24Game8StateArg(void) { }
/*
* --INFO--
* Address: 801C4AE8
* Size: 000004
*/
void cleanup__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
/*
* --INFO--
* Address: 801C4AEC
* Size: 000084
*/
void registerState__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game32FSMState<Game::VsGameSection>(void)
{
/*
.loc_0x0:
lwz r6, 0x8(r3)
lwz r0, 0xC(r3)
cmpw r6, r0
bgelr-
lwz r5, 0x4(r3)
rlwinm r0,r6,2,0,29
stwx r4, r5, r0
lwz r5, 0x4(r4)
cmpwi r5, 0
blt- .loc_0x34
lwz r0, 0xC(r3)
cmpw r5, r0
blt- .loc_0x3C
.loc_0x34:
li r0, 0
b .loc_0x40
.loc_0x3C:
li r0, 0x1
.loc_0x40:
rlwinm. r0,r0,0,24,31
beqlr-
stw r3, 0x8(r4)
lwz r0, 0x8(r3)
lwz r6, 0x4(r4)
lwz r5, 0x10(r3)
rlwinm r0,r0,2,0,29
stwx r6, r5, r0
lwz r0, 0x4(r4)
lwz r5, 0x8(r3)
lwz r4, 0x14(r3)
rlwinm r0,r0,2,0,29
stwx r5, r4, r0
lwz r4, 0x8(r3)
addi r0, r4, 0x1
stw r0, 0x8(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C4B70
* Size: 000038
*/
void exec__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSection(void)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r3, 0x180(r4)
cmplwi r3, 0
beq- .loc_0x28
lwz r12, 0x0(r3)
lwz r12, 0xC(r12)
mtctr r12
bctrl
.loc_0x28:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C4BA8
* Size: 000004
*/
void exec__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
/*
* --INFO--
* Address: 801C4BAC
* Size: 000028
*/
void __sinit_vsGameSection_cpp(void)
{
/*
lis r4, __float_nan@ha
li r0, -1
lfs f0, __float_nan@l(r4)
lis r3, lbl_804B60E8@ha
stw r0, lbl_80515A88@sda21(r13)
stfsu f0, lbl_804B60E8@l(r3)
stfs f0, lbl_80515A8C@sda21(r13)
stfs f0, 4(r3)
stfs f0, 8(r3)
blr
*/
}
| 21.726418 | 109 | 0.596313 |
de6d3617beacfb1559a28d796d311db01954a766 | 687 | cpp | C++ | CastleDoctrine/gameSource/sharedServerSecret.cpp | PhilipLudington/CastleDoctrine | 443f2b6b0215a6d71515c8887c99b4322965622e | [
"Unlicense"
] | 1 | 2020-01-16T00:07:11.000Z | 2020-01-16T00:07:11.000Z | CastleDoctrine/gameSource/sharedServerSecret.cpp | PhilipLudington/CastleDoctrine | 443f2b6b0215a6d71515c8887c99b4322965622e | [
"Unlicense"
] | null | null | null | CastleDoctrine/gameSource/sharedServerSecret.cpp | PhilipLudington/CastleDoctrine | 443f2b6b0215a6d71515c8887c99b4322965622e | [
"Unlicense"
] | 2 | 2019-09-17T12:08:20.000Z | 2020-09-26T00:54:48.000Z |
// you can replace this string before building the client in order to
// match the shared secret that the server is expecting.
// Please don't abuse your power to do this.
// Remember that this is an indie game made entirely by one guy and being
// run on a shoestring budget server. Making a truly "secure" game, where
// every move happens on the server, would exceed the resources that I had
// available.
// If any mod that you're building might give you a questionable advantage,
// please don't connect to the main server with that mod.
const char *sharedServerSecret = "This is an example secret. You probably cannot connect to the main server without replacing this.";
| 36.157895 | 134 | 0.755459 |
de70f85d4eeb1240a8026a6a5965668e45e018c7 | 4,633 | cpp | C++ | Samples/Simple.cpp | QtExcel/QSimpleXlsxWriter | da96975bfd089fcb779fd871c9075e097a8373c0 | [
"MIT"
] | 13 | 2019-02-15T06:16:30.000Z | 2022-02-17T04:58:49.000Z | Samples/Simple.cpp | umaysahan/QSimpleXlsxWriter | da96975bfd089fcb779fd871c9075e097a8373c0 | [
"MIT"
] | 1 | 2019-01-13T07:12:26.000Z | 2019-01-13T09:58:27.000Z | Samples/Simple.cpp | umaysahan/QSimpleXlsxWriter | da96975bfd089fcb779fd871c9075e097a8373c0 | [
"MIT"
] | 6 | 2019-07-19T01:45:48.000Z | 2021-03-17T09:57:59.000Z | #include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <vector>
#include <Xlsx/Workbook.h>
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef QT_CORE_LIB
#include <QDateTime>
#endif
using namespace SimpleXlsx;
int main()
{
setlocale( LC_ALL, "" );
time_t CurTime = time( NULL );
CWorkbook book( "Incognito" );
std::vector<ColumnWidth> ColWidth;
ColWidth.push_back( ColumnWidth( 0, 3, 25 ) );
CWorksheet & Sheet = book.AddSheet( "Unicode", ColWidth );
Style style;
style.horizAlign = ALIGN_H_CENTER;
style.font.attributes = FONT_BOLD;
const size_t CenterStyleIndex = book.AddStyle( style );
Sheet.BeginRow();
Sheet.AddCell( "Common test of Unicode support", CenterStyleIndex );
Sheet.MergeCells( CellCoord( 1, 0 ), CellCoord( 1, 3 ) );
Sheet.EndRow();
Font TmpFont = book.GetFonts().front();
TmpFont.attributes = FONT_ITALIC;
Comment Com;
Com.x = 300;
Com.y = 100;
Com.width = 100;
Com.height = 30;
Com.cellRef = CellCoord( 8, 1 );
Com.isHidden = false;
Com.AddContent( TmpFont, "Comment with custom style" );
Sheet.AddComment( Com );
Sheet.BeginRow().AddCell( "English language" ).AddCell( "English language" ).EndRow();
Sheet.BeginRow().AddCell( "Russian language" ).AddCell( L"Русский язык" ).EndRow();
Sheet.BeginRow().AddCell( "Chinese language" ).AddCell( L"中文" ).EndRow();
Sheet.BeginRow().AddCell( "French language" ).AddCell( L"le français" ).EndRow();
Sheet.BeginRow().AddCell( "Arabic language" ).AddCell( L"العَرَبِيَّة" ).EndRow();
Sheet.AddEmptyRow();
style.fill.patternType = PATTERN_NONE;
style.font.theme = true;
style.horizAlign = ALIGN_H_RIGHT;
style.vertAlign = ALIGN_V_CENTER;
style.numFormat.numberStyle = NUMSTYLE_MONEY;
const size_t MoneyStyleIndex = book.AddStyle( style );
Sheet.BeginRow().AddCell( "Money symbol" ).AddCell( 123.45, MoneyStyleIndex ).EndRow();
Style stPanel;
stPanel.border.top.style = BORDER_THIN;
stPanel.border.bottom.color = "FF000000";
stPanel.fill.patternType = PATTERN_SOLID;
stPanel.fill.fgColor = "FFCCCCFF";
const size_t PanelStyleIndex = book.AddStyle( stPanel );
Sheet.AddEmptyRow().BeginRow();
Sheet.AddCell( "Cells with border", PanelStyleIndex );
Sheet.AddCell( "", PanelStyleIndex ).AddCell( "", PanelStyleIndex ).AddCell( "", PanelStyleIndex );
Sheet.EndRow();
style.numFormat.numberStyle = NUMSTYLE_DATETIME;
style.font.attributes = FONT_NORMAL;
style.horizAlign = ALIGN_H_LEFT;
const size_t DateTimeStyleIndex = book.AddStyle( style );
Sheet.AddEmptyRow().AddSimpleRow( "time_t", CenterStyleIndex );
Sheet.AddSimpleRow( CellDataTime( CurTime, DateTimeStyleIndex ) );
Style stRotated;
stRotated.horizAlign = EAlignHoriz::ALIGN_H_CENTER;
stRotated.vertAlign = EAlignVert::ALIGN_V_CENTER;
stRotated.textRotation = 45;
const size_t RotatedStyleIndex = book.AddStyle( stRotated );
Sheet.AddSimpleRow( "Rotated text", RotatedStyleIndex, 3, 20 );
Sheet.MergeCells( CellCoord( 14, 3 ), CellCoord( 19, 3 ) );
/* Be careful with the style of date and time.
* If milliseconds are specified, then the style used should take them into account.
* Otherwise, Excel will round milliseconds and may change seconds.
* See example below. */
style.numFormat.formatString = "yyyy.mm.dd hh:mm:ss.000";
const size_t CustomDateTimeStyleIndex = book.AddStyle( style );
Sheet.AddSimpleRow( "Direct date and time", CenterStyleIndex );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 500, CustomDateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 500, DateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 499, CustomDateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 499, DateTimeStyleIndex ) );
#ifdef _WIN32
Sheet.AddEmptyRow().AddSimpleRow( "Windows SYSTEMTIME", CenterStyleIndex );
SYSTEMTIME lt;
GetLocalTime( & lt );
Sheet.AddSimpleRow( CellDataTime( lt, CustomDateTimeStyleIndex ) );
#endif
#if defined( QT_VERSION ) && ( QT_VERSION >= 0x040000 )
Sheet.AddEmptyRow().AddSimpleRow( "Qt QDateTime", CenterStyleIndex );
const QDateTime CurDT = QDateTime::currentDateTime();
Sheet.AddSimpleRow( CellDataTime( CurDT, CustomDateTimeStyleIndex ) );
#endif
if( book.Save( "Simple.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
else std::cout << "The book saving has been failed" << std::endl;
return 0;
}
| 37.666667 | 103 | 0.690481 |
de73b5485234ba8ed43297cd580bd6f40f60d4bd | 572 | cc | C++ | atcoder/arc/007/b_maigo_no_cd_case.cc | boobam0618/competitive-programming | 0341bd8bb240b1ed0d84cc60db91508242fc867b | [
"MIT"
] | null | null | null | atcoder/arc/007/b_maigo_no_cd_case.cc | boobam0618/competitive-programming | 0341bd8bb240b1ed0d84cc60db91508242fc867b | [
"MIT"
] | 32 | 2019-08-15T09:16:48.000Z | 2020-02-09T16:23:30.000Z | atcoder/arc/007/b_maigo_no_cd_case.cc | boobam0618/competitive-programming | 0341bd8bb240b1ed0d84cc60db91508242fc867b | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
int main() {
int cd_case_num, listen_cd_num;
std::cin >> cd_case_num >> listen_cd_num;
std::vector<int> cds(cd_case_num);
for (int i = 0; i < cd_case_num; ++i) {
cds.at(i) = i + 1;
}
int current = 0;
for (int i = 0; i < listen_cd_num; ++i) {
int listen_cd;
std::cin >> listen_cd;
for (int j = 0; j < cd_case_num; ++j) {
if (cds.at(j) == listen_cd) {
std::swap(current, cds.at(j));
}
}
}
for (int i = 0; i < cd_case_num; ++i) {
std::cout << cds.at(i) << std::endl;
}
}
| 22 | 43 | 0.536713 |
de742378fbcc59e333009e743335a1b22585d443 | 2,594 | cpp | C++ | outdated/tests/io_copy.cpp | pjsaksa/x0 | 96b69e5a54b006e3d929b9934c2708f7967371bb | [
"MIT"
] | 24 | 2016-07-10T08:05:11.000Z | 2021-11-16T10:53:48.000Z | outdated/tests/io_copy.cpp | pjsaksa/x0 | 96b69e5a54b006e3d929b9934c2708f7967371bb | [
"MIT"
] | 14 | 2015-04-12T10:45:26.000Z | 2016-06-28T22:27:50.000Z | outdated/tests/io_copy.cpp | pjsaksa/x0 | 96b69e5a54b006e3d929b9934c2708f7967371bb | [
"MIT"
] | 4 | 2016-10-05T17:51:38.000Z | 2020-04-20T07:45:23.000Z | // This file is part of the "x0" project, http://xzero.io/
// (c) 2009-2018 Christian Parpart <christian@parpart.family>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT
#include <x0/io/source.hpp>
#include <x0/io/fd_source.hpp>
#include <x0/io/file_source.hpp>
#include <x0/io/sink.hpp>
#include <x0/io/file_sink.hpp>
#include <x0/io/filter.hpp>
#include <x0/io/null_filter.hpp>
#include <x0/io/uppercase_filter.hpp>
#include <x0/io/CompressFilter.h>
#include <x0/io/chain_filter.hpp>
#include <x0/io/pump.hpp>
#include <iostream>
#include <memory>
#include <getopt.h>
inline x0::file_ptr getfile(const std::string ifname) {
return x0::file_ptr(new x0::File(x0::FileInfoPtr(new x0::FileInfo(ifname))));
}
int main(int argc, char *argv[]) {
struct option options[] = {{"input", required_argument, 0, 'i'},
{"output", required_argument, 0, 'o'},
{"gzip", no_argument, 0, 'c'},
{"uppercase", no_argument, 0, 'U'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}};
std::string ifname("-");
std::string ofname("-");
x0::chain_filter cf;
for (bool done = false; !done;) {
int index = 0;
int rv = (getopt_long(argc, argv, "i:o:hUc", options, &index));
switch (rv) {
case 'i':
ifname = optarg;
break;
case 'o':
ofname = optarg;
break;
case 'U':
cf.push_back(x0::filter_ptr(new x0::uppercase_filter()));
break;
case 'c':
cf.push_back(x0::filter_ptr(new x0::CompressFilter()));
break;
case 'h':
std::cerr << "usage: " << argv[0] << " INPUT OUTPUT [-u]" << std::endl
<< " where INPUT and OUTPUT can be '-' to be interpreted as "
"stdin/stdout respectively." << std::endl;
return 0;
case 0:
break;
case -1:
done = true;
break;
default:
std::cerr << "syntax error: "
<< "(" << rv << ")" << std::endl;
return 1;
}
}
x0::source_ptr input(ifname == "-" ? new x0::fd_source(STDIN_FILENO)
: new x0::file_source(getfile(ifname)));
x0::sink_ptr output(ofname == "-" ? new x0::fd_sink(STDOUT_FILENO)
: new x0::file_sink(ofname));
pump(*input, *output, cf);
return 0;
}
| 30.162791 | 80 | 0.543562 |
de779371a7cf848da1afcdcfd9208f0abfc7a65d | 1,931 | cc | C++ | runtime/vm/datastream.cc | wennyyustalim/sdk | e6ffc0b285fb393ba04c4afa35f9a7eae0e05793 | [
"BSD-3-Clause"
] | 3 | 2020-04-20T00:11:34.000Z | 2022-01-24T20:43:43.000Z | runtime/vm/datastream.cc | wennyyustalim/sdk | e6ffc0b285fb393ba04c4afa35f9a7eae0e05793 | [
"BSD-3-Clause"
] | 4 | 2020-04-20T11:16:42.000Z | 2020-04-20T11:18:30.000Z | runtime/vm/datastream.cc | wennyyustalim/sdk | e6ffc0b285fb393ba04c4afa35f9a7eae0e05793 | [
"BSD-3-Clause"
] | 3 | 2020-02-13T02:08:04.000Z | 2020-08-09T07:49:55.000Z | // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/datastream.h"
namespace dart {
StreamingWriteStream::StreamingWriteStream(intptr_t initial_capacity,
Dart_StreamingWriteCallback callback,
void* callback_data)
: flushed_size_(0), callback_(callback), callback_data_(callback_data) {
buffer_ = reinterpret_cast<uint8_t*>(malloc(initial_capacity));
if (buffer_ == NULL) {
OUT_OF_MEMORY();
}
cursor_ = buffer_;
limit_ = buffer_ + initial_capacity;
}
StreamingWriteStream::~StreamingWriteStream() {
Flush();
free(buffer_);
}
void StreamingWriteStream::VPrint(const char* format, va_list args) {
// Measure.
va_list measure_args;
va_copy(measure_args, args);
intptr_t len = Utils::VSNPrint(NULL, 0, format, measure_args);
va_end(measure_args);
// Alloc.
EnsureAvailable(len + 1);
// Print.
va_list print_args;
va_copy(print_args, args);
Utils::VSNPrint(reinterpret_cast<char*>(cursor_), len + 1, format,
print_args);
va_end(print_args);
cursor_ += len; // Not len + 1 to swallow the terminating NUL.
}
void StreamingWriteStream::EnsureAvailableSlowPath(intptr_t needed) {
Flush();
intptr_t available = limit_ - cursor_;
if (available >= needed) return;
intptr_t new_capacity = Utils::RoundUp(needed, 64 * KB);
free(buffer_);
buffer_ = reinterpret_cast<uint8_t*>(malloc(new_capacity));
if (buffer_ == NULL) {
OUT_OF_MEMORY();
}
cursor_ = buffer_;
limit_ = buffer_ + new_capacity;
}
void StreamingWriteStream::Flush() {
intptr_t size = cursor_ - buffer_;
callback_(callback_data_, buffer_, size);
flushed_size_ += size;
cursor_ = buffer_;
}
} // namespace dart
| 27.985507 | 80 | 0.683584 |
de77a51807f0b0b0d4e3577cd24d13557acf9458 | 324 | cpp | C++ | pgf+/src/reader/Expr.cpp | egladil/mscthesis | d6f0c9b1b1e73b749894405372f2edf01e746920 | [
"BSD-2-Clause"
] | 1 | 2019-05-03T18:00:39.000Z | 2019-05-03T18:00:39.000Z | pgf+/src/reader/Expr.cpp | egladil/mscthesis | d6f0c9b1b1e73b749894405372f2edf01e746920 | [
"BSD-2-Clause"
] | null | null | null | pgf+/src/reader/Expr.cpp | egladil/mscthesis | d6f0c9b1b1e73b749894405372f2edf01e746920 | [
"BSD-2-Clause"
] | null | null | null | //
// Expr.cpp
// pgf+
//
// Created by Emil Djupfeldt on 2012-06-26.
// Copyright (c) 2012 Chalmers University of Technology. All rights reserved.
//
#include <gf/reader/Expr.h>
namespace gf {
namespace reader {
Expr::Expr() {
}
Expr::~Expr() {
}
}
} | 15.428571 | 78 | 0.509259 |
de7b08cf91b5e5aaed7f68e56832ea58dac9d4de | 6,995 | cpp | C++ | src/Ainur/AinurState1.cpp | g1257/PsimagLite | 1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010 | [
"Unlicense"
] | 8 | 2015-08-19T16:06:52.000Z | 2021-12-05T02:37:47.000Z | src/Ainur/AinurState1.cpp | g1257/PsimagLite | 1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010 | [
"Unlicense"
] | 5 | 2016-02-02T20:28:21.000Z | 2019-07-08T22:56:12.000Z | src/Ainur/AinurState1.cpp | g1257/PsimagLite | 1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010 | [
"Unlicense"
] | 5 | 2016-04-29T17:28:00.000Z | 2019-11-22T03:33:19.000Z | #include "AinurState.h"
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include "AinurDoubleOrFloat.h"
namespace PsimagLite {
struct MyProxyFor {
static void convert(long unsigned int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(unsigned int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(long int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(double& t, std::string str)
{
t = PsimagLite::atof(str);
}
static void convert(float& t, std::string str)
{
t = PsimagLite::atof(str);
}
template<typename T>
static void convert(std::complex<T>& t, std::string str)
{
t = toComplex<T>(str);
}
static void convert(String& t, std::string str)
{
t = str;
}
template<typename T>
static void convert(T& t, std::string str)
{
String msg("Unknown type ");
throw RuntimeError("convert(): " + msg + typeid(t).name() + " for " + str + "\n");
}
private:
template<typename RealType>
static std::complex<RealType> toComplex(std::string str)
{
typedef std::complex<RealType> ComplexType;
String buffer;
bool flag = false;
const SizeType n = str.length();
RealType real1 = 0;
for (SizeType i = 0; i < n; ++i) {
bool isSqrtMinus1 = (str[i] == 'i');
if (isSqrtMinus1 && flag)
throw RuntimeError("Error parsing number " + str + "\n");
if (isSqrtMinus1) {
flag = true;
real1 = atof(buffer.c_str());
buffer = "";
continue;
}
buffer += str[i];
}
return (flag) ? ComplexType(real1, atof(buffer.c_str())) :
ComplexType(atof(buffer.c_str()), 0);
}
};
//---------
boost::spirit::qi::rule<std::string::iterator,
std::vector<std::string>(),
boost::spirit::qi::space_type>
ruleRows()
{
boost::spirit::qi::rule<std::string::iterator,
std::vector<std::string>(),
boost::spirit::qi::space_type> myrule = "[" >> (+~boost::spirit::qi::char_(",[]"))
% ',' >> "]";
return myrule;
}
//---------
void AinurState::assign(String k, String v)
{
int x = storageIndexByName(k);
if (x < 0)
err(errLabel(ERR_PARSE_UNDECLARED, k));
assert(static_cast<SizeType>(x) < values_.size());
//if (values_[x] != "")
// std::cerr<<"Overwriting label "<<k<<" with "<<v<<"\n";
values_[x] = v;
}
//---------
template <typename T>
template <typename A, typename ContextType>
void AinurState::ActionMatrix<T>::operator()(A& attr,
ContextType&,
bool&) const
{
SizeType rows = attr.size();
if (rows == 0) return;
SizeType cols = attr[0].size();
t_.resize(rows, cols);
for (SizeType i = 0; i < rows; ++i) {
if (attr[i].size() != cols)
err("Ainur: Problem reading matrix\n");
for (SizeType j = 0; j < cols; ++j)
MyProxyFor::convert(t_(i, j), attr[i][j]);
}
}
//---------
template <typename T>
template <typename A, typename ContextType>
void AinurState::Action<T>::operator()(A& attr,
ContextType&,
bool&) const
{
const SizeType n = attr.size();
if (n == 2 && attr[1] == "...") {
const SizeType m = t_.size();
if (m == 0)
err("Cannot use ellipsis for vector of unknown size\n");
MyProxyFor::convert(t_[0], attr[0]);
for (SizeType i = 1; i < m; ++i)
t_[i] = t_[0];
return;
}
if (n == 2 && attr[1].length() > 4 && attr[1].substr(0, 4) == "...x") {
const SizeType m = t_.size();
const SizeType l = attr[1].length();
const SizeType mm = PsimagLite::atoi(attr[1].substr(4, l - 4));
if (m != 0)
std::cout<<"Resizing vector to "<<mm<<"\n";
t_.resize(mm);
MyProxyFor::convert(t_[0], attr[0]);
for (SizeType i = 1; i < mm; ++i)
t_[i] = t_[0];
return;
}
t_.resize(n);
for (SizeType i = 0; i < n; ++i)
MyProxyFor::convert(t_[i], attr[i]);
}
//---------
template<typename T>
void AinurState::convertInternal(Matrix<T>& t,
String value) const
{
namespace qi = boost::spirit::qi;
typedef std::string::iterator IteratorType;
typedef std::vector<std::string> VectorStringType;
typedef std::vector<VectorStringType> VectorVectorVectorType;
IteratorType it = value.begin();
qi::rule<IteratorType, VectorStringType(), qi::space_type> ruRows = ruleRows();
qi::rule<IteratorType, VectorVectorVectorType(), qi::space_type> full =
"[" >> -(ruRows % ",") >> "]";
ActionMatrix<T> actionMatrix("matrix", t);
bool r = qi::phrase_parse(it,
value.end(),
full [actionMatrix],
qi::space);
//check if we have a match
if (!r) {
err("matrix parsing failed near " +
stringContext(it, value.begin(), value.end())
+ "\n");
}
if (it != value.end())
std::cerr << "matrix parsing: unmatched part exists\n";
}
template<typename T>
void AinurState::convertInternal(std::vector<T>& t,
String value,
typename EnableIf<Loki::TypeTraits<T>::isArith ||
IsComplexNumber<T>::True ||
TypesEqual<T, String>::True,
int>::Type) const
{
namespace qi = boost::spirit::qi;
typedef std::string::iterator IteratorType;
typedef std::vector<std::string> VectorStringType;
IteratorType it = value.begin();
qi::rule<IteratorType, VectorStringType(), qi::space_type> ruRows = ruleRows();
Action<T> actionRows("rows", t);
bool r = qi::phrase_parse(it,
value.end(),
ruRows [actionRows],
qi::space);
//check if we have a match
if (!r)
err("vector parsing failed near " + stringContext(it, value.begin(), value.end()) + "\n");
if (it != value.end()) {
std::cerr << "vector parsing: unmatched part exists near ";
std::cerr << stringContext(it, value.begin(), value.end())<<"\n";
}
}
//---------
template void AinurState::convertInternal(Matrix<DoubleOrFloatType>&,String) const;
template void AinurState::convertInternal(Matrix<std::complex<DoubleOrFloatType> >&,
String) const;
template void AinurState::convertInternal(Matrix<String>&, String) const;
template void AinurState::convertInternal(std::vector<DoubleOrFloatType>&, String, int) const;
template void AinurState::convertInternal(std::vector<std::complex<DoubleOrFloatType> >&,
String,
int) const;
template void AinurState::convertInternal(std::vector<SizeType>&, String, int) const;
template void AinurState::convertInternal(std::vector<int>&, String, int) const;
template void AinurState::convertInternal(std::vector<String>&, String, int) const;
} // namespace PsimagLite
| 26.396226 | 94 | 0.59371 |
de7bc38940fabadee14bc424f9d42b666e7f58aa | 5,924 | cpp | C++ | wordlist_wordle_solver.cpp | themattman/wordle-solver | 6fb4cd1726a27dc6609a978b3a482fd51d46d8b7 | [
"0BSD"
] | null | null | null | wordlist_wordle_solver.cpp | themattman/wordle-solver | 6fb4cd1726a27dc6609a978b3a482fd51d46d8b7 | [
"0BSD"
] | null | null | null | wordlist_wordle_solver.cpp | themattman/wordle-solver | 6fb4cd1726a27dc6609a978b3a482fd51d46d8b7 | [
"0BSD"
] | null | null | null | #include "wordlist_wordle_solver.h"
#include "wordle_helpers.h"
#include "wordle_rules.h"
#include "wordle_selectors.h"
#include "wordle_solver.h"
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
WordlistWordleSolver::WordlistWordleSolver() : WordleSolverImpl() {
m_selector = SelectorFactory<SetIterator>::makeSelector(SelectorType::FrequencyAndPositionalLetter); // Choose `Selector` HERE!!
loadWordList([this](const string& word) -> void {
m_wordlist.push_back(word);
m_wordSet.insert(word);
for (size_t i = 0; i < LETTER_COUNT; i++) {
char curChar = word[i];
if (m_letterMaps[i].find(curChar) != m_letterMaps[i].end()) {
m_letterMaps[i][curChar].push_back(word);
} else {
m_letterMaps[i][curChar] = {word};
}
}
});
}
void WordlistWordleSolver::loadWordList(function<void(string)> eachLineCallback) {
for (size_t i = 0; i < LETTER_COUNT; i++) {
m_letterMaps.push_back(unordered_map<char, vector<string>>{});
}
// src: https://raw.githubusercontent.com/printfn/wordle-dict/main/answers.txt
// src: https://raw.githubusercontent.com/AllValley/WordleDictionary/main/wordle_complete_dictionary.txt
auto filein = ifstream(DICTIONARY_FILENAME);
string word;
while (std::getline(filein, word)) {
eachLineCallback(word);
}
if (DEBUG) cout << "Size of wordlist: " << m_wordlist.size() << endl;
}
/////////////////////
TrieBasedWordleSolver::TrieBasedWordleSolver() : PassthroughWordleSolver() {
m_selector = SelectorFactory<SetIterator>::makeSelector(SelectorType::FrequencyAndPositionalLetter); // Choose `Selector` HERE!!
m_trie = new WordleTrie();
loadWordList([this](const string& line){
m_trie->insert(line);
});
}
string TrieBasedWordleSolver::makeInitialGuess() {
if (m_trie->getNumCandidates() > 0) {
string candidateWord = "slice"; //m_trie->getCandidate(m_selector, m_knownCorrects, 0);
if (candidateWord.size() == 0) {
if (DEBUG) cerr << "Error: [solver] empty word" << endl;
throw;
}
cerr << m_trie->getNumCandidates() << ",";
return candidateWord;
}
if (DEBUG) cerr << "Error: [solver] no more candidates" << endl;
throw;
}
string TrieBasedWordleSolver::makeSubsequentGuess(size_t numGuess) {
if (m_trie->getNumCandidates() > 0) {
string candidateWord = m_trie->getCandidate(m_selector, m_knownCorrects, numGuess);
if (candidateWord.size() == 0) {
if (DEBUG) cerr << "Error: [solver] empty word" << endl;
throw;
}
cerr << m_trie->getNumCandidates() << ",";
return candidateWord;
}
if (DEBUG) cerr << "Error: [solver] no more candidates" << endl;
throw;
}
void TrieBasedWordleSolver::printNumCands(const string& color) const {
if (DEBUG) {
string color_code;
string end_color_code = "\033[0m";
if (color == "green") {
color_code = "\033[0;32m";
} else if (color == "yellow") {
color_code = "\033[0;33m";
} else if (color == "black") {
color_code = "\033[0;30m";
}
cout << "numCandidates [" << color_code << color << end_color_code << "] done:" << m_trie->getNumCandidates() << endl;
}
}
void TrieBasedWordleSolver::processResult(const WordleGuess& guess) {
// most restrictive -> least restrictive
trimGreens(guess, createPositionVector(guess, WordleResult::GREEN));
printNumCands("green");
trimYellows(guess, createPositionVector(guess, WordleResult::YELLOW));
printNumCands("yellow");
trimBlacks(guess, createPositionVector(guess, WordleResult::BLACK));
printNumCands("black");
#if PRINT_GUESSES == true
m_trie->printCandidates();
#endif
}
vector<size_t> TrieBasedWordleSolver::createPositionVector(const WordleGuess& allPositions, WordleResult wr) {
vector<size_t> positions;
for (size_t i = 0; i < allPositions.results.size(); i++) {
if (allPositions.results[i] == wr) {
positions.push_back(i);
if (wr == WordleResult::GREEN && m_knownCorrects[i].result != WordleResult::GREEN) {
m_knownCorrects[i].result = WordleResult::GREEN;
m_knownCorrects[i].letter = allPositions.guessStr[i];
}
}
}
return positions;
}
void TrieBasedWordleSolver::trimGreens(const WordleGuess& g, const vector<size_t>& positions) {
for (auto& p : positions) {
m_trie->fixupGreen(p, g.guessStr[p]);
}
}
void TrieBasedWordleSolver::trimYellows(const WordleGuess& g, const vector<size_t>& positions) {
for (auto& p : positions) {
m_trie->fixupYellow(p, g.guessStr[p]);
}
}
void TrieBasedWordleSolver::trimBlacks(const WordleGuess& g, const vector<size_t>& positions) {
for (auto& p : positions) {
if (countOccurs(g.guessStr[p], g.guessStr) > 1) {
if (isAnotherOccurrenceNotBlack(p, g)) {
// only remove letter for current slot
m_trie->fixupYellow(p, g.guessStr[p]);
} else {
// remove letter from all slots
m_trie->fixupBlack(p, g.guessStr[p]);
}
} else {
m_trie->fixupBlack(p, g.guessStr[p]);
}
}
}
bool TrieBasedWordleSolver::isAnotherOccurrenceNotBlack(size_t position, const WordleGuess& g) const {
char letter = g.guessStr[position];
for (size_t i = 0; i < g.guessStr.size(); i++) {
if (i == position) continue;
if (g.guessStr[i] == letter) {
if (g.results[i] != WordleResult::BLACK) {
return true;
}
}
}
return false;
}
| 33.659091 | 132 | 0.621371 |
de7e28964c63dffd7045225e1a0544cf61653e85 | 1,539 | cpp | C++ | Algorithms/Search/SherlockandArray/Solution.cpp | 4ngelica/HackerRank | 61c4269168a9b35c98840e40637fe87c9735356c | [
"MIT"
] | 1,122 | 2017-03-22T03:52:28.000Z | 2022-03-31T06:01:39.000Z | Algorithms/Search/SherlockandArray/Solution.cpp | 4ngelica/HackerRank | 61c4269168a9b35c98840e40637fe87c9735356c | [
"MIT"
] | 100 | 2017-03-15T20:01:28.000Z | 2021-07-12T14:42:21.000Z | Algorithms/Search/SherlockandArray/Solution.cpp | 4ngelica/HackerRank | 61c4269168a9b35c98840e40637fe87c9735356c | [
"MIT"
] | 799 | 2017-03-19T21:28:30.000Z | 2022-03-26T16:58:54.000Z | /*
Problem : https://www.hackerrank.com/challenges/sherlock-and-array
C++ 14
Approach :
This is quite a straight forward problem. All elements of the input array is
set to the sum of all the elements upto that point of the input array, i.e.
arr[i] = Sum(arr[j]) for 0 <= j <=i < n
Then in an other loop we compare arr[i] and arr[n-1] - arr[i] , which will
turn the answer to be YES, otherwise it is NO.
Time Complexity : O( n ) for each test case.
Overall Time Complexity : O( t*n ) for entire input file.
Space Complextiy : O( n ) for entire input file.
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int test; cin>>test;
int n=100000, i=0, temp=0;
unsigned long long arr[n], sum=0;
while(test--){
for(i=0; i<=100000; i++){
arr[i]=0;
}
cin>>n;
for(i=0; i<n; i++){
cin>>temp;
sum+=temp;
arr[i]=sum;
temp=0;
}
if(n==1){
cout<<"YES\n";
sum=0;
continue;
}
for(i=1; i<n; i++){
if(arr[i-1]==(arr[n-1]-arr[i])){
cout<<"YES\n";
break;
}
else
continue;
}
if(i==n)
cout<<"NO\n";
sum=0;
}
return 0;
}
| 27 | 84 | 0.492528 |