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
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f79074dc39521a9e99547f493895a7136242a1ce
| 6,262
|
cpp
|
C++
|
Libraries/RobsJuceModules/jura_framework/gui/panels/jura_ThreadedDrawingComponent.cpp
|
RobinSchmidt/RS-MET-Preliminary
|
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
|
[
"FTL"
] | 34
|
2017-04-19T18:26:02.000Z
|
2022-02-15T17:47:26.000Z
|
Libraries/RobsJuceModules/jura_framework/gui/panels/jura_ThreadedDrawingComponent.cpp
|
RobinSchmidt/RS-MET-Preliminary
|
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
|
[
"FTL"
] | 307
|
2017-05-04T21:45:01.000Z
|
2022-02-03T00:59:01.000Z
|
Libraries/RobsJuceModules/jura_framework/gui/panels/jura_ThreadedDrawingComponent.cpp
|
RobinSchmidt/RS-MET-Preliminary
|
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
|
[
"FTL"
] | 4
|
2017-09-05T17:04:31.000Z
|
2021-12-15T21:24:28.000Z
|
//-------------------------------------------------------------------------------------------------
// construction/destruction:
ThreadedDrawingComponent::ThreadedDrawingComponent(TimeSliceThread* newThreadToUse)
{
ScopedLock scopedLock(clientAreaImageLock);
clientAreaImage = NULL;
clientAreaImage = new Image(Image::ARGB, 1, 1, true);
clientAreaImageIsDirty = false;
repaintDelayInMilliseconds = 100;
if( newThreadToUse != NULL )
threadToUse = newThreadToUse;
else
threadToUse = DrawingThread::getInstance();
threadToUse->addTimeSliceClient(this);
}
ThreadedDrawingComponent::~ThreadedDrawingComponent()
{
ScopedLock scopedLock(clientAreaImageLock);
if( threadToUse != NULL )
threadToUse->removeTimeSliceClient(this);
if( clientAreaImage != NULL )
delete clientAreaImage;
}
//-------------------------------------------------------------------------------------------------
// setup:
void ThreadedDrawingComponent::setDrawingThread(TimeSliceThread *newThreadToUse)
{
if( threadToUse != NULL )
threadToUse->removeTimeSliceClient(this);
threadToUse = newThreadToUse;
if( threadToUse != NULL )
threadToUse->addTimeSliceClient(this);
}
//-------------------------------------------------------------------------------------------------
// callbacks:
void ThreadedDrawingComponent::timerCallback()
{
repaint();
//stopTimer();
}
void ThreadedDrawingComponent::resized()
{
Component::resized();
setDirty();
}
void ThreadedDrawingComponent::paint(Graphics &g)
{
if( threadToUse == NULL )
{
Component::paint(g);
return;
}
if( clientAreaImageIsDirty )
{
//g.fillAll(Colours::white);
return;
}
bool lockAquired = clientAreaImageLock.tryEnter();
if( lockAquired )
{
if( clientAreaImage != NULL )
g.drawImageAt(*clientAreaImage, 0, 0, false);
else
g.fillAll(Colours::red);
// could be that we have just drawn a dirty image, so stop the timer only when the image just
// drawn is not dirty:
if( !clientAreaImageIsDirty )
//stopTimer();
startTimer(1000);
clientAreaImageLock.exit();
}
else
{
// we could not aquire the mutex-lock for the image to be drawn - it is probably currently
// held by the drawing thread - we draw a white background and spawn a new (asynchronous)
// call to this function:
//g.fillAll(Colours::white);
startTimer(repaintDelayInMilliseconds);
}
}
int ThreadedDrawingComponent::useTimeSlice()
{
//ScopedLock scopedLock(clientAreaImageLock);
if( clientAreaImageIsDirty )
{
renderClientAreaImageInternal();
//return true; // indicate that the thread is currently very busy - old
}
else
{
//return true;
//return false; // indicate that the thread is currently not too busy
}
return 20; // number of milliseconds after this thread shall be called again - maybe we need to tweak
}
//-------------------------------------------------------------------------------------------------
// others:
void ThreadedDrawingComponent::setDirty(bool shouldSetToDirty)
{
ScopedLock imageLock(clientAreaImageLock);
clientAreaImageIsDirty = shouldSetToDirty;
//startTimer(300);
if( threadToUse == NULL && clientAreaImageIsDirty )
repaint();
}
void ThreadedDrawingComponent::drawComponent(Image *imageToDrawOnto)
{
Graphics g(*imageToDrawOnto);
//int w = imageToDrawOnto->getWidth();
//int h = imageToDrawOnto->getHeight();
g.setColour(Colours::black);
//g.drawFittedText(String(T("ThreadedDrawingComponent")), 0, 0, w, h, Justification::centred, 1);
// triggers a JUCE-breakpoint when called early on app-startup
}
void ThreadedDrawingComponent::renderClientAreaImageInternal()
{
ScopedLock imageLock(clientAreaImageLock);
if( getWidth() < 1 || getHeight() < 1 )
{
clientAreaImageIsDirty = false;
return;
}
if( clientAreaImage->getWidth() != getWidth()
|| clientAreaImage->getHeight() != getHeight() )
{
allocateClientAreaImage(getWidth(), getHeight());
}
// initialize the image as a white canvas and set the dirty flag:
Graphics g(*clientAreaImage);
//g.fillAll(Colours::white);
//clientAreaImageIsDirty = true;
// call the actual drawing rutine (hich is supposed to be overriden by subclasses):
drawComponent(clientAreaImage);
// when the drawComponent-function returns, we assume that the clientArwaImage has been drawn, so
// we set our dirty flag flase and trigger a (delayed) repaint:
clientAreaImageIsDirty = false;
startTimer(repaintDelayInMilliseconds);
}
bool ThreadedDrawingComponent::allocateClientAreaImage(int desiredWidth, int desiredHeight)
{
ScopedLock imageLock(clientAreaImageLock);
bool result = false;
desiredWidth = jmax(1, desiredWidth);
desiredHeight = jmax(1, desiredHeight);
// allocate memory for the first time:
if( clientAreaImage == NULL )
{
clientAreaImage = new Image(Image::ARGB, desiredWidth, desiredHeight, true);
if( clientAreaImage == NULL )
{
jassertfalse;
showMemoryAllocationErrorBox(String("ThreadedDrawingComponent::allocateClientAreaImage"));
return false;
}
else
result = true;
}
// reallocate memory, if necessary (i.e. the deired size differs from the current size of the
// image):
if( clientAreaImage->getWidth() != desiredWidth
|| clientAreaImage->getHeight() != desiredHeight )
{
// delete the old and create a new Image-object:
if( clientAreaImage != NULL )
{
delete clientAreaImage;
clientAreaImage = NULL;
}
clientAreaImage = new Image(Image::ARGB, desiredWidth, desiredHeight, true);
result = true;
if( clientAreaImage == NULL )
{
showMemoryAllocationErrorBox(String("ThreadedDrawingComponent::allocateClientAreaImage"));
jassertfalse;
return false;
}
}
// when we indeed have allocated new memory, the image associated with this new memory is
// certainly not what we want to see:
if( result == true ) // was formerly if( result = true ) - so it was always excuted -> test
{
clientAreaImageIsDirty = true;
Graphics g(*clientAreaImage);
g.fillAll(Colours::white);
}
return result;
}
| 27.108225
| 103
| 0.65634
|
RobinSchmidt
|
f7924030e405fc5eb3e8c2c5321f540a2ca9b896
| 380
|
cpp
|
C++
|
214A.cpp
|
basuki57/Codeforces
|
5227c3deecf13d90e5ea45dab0dfc16b44bd028c
|
[
"MIT"
] | null | null | null |
214A.cpp
|
basuki57/Codeforces
|
5227c3deecf13d90e5ea45dab0dfc16b44bd028c
|
[
"MIT"
] | null | null | null |
214A.cpp
|
basuki57/Codeforces
|
5227c3deecf13d90e5ea45dab0dfc16b44bd028c
|
[
"MIT"
] | 2
|
2020-10-03T04:52:14.000Z
|
2020-10-03T05:19:12.000Z
|
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve(){
ll n, m, cnt = 0;
cin >> n >> m;
for(ll i = 0; i < 1001; i++)
for(ll j = 0; j < 1001; j++) if(i*i + j == n && i + j*j == m) ++cnt;
cout << cnt << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
//int t;cin>>t;while(t--)
solve();
return 0;
}
| 19
| 76
| 0.507895
|
basuki57
|
f792dc3c1a4a5d4cb59bd31a3d3a899731bd1bfb
| 316
|
cpp
|
C++
|
January Challenges/Day28-Smallest String With A Given Numeric Value.cpp
|
kaushalk844/leetcode
|
c9497a1cf36e4d7f84161cf8d12e2cfc4a6b937d
|
[
"MIT"
] | null | null | null |
January Challenges/Day28-Smallest String With A Given Numeric Value.cpp
|
kaushalk844/leetcode
|
c9497a1cf36e4d7f84161cf8d12e2cfc4a6b937d
|
[
"MIT"
] | null | null | null |
January Challenges/Day28-Smallest String With A Given Numeric Value.cpp
|
kaushalk844/leetcode
|
c9497a1cf36e4d7f84161cf8d12e2cfc4a6b937d
|
[
"MIT"
] | null | null | null |
class Solution {
public:
string getSmallestString(int n, int k) {
string res(n, 'a');
k -= n;
int i = res.size()-1;
while(k > 0){
int t = min(25,k);
res[i] += t;
k -= t;
i--;
}
return res;
}
};
| 17.555556
| 44
| 0.344937
|
kaushalk844
|
f79a47959bf7218d42e245e17725206e2d6250c8
| 4,982
|
cpp
|
C++
|
PathFinding.cpp
|
TheNewBob/IMS2
|
572dcfd4c3621458f01278713437c2aca526d2e6
|
[
"MIT"
] | 2
|
2018-01-28T20:07:52.000Z
|
2018-03-01T22:41:39.000Z
|
PathFinding.cpp
|
TheNewBob/IMS2
|
572dcfd4c3621458f01278713437c2aca526d2e6
|
[
"MIT"
] | 6
|
2017-08-26T10:24:48.000Z
|
2018-01-28T13:45:34.000Z
|
PathFinding.cpp
|
TheNewBob/IMS2
|
572dcfd4c3621458f01278713437c2aca526d2e6
|
[
"MIT"
] | null | null | null |
#include "Common.h"
#include <queue>
#include <deque>
#include <stack>
#include "SimpleTreeNode.h"
#include "SimplePathNode.h"
#include "PathFinding.h"
PathFinding::PathFinding()
{
}
PathFinding::~PathFinding()
{
}
/* algorithm description:
* A breadth-first search in concept (i.e. nodes of the same level are all checked before moving on to a deeper level),
* but with two twists: The common breadth-first search is a tree search, while this deals with a map that is expected
* to have circular interconnections. The common breadth-first search also does not have path-awareness, since this is
* given by the tree it is searching through. You find the node in the tree, you can trace it back to the root. And
* again, we don't have a tree.
* The algorithm solves this by dynamically building a SimpleTree to document its search through the map. Since the
* job of the SimpleTree structure is to build a stable tree, it is not an efficient structure to search through, which
* is annoying since because of the circularity of the map we also have to check which nodes have already been looked at.
* For this reason, the nodes of the SimpleTree are stored in a search tree (an STL map), which might be a bit confusing
* at first, but this way we get an optimised search structure and a stable representation.
*/
bool PathFinding::BreadthFirst(SimplePathNode *origin, SimplePathNode *target, stack<int> &OUT_path)
{
//make shure the path is clear... er... empty.
OUT_path.empty();
//search tree that will contain the nodes of our SimpleTree,
//which are also the nodes that were already checked.
//the SimpleTree itself is a logical construct resulting from
//the connection of its nodes
map<int, SimpleTreeNode*> checkednodes;
//the queue that will handle the breadth-first search
queue<SimplePathNode*> nodestocheck;
nodestocheck.push(origin);
//create the root of the SimpleTree and add it to the searchtree
SimpleTreeNode *originnode = new SimpleTreeNode(origin->GetId(), NULL);
checkednodes[origin->GetId()] = originnode;
//do the actual search
SimpleTreeNode *targettreenode = NULL; //this will contain the top node of the SimpleTree (the target) when the search has finished
while (nodestocheck.size() > 0 && targettreenode == NULL)
{
//remove the oldest element from our queue and walk through its neighbors
SimplePathNode *checknode = nodestocheck.front();
nodestocheck.pop();
vector<SimplePathNode*> neighbors = checknode->GetConnected();
//retrieve the treenode of the currently processed PathNode
SimpleTreeNode *currentparent = checkednodes[checknode->GetId()];
//walk through neighbors
for (UINT i = 0; i < neighbors.size() && targettreenode == 0; ++i)
{
//check if we already checked this particular node
if (checkednodes.find(neighbors[i]->GetId()) == checkednodes.end())
{
//add the node to the queue so it will eventually get its neighbors checked
nodestocheck.push(neighbors[i]);
//insert the node into the SimpleTree
SimpleTreeNode *neighbornode = new SimpleTreeNode(neighbors[i]->GetId(), currentparent);
//add the node to the list of already checked elements
checkednodes[neighbors[i]->GetId()] = neighbornode;
}
//if this particular neighbor is the actual target, terminate the search
//this stands outside the check so the algorithm works when current state and target state
//are identical. It means that the algorithm will search for the shortest path to loop around
//and arrive at the origin again. This is necessary for some operations.
if (neighbors[i] == target)
{
//check if the found target node is actually the same as the origin node.
//this is expected in cases where we sought the shortest path from a node back
//to itself through its neighboring nodes
if (neighbors[i]->GetId() == originnode->GetId())
{
//The node will technically be twice in the simple tree after this,
//but that is not important. The SimpleTree describes a PATH, and every
//step on that path must be present and connected.
targettreenode = new SimpleTreeNode(originnode->GetId(), currentparent);
}
else
{
//the target node will already have been created at line 73
targettreenode = checkednodes[target->GetId()];
}
}
}
}
if (targettreenode == NULL)
{
//no path has been found!
return false;
}
//What we end up with is the SimpleTree containing all nodes the search went over,
//ordered in exactly the way the search found them. All that's left to do is take the
//SimpleTreeNode for the target pathnode, move up the tree to the root and add the proper
//pathnode ids to the path.
SimpleTreeNode *currentnode = targettreenode;
while (currentnode != NULL)
{
OUT_path.push(currentnode->GetId());
currentnode = currentnode->GetParent();
}
//clean up the SimpleTree
SimpleTreeNode *rootnode = checkednodes[origin->GetId()];
delete rootnode;
return true;
}
| 39.539683
| 136
| 0.73324
|
TheNewBob
|
f7a42a648e47142381fb6ecd7e9cddaeaf3a9802
| 1,870
|
cpp
|
C++
|
libcaf_core/src/type_id.cpp
|
jsiwek/actor-framework
|
06cd2836f4671725cb7eaa22b3cc115687520fc1
|
[
"BSL-1.0",
"BSD-3-Clause"
] | 4
|
2019-05-03T05:38:15.000Z
|
2020-08-25T15:23:19.000Z
|
libcaf_core/src/type_id.cpp
|
jsiwek/actor-framework
|
06cd2836f4671725cb7eaa22b3cc115687520fc1
|
[
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null |
libcaf_core/src/type_id.cpp
|
jsiwek/actor-framework
|
06cd2836f4671725cb7eaa22b3cc115687520fc1
|
[
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null |
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2020 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/type_id.hpp"
#include "caf/detail/meta_object.hpp"
namespace caf {
string_view query_type_name(type_id_t type) {
if (auto ptr = detail::global_meta_object(type))
return ptr->type_name;
return {};
}
type_id_t query_type_id(string_view name) {
auto objects = detail::global_meta_objects();
for (size_t index = 0; index < objects.size(); ++index)
if (objects[index].type_name == name)
return static_cast<type_id_t>(index);
return invalid_type_id;
}
} // namespace caf
| 46.75
| 80
| 0.389305
|
jsiwek
|
f7ab5ff71871d1c348648ef6484f0bff047b4a38
| 51,722
|
cc
|
C++
|
src/xenia/ui/window_win.cc
|
amessier/xenia
|
6b45cf84472c26436d4a5db61a7b50dab301e398
|
[
"BSD-3-Clause"
] | 1
|
2022-03-21T07:35:46.000Z
|
2022-03-21T07:35:46.000Z
|
src/xenia/ui/window_win.cc
|
amessier/xenia
|
6b45cf84472c26436d4a5db61a7b50dab301e398
|
[
"BSD-3-Clause"
] | null | null | null |
src/xenia/ui/window_win.cc
|
amessier/xenia
|
6b45cf84472c26436d4a5db61a7b50dab301e398
|
[
"BSD-3-Clause"
] | null | null | null |
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2022 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "xenia/ui/window_win.h"
#include <algorithm>
#include <memory>
#include <string>
#include "xenia/base/assert.h"
#include "xenia/base/filesystem.h"
#include "xenia/base/logging.h"
#include "xenia/ui/surface_win.h"
// Must be included before Windows headers for things like NOMINMAX.
#include "xenia/base/platform_win.h"
#include "xenia/ui/virtual_key.h"
#include "xenia/ui/windowed_app_context_win.h"
// For per-monitor DPI awareness v1.
#include <ShellScalingApi.h>
namespace xe {
namespace ui {
std::unique_ptr<Window> Window::Create(WindowedAppContext& app_context,
const std::string_view title,
uint32_t desired_logical_width,
uint32_t desired_logical_height) {
return std::make_unique<Win32Window>(
app_context, title, desired_logical_width, desired_logical_height);
}
Win32Window::Win32Window(WindowedAppContext& app_context,
const std::string_view title,
uint32_t desired_logical_width,
uint32_t desired_logical_height)
: Window(app_context, title, desired_logical_width, desired_logical_height),
arrow_cursor_(LoadCursor(nullptr, IDC_ARROW)) {
dpi_ = GetCurrentSystemDpi();
}
Win32Window::~Win32Window() {
EnterDestructor();
if (cursor_auto_hide_timer_) {
DeleteTimerQueueTimer(nullptr, cursor_auto_hide_timer_, nullptr);
cursor_auto_hide_timer_ = nullptr;
}
if (hwnd_) {
// Set hwnd_ to null to ignore events from now on since this Win32Window is
// entering an indeterminate state.
HWND hwnd = hwnd_;
hwnd_ = nullptr;
SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
DestroyWindow(hwnd);
}
if (icon_) {
DestroyIcon(icon_);
}
}
uint32_t Win32Window::GetMediumDpi() const { return USER_DEFAULT_SCREEN_DPI; }
bool Win32Window::OpenImpl() {
const Win32WindowedAppContext& win32_app_context =
static_cast<const Win32WindowedAppContext&>(app_context());
HINSTANCE hinstance = win32_app_context.hinstance();
static bool has_registered_class = false;
if (!has_registered_class) {
WNDCLASSEXW wcex;
wcex.cbSize = sizeof(wcex);
wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wcex.lpfnWndProc = Win32Window::WndProcThunk;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hinstance;
wcex.hIcon = LoadIconW(hinstance, L"MAINICON");
wcex.hIconSm = nullptr; // LoadIconW(hinstance, L"MAINICON");
wcex.hCursor = arrow_cursor_;
// Matches the black background color of the presenter's painting.
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = L"XeniaWindowClass";
if (!RegisterClassExW(&wcex)) {
XELOGE("RegisterClassEx failed");
return false;
}
has_registered_class = true;
}
const Win32MenuItem* main_menu =
static_cast<const Win32MenuItem*>(GetMainMenu());
// Setup the initial size for the non-fullscreen window. With per-monitor DPI,
// this is also done to be able to obtain the initial window rectangle (with
// CW_USEDEFAULT) to get the monitor for the window position, and then to
// adjust the normal window size to the new DPI.
// Save the initial desired size since it may be modified by the handler of
// the WM_SIZE sent during window creation - it's needed for the initial
// per-monitor DPI scaling.
uint32_t initial_desired_logical_width = GetDesiredLogicalWidth();
uint32_t initial_desired_logical_height = GetDesiredLogicalHeight();
const Win32WindowedAppContext::PerMonitorDpiV2Api* per_monitor_dpi_v2_api =
win32_app_context.per_monitor_dpi_v2_api();
const Win32WindowedAppContext::PerMonitorDpiV1Api* per_monitor_dpi_v1_api =
win32_app_context.per_monitor_dpi_v1_api();
// Even with per-monitor DPI, take the closest approximation (system DPI) to
// potentially more accurately determine the initial monitor.
dpi_ = GetCurrentSystemDpi();
DWORD window_style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
DWORD window_ex_style = WS_EX_APPWINDOW | WS_EX_CONTROLPARENT;
RECT window_size_rect;
window_size_rect.left = 0;
window_size_rect.top = 0;
window_size_rect.right = LONG(ConvertSizeDpi(initial_desired_logical_width,
dpi_, USER_DEFAULT_SCREEN_DPI));
window_size_rect.bottom = LONG(ConvertSizeDpi(initial_desired_logical_height,
dpi_, USER_DEFAULT_SCREEN_DPI));
AdjustWindowRectangle(window_size_rect, window_style,
BOOL(main_menu != nullptr), window_ex_style, dpi_);
// Create the window. Though WM_NCCREATE will assign to `hwnd_` too, still do
// the assignment here to handle the case of a failure after WM_NCCREATE, for
// instance.
hwnd_ = CreateWindowExW(
window_ex_style, L"XeniaWindowClass",
reinterpret_cast<LPCWSTR>(xe::to_utf16(GetTitle()).c_str()), window_style,
CW_USEDEFAULT, CW_USEDEFAULT,
window_size_rect.right - window_size_rect.left,
window_size_rect.bottom - window_size_rect.top, nullptr, nullptr,
hinstance, this);
if (!hwnd_) {
XELOGE("CreateWindowExW failed");
return false;
}
// For per-monitor DPI, obtain the DPI of the monitor the window was created
// on, and adjust the initial normal size for it. If as a result of this
// resizing, the window is moved to a different monitor, the WM_DPICHANGED
// handler will do the needed correction.
uint32_t initial_monitor_dpi = dpi_;
if (per_monitor_dpi_v2_api) {
initial_monitor_dpi = per_monitor_dpi_v2_api->get_dpi_for_window(hwnd_);
} else if (per_monitor_dpi_v1_api) {
HMONITOR monitor = MonitorFromWindow(hwnd_, MONITOR_DEFAULTTONEAREST);
UINT monitor_dpi_x, monitor_dpi_y;
if (monitor && SUCCEEDED(per_monitor_dpi_v1_api->get_dpi_for_monitor(
monitor, MDT_DEFAULT, &monitor_dpi_x, &monitor_dpi_y))) {
initial_monitor_dpi = monitor_dpi_x;
}
}
if (dpi_ != initial_monitor_dpi) {
dpi_ = initial_monitor_dpi;
WINDOWPLACEMENT initial_dpi_placement;
// Note that WINDOWPLACEMENT contains workspace coordinates, which are
// adjusted to exclude toolbars such as the taskbar - the positions and
// rectangle origins there can't be mixed with origins of rectangles in
// virtual screen coordinates such as those involved in functions like
// GetWindowRect.
initial_dpi_placement.length = sizeof(initial_dpi_placement);
if (GetWindowPlacement(hwnd_, &initial_dpi_placement)) {
window_size_rect.left = 0;
window_size_rect.top = 0;
window_size_rect.right = LONG(ConvertSizeDpi(
initial_desired_logical_width, dpi_, USER_DEFAULT_SCREEN_DPI));
window_size_rect.bottom = LONG(ConvertSizeDpi(
initial_desired_logical_height, dpi_, USER_DEFAULT_SCREEN_DPI));
AdjustWindowRectangle(window_size_rect, window_style,
BOOL(main_menu != nullptr), window_ex_style, dpi_);
initial_dpi_placement.rcNormalPosition.right =
initial_dpi_placement.rcNormalPosition.left +
(window_size_rect.right - window_size_rect.left);
initial_dpi_placement.rcNormalPosition.bottom =
initial_dpi_placement.rcNormalPosition.top +
(window_size_rect.bottom - window_size_rect.top);
SetWindowPlacement(hwnd_, &initial_dpi_placement);
}
}
// Disable flicks.
ATOM atom = GlobalAddAtomW(L"MicrosoftTabletPenServiceProperty");
const DWORD_PTR dwHwndTabletProperty =
TABLET_DISABLE_PRESSANDHOLD | // disables press and hold (right-click)
// gesture
TABLET_DISABLE_PENTAPFEEDBACK | // disables UI feedback on pen up (waves)
TABLET_DISABLE_PENBARRELFEEDBACK | // disables UI feedback on pen button
// down (circle)
TABLET_DISABLE_FLICKS | // disables pen flicks (back, forward, drag down,
// drag up)
TABLET_DISABLE_TOUCHSWITCH | TABLET_DISABLE_SMOOTHSCROLLING |
TABLET_DISABLE_TOUCHUIFORCEON | TABLET_ENABLE_MULTITOUCHDATA;
SetPropW(hwnd_, L"MicrosoftTabletPenServiceProperty",
reinterpret_cast<HANDLE>(dwHwndTabletProperty));
GlobalDeleteAtom(atom);
// Enable file dragging from external sources
DragAcceptFiles(hwnd_, true);
// Apply the initial state from the Window that the window shouldn't be
// visibly transitioned to.
if (icon_) {
SendMessageW(hwnd_, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icon_));
SendMessageW(hwnd_, WM_SETICON, ICON_SMALL,
reinterpret_cast<LPARAM>(icon_));
}
if (IsFullscreen()) {
// Go fullscreen after setting up everything related to the placement of the
// non-fullscreen window.
WindowDestructionReceiver destruction_receiver(this);
ApplyFullscreenEntry(destruction_receiver);
if (destruction_receiver.IsWindowDestroyed()) {
return true;
}
} else {
if (main_menu) {
SetMenu(hwnd_, main_menu->handle());
}
}
// Finally show the window.
ShowWindow(hwnd_, SW_SHOWNORMAL);
// Report the initial actual state after opening, messages for which might
// have missed if they were processed during CreateWindowExW when the HWND was
// not yet attached to the Win32Window.
{
WindowDestructionReceiver destruction_receiver(this);
// Report the desired logical size of the client area in the non-maximized
// state after the initial layout setup in Windows.
WINDOWPLACEMENT shown_placement;
shown_placement.length = sizeof(shown_placement);
if (GetWindowPlacement(hwnd_, &shown_placement)) {
// Get the size of the non-client area to subtract it from the size of the
// entire window in its non-maximized state, to get the client area. For
// safety, in case the window is somehow smaller than its non-client area
// (AdjustWindowRect is not exact in various cases also, such as when the
// menu becomes multiline), clamp to 0.
RECT non_client_area_rect = {};
AdjustWindowRectangle(non_client_area_rect);
OnDesiredLogicalSizeUpdate(
SizeToLogical(uint32_t(std::max(
(shown_placement.rcNormalPosition.right -
shown_placement.rcNormalPosition.left) -
(non_client_area_rect.right - non_client_area_rect.left),
LONG(0)))),
SizeToLogical(uint32_t(std::max(
(shown_placement.rcNormalPosition.bottom -
shown_placement.rcNormalPosition.top) -
(non_client_area_rect.bottom - non_client_area_rect.top),
LONG(0)))));
}
// Report the actual physical size in the current state.
// GetClientRect returns a rectangle with 0 origin.
RECT shown_client_rect;
if (GetClientRect(hwnd_, &shown_client_rect)) {
OnActualSizeUpdate(uint32_t(shown_client_rect.right),
uint32_t(shown_client_rect.bottom),
destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return true;
}
}
OnFocusUpdate(GetFocus() == hwnd_, destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return true;
}
}
// Apply the initial state from the Window that involves interaction with the
// user.
if (IsMouseCaptureRequested()) {
SetCapture(hwnd_);
}
cursor_currently_auto_hidden_ = false;
CursorVisibility cursor_visibility = GetCursorVisibility();
if (cursor_visibility != CursorVisibility::kVisible) {
if (cursor_visibility == CursorVisibility::kAutoHidden) {
if (!GetCursorPos(&cursor_auto_hide_last_screen_pos_)) {
cursor_auto_hide_last_screen_pos_.x = LONG_MAX;
cursor_auto_hide_last_screen_pos_.y = LONG_MAX;
}
cursor_currently_auto_hidden_ = true;
}
// OnFocusUpdate needs to be done before this.
SetCursorIfFocusedOnClientArea(nullptr);
}
return true;
}
void Win32Window::RequestCloseImpl() {
// Note that CloseWindow doesn't close the window, rather, it only minimizes
// it - need to send WM_CLOSE to let the Win32Window WndProc perform all the
// shutdown.
SendMessageW(hwnd_, WM_CLOSE, 0, 0);
// The window might have been deleted by the close handler, don't do anything
// with *this anymore (if that's needed, use a WindowDestructionReceiver).
}
uint32_t Win32Window::GetLatestDpiImpl() const {
// hwnd_ may be null in this function, but the latest DPI is stored in a
// variable anyway.
return dpi_;
}
void Win32Window::ApplyNewFullscreen() {
// Various functions here may send messages that may result in the
// listeners being invoked, and potentially cause the destruction of the
// window or fullscreen being toggled from inside this function.
WindowDestructionReceiver destruction_receiver(this);
if (IsFullscreen()) {
ApplyFullscreenEntry(destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return;
}
} else {
// Changing the style and the menu may change the size too, don't handle
// the resize multiple times (also potentially with the listeners changing
// the desired fullscreen if called from the handling of some message like
// WM_SIZE).
BeginBatchedSizeUpdate();
// Reinstate the non-client area.
SetWindowLong(hwnd_, GWL_STYLE,
GetWindowLong(hwnd_, GWL_STYLE) | WS_OVERLAPPEDWINDOW);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
if (!destruction_receiver.IsWindowDestroyed()) {
EndBatchedSizeUpdate(destruction_receiver);
}
return;
}
const Win32MenuItem* main_menu =
static_cast<const Win32MenuItem*>(GetMainMenu());
if (main_menu) {
SetMenu(hwnd_, main_menu->handle());
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
if (!destruction_receiver.IsWindowDestroyed()) {
EndBatchedSizeUpdate(destruction_receiver);
}
return;
}
}
// For some reason, WM_DPICHANGED is not sent when the window is borderless
// fullscreen with per-monitor DPI awareness v1 (on Windows versions since
// Windows 8.1 before Windows 10 1703) - refresh the current DPI explicitly.
dpi_ = GetCurrentDpi();
if (dpi_ != pre_fullscreen_dpi_) {
// Rescale the pre-fullscreen non-maximized window size to the new DPI as
// WM_DPICHANGED with the new rectangle was received for the fullscreen
// window size, not the windowed one. Simulating the behavior of the
// automatic resizing when changing the scale in the Windows settings (as
// of Windows 11 21H2 at least), which keeps the physical top-left origin
// of the entire window including the non-client area, but rescales the
// size.
// Note that WINDOWPLACEMENT contains workspace coordinates, which are
// adjusted to exclude toolbars such as the taskbar - the positions and
// rectangle origins there can't be mixed with origins of rectangles in
// virtual screen coordinates such as those involved in functions like
// GetWindowRect.
RECT new_dpi_rect;
new_dpi_rect.left = 0;
new_dpi_rect.top = 0;
new_dpi_rect.right = LONG(ConvertSizeDpi(
pre_fullscreen_normal_client_width_, dpi_, pre_fullscreen_dpi_));
new_dpi_rect.bottom = LONG(ConvertSizeDpi(
pre_fullscreen_normal_client_height_, dpi_, pre_fullscreen_dpi_));
AdjustWindowRectangle(new_dpi_rect);
pre_fullscreen_placement_.rcNormalPosition.right =
pre_fullscreen_placement_.rcNormalPosition.left +
(new_dpi_rect.right - new_dpi_rect.left);
pre_fullscreen_placement_.rcNormalPosition.bottom =
pre_fullscreen_placement_.rcNormalPosition.top +
(new_dpi_rect.bottom - new_dpi_rect.top);
}
SetWindowPlacement(hwnd_, &pre_fullscreen_placement_);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
if (!destruction_receiver.IsWindowDestroyed()) {
EndBatchedSizeUpdate(destruction_receiver);
}
return;
}
// https://devblogs.microsoft.com/oldnewthing/20131017-00/?p=2903
SetWindowPos(hwnd_, nullptr, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER |
SWP_FRAMECHANGED);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
if (!destruction_receiver.IsWindowDestroyed()) {
EndBatchedSizeUpdate(destruction_receiver);
}
return;
}
EndBatchedSizeUpdate(destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return;
}
}
}
void Win32Window::ApplyNewTitle() {
SetWindowTextW(hwnd_,
reinterpret_cast<LPCWSTR>(xe::to_utf16(GetTitle()).c_str()));
}
void Win32Window::LoadAndApplyIcon(const void* buffer, size_t size,
bool can_apply_state_in_current_phase) {
bool reset = !buffer || !size;
HICON new_icon, new_icon_small;
if (reset) {
if (!icon_) {
// The icon is already the default one.
return;
}
if (!hwnd_) {
// Don't need to get the actual icon from the class if there's nothing to
// set it for yet (and there's no HWND to get it from, and the class may
// have not been registered yet also).
DestroyIcon(icon_);
icon_ = nullptr;
return;
}
new_icon = reinterpret_cast<HICON>(GetClassLongPtrW(hwnd_, GCLP_HICON));
new_icon_small =
reinterpret_cast<HICON>(GetClassLongPtrW(hwnd_, GCLP_HICONSM));
// Not caring if it's null in the class, accepting anything the class
// specifies.
} else {
new_icon = CreateIconFromResourceEx(
static_cast<PBYTE>(const_cast<void*>(buffer)), DWORD(size), TRUE,
0x00030000, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
if (!new_icon) {
return;
}
new_icon_small = new_icon;
}
if (hwnd_) {
SendMessageW(hwnd_, WM_SETICON, ICON_BIG,
reinterpret_cast<LPARAM>(new_icon));
SendMessageW(hwnd_, WM_SETICON, ICON_SMALL,
reinterpret_cast<LPARAM>(new_icon_small));
}
// The old icon is not in use anymore, safe to destroy it now.
if (icon_) {
DestroyIcon(icon_);
icon_ = nullptr;
}
if (!reset) {
assert_true(new_icon_small == new_icon);
icon_ = new_icon;
}
}
void Win32Window::ApplyNewMainMenu(MenuItem* old_main_menu) {
if (IsFullscreen()) {
// The menu will be set when exiting fullscreen.
return;
}
const Win32MenuItem* main_menu =
static_cast<const Win32MenuItem*>(GetMainMenu());
WindowDestructionReceiver destruction_receiver(this);
SetMenu(hwnd_, main_menu ? main_menu->handle() : nullptr);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return;
}
}
void Win32Window::CompleteMainMenuItemsUpdateImpl() {
if (IsFullscreen()) {
return;
}
DrawMenuBar(hwnd_);
}
void Win32Window::ApplyNewMouseCapture() {
WindowDestructionReceiver destruction_receiver(this);
SetCapture(hwnd_);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return;
}
}
void Win32Window::ApplyNewMouseRelease() {
if (GetCapture() != hwnd_) {
return;
}
WindowDestructionReceiver destruction_receiver(this);
ReleaseCapture();
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return;
}
}
void Win32Window::ApplyNewCursorVisibility(
CursorVisibility old_cursor_visibility) {
CursorVisibility new_cursor_visibility = GetCursorVisibility();
cursor_currently_auto_hidden_ = false;
if (new_cursor_visibility == CursorVisibility::kAutoHidden) {
if (!GetCursorPos(&cursor_auto_hide_last_screen_pos_)) {
cursor_auto_hide_last_screen_pos_.x = LONG_MAX;
cursor_auto_hide_last_screen_pos_.y = LONG_MAX;
}
cursor_currently_auto_hidden_ = true;
} else if (old_cursor_visibility == CursorVisibility::kAutoHidden) {
if (cursor_auto_hide_timer_) {
DeleteTimerQueueTimer(nullptr, cursor_auto_hide_timer_, nullptr);
cursor_auto_hide_timer_ = nullptr;
}
}
SetCursorIfFocusedOnClientArea(
new_cursor_visibility == CursorVisibility::kVisible ? arrow_cursor_
: nullptr);
}
void Win32Window::FocusImpl() { SetFocus(hwnd_); }
std::unique_ptr<Surface> Win32Window::CreateSurfaceImpl(
Surface::TypeFlags allowed_types) {
HINSTANCE hInstance =
static_cast<const Win32WindowedAppContext&>(app_context()).hinstance();
if (allowed_types & Surface::kTypeFlag_Win32Hwnd) {
return std::make_unique<Win32HwndSurface>(hInstance, hwnd_);
}
return nullptr;
}
void Win32Window::RequestPaintImpl() { InvalidateRect(hwnd_, nullptr, FALSE); }
BOOL Win32Window::AdjustWindowRectangle(RECT& rect, DWORD style, BOOL menu,
DWORD ex_style, UINT dpi) const {
const Win32WindowedAppContext& win32_app_context =
static_cast<const Win32WindowedAppContext&>(app_context());
const Win32WindowedAppContext::PerMonitorDpiV2Api* per_monitor_dpi_v2_api =
win32_app_context.per_monitor_dpi_v2_api();
if (per_monitor_dpi_v2_api) {
return per_monitor_dpi_v2_api->adjust_window_rect_ex_for_dpi(
&rect, style, menu, ex_style, dpi);
}
// Before per-monitor DPI v2, there was no rescaling of the non-client
// area at runtime at all, so throughout the execution of the process it will
// behave the same regardless of the DPI.
return AdjustWindowRectEx(&rect, style, menu, ex_style);
}
BOOL Win32Window::AdjustWindowRectangle(RECT& rect) const {
if (!hwnd_) {
return FALSE;
}
return AdjustWindowRectangle(rect, GetWindowLong(hwnd_, GWL_STYLE),
BOOL(GetMainMenu() != nullptr),
GetWindowLong(hwnd_, GWL_EXSTYLE), dpi_);
}
uint32_t Win32Window::GetCurrentSystemDpi() const {
const Win32WindowedAppContext& win32_app_context =
static_cast<const Win32WindowedAppContext&>(app_context());
const Win32WindowedAppContext::PerMonitorDpiV2Api* per_monitor_dpi_v2_api =
win32_app_context.per_monitor_dpi_v2_api();
if (per_monitor_dpi_v2_api) {
return per_monitor_dpi_v2_api->get_dpi_for_system();
}
HDC screen_hdc = GetDC(nullptr);
if (!screen_hdc) {
return USER_DEFAULT_SCREEN_DPI;
}
// According to MSDN, x and y are identical.
int logical_pixels_x = GetDeviceCaps(screen_hdc, LOGPIXELSX);
ReleaseDC(nullptr, screen_hdc);
return uint32_t(logical_pixels_x);
}
uint32_t Win32Window::GetCurrentDpi() const {
if (hwnd_) {
const Win32WindowedAppContext& win32_app_context =
static_cast<const Win32WindowedAppContext&>(app_context());
const Win32WindowedAppContext::PerMonitorDpiV2Api* per_monitor_dpi_v2_api =
win32_app_context.per_monitor_dpi_v2_api();
if (per_monitor_dpi_v2_api) {
return per_monitor_dpi_v2_api->get_dpi_for_window(hwnd_);
}
const Win32WindowedAppContext::PerMonitorDpiV1Api* per_monitor_dpi_v1_api =
win32_app_context.per_monitor_dpi_v1_api();
if (per_monitor_dpi_v1_api) {
HMONITOR monitor = MonitorFromWindow(hwnd_, MONITOR_DEFAULTTONEAREST);
UINT monitor_dpi_x, monitor_dpi_y;
if (monitor &&
SUCCEEDED(per_monitor_dpi_v1_api->get_dpi_for_monitor(
monitor, MDT_DEFAULT, &monitor_dpi_x, &monitor_dpi_y))) {
// According to MSDN, x and y are identical.
return monitor_dpi_x;
}
}
}
return GetCurrentSystemDpi();
}
void Win32Window::ApplyFullscreenEntry(
WindowDestructionReceiver& destruction_receiver) {
if (!IsFullscreen()) {
return;
}
// https://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
// No reason to use MONITOR_DEFAULTTOPRIMARY instead of
// MONITOR_DEFAULTTONEAREST, however.
pre_fullscreen_dpi_ = dpi_;
pre_fullscreen_placement_.length = sizeof(pre_fullscreen_placement_);
HMONITOR monitor;
MONITORINFO monitor_info;
monitor_info.cbSize = sizeof(monitor_info);
if (!GetWindowPlacement(hwnd_, &pre_fullscreen_placement_) ||
!(monitor = MonitorFromWindow(hwnd_, MONITOR_DEFAULTTONEAREST)) ||
!GetMonitorInfo(monitor, &monitor_info)) {
OnDesiredFullscreenUpdate(false);
return;
}
// Preserve values for DPI rescaling of the window in the non-maximized state
// if DPI is changed mid-fullscreen.
// Get the size of the non-client area to subtract it from the size of the
// entire window in its non-maximized state, to get the client area. For
// safety, in case the window is somehow smaller than its non-client area
// (AdjustWindowRect is not exact in various cases also, such as when the menu
// becomes multiline), clamp to 0.
RECT non_client_area_rect = {};
AdjustWindowRectangle(non_client_area_rect);
pre_fullscreen_normal_client_width_ = uint32_t(
std::max((pre_fullscreen_placement_.rcNormalPosition.right -
pre_fullscreen_placement_.rcNormalPosition.left) -
(non_client_area_rect.right - non_client_area_rect.left),
LONG(0)));
pre_fullscreen_normal_client_height_ = uint32_t(
std::max((pre_fullscreen_placement_.rcNormalPosition.bottom -
pre_fullscreen_placement_.rcNormalPosition.top) -
(non_client_area_rect.bottom - non_client_area_rect.top),
LONG(0)));
// Changing the style and the menu may change the size too, don't handle the
// resize multiple times (also potentially with the listeners changing the
// desired fullscreen if called from the handling of some message like
// WM_SIZE).
BeginBatchedSizeUpdate();
// Remove the non-client area.
if (GetMainMenu()) {
SetMenu(hwnd_, nullptr);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
if (!destruction_receiver.IsWindowDestroyed()) {
EndBatchedSizeUpdate(destruction_receiver);
}
return;
}
}
SetWindowLong(hwnd_, GWL_STYLE,
GetWindowLong(hwnd_, GWL_STYLE) & ~DWORD(WS_OVERLAPPEDWINDOW));
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
if (!destruction_receiver.IsWindowDestroyed()) {
EndBatchedSizeUpdate(destruction_receiver);
}
return;
}
// Resize the window to fullscreen. It is important that this is done _after_
// disabling the decorations and the menu, to make sure that composition will
// not have to be done for the new size of the window at all, so independent,
// low-latency presentation is possible immediately - if the window was
// involved in composition, it may stay composed persistently until some other
// state change that sometimes helps, sometimes doesn't, even if it becomes
// borderless fullscreen again - this occurs sometimes at least on Windows 11
// 21H2 on Nvidia GeForce GTX 1070 on driver version 472.12.
SetWindowPos(hwnd_, HWND_TOP, monitor_info.rcMonitor.left,
monitor_info.rcMonitor.top,
monitor_info.rcMonitor.right - monitor_info.rcMonitor.left,
monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top,
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
if (!destruction_receiver.IsWindowDestroyed()) {
EndBatchedSizeUpdate(destruction_receiver);
}
return;
}
EndBatchedSizeUpdate(destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return;
}
}
void Win32Window::HandleSizeUpdate(
WindowDestructionReceiver& destruction_receiver) {
if (!hwnd_) {
// Batched size update ended when the window has already been closed, for
// instance.
return;
}
{
MonitorUpdateEvent e(this, false);
OnMonitorUpdate(e);
}
// For the desired size in the normal, not maximized and not fullscreen state.
if (!IsFullscreen()) {
WINDOWPLACEMENT window_placement;
window_placement.length = sizeof(window_placement);
if (GetWindowPlacement(hwnd_, &window_placement)) {
// window_placement.rcNormalPosition is the entire window's rectangle, not
// only the client area - convert to client.
// https://devblogs.microsoft.com/oldnewthing/20131017-00/?p=2903
// For safety, in case the window is somehow smaller than its non-client
// area (AdjustWindowRect is not exact in various cases also, such as when
// the menu becomes multiline), clamp to 0.
RECT non_client_area_rect = {};
if (AdjustWindowRectangle(non_client_area_rect)) {
OnDesiredLogicalSizeUpdate(
SizeToLogical(uint32_t(std::max(
(window_placement.rcNormalPosition.right -
window_placement.rcNormalPosition.left) -
(non_client_area_rect.right - non_client_area_rect.left),
LONG(0)))),
SizeToLogical(uint32_t(std::max(
(window_placement.rcNormalPosition.bottom -
window_placement.rcNormalPosition.top) -
(non_client_area_rect.bottom - non_client_area_rect.top),
LONG(0)))));
}
}
}
// For the actual state.
// GetClientRect returns a rectangle with 0 origin.
RECT client_rect;
if (GetClientRect(hwnd_, &client_rect)) {
OnActualSizeUpdate(uint32_t(client_rect.right),
uint32_t(client_rect.bottom), destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
return;
}
}
}
void Win32Window::BeginBatchedSizeUpdate() {
// It's okay if batched_size_update_contained_* are not false when beginning
// a batched update, in case the new batched update was started by a window
// listener called from within EndBatchedSizeUpdate.
++batched_size_update_depth_;
}
void Win32Window::EndBatchedSizeUpdate(
WindowDestructionReceiver& destruction_receiver) {
assert_not_zero(batched_size_update_depth_);
if (--batched_size_update_depth_) {
return;
}
// Resetting batched_size_update_contained_* in closing, not opening, because
// a listener may start a new batch, and finish it, and there won't be need to
// handle the deferred messages twice.
if (batched_size_update_contained_wm_size_) {
batched_size_update_contained_wm_size_ = false;
HandleSizeUpdate(destruction_receiver);
if (destruction_receiver.IsWindowDestroyed()) {
return;
}
}
if (batched_size_update_contained_wm_paint_) {
batched_size_update_contained_wm_paint_ = false;
RequestPaint();
}
}
bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam,
WindowDestructionReceiver& destruction_receiver) {
// Mouse messages usually contain the position in the client area in lParam,
// but WM_MOUSEWHEEL is an exception, it passes the screen position.
int32_t message_x = GET_X_LPARAM(lParam);
int32_t message_y = GET_Y_LPARAM(lParam);
bool message_pos_is_screen = message == WM_MOUSEWHEEL;
POINT client_pos = {message_x, message_y};
if (message_pos_is_screen) {
ScreenToClient(hwnd_, &client_pos);
}
if (GetCursorVisibility() == CursorVisibility::kAutoHidden) {
POINT screen_pos = {message_x, message_y};
if (message_pos_is_screen || ClientToScreen(hwnd_, &screen_pos)) {
if (screen_pos.x != cursor_auto_hide_last_screen_pos_.x ||
screen_pos.y != cursor_auto_hide_last_screen_pos_.y) {
// WM_MOUSEMOVE messages followed by WM_SETCURSOR may be sent for
// reasons not always involving actual mouse movement performed by the
// user. They're sent when the position of the cursor relative to the
// client area has been changed, as well as other events related to
// window management (including when creating the window), even when not
// interacting with the OS. These should not be revealing the cursor.
// Only revealing it if the mouse has actually been moved.
cursor_currently_auto_hidden_ = false;
SetCursorAutoHideTimer();
// There's no need to SetCursor here, mouse messages relevant to the
// cursor within the window are always followed by WM_SETCURSOR.
cursor_auto_hide_last_screen_pos_ = screen_pos;
}
}
}
MouseEvent::Button button = MouseEvent::Button::kNone;
int32_t scroll_y = 0;
switch (message) {
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
button = MouseEvent::Button::kLeft;
break;
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
button = MouseEvent::Button::kRight;
break;
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
button = MouseEvent::Button::kMiddle;
break;
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
switch (GET_XBUTTON_WPARAM(wParam)) {
case XBUTTON1:
button = MouseEvent::Button::kX1;
break;
case XBUTTON2:
button = MouseEvent::Button::kX2;
break;
default:
// Still handle the movement.
break;
}
break;
case WM_MOUSEMOVE:
button = MouseEvent::Button::kNone;
break;
case WM_MOUSEWHEEL:
button = MouseEvent::Button::kNone;
static_assert(
MouseEvent::kScrollPerDetent == WHEEL_DELTA,
"Assuming the Windows scroll amount can be passed directly to "
"MouseEvent");
scroll_y = GET_WHEEL_DELTA_WPARAM(wParam);
break;
default:
return false;
}
MouseEvent e(this, button, client_pos.x, client_pos.y, 0, scroll_y);
switch (message) {
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_XBUTTONDOWN:
OnMouseDown(e, destruction_receiver);
break;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
case WM_MBUTTONUP:
case WM_XBUTTONUP:
OnMouseUp(e, destruction_receiver);
break;
case WM_MOUSEMOVE:
OnMouseMove(e, destruction_receiver);
break;
case WM_MOUSEWHEEL:
OnMouseWheel(e, destruction_receiver);
break;
default:
break;
}
// Returning immediately anyway - no need to check
// destruction_receiver.IsWindowDestroyed().
return e.is_handled();
}
bool Win32Window::HandleKeyboard(
UINT message, WPARAM wParam, LPARAM lParam,
WindowDestructionReceiver& destruction_receiver) {
KeyEvent e(this, VirtualKey(wParam), lParam & 0xFFFF,
!!(lParam & (LPARAM(1) << 30)), !!(GetKeyState(VK_SHIFT) & 0x80),
!!(GetKeyState(VK_CONTROL) & 0x80),
!!(GetKeyState(VK_MENU) & 0x80), !!(GetKeyState(VK_LWIN) & 0x80));
switch (message) {
case WM_KEYDOWN:
OnKeyDown(e, destruction_receiver);
break;
case WM_KEYUP:
OnKeyUp(e, destruction_receiver);
break;
case WM_CHAR:
OnKeyChar(e, destruction_receiver);
break;
default:
break;
}
// Returning immediately anyway - no need to check
// destruction_receiver.IsWindowDestroyed().
return e.is_handled();
}
void Win32Window::SetCursorIfFocusedOnClientArea(HCURSOR cursor) const {
if (!HasFocus()) {
return;
}
POINT cursor_pos;
if (!GetCursorPos(&cursor_pos)) {
return;
}
if (WindowFromPoint(cursor_pos) == hwnd_ &&
SendMessage(hwnd_, WM_NCHITTEST, 0,
MAKELONG(cursor_pos.x, cursor_pos.y)) == HTCLIENT) {
SetCursor(cursor);
}
}
void Win32Window::SetCursorAutoHideTimer() {
// Reset the timer by deleting the old timer and creating the new one.
// ChangeTimerQueueTimer doesn't work if the timer has already expired.
if (cursor_auto_hide_timer_) {
DeleteTimerQueueTimer(nullptr, cursor_auto_hide_timer_, nullptr);
cursor_auto_hide_timer_ = nullptr;
}
// After making sure that the callback is not callable anymore
// (DeleteTimerQueueTimer waits for the completion of the callback if it has
// been called already, or cancels it if it's hasn't), update the most recent
// message revision.
last_cursor_auto_hide_queued = last_cursor_auto_hide_signaled + 1;
CreateTimerQueueTimer(&cursor_auto_hide_timer_, nullptr,
AutoHideCursorTimerCallback, this,
kDefaultCursorAutoHideMilliseconds, 0,
WT_EXECUTEINTIMERTHREAD | WT_EXECUTEONLYONCE);
}
void Win32Window::AutoHideCursorTimerCallback(void* parameter,
BOOLEAN timer_or_wait_fired) {
if (!timer_or_wait_fired) {
// Not a timer callback.
return;
}
Win32Window& window = *static_cast<Win32Window*>(parameter);
window.last_cursor_auto_hide_signaled = window.last_cursor_auto_hide_queued;
SendMessage(window.hwnd_, kUserMessageAutoHideCursor,
window.last_cursor_auto_hide_signaled, 0);
}
LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam) {
if (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) {
WindowDestructionReceiver destruction_receiver(this);
// Returning immediately anyway - no need to check
// destruction_receiver.IsWindowDestroyed() afterwards.
return HandleMouse(message, wParam, lParam, destruction_receiver)
? 0
: DefWindowProc(hWnd, message, wParam, lParam);
}
if (message >= WM_KEYFIRST && message <= WM_KEYLAST) {
WindowDestructionReceiver destruction_receiver(this);
// Returning immediately anyway - no need to check
// destruction_receiver.IsWindowDestroyed() afterwards.
return HandleKeyboard(message, wParam, lParam, destruction_receiver)
? 0
: DefWindowProc(hWnd, message, wParam, lParam);
}
switch (message) {
case WM_CLOSE:
// In case the Windows window was somehow forcibly destroyed without
// WM_CLOSE.
case WM_DESTROY: {
if (cursor_auto_hide_timer_) {
DeleteTimerQueueTimer(nullptr, cursor_auto_hide_timer_, nullptr);
cursor_auto_hide_timer_ = nullptr;
}
{
WindowDestructionReceiver destruction_receiver(this);
OnBeforeClose(destruction_receiver);
if (destruction_receiver.IsWindowDestroyed()) {
break;
}
}
// Set hwnd_ to null to ignore events from now on since this Win32Window
// is entering an indeterminate state - this should be done at some point
// in closing anyway.
hwnd_ = nullptr;
SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
if (message != WM_DESTROY) {
DestroyWindow(hWnd);
}
OnAfterClose();
} break;
case WM_DROPFILES: {
HDROP drop_handle = reinterpret_cast<HDROP>(wParam);
auto drop_count = DragQueryFileW(drop_handle, 0xFFFFFFFFu, nullptr, 0);
if (drop_count > 0) {
// Get required buffer size
UINT path_size = DragQueryFileW(drop_handle, 0, nullptr, 0);
if (path_size > 0 && path_size < 0xFFFFFFFFu) {
std::u16string path;
++path_size; // Ensure space for the null terminator
path.resize(path_size); // Reserve space
// Only getting first file dropped (other files ignored)
path_size =
DragQueryFileW(drop_handle, 0, (LPWSTR)&path[0], path_size);
if (path_size > 0) {
path.resize(path_size); // Will drop the null terminator
FileDropEvent e(this, xe::to_path(path));
WindowDestructionReceiver destruction_receiver(this);
OnFileDrop(e, destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
DragFinish(drop_handle);
break;
}
}
}
}
DragFinish(drop_handle);
} break;
case WM_MOVE: {
OnMonitorUpdate(MonitorUpdateEvent(this, false));
} break;
case WM_SIZE: {
if (batched_size_update_depth_) {
batched_size_update_contained_wm_size_ = true;
} else {
WindowDestructionReceiver destruction_receiver(this);
HandleSizeUpdate(destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
break;
}
}
} break;
case WM_PAINT: {
if (batched_size_update_depth_) {
// Avoid painting an outdated surface during a batched size update when
// WM_SIZE handling is deferred.
batched_size_update_contained_wm_paint_ = true;
} else {
ValidateRect(hwnd_, nullptr);
OnPaint();
}
// Custom painting via OnPaint - don't pass to DefWindowProc.
return 0;
} break;
case WM_ERASEBKGND: {
if (HasSurface()) {
// Don't erase between paints because painting may be dropped if nothing
// has changed since the last one.
return 0;
}
} break;
case WM_DISPLAYCHANGE: {
OnMonitorUpdate(MonitorUpdateEvent(this, true));
} break;
case WM_DPICHANGED: {
// Note that for some reason, WM_DPICHANGED is not sent when the window is
// borderless fullscreen with per-monitor DPI awareness v1.
dpi_ = GetCurrentDpi();
WindowDestructionReceiver destruction_receiver(this);
{
UISetupEvent e(this);
OnDpiChanged(e, destruction_receiver);
// The window might have been closed by the handler, check hwnd_ too
// since it's needed below.
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
break;
}
}
auto rect = reinterpret_cast<const RECT*>(lParam);
if (rect) {
// SetWindowPos arguments according to WM_DPICHANGED MSDN documentation.
// https://docs.microsoft.com/en-us/windows/win32/hidpi/wm-dpichanged
// There's no need to handle the maximized state any special way (by
// updating the window placement instead of the window position in this
// case, for instance), as Windows (by design) restores the window when
// changing the DPI to a new one.
SetWindowPos(hwnd_, nullptr, int(rect->left), int(rect->top),
int(rect->right - rect->left),
int(rect->bottom - rect->top),
SWP_NOZORDER | SWP_NOACTIVATE);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
break;
}
}
} break;
case WM_KILLFOCUS: {
WindowDestructionReceiver destruction_receiver(this);
OnFocusUpdate(false, destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
break;
}
} break;
case WM_SETFOCUS: {
WindowDestructionReceiver destruction_receiver(this);
OnFocusUpdate(true, destruction_receiver);
if (destruction_receiver.IsWindowDestroyedOrClosed()) {
break;
}
} break;
case WM_SETCURSOR: {
if (reinterpret_cast<HWND>(wParam) == hwnd_ && HasFocus() &&
LOWORD(lParam) == HTCLIENT) {
switch (GetCursorVisibility()) {
case CursorVisibility::kAutoHidden: {
// Always revealing the cursor in case of events like clicking, but
// WM_MOUSEMOVE messages may be sent for reasons not always
// involving actual mouse movement performed by the user. Revealing
// the cursor in case of movement is done in HandleMouse instead.
if (HIWORD(lParam) != WM_MOUSEMOVE) {
cursor_currently_auto_hidden_ = false;
SetCursorAutoHideTimer();
}
if (cursor_currently_auto_hidden_) {
SetCursor(nullptr);
return TRUE;
}
} break;
case CursorVisibility::kHidden:
SetCursor(nullptr);
return TRUE;
default:
break;
}
}
// For the non-client area, and for visible cursor, letting normal
// processing happen, setting the cursor to an arrow or to something
// specific to non-client parts of the window.
} break;
case kUserMessageAutoHideCursor: {
// Recheck the cursor visibility - the callback might have been called
// before or while the timer is deleted. Also ignore messages from
// outdated mouse interactions.
if (GetCursorVisibility() == CursorVisibility::kAutoHidden &&
wParam == last_cursor_auto_hide_queued) {
// The timer object is not needed anymore.
if (cursor_auto_hide_timer_) {
DeleteTimerQueueTimer(nullptr, cursor_auto_hide_timer_, nullptr);
cursor_auto_hide_timer_ = nullptr;
}
cursor_currently_auto_hidden_ = true;
SetCursorIfFocusedOnClientArea(nullptr);
}
return 0;
} break;
case WM_TABLET_QUERYSYSTEMGESTURESTATUS:
return
// disables press and hold (right-click) gesture
TABLET_DISABLE_PRESSANDHOLD |
// disables UI feedback on pen up (waves)
TABLET_DISABLE_PENTAPFEEDBACK |
// disables UI feedback on pen button down (circle)
TABLET_DISABLE_PENBARRELFEEDBACK |
// disables pen flicks (back, forward, drag down, drag up)
TABLET_DISABLE_FLICKS | TABLET_DISABLE_TOUCHSWITCH |
TABLET_DISABLE_SMOOTHSCROLLING | TABLET_DISABLE_TOUCHUIFORCEON |
TABLET_ENABLE_MULTITOUCHDATA;
case WM_MENUCOMMAND: {
MENUINFO menu_info = {0};
menu_info.cbSize = sizeof(menu_info);
menu_info.fMask = MIM_MENUDATA;
GetMenuInfo(HMENU(lParam), &menu_info);
auto parent_item = reinterpret_cast<Win32MenuItem*>(menu_info.dwMenuData);
auto child_item =
reinterpret_cast<Win32MenuItem*>(parent_item->child(wParam));
assert_not_null(child_item);
WindowDestructionReceiver destruction_receiver(this);
child_item->OnSelected();
if (destruction_receiver.IsWindowDestroyed()) {
break;
}
// The menu item might have been destroyed by its OnSelected, don't do
// anything with it here from now on.
} break;
}
// The window might have been destroyed by the handlers, don't interact with
// *this in this function from now on.
// Passing the original hWnd argument rather than hwnd_ as the window might
// have been closed or destroyed by a handler, making hwnd_ null even though
// DefWindowProc still needs to be called to propagate the closing-related
// messages needed by Windows, or inaccessible (due to use-after-free) at all.
return DefWindowProc(hWnd, message, wParam, lParam);
}
LRESULT CALLBACK Win32Window::WndProcThunk(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam) {
if (hWnd) {
Win32Window* window = nullptr;
if (message == WM_NCCREATE) {
auto create_struct = reinterpret_cast<LPCREATESTRUCT>(lParam);
window = reinterpret_cast<Win32Window*>(create_struct->lpCreateParams);
SetWindowLongPtr(hWnd, GWLP_USERDATA, (__int3264)(LONG_PTR)window);
// Don't miss any messages (as they may have effect on the actual state
// stored in Win32Window) sent before the completion of CreateWindowExW
// dropped because `window->hwnd_ != hWnd`, when the result of
// CreateWindowExW still hasn't been assigned to `hwnd_` (however, don't
// reattach this window to a closed window if WM_NCCREATE was somehow sent
// to a window being closed).
if (window->phase() == Phase::kOpening) {
assert_true(!window->hwnd_ || window->hwnd_ == hWnd);
window->hwnd_ = hWnd;
}
// Enable non-client area DPI scaling for AdjustWindowRectExForDpi to work
// correctly between Windows 10 1607 (when AdjustWindowRectExForDpi and
// EnableNonClientDpiScaling were added) and 1703 (when per-monitor
// awareness version 2 was added with automatically enabled non-client
// area DPI scaling).
const Win32WindowedAppContext& win32_app_context =
static_cast<const Win32WindowedAppContext&>(window->app_context());
const Win32WindowedAppContext::PerMonitorDpiV2Api*
per_monitor_dpi_v2_api = win32_app_context.per_monitor_dpi_v2_api();
if (per_monitor_dpi_v2_api) {
per_monitor_dpi_v2_api->enable_non_client_dpi_scaling(hWnd);
}
// Already fully handled, no need to call Win32Window::WndProc.
} else {
window =
reinterpret_cast<Win32Window*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
if (window && window->hwnd_ == hWnd) {
return window->WndProc(hWnd, message, wParam, lParam);
}
}
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
std::unique_ptr<ui::MenuItem> MenuItem::Create(Type type,
const std::string& text,
const std::string& hotkey,
std::function<void()> callback) {
return std::make_unique<Win32MenuItem>(type, text, hotkey, callback);
}
Win32MenuItem::Win32MenuItem(Type type, const std::string& text,
const std::string& hotkey,
std::function<void()> callback)
: MenuItem(type, text, hotkey, std::move(callback)) {
switch (type) {
case MenuItem::Type::kNormal:
handle_ = CreateMenu();
break;
case MenuItem::Type::kPopup:
handle_ = CreatePopupMenu();
break;
default:
// May just be a placeholder.
break;
}
if (handle_) {
MENUINFO menu_info = {0};
menu_info.cbSize = sizeof(menu_info);
menu_info.fMask = MIM_MENUDATA | MIM_STYLE;
menu_info.dwMenuData = ULONG_PTR(this);
menu_info.dwStyle = MNS_NOTIFYBYPOS;
SetMenuInfo(handle_, &menu_info);
}
}
Win32MenuItem::~Win32MenuItem() {
if (handle_) {
DestroyMenu(handle_);
}
}
void Win32MenuItem::SetEnabled(bool enabled) {
UINT enable_flags = MF_BYPOSITION | (enabled ? MF_ENABLED : MF_GRAYED);
UINT i = 0;
for (auto iter = children_.begin(); iter != children_.end(); ++iter, ++i) {
EnableMenuItem(handle_, i, enable_flags);
}
}
void Win32MenuItem::OnChildAdded(MenuItem* generic_child_item) {
auto child_item = static_cast<Win32MenuItem*>(generic_child_item);
switch (child_item->type()) {
case MenuItem::Type::kNormal:
// Nothing special.
break;
case MenuItem::Type::kPopup:
AppendMenuW(
handle_, MF_POPUP, reinterpret_cast<UINT_PTR>(child_item->handle()),
reinterpret_cast<LPCWSTR>(xe::to_utf16(child_item->text()).c_str()));
break;
case MenuItem::Type::kSeparator:
AppendMenuW(handle_, MF_SEPARATOR, UINT_PTR(child_item->handle_), 0);
break;
case MenuItem::Type::kString:
auto full_name = child_item->text();
if (!child_item->hotkey().empty()) {
full_name += "\t" + child_item->hotkey();
}
AppendMenuW(handle_, MF_STRING, UINT_PTR(child_item->handle_),
reinterpret_cast<LPCWSTR>(xe::to_utf16(full_name).c_str()));
break;
}
}
void Win32MenuItem::OnChildRemoved(MenuItem* generic_child_item) {}
} // namespace ui
} // namespace xe
| 38.569724
| 80
| 0.680059
|
amessier
|
f7acb0cf43b566c72b3399e639d41bdf13fbf701
| 2,424
|
hpp
|
C++
|
allocgc/include/liballocgc/details/utils/math.hpp
|
eucpp/allocgc
|
8d134d58515e0e2a7348fdd1fdbe8c2e8423cfef
|
[
"Apache-2.0"
] | null | null | null |
allocgc/include/liballocgc/details/utils/math.hpp
|
eucpp/allocgc
|
8d134d58515e0e2a7348fdd1fdbe8c2e8423cfef
|
[
"Apache-2.0"
] | 2
|
2017-01-17T16:24:59.000Z
|
2017-06-08T17:39:26.000Z
|
allocgc/include/liballocgc/details/utils/math.hpp
|
eucpp/allocgc
|
8d134d58515e0e2a7348fdd1fdbe8c2e8423cfef
|
[
"Apache-2.0"
] | null | null | null |
#ifndef ALLOCGC_UTIL_H
#define ALLOCGC_UTIL_H
#include <cassert>
#include <cstddef>
#include <climits>
namespace allocgc { namespace details {
constexpr bool check_pow2(size_t n)
{
return (n != 0) && !(n & (n - 1));
}
constexpr size_t pow2(size_t n)
{
return ((size_t) 1) << n;
}
// returns log2 if argument is a power of 2
inline size_t log2(size_t n)
{
assert(check_pow2(n));
size_t l = sizeof(size_t) * CHAR_BIT, r = 0;
while (true) {
size_t m = ((l - r) >> 1) + r;
if (l == m || r == m) {
return m;
}
if (((((size_t)1 << m) - 1) & n) == 0) {
r = m;
}
else {
l = m;
}
}
}
// implementation is taken from http://stackoverflow.com/a/11398748/4676150
inline size_t msb(unsigned long long n)
{
static const std::int8_t tab64[64] = {
63, 0, 58, 1, 59, 47, 53, 2,
60, 39, 48, 27, 54, 33, 42, 3,
61, 51, 37, 40, 49, 18, 28, 20,
55, 30, 34, 11, 43, 14, 22, 4,
62, 57, 46, 52, 38, 26, 32, 41,
50, 36, 17, 19, 29, 10, 13, 21,
56, 45, 25, 31, 35, 16, 9, 12,
44, 24, 15, 8, 23, 7, 6, 5
};
assert(n != 0);
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n |= n >> 32;
return tab64[((uint64_t)((n - (n >> 1))*0x07EDD5E59A4E28C2)) >> 58];
}
/**
* implementation is taken from http://chessprogramming.wikispaces.com/BitScan
*
* bitScanForward
* @author Martin Läuter (1997)
* Charles E. Leiserson
* Harald Prokop
* Keith H. Randall
* "Using de Bruijn Sequences to Index a 1 in a Computer Word"
* @param bb bitboard to scan
* @precondition bb != 0
* @return index (0..63) of least significant one bit
*/
inline size_t lsb(unsigned long long n)
{
static const size_t index64[64] = {
0, 1, 48, 2, 57, 49, 28, 3,
61, 58, 50, 42, 38, 29, 17, 4,
62, 55, 59, 36, 53, 51, 43, 22,
45, 39, 33, 30, 24, 18, 12, 5,
63, 47, 56, 27, 60, 41, 37, 16,
54, 35, 52, 21, 44, 32, 23, 11,
46, 26, 40, 15, 34, 20, 31, 10,
25, 14, 19, 9, 13, 8, 7, 6
};
const unsigned long long debruijn64 = 0x03f79d71b4cb0a89ULL;
assert (n != 0);
return index64[((n & -n) * debruijn64) >> 58];
}
}}
#endif //ALLOCGC_UTIL_H
| 24.484848
| 78
| 0.496287
|
eucpp
|
f7af5f27538917636a5d0e6b9212b0dfd9841f4a
| 2,157
|
hpp
|
C++
|
include/nginxconfig/parse.hpp
|
tgockel/nginxconfig
|
57a4a4c00ee4f47b617ba2d7eaceab14ee20fa44
|
[
"Apache-2.0"
] | 10
|
2015-02-12T02:42:06.000Z
|
2021-06-03T13:14:29.000Z
|
include/nginxconfig/parse.hpp
|
tgockel/nginxconfig
|
57a4a4c00ee4f47b617ba2d7eaceab14ee20fa44
|
[
"Apache-2.0"
] | null | null | null |
include/nginxconfig/parse.hpp
|
tgockel/nginxconfig
|
57a4a4c00ee4f47b617ba2d7eaceab14ee20fa44
|
[
"Apache-2.0"
] | 4
|
2015-08-04T21:02:53.000Z
|
2021-08-05T07:20:38.000Z
|
/** \file nginxconfig/parse.hpp
* Include this file if you're trying to parse an nginx configuration file.
*
* Copyright (c) 2014 by Travis Gockel. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it under the terms of the Apache License
* as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* \author Travis Gockel (travis@gockelhut.com)
**/
#ifndef __NGINXCONFIG_PARSE_HPP_INCLUDED__
#define __NGINXCONFIG_PARSE_HPP_INCLUDED__
#include <nginxconfig/config.hpp>
#include <iosfwd>
#include <string>
#include <stdexcept>
namespace nginxconfig
{
class ast_entry;
class NGINXCONFIG_PUBLIC parse_error :
public std::runtime_error
{
public:
using size_type = std::size_t;
/** In some cases, problems do not occur at a specific column (such as EOF). In these cases, the value of \c column
* will be set to \c no_column.
**/
static constexpr size_type no_column = ~0;
public:
explicit parse_error(size_type line, size_type column, size_type character, std::string message);
virtual ~parse_error() noexcept;
/** The line of input this error was encountered on. **/
size_type line() const { return _line; }
/** The character index on the current line this error was encountered on. **/
size_type column() const { return _column; }
/** The character index into the entire input this error was encountered on. **/
size_type character() const { return _character; }
/** A message from the parser which has user-readable details about the encountered problem. **/
const std::string& message() const { return _message; }
private:
size_type _line;
size_type _column;
size_type _character;
std::string _message;
};
/** Parse the given input. The root entry will always be have \c ast_entry_kind::document. **/
ast_entry parse(std::istream& input);
/** Convenience function to parse a given file. **/
ast_entry parse_file(const std::string& filename);
}
#endif/*__NGINXCONFIG_PARSE_HPP_INCLUDED__*/
| 30.814286
| 119
| 0.707464
|
tgockel
|
f7b0273836636363af823cae001b5197c9f95934
| 849
|
cc
|
C++
|
sample_addon/8_passing_wrapped/node_0.12/addon.cc
|
Cereceres/SVD-
|
bac3b8cce5b958aaccc1081ec60ecc5c81b3b2f9
|
[
"MIT"
] | 24
|
2018-11-20T14:45:57.000Z
|
2021-12-30T13:38:42.000Z
|
sample_addon/8_passing_wrapped/node_0.12/addon.cc
|
Cereceres/SVD
|
bac3b8cce5b958aaccc1081ec60ecc5c81b3b2f9
|
[
"MIT"
] | null | null | null |
sample_addon/8_passing_wrapped/node_0.12/addon.cc
|
Cereceres/SVD
|
bac3b8cce5b958aaccc1081ec60ecc5c81b3b2f9
|
[
"MIT"
] | 11
|
2018-11-29T00:09:14.000Z
|
2021-11-23T08:13:17.000Z
|
#include <node.h>
#include <node_object_wrap.h>
#include "myobject.h"
using namespace v8;
void CreateObject(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
MyObject::NewInstance(args);
}
void Add(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
MyObject* obj1 = node::ObjectWrap::Unwrap<MyObject>(
args[0]->ToObject());
MyObject* obj2 = node::ObjectWrap::Unwrap<MyObject>(
args[1]->ToObject());
double sum = obj1->value() + obj2->value();
args.GetReturnValue().Set(Number::New(isolate, sum));
}
void InitAll(Handle<Object> exports) {
MyObject::Init();
NODE_SET_METHOD(exports, "createObject", CreateObject);
NODE_SET_METHOD(exports, "add", Add);
}
NODE_MODULE(addon, InitAll)
| 24.970588
| 60
| 0.709069
|
Cereceres
|
fc92983a4fbc4cadfe22630b95519c852898c683
| 2,125
|
cpp
|
C++
|
trunk/ProjectFootball/src/audio/CPlayListSystem.cpp
|
dividio/projectfootball
|
3c0b94937de2e3cd6e7daf9d3b4942fda974f20c
|
[
"Zlib"
] | null | null | null |
trunk/ProjectFootball/src/audio/CPlayListSystem.cpp
|
dividio/projectfootball
|
3c0b94937de2e3cd6e7daf9d3b4942fda974f20c
|
[
"Zlib"
] | null | null | null |
trunk/ProjectFootball/src/audio/CPlayListSystem.cpp
|
dividio/projectfootball
|
3c0b94937de2e3cd6e7daf9d3b4942fda974f20c
|
[
"Zlib"
] | null | null | null |
/******************************************************************************
* Copyright (C) 2007 - Ikaro Games www.ikarogames.com *
* *
* This program 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 2 *
* of the License, or (at your option) any later version. *
* *
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* *
******************************************************************************/
#include "CPlayListSystem.h"
CPlayListSystem::CPlayListSystem()
{
}
CPlayListSystem::~CPlayListSystem()
{
}
void CPlayListSystem::addTrack(IAudioFile * audioFile)
{
}
void CPlayListSystem::deleteTrack(int pos)
{
}
CPlayListSystem * CPlayListSystem::getInstance()
{
return 0;
}
void CPlayListSystem::nextTrack()
{
}
void CPlayListSystem::pausePlayback()
{
}
void CPlayListSystem::previousTrack()
{
}
void CPlayListSystem::startPlayback(int pos)
{
}
void CPlayListSystem::stopPlayback()
{
}
| 25.60241
| 80
| 0.448
|
dividio
|
fc981c53fabc0c784fc498dab6ff4051d4f55b06
| 28,217
|
cpp
|
C++
|
dist/wcjukebox/src/main.cpp
|
Bekenn/wcdx
|
148bda0c17b9a977e2ef90f27d48b206f89498da
|
[
"MIT"
] | 14
|
2015-01-13T18:33:37.000Z
|
2022-01-10T22:17:41.000Z
|
dist/wcjukebox/src/main.cpp
|
Bekenn/wcdx
|
148bda0c17b9a977e2ef90f27d48b206f89498da
|
[
"MIT"
] | 5
|
2020-07-12T22:54:11.000Z
|
2022-01-30T12:18:56.000Z
|
dist/wcjukebox/src/main.cpp
|
Bekenn/wcdx
|
148bda0c17b9a977e2ef90f27d48b206f89498da
|
[
"MIT"
] | 1
|
2019-05-24T22:18:10.000Z
|
2019-05-24T22:18:10.000Z
|
#include "wcaudio_stream.h"
#include "wave.h"
#include <stdext/array_view.h>
#include <stdext/file.h>
#include <stdext/scope_guard.h>
#include <stdext/string.h>
#include <stdext/utility.h>
#include <filesystem>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string_view>
#include <unordered_map>
#include <utility>
#include <cstdlib>
#include <cstddef>
using namespace std::literals;
namespace
{
enum : uint32_t
{
mode_none = 0x000,
mode_track = 0x001,
mode_wc2 = 0x002,
mode_trigger = 0x004,
mode_intensity = 0x008,
mode_stream = 0x010,
mode_show_tracks = 0x020,
mode_show_triggers = 0x040,
mode_wav = 0x080,
mode_loop = 0x100,
mode_single = 0x200,
mode_debug_info = 0x400
};
struct program_options
{
uint32_t program_mode = mode_none;
int track = -1;
const wchar_t* stream_path = nullptr;
const wchar_t* wav_path = nullptr;
uint8_t trigger = no_trigger;
uint8_t intensity = 15; // default for WC1 (selects patrol music)
int loops = -1;
};
class usage_error : public std::runtime_error
{
using runtime_error::runtime_error;
};
void show_usage(const wchar_t* invocation);
void diagnose_mode(uint32_t mode);
void diagnose_unrecognized(const wchar_t* str);
void show_tracks(program_options& options);
void select_track(program_options& options);
int parse_int(const wchar_t* str);
}
int wmain(int argc, wchar_t* argv[])
{
std::wstring invocation = argc > 0 ? std::filesystem::path(argv[0]).filename() : "wcjukebox";
try
{
if (argc < 2)
{
show_usage(invocation.c_str());
return EXIT_SUCCESS;
}
program_options options;
for (const wchar_t* const* arg = &argv[1]; *arg != nullptr; ++arg)
{
if ((*arg)[0] == L'-' || (*arg)[0] == L'/')
{
if (*arg + 1 == L"track"sv)
{
if ((options.program_mode & mode_track) != 0)
throw usage_error("The -track option can only be used once.");
options.program_mode |= mode_track;
diagnose_mode(options.program_mode);
auto game = *++arg;
if (game == L"wc2"sv)
options.program_mode |= mode_wc2;
else if (game != L"wc1"sv)
throw usage_error("The -track option must be followed by 'wc1' or 'wc2'.");
options.track = parse_int(*++arg);
}
else if (*arg + 1 == L"trigger"sv)
{
if ((options.program_mode & mode_trigger) != 0)
throw usage_error("The -trigger option can only be used once.");
options.program_mode |= mode_trigger;
diagnose_mode(options.program_mode);
auto value = parse_int(*++arg);
if (value < 0 || unsigned(value) > 0xFF)
throw usage_error("Trigger must be between 0 and 255.");
options.trigger = uint8_t(value);
}
else if (*arg + 1 == L"show-tracks"sv)
{
if ((options.program_mode & mode_show_tracks) != 0)
throw usage_error("The -show-tracks option can only be used once.");
options.program_mode |= mode_show_tracks;
diagnose_mode(options.program_mode);
auto game = *++arg;
if (game == L"wc2"sv)
options.program_mode |= mode_wc2;
else if (game != L"wc1"sv)
throw usage_error("The -show-tracks option must be followed by 'wc1' or 'wc2'.");
}
else if (*arg + 1 == L"show-triggers"sv)
{
if ((options.program_mode & mode_show_triggers) != 0)
throw usage_error("The -show-triggers option can only be used once.");
options.program_mode |= mode_show_triggers;
diagnose_mode(options.program_mode);
options.stream_path = *++arg;
if (options.stream_path == nullptr)
throw usage_error("Expected STR file path.");
}
else if (*arg + 1 == L"o"sv)
{
if ((options.program_mode & mode_wav) != 0)
throw usage_error("The -o option can only be used once.");
options.program_mode |= mode_wav;
diagnose_mode(options.program_mode);
options.wav_path = *++arg;
if (options.wav_path == nullptr)
throw usage_error("Expected WAV file path.");
}
else if (*arg + 1 == L"intensity"sv)
{
if ((options.program_mode & mode_intensity) != 0)
throw usage_error("The -intensity option can only be used once.");
options.program_mode |= mode_intensity;
diagnose_mode(options.program_mode);
auto value = parse_int(*++arg);
if (value < 0 || unsigned(value) > 100)
throw usage_error("Intensity must be between 0 and 100.");
options.intensity = uint8_t(value);
}
else if (*arg + 1 == L"loop"sv)
{
if ((options.program_mode & mode_loop) != 0)
throw usage_error("The -loop option can only be used once.");
options.program_mode |= mode_loop;
diagnose_mode(options.program_mode);
options.loops = parse_int(*++arg);
if (options.loops < 0)
throw usage_error("The -loop option cannot be negative.");
}
else if (*arg + 1 == L"single"sv)
{
if ((options.program_mode & mode_single) != 0)
throw usage_error("The -single option can only be used once.");
options.program_mode |= mode_single;
diagnose_mode(options.program_mode);
}
else if (*arg + 1 == L"debug-info"sv)
{
if ((options.program_mode & mode_debug_info) != 0)
throw usage_error("The debug-info option can only be used once.");
options.program_mode |= mode_debug_info;
diagnose_mode(options.program_mode);
}
else
diagnose_unrecognized(*arg);
}
else
{
if ((options.program_mode & mode_stream) != 0)
diagnose_unrecognized(*arg);
options.program_mode |= mode_stream;
diagnose_mode(options.program_mode);
options.stream_path = *arg;
}
}
if ((options.program_mode & (mode_track | mode_stream | mode_show_tracks | mode_show_triggers)) == 0)
throw usage_error("Missing required options.");
if ((options.program_mode & mode_show_tracks) != 0)
{
show_tracks(options);
return EXIT_SUCCESS;
}
if ((options.program_mode & mode_track) != 0)
select_track(options);
stdext::file_input_stream file(options.stream_path);
wcaudio_stream stream(file);
if ((options.program_mode & mode_show_triggers) != 0)
{
std::cout << "Available triggers:";
for (auto trigger : stream.triggers())
std::cout << ' ' << unsigned(trigger);
std::cout << "\nAvailable intensities:";
for (auto intensity : stream.intensities())
std::cout << ' ' << unsigned(intensity);
std::cout << '\n';
return EXIT_SUCCESS;
}
std::unordered_map<uint32_t, unsigned> chunk_frame_map;
chunk_frame_map.reserve(128);
stream.on_next_chunk([&](uint32_t chunk_index, unsigned frame_count)
{
chunk_frame_map.insert({ chunk_index, frame_count });
});
stream.on_loop([&](uint32_t chunk_index, unsigned frame_count)
{
stdext::discard(frame_count);
if ((options.program_mode & mode_debug_info) != 0)
{
std::cout << "Loop to chunk " << chunk_index
<< " (frame index " << chunk_frame_map[chunk_index] << ')'
<< std::endl;
}
return options.loops < 0 || options.loops-- != 0;
});
stream.on_start_track([&](uint32_t chunk_index)
{
if ((options.program_mode & mode_debug_info) != 0)
std::cout << "Start track at chunk " << chunk_index << std::endl;
chunk_frame_map.insert({ chunk_index, 0 });
});
stream.on_next_track([&](uint32_t chunk_index, unsigned frame_count)
{
chunk_frame_map.insert({ chunk_index, frame_count });
if ((options.program_mode & mode_debug_info) != 0)
std::cout << "Switch to track at chunk " << chunk_index << std::endl;
return (options.program_mode & mode_single) == 0;
});
stream.on_prev_track([&](unsigned frame_count)
{
stdext::discard(frame_count);
if ((options.program_mode & mode_debug_info) != 0)
std::cout << "Return to previous track" << std::endl;
});
stream.on_end_of_stream([&](unsigned frame_count)
{
stdext::discard(frame_count);
if ((options.program_mode & mode_debug_info) != 0)
std::cout << "End of stream" << std::endl;
});
if ((options.program_mode & mode_wav) == 0)
std::cout << "Press Ctrl-C to end playback." << std::endl;
stream.select(options.trigger, options.intensity);
if ((options.program_mode & mode_wav) != 0)
{
if (options.loops < 0)
options.loops = 0;
stdext::file_output_stream out(options.wav_path);
write_wave(out, stream, stream.channels(), stream.sample_rate(), stream.bits_per_sample(), stream.buffer_size());
}
else
play_wave(stream, stream.channels(), stream.sample_rate(), stream.bits_per_sample(), stream.buffer_size());
return EXIT_SUCCESS;
}
catch (const usage_error& e)
{
std::cerr << "Error: " << e.what() << '\n';
show_usage(invocation.c_str());
}
catch (const std::exception& e)
{
std::cerr << "Error: " << e.what() << '\n';
}
catch (...)
{
std::cerr << "Unknown error\n";
}
return EXIT_FAILURE;
}
namespace
{
enum stream_archive
{
invalid = -1,
wc1_preflight, wc1_postflight, wc1_mission,
wc2_gameflow, wc2_gametwo, wc2_spaceflight
};
struct track_desc
{
stream_archive archive;
uint8_t trigger;
};
constexpr const wchar_t* stream_filenames[]
{
L"STREAMS\\PREFLITE.STR",
L"STREAMS\\POSFLITE.STR",
L"STREAMS\\MISSION.STR",
L"STREAMS\\GAMEFLOW.STR",
L"STREAMS\\GAMETWO.STR",
L"STREAMS\\SPACEFLT.STR"
};
// Maps from a track number to a stream archive and trigger number
// See StreamLoadTrack and GetStreamTrack in Wing1.i64
constexpr track_desc wc1_track_map[] =
{
{ stream_archive::wc1_mission, no_trigger }, // 0 - Regular Combat
{ stream_archive::wc1_mission, no_trigger }, // 1 - Being Tailed
{ stream_archive::wc1_mission, no_trigger }, // 2 - Tailing An Enemy
{ stream_archive::wc1_mission, no_trigger }, // 3 - Missile Tracking You
{ stream_archive::wc1_mission, no_trigger }, // 4 - You're Severely Damaged - Floundering
{ stream_archive::wc1_mission, no_trigger }, // 5 - Intense Combat
{ stream_archive::wc1_mission, 6 }, // 6 - Target Hit
{ stream_archive::wc1_mission, 7 }, // 7 - Ally Killed
{ stream_archive::wc1_mission, 8 }, // 8 - Your Wingman's been hit
{ stream_archive::wc1_mission, 9 }, // 9 - Enemy Ace Killed
{ stream_archive::wc1_mission, 10 }, // 10 - Overall Victory
{ stream_archive::wc1_mission, 11 }, // 11 - Overall Defeat
{ stream_archive::wc1_mission, no_trigger }, // 12 - Returning Defeated
{ stream_archive::wc1_mission, no_trigger }, // 13 - Returning Normal
{ stream_archive::wc1_mission, no_trigger }, // 14 - Returning Triumphant
{ stream_archive::wc1_mission, no_trigger }, // 15 - Flying to Dogfight
{ stream_archive::wc1_mission, no_trigger }, // 16 - Goal Line - Defending the Claw
{ stream_archive::wc1_mission, no_trigger }, // 17 - Strike Mission - Go Get 'Em
{ stream_archive::wc1_mission, no_trigger }, // 18 - Grim or Escort Mission
{ stream_archive::wc1_preflight, no_trigger }, // 19 - OriginFX (actually, fanfare)
{ stream_archive::wc1_preflight, 1 }, // 20 - Arcade Theme
{ stream_archive::wc1_preflight, 4 }, // 21 - Arcade Victory
{ stream_archive::wc1_preflight, 3 }, // 22 - Arcade Death
{ stream_archive::wc1_preflight, no_trigger }, // 23 - Fanfare
{ stream_archive::wc1_preflight, 5 }, // 24 - Briefing intro
{ stream_archive::wc1_preflight, 6 }, // 25 - Briefing middle
{ stream_archive::wc1_preflight, 7 }, // 26 - Briefing end
{ stream_archive::wc1_mission, 27 }, // 27 - Scramble through launch
{ stream_archive::wc1_postflight, no_trigger }, // 28 - Landing
{ stream_archive::wc1_postflight, 0, }, // 29 - Medium Damage Assessment
{ stream_archive::wc1_preflight, 0 }, // 30 - Rec Room
{ stream_archive::wc1_mission, 31 }, // 31 - Eject - Imminent Rescue
{ stream_archive::wc1_mission, 32 }, // 32 - Funeral
{ stream_archive::wc1_postflight, 2 }, // 33 - Debriefing - Successful
{ stream_archive::wc1_postflight, 1 }, // 34 - Debriefing - Unsuccessful
{ stream_archive::wc1_preflight, 2 }, // 35 - Barracks - Go To Sleep You Pilots
{ stream_archive::wc1_postflight, 3 }, // 36 - Commander's Office
{ stream_archive::wc1_postflight, 4 }, // 37 - Medel Ceremony - General
{ stream_archive::wc1_postflight, 5 }, // 38 - Medal Ceremony - Purple Heart
{ stream_archive::wc1_postflight, 7 }, // 39 - Minor Bravery
{ stream_archive::wc1_postflight, 6 }, // 40 - Major Bravery
};
constexpr track_desc wc2_track_map[] =
{
{ stream_archive::wc2_spaceflight, no_trigger }, // 0 - Combat 1
{ stream_archive::wc2_spaceflight, no_trigger }, // 1 - Combat 2
{ stream_archive::wc2_spaceflight, no_trigger }, // 2 - Combat 3
{ stream_archive::wc2_spaceflight, no_trigger }, // 3 - Combat 4
{ stream_archive::wc2_spaceflight, no_trigger }, // 4 - Combat 5
{ stream_archive::wc2_spaceflight, no_trigger }, // 5 - Combat 6
{ stream_archive::wc2_spaceflight, 6 }, // 6 - Victorious Combat
{ stream_archive::wc2_spaceflight, 7 }, // 7 - Tragedy
{ stream_archive::wc2_spaceflight, 8 }, // 8 - Dire straits
{ stream_archive::wc2_spaceflight, 9 }, // 9 - Scratch one fighter
{ stream_archive::wc2_spaceflight, 10 }, // 10 - Defeated fleeing enemy
{ stream_archive::wc2_spaceflight, 11 }, // 11 - Wingman death
{ stream_archive::wc2_spaceflight, no_trigger }, // 12 - Returning defeated
{ stream_archive::wc2_spaceflight, no_trigger }, // 13 - Returning successful
{ stream_archive::wc2_spaceflight, no_trigger }, // 14 - Returning jubilant
{ stream_archive::wc2_spaceflight, no_trigger }, // 15 - Mission 1
{ stream_archive::wc2_spaceflight, no_trigger }, // 16 - Mission 2
{ stream_archive::wc2_spaceflight, no_trigger }, // 17 - Mission 3
{ stream_archive::wc2_spaceflight, no_trigger }, // 18 - Mission 4
{ stream_archive::invalid, no_trigger },
{ stream_archive::invalid, no_trigger },
{ stream_archive::invalid, no_trigger },
{ stream_archive::invalid, no_trigger },
{ stream_archive::invalid, no_trigger },
{ stream_archive::invalid, no_trigger },
{ stream_archive::invalid, no_trigger },
{ stream_archive::invalid, no_trigger },
{ stream_archive::wc2_spaceflight, no_trigger }, // 27 - Scramble
{ stream_archive::wc2_gametwo, 28 }, // 28 - Landing
{ stream_archive::wc2_gametwo, 29 }, // 29 - Damage Assessment
{ stream_archive::invalid, no_trigger },
{ stream_archive::wc2_spaceflight, no_trigger }, // 31 - Eject
{ stream_archive::wc2_spaceflight, no_trigger }, // 32 - Death
{ stream_archive::wc2_gametwo, 33 }, // 33 - debriefing (successful)
{ stream_archive::wc2_gametwo, 34 }, // 34 - debriefing (failed)
{ stream_archive::invalid, no_trigger },
{ stream_archive::wc2_gametwo, 36 }, // 36 - Briefing 2
{ stream_archive::wc2_gametwo, 37 }, // 37 - medal (valor?)
{ stream_archive::wc2_gametwo, 38 }, // 38 - medal (golden sun?)
{ stream_archive::wc2_gametwo, 39 }, // 39 - another medal
{ stream_archive::wc2_gametwo, 40 }, // 40 - big medal
{ stream_archive::wc2_spaceflight, no_trigger }, // 41 - Prologue
{ stream_archive::wc2_spaceflight, 42 }, // 42 - Torpedo lock
{ stream_archive::wc2_gameflow, 43 }, // 43 - Flight deck 1
{ stream_archive::wc2_gameflow, 44 }, // 44 - Angel
{ stream_archive::wc2_gameflow, 45 }, // 45 - Jazz 1
{ stream_archive::wc2_gameflow, 46 }, // 46 - Briefing
{ stream_archive::wc2_gameflow, 47 }, // 47 - Jump
{ stream_archive::wc2_gameflow, 48 }, // 48 - Prologue (quieter)
{ stream_archive::wc2_gameflow, 49 }, // 49 - Lounge 1
{ stream_archive::wc2_gameflow, 50 }, // 50 - Jazz 2
{ stream_archive::wc2_gameflow, 51 }, // 51 - Jazz 3
{ stream_archive::wc2_gameflow, 52 }, // 52 - Jazz 4
{ stream_archive::wc2_gameflow, 53 }, // 53 - Interlude 1
{ stream_archive::wc2_gameflow, 54 }, // 54 - Theme
{ stream_archive::wc2_spaceflight, no_trigger }, // 55 - Bombing run
{ stream_archive::wc2_spaceflight, no_trigger }, // 56 - Final Mission
{ stream_archive::wc2_spaceflight, no_trigger }, // 57 - Fighting Thrakhath
{ stream_archive::wc2_gameflow, 58 }, // 58 - Kilrathi Theme
{ stream_archive::wc2_gametwo, 59 }, // 59 - Good Ending
{ stream_archive::wc2_gametwo, 60 }, // 60 - Lounge 2
{ stream_archive::wc2_gameflow, 61 }, // 61 - End Credits
{ stream_archive::wc2_gameflow, 62 }, // 62 - Interlude 2
{ stream_archive::wc2_gametwo, 63 }, // 63 - Jazz 5
{ stream_archive::wc2_gametwo, 20 }, // 64 - Flight Deck 2
{ stream_archive::wc2_gametwo, 21 }, // 65 - Sabotage
// Bonus tracks
{ stream_archive::wc2_gameflow, 59 }, // 66 - Defeated fleeing enemy (alternate)
{ stream_archive::wc2_gameflow, 60 }, // 67 - Wingman death (alternate)
{ stream_archive::wc2_gameflow, 63 }, // 68 - Unknown
{ stream_archive::wc2_spaceflight, no_trigger }, // 69 - Jump (looping)
};
void show_usage(const wchar_t* invocation)
{
std::wcout << L"Usage:\n"
L" " << invocation << L" [<options>...] -track (wc1|wc2) <num>\n"
L" " << invocation << L" [<options>...] -trigger <num> <filename>\n"
L" " << invocation << L" -show-tracks (wc1|wc2)\n"
L" " << invocation << L" -show-triggers <filename>\n"
L"\n"
L"The first form selects a music track to play. The command must be invoked from\n"
L"the game directory (the same directory containing the STREAMS directory). The\n"
L"correct stream file will be loaded automatically based on an internal mapping\n"
L"from track number to stream file, trigger, and intensity values. To view the\n"
L"mapping, use the -show-tracks option.\n"
L"\n"
L"The second form selects a track using the provided trigger value for the given\n"
L"stream file. If the trigger is not provided, " << invocation << L" will play from the\n"
L"first piece of audio data contained in the stream. If the intensity value is\n"
L"not provided, a default value will be used. To view the list of triggers and\n"
L"intensities supported by a given stream file, use the -show-triggers option.\n"
L"This form may be used with any stream file.\n"
L"\n"
L"Options:\n"
L" -o <filename>\n"
L" Instead of playing music, write it to a WAV file.\n"
L"\n"
L" -intensity <num>\n"
L" This value is used by the playback engine to handle transitions between\n"
L" tracks. Some tracks are designed to transition to other specific tracks\n"
L" upon completion, and this value determines which one that is. For example,\n"
L" the scramble music from WC1 will transition to a track appropriate to a\n"
L" given mission type based on the intensity value. If this value is not\n"
L" provided, a default value will be used. For a list of supported triggers\n"
L" and intensity values, use the -show-triggers option.\n"
L"\n"
L" -loop <num>\n"
L" Continue playback until <num> loops have been completed. For instance,\n"
L" -loop 0 will disable looping (causing a track to be played only once), and\n"
L" -loop 1 will cause the track to repeat once (provided it has a loop point).\n"
L" If the track does not have a loop point, this option is ignored. If this\n"
L" option is not specified, the track will loop indefinitely.\n"
L"\n"
L" -single\n"
L" Stop playback at transition points instead of following the transition to\n"
L" the next track.\n"
L"\n"
L" -debug-info\n"
L" Display information related to playback. The stream contains embedded\n"
L" information that tells the player how to loop a track or how to progress\n"
L" from one track to another. This information will be printed out as it is\n"
L" encountered. If the -o option is being used, this option will also print\n"
L" corresponding frame numbers in the output file.\n";
}
void diagnose_mode(uint32_t mode)
{
if ((mode & (mode_track | mode_trigger)) == (mode_track | mode_trigger))
throw usage_error("The -trigger option cannot be used with -track.");
if ((mode & (mode_track | mode_stream)) == (mode_track | mode_stream))
throw usage_error("Cannot specify a stream file with -track.");
if ((mode & mode_show_tracks) != 0 && mode != mode_show_tracks)
throw usage_error("The -show-tracks option cannot be used with other options.");
if ((mode & mode_show_triggers) != 0 && (mode & ~mode_stream) != mode_show_triggers)
throw usage_error("The -show-triggers option cannot be used with other options.");
}
void diagnose_unrecognized(const wchar_t* str)
{
std::ostringstream message;
message << "Unexpected option: " << str;
throw usage_error(std::move(message).str());
}
void show_tracks(program_options& options)
{
stdext::array_view<const track_desc> track_map;
if ((options.program_mode & mode_wc2) == 0)
track_map = wc1_track_map;
else
track_map = wc2_track_map;
std::wcout <<
L"Track | File | Trigger | Intensity\n"
L"------|----------------------|---------|----------\n";
unsigned track_number = 0;
for (auto entry : track_map)
{
at_scope_exit([&]{ ++track_number; });
if (entry.archive == stream_archive::invalid)
continue;
std::wcout << std::setw(5) << track_number << L" | ";
std::wcout << std::setw(20) << std::setiosflags(std::ios_base::left) << stream_filenames[entry.archive] << L" | ";
std::wcout.unsetf(std::ios_base::adjustfield);
std::wcout.width(7);
if (entry.trigger == no_trigger)
std::wcout << L"";
else
std::wcout << entry.trigger;
std::wcout << L" | ";
std::wcout.width(9);
if (entry.trigger == no_trigger)
std::wcout << (track_number == 69 ? 47 : track_number);
else
std::wcout << L"";
std::wcout << L'\n';
}
}
void select_track(program_options& options)
{
stdext::array_view<const track_desc> track_map;
if ((options.program_mode & mode_wc2) == 0)
track_map = wc1_track_map;
else
track_map = wc2_track_map;
if (options.track < 0 || unsigned(options.track) >= track_map.size())
{
std::ostringstream message;
message << "Track must be between 0 and " << track_map.size() - 1 << '.';
throw usage_error(std::move(message).str());
}
if (track_map[options.track].archive == stream_archive::invalid)
{
std::ostringstream message;
message << "There is no track " << options.track << '.';
throw std::runtime_error(std::move(message).str());
}
options.stream_path = stream_filenames[track_map[options.track].archive];
options.trigger = track_map[options.track].trigger;
if (options.trigger == no_trigger)
{
// There's no easy way to map this one, so hard-code it instead.
if (options.track == 69)
options.intensity = 47;
else
options.intensity = uint8_t(options.track);
}
}
int parse_int(const wchar_t* str)
{
if (str == nullptr)
throw usage_error("Expected number.");
wchar_t* end;
auto value = int(wcstol(str, &end, 10));
if (*end != '\0')
{
std::ostringstream message;
message << "Unexpected argument: " << stdext::to_mbstring(str) << " (Expected number.)\n";
throw usage_error(std::move(message).str());
}
return value;
}
}
| 45.806818
| 126
| 0.543077
|
Bekenn
|
fca225d128299273e9c10512d3605b9a118b9324
| 129
|
cpp
|
C++
|
tensorflow-yolo-ios/dependencies/eigen/bench/btl/libs/BLAS/main.cpp
|
initialz/tensorflow-yolo-face-ios
|
ba74cf39168d0128e91318e65a1b88ce4d65a167
|
[
"MIT"
] | 27
|
2017-06-07T19:07:32.000Z
|
2020-10-15T10:09:12.000Z
|
tensorflow-yolo-ios/dependencies/eigen/bench/btl/libs/BLAS/main.cpp
|
initialz/tensorflow-yolo-face-ios
|
ba74cf39168d0128e91318e65a1b88ce4d65a167
|
[
"MIT"
] | 3
|
2017-08-25T17:39:46.000Z
|
2017-11-18T03:40:55.000Z
|
tensorflow-yolo-ios/dependencies/eigen/bench/btl/libs/BLAS/main.cpp
|
initialz/tensorflow-yolo-face-ios
|
ba74cf39168d0128e91318e65a1b88ce4d65a167
|
[
"MIT"
] | 10
|
2017-06-16T18:04:45.000Z
|
2018-07-05T17:33:01.000Z
|
version https://git-lfs.github.com/spec/v1
oid sha256:cd4a0e77cbc83e004385d988fa1135793c26b4f6a51cb6be3764696a721e007d
size 2963
| 32.25
| 75
| 0.883721
|
initialz
|
fca29685edccd4fc21a8a33358f81729eab0c509
| 8,845
|
cpp
|
C++
|
obelus/client/math/math.cpp
|
monthyx1337/obelus-hack
|
8e83eb89ef56788c1b9c5af66b815824d17f309d
|
[
"MIT"
] | 36
|
2021-07-08T01:30:44.000Z
|
2022-03-25T13:16:59.000Z
|
obelus/client/math/math.cpp
|
monthyx1337/obelus-hack
|
8e83eb89ef56788c1b9c5af66b815824d17f309d
|
[
"MIT"
] | 2
|
2021-09-11T05:11:55.000Z
|
2022-01-28T07:49:39.000Z
|
obelus/client/math/math.cpp
|
monthyx1337/obelus-hack
|
8e83eb89ef56788c1b9c5af66b815824d17f309d
|
[
"MIT"
] | 14
|
2021-07-08T00:11:12.000Z
|
2022-03-20T11:10:17.000Z
|
#include "../utilities/csgo.hpp"
#include "../../hack/features/visuals/esp.h"
bool math::GetBoundingBox(BaseEntity* entity, bbox_t& box)
{
const auto collideable = entity->Collideables();
if (collideable == nullptr)
return false;
vec3_t top, down, air, s[2];
vec3_t adjust = vec3_t(0, 0, -15) * entity->DuckAmount();
if (!(entity->Flags() & FL_ONGROUND) && (entity->MoveType() != MOVETYPE_LADDER))
air = vec3_t(0, 0, 10);
else
air = vec3_t(0, 0, 0);
down = entity->AbsOrigin() + air;
top = down + vec3_t(0, 0, 72) + adjust;
if (visuals::WorldToScreen(top, s[1]) && visuals::WorldToScreen(down, s[0]))
{
vec3_t delta = s[1] - s[0];
box.h = fabsf(delta.y) + 6;
box.w = box.h / 2 + 5;
box.x = s[1].x - (box.w / 2) + 2;
box.y = s[1].y - 1;
return true;
}
return false;
}
vec3_t math::calculate_angle(const vec3_t& source, const vec3_t& destination, const vec3_t& viewAngles) {
vec3_t delta = source - destination;
auto radians_to_degrees = [](float radians) { return radians * 180 / static_cast<float>(M_PI); };
vec3_t angles;
angles.x = radians_to_degrees(atanf(delta.z / std::hypotf(delta.x, delta.y))) - viewAngles.x;
angles.y = radians_to_degrees(atanf(delta.y / delta.x)) - viewAngles.y;
angles.z = 0.0f;
if (delta.x >= 0.0)
angles.y += 180.0f;
angles.normalize_aimbot();
return angles;
}
void math::FixMove(UserCmd* m_pcmd, vec3_t wish_angle) {
vec3_t view_fwd, view_right, view_up, cmd_fwd, cmd_right, cmd_up;
auto viewangles = m_pcmd->viewangles;
viewangles.normalized();
math::angle_vectors(wish_angle, &view_fwd, &view_right, &view_up);
math::angle_vectors(viewangles, &cmd_fwd, &cmd_right, &cmd_up);
float v8 = sqrtf((view_fwd.x * view_fwd.x) + (view_fwd.y * view_fwd.y));
float v10 = sqrtf((view_right.x * view_right.x) + (view_right.y * view_right.y));
float v12 = sqrtf(view_up.z * view_up.z);
vec3_t norm_view_fwd((1.f / v8) * view_fwd.x, (1.f / v8) * view_fwd.y, 0.f);
vec3_t norm_view_right((1.f / v10) * view_right.x, (1.f / v10) * view_right.y, 0.f);
vec3_t norm_view_up(0.f, 0.f, (1.f / v12) * view_up.z);
float v14 = sqrtf((cmd_fwd.x * cmd_fwd.x) + (cmd_fwd.y * cmd_fwd.y));
float v16 = sqrtf((cmd_right.x * cmd_right.x) + (cmd_right.y * cmd_right.y));
float v18 = sqrtf(cmd_up.z * cmd_up.z);
vec3_t norm_cmd_fwd((1.f / v14) * cmd_fwd.x, (1.f / v14) * cmd_fwd.y, 0.f);
vec3_t norm_cmd_right((1.f / v16) * cmd_right.x, (1.f / v16) * cmd_right.y, 0.f);
vec3_t norm_cmd_up(0.f, 0.f, (1.f / v18) * cmd_up.z);
float v22 = norm_view_fwd.x * m_pcmd->forwardmove;
float v26 = norm_view_fwd.y * m_pcmd->forwardmove;
float v28 = norm_view_fwd.z * m_pcmd->forwardmove;
float v24 = norm_view_right.x * m_pcmd->sidemove;
float v23 = norm_view_right.y * m_pcmd->sidemove;
float v25 = norm_view_right.z * m_pcmd->sidemove;
float v30 = norm_view_up.x * m_pcmd->upmove;
float v27 = norm_view_up.z * m_pcmd->upmove;
float v29 = norm_view_up.y * m_pcmd->upmove;
m_pcmd->forwardmove = ((((norm_cmd_fwd.x * v24) + (norm_cmd_fwd.y * v23)) + (norm_cmd_fwd.z * v25))
+ (((norm_cmd_fwd.x * v22) + (norm_cmd_fwd.y * v26)) + (norm_cmd_fwd.z * v28)))
+ (((norm_cmd_fwd.y * v30) + (norm_cmd_fwd.x * v29)) + (norm_cmd_fwd.z * v27));
m_pcmd->sidemove = ((((norm_cmd_right.x * v24) + (norm_cmd_right.y * v23)) + (norm_cmd_right.z * v25))
+ (((norm_cmd_right.x * v22) + (norm_cmd_right.y * v26)) + (norm_cmd_right.z * v28)))
+ (((norm_cmd_right.x * v29) + (norm_cmd_right.y * v30)) + (norm_cmd_right.z * v27));
m_pcmd->upmove = ((((norm_cmd_up.x * v23) + (norm_cmd_up.y * v24)) + (norm_cmd_up.z * v25))
+ (((norm_cmd_up.x * v26) + (norm_cmd_up.y * v22)) + (norm_cmd_up.z * v28)))
+ (((norm_cmd_up.x * v30) + (norm_cmd_up.y * v29)) + (norm_cmd_up.z * v27));
static auto cl_forwardspeed = interfaces::console->FindVar(XOR("cl_forwardspeed"));
static auto cl_sidespeed = interfaces::console->FindVar(XOR("cl_sidespeed"));
static auto cl_upspeed = interfaces::console->FindVar(XOR("cl_upspeed"));
m_pcmd->forwardmove = std::clamp(m_pcmd->forwardmove, -cl_forwardspeed->GetFloat(), cl_forwardspeed->GetFloat());
m_pcmd->sidemove = std::clamp(m_pcmd->sidemove, -cl_sidespeed->GetFloat(), cl_sidespeed->GetFloat());
m_pcmd->upmove = std::clamp(m_pcmd->upmove, -cl_upspeed->GetFloat(), cl_upspeed->GetFloat());
}
vec3_t math::calculate_angle(vec3_t& a, vec3_t& b) {
vec3_t angles;
vec3_t delta;
delta.x = (a.x - b.x);
delta.y = (a.y - b.y);
delta.z = (a.z - b.z);
double hyp = sqrt(delta.x * delta.x + delta.y * delta.y);
angles.x = (float)(atanf(delta.z / hyp) * 57.295779513082f);
angles.y = (float)(atanf(delta.y / delta.x) * 57.295779513082f);
angles.z = 0.0f;
if (delta.x >= 0.0) { angles.y += 180.0f; }
return angles;
}
void math::sin_cos(float r, float* s, float* c) {
*s = sin(r);
*c = cos(r);
}
vec3_t math::angle_vector(vec3_t angle) {
auto sy = sin(angle.y / 180.f * static_cast<float>(M_PI));
auto cy = cos(angle.y / 180.f * static_cast<float>(M_PI));
auto sp = sin(angle.x / 180.f * static_cast<float>(M_PI));
auto cp = cos(angle.x / 180.f * static_cast<float>(M_PI));
return vec3_t(cp * cy, cp * sy, -sp);
}
void math::transform_vector(vec3_t & a, matrix_t & b, vec3_t & out) {
out.x = a.dot(b.mat_val[0]) + b.mat_val[0][3];
out.y = a.dot(b.mat_val[1]) + b.mat_val[1][3];
out.z = a.dot(b.mat_val[2]) + b.mat_val[2][3];
}
void math::vector_angles(vec3_t & forward, vec3_t & angles) {
vec3_t view;
if (!forward[0] && !forward[1])
{
view[0] = 0.0f;
view[1] = 0.0f;
}
else
{
view[1] = atan2(forward[1], forward[0]) * 180.0f / M_PI;
if (view[1] < 0.0f)
view[1] += 360.0f;
view[2] = sqrt(forward[0] * forward[0] + forward[1] * forward[1]);
view[0] = atan2(forward[2], view[2]) * 180.0f / M_PI;
}
angles[0] = -view[0];
angles[1] = view[1];
angles[2] = 0.f;
}
void math::angle_vectors(const vec3_t& angles, vec3_t& forward)
{
float sp, sy, cp, cy;
sy = sin(DEG2RAD(angles[1]));
cy = cos(DEG2RAD(angles[1]));
sp = sin(DEG2RAD(angles[0]));
cp = cos(DEG2RAD(angles[0]));
forward.x = cp * cy;
forward.y = cp * sy;
forward.z = -sp;
}
void math::angle_vectors(vec3_t & angles, vec3_t * forward, vec3_t * right, vec3_t * up) {
float sp, sy, sr, cp, cy, cr;
sin_cos(DEG2RAD(angles.x), &sp, &cp);
sin_cos(DEG2RAD(angles.y), &sy, &cy);
sin_cos(DEG2RAD(angles.z), &sr, &cr);
if (forward) {
forward->x = cp * cy;
forward->y = cp * sy;
forward->z = -sp;
}
if (right) {
right->x = -1 * sr * sp * cy + -1 * cr * -sy;
right->y = -1 * sr * sp * sy + -1 * cr * cy;
right->z = -1 * sr * cp;
}
if (up) {
up->x = cr * sp * cy + -sr * -sy;
up->y = cr * sp * sy + -sr * cy;
up->z = cr * cp;
}
}
vec3_t math::vector_add(vec3_t & a, vec3_t & b) {
return vec3_t(a.x + b.x,
a.y + b.y,
a.z + b.z);
}
void math::angle_matrix(const vec3_t& ang, const vec3_t& pos, matrix_t& out) {
g::AngleMatrix(ang, out);
out.set_origin(pos);
}
vec3_t math::vector_subtract(vec3_t & a, vec3_t & b) {
return vec3_t(a.x - b.x,
a.y - b.y,
a.z - b.z);
}
vec3_t math::vector_multiply(vec3_t & a, vec3_t & b) {
return vec3_t(a.x * b.x,
a.y * b.y,
a.z * b.z);
}
vec3_t math::vector_divide(vec3_t & a, vec3_t & b) {
return vec3_t(a.x / b.x,
a.y / b.y,
a.z / b.z);
}
bool math::screen_transform(const vec3_t & point, vec3_t & screen) {
auto matrix = interfaces::engine->world_to_screen_matrix();
float w = matrix[3][0] * point.x + matrix[3][1] * point.y + matrix[3][2] * point.z + matrix[3][3];
screen.x = matrix[0][0] * point.x + matrix[0][1] * point.y + matrix[0][2] * point.z + matrix[0][3];
screen.y = matrix[1][0] * point.x + matrix[1][1] * point.y + matrix[1][2] * point.z + matrix[1][3];
screen.z = 0.0f;
int inverse_width = static_cast<int>((w < 0.001f) ? -1.0f / w :
1.0f / w);
screen.x *= inverse_width;
screen.y *= inverse_width;
return (w < 0.001f);
}
bool math::world_to_screen(const vec3_t & origin, vec2_t & screen) {
static std::uintptr_t view_matrix;
if ( !view_matrix )
view_matrix = *reinterpret_cast< std::uintptr_t* >( reinterpret_cast< std::uintptr_t >( pattern::Scan( XOR("client.dll"), XOR("0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9") ) ) + 3 ) + 176;
const auto& matrix = *reinterpret_cast< view_matrix_t* >( view_matrix );
const auto w = matrix.m[ 3 ][ 0 ] * origin.x + matrix.m[ 3 ][ 1 ] * origin.y + matrix.m[ 3 ][ 2 ] * origin.z + matrix.m[ 3 ][ 3 ];
if ( w < 0.001f )
return false;
int x, y;
interfaces::engine->GetScreenSize( x, y );
screen.x = static_cast<float>(x) / 2.0f;
screen.y = static_cast<float>(y) / 2.0f;
screen.x *= 1.0f + ( matrix.m[ 0 ][ 0 ] * origin.x + matrix.m[ 0 ][ 1 ] * origin.y + matrix.m[ 0 ][ 2 ] * origin.z + matrix.m[ 0 ][ 3 ] ) / w;
screen.y *= 1.0f - ( matrix.m[ 1 ][ 0 ] * origin.x + matrix.m[ 1 ][ 1 ] * origin.y + matrix.m[ 1 ][ 2 ] * origin.z + matrix.m[ 1 ][ 3 ] ) / w;
return true;
}
| 32.638376
| 181
| 0.625438
|
monthyx1337
|
fca51743d38453ae21af19365b6a2abe635f8d6d
| 2,655
|
cpp
|
C++
|
DungeonScene.cpp
|
kaitokidi/ChamanClickerBattle
|
248ca07c80a2ab3ee6376c8262e6c120e4650051
|
[
"MIT"
] | 1
|
2016-01-27T17:02:03.000Z
|
2016-01-27T17:02:03.000Z
|
DungeonScene.cpp
|
kaitokidi/ChamanClickerBattle
|
248ca07c80a2ab3ee6376c8262e6c120e4650051
|
[
"MIT"
] | null | null | null |
DungeonScene.cpp
|
kaitokidi/ChamanClickerBattle
|
248ca07c80a2ab3ee6376c8262e6c120e4650051
|
[
"MIT"
] | null | null | null |
#include "DungeonScene.hpp"
#include "Game.hpp"
DungeonScene::DungeonScene(Game* g, sf::RenderWindow* w, sceneTypes sT, std::string name, std::string description) :
ScenePlayable(g,w,sT,name,description),
_topDoor(0,sf::Vector2f(120,16),directions::up),
_botDoor(0,sf::Vector2f(120,144),directions::down),
_leftDoor(0,sf::Vector2f(16,80),directions::left),
_rightDoor(0,sf::Vector2f(224,80),directions::right)
{
_sceneIniCoord = sf::Vector2f(FLT_MAX,FLT_MAX);
}
DungeonScene::~DungeonScene() {
}
void DungeonScene::init(sf::Vector2f sceneIniCoord = sf::Vector2f(0,0)) {
sf::Vector2f aux = _sceneIniCoord;
ScenePlayable::init(sceneIniCoord);
if (sceneIniCoord == aux) return;
if (aux == sf::Vector2f(FLT_MAX,FLT_MAX)) {
auto mapDoors = _map.getDungeonDoors();
for (auto it = mapDoors.begin(); it != mapDoors.end(); ++it) addDoor(*(*it).first,(*it).second);
addProp(&_topDoor);
addProp(&_botDoor);
addProp(&_leftDoor);
addProp(&_rightDoor);
}
_topDoor.setIniCoord(_sceneIniCoord);
_botDoor.setIniCoord(_sceneIniCoord);
_leftDoor.setIniCoord(_sceneIniCoord);
_rightDoor.setIniCoord(_sceneIniCoord);
_topDoor.setScene(this);
_botDoor.setScene(this);
_leftDoor.setScene(this);
_rightDoor.setScene(this);
if (DataManager::getBool(_sceneName+std::to_string(directions::up ), false)) _topDoor.openWithKey();
if (DataManager::getBool(_sceneName+std::to_string(directions::down ), false)) _botDoor.openWithKey();
if (DataManager::getBool(_sceneName+std::to_string(directions::left ), false)) _leftDoor.openWithKey();
if (DataManager::getBool(_sceneName+std::to_string(directions::right), false)) _rightDoor.openWithKey();
}
void DungeonScene::update(float deltaTime) {
ScenePlayable::update(deltaTime);
if (_enemies.empty()) openDoors();
else closeDoors();
}
void DungeonScene::render(sf::RenderTarget* target) {
ScenePlayable::render(target);
}
sceneTypes DungeonScene::getType(){
return sceneTypes::dungeon;
}
void DungeonScene::addDoor(DungeonDoor door,directions dir) {
if (dir == directions::up) _topDoor = door;
else if (dir == directions::down) _botDoor = door;
else if (dir == directions::left) _leftDoor = door;
else if (dir == directions::right) _rightDoor = door;
else {
std::cout << "Wrong direction adding a door " << std::endl;
exit(EXIT_FAILURE);
}
}
void DungeonScene::openDoors() {
_topDoor.open();
_botDoor.open();
_leftDoor.open();
_rightDoor.open();
}
void DungeonScene::closeDoors() {
_topDoor.close();
_botDoor.close();
_leftDoor.close();
_rightDoor.close();
}
| 31.987952
| 116
| 0.699435
|
kaitokidi
|
fca760afd3e25385bd40abc1797bfb0dfacc7e7b
| 11,996
|
cpp
|
C++
|
raptor/external/hypre_wrapper.cpp
|
lukeolson/raptor
|
526c88d0801634e6fb41375ae077f2d4aa3241a4
|
[
"BSD-2-Clause"
] | 25
|
2017-11-20T21:45:43.000Z
|
2019-01-27T15:03:25.000Z
|
raptor/external/hypre_wrapper.cpp
|
lukeolson/raptor
|
526c88d0801634e6fb41375ae077f2d4aa3241a4
|
[
"BSD-2-Clause"
] | 3
|
2017-11-21T01:20:20.000Z
|
2018-11-16T17:33:06.000Z
|
raptor/external/hypre_wrapper.cpp
|
lukeolson/raptor
|
526c88d0801634e6fb41375ae077f2d4aa3241a4
|
[
"BSD-2-Clause"
] | 5
|
2017-11-20T22:03:57.000Z
|
2018-12-05T10:30:22.000Z
|
// Copyright (c) 2015-2017, RAPtor Developer Team
// License: Simplified BSD, http://opensource.org/licenses/BSD-2-Clause
#include "hypre_wrapper.hpp"
HYPRE_IJVector convert(raptor::ParVector& x_rap, RAPtor_MPI_Comm comm_mat)
{
int num_procs, rank;
RAPtor_MPI_Comm_rank(comm_mat, &rank);
RAPtor_MPI_Comm_size(comm_mat, &num_procs);
HYPRE_IJVector x;
HYPRE_Int local_n = x_rap.local_n;
std::vector<int> first_n(num_procs);
RAPtor_MPI_Allgather(&local_n, 1, RAPtor_MPI_INT, first_n.data(), 1, RAPtor_MPI_INT, comm_mat);
HYPRE_Int first_local = 0;
for (int i = 0; i < rank; i++)
{
first_local += first_n[i];
}
HYPRE_Int last_local = first_local + local_n - 1;
HYPRE_IJVectorCreate(comm_mat, first_local, last_local, &x);
HYPRE_IJVectorSetObjectType(x, HYPRE_PARCSR);
HYPRE_IJVectorInitialize(x);
HYPRE_Int* rows = new HYPRE_Int[local_n];
for (HYPRE_Int i = 0; i < local_n; i++)
{
rows[i] = i+first_local;
}
HYPRE_Real* x_data = x_rap.local.data();
HYPRE_IJVectorSetValues(x, local_n, rows, x_data);
HYPRE_IJVectorAssemble(x);
delete[] rows;
return x;
}
HYPRE_IJMatrix convert(raptor::ParCSRMatrix* A_rap, RAPtor_MPI_Comm comm_mat)
{
HYPRE_IJMatrix A;
HYPRE_Int n_rows = 0;
HYPRE_Int n_cols = 0;
HYPRE_Int local_row_start = 0;
HYPRE_Int local_col_start = 0;
HYPRE_Int rank, num_procs;
HYPRE_Int one = 1;
RAPtor_MPI_Comm_rank(comm_mat, &rank);
RAPtor_MPI_Comm_size(comm_mat, &num_procs);
std::vector<int> row_sizes(num_procs);
std::vector<int> col_sizes(num_procs);
RAPtor_MPI_Allgather(&(A_rap->local_num_rows), 1, RAPtor_MPI_INT, row_sizes.data(), 1, RAPtor_MPI_INT,
RAPtor_MPI_COMM_WORLD);
RAPtor_MPI_Allgather(&(A_rap->on_proc_num_cols), 1, RAPtor_MPI_INT, col_sizes.data(), 1, RAPtor_MPI_INT,
RAPtor_MPI_COMM_WORLD);
for (int i = 0; i < rank; i++)
{
local_row_start += row_sizes[i];
local_col_start += col_sizes[i];
}
// Send new global cols (to update off_proc_col_map)
std::vector<int> new_cols(A_rap->on_proc_num_cols);
for (int i = 0; i < A_rap->on_proc_num_cols; i++)
{
new_cols[i] = i + local_col_start;
}
if (!A_rap->comm) A_rap->comm = new ParComm(A_rap->partition,
A_rap->off_proc_column_map, A_rap->on_proc_column_map);
std::vector<int>& recvbuf = A_rap->comm->communicate(new_cols);
std::vector<int> off_proc_cols(A_rap->off_proc_num_cols);
std::copy(recvbuf.begin(), recvbuf.begin() + A_rap->off_proc_num_cols,
off_proc_cols.begin());
n_rows = A_rap->local_num_rows;
if (n_rows)
{
n_cols = A_rap->on_proc_num_cols;
}
/**********************************
****** CREATE HYPRE MATRIX
************************************/
HYPRE_IJMatrixCreate(comm_mat, local_row_start, local_row_start + n_rows - 1, local_col_start, local_col_start + n_cols - 1, &A);
HYPRE_IJMatrixSetObjectType(A, HYPRE_PARCSR);
HYPRE_IJMatrixInitialize(A);
HYPRE_Int row_start, row_end;
HYPRE_Int global_row, global_col;
HYPRE_Real value;
for (int i = 0; i < A_rap->on_proc->n_rows; i++)
{
row_start = A_rap->on_proc->idx1[i];
row_end = A_rap->on_proc->idx1[i+1];
global_row = i + local_row_start;
for (int j = row_start; j < row_end; j++)
{
global_col = A_rap->on_proc->idx2[j] + local_col_start;
value = A_rap->on_proc->vals[j];
HYPRE_IJMatrixSetValues(A, 1, &one, &global_row, &global_col, &value);
}
}
for (int i = 0; i < A_rap->off_proc->n_rows; i++)
{
row_start = A_rap->off_proc->idx1[i];
row_end = A_rap->off_proc->idx1[i+1];
global_row = i + local_row_start;
for (int j = row_start; j < row_end; j++)
{
global_col = off_proc_cols[A_rap->off_proc->idx2[j]];
value = A_rap->off_proc->vals[j];
HYPRE_IJMatrixSetValues(A, 1, &one, &global_row, &global_col, &value);
}
}
HYPRE_IJMatrixAssemble(A);
return A;
}
raptor::ParCSRMatrix* convert(hypre_ParCSRMatrix* A_hypre, RAPtor_MPI_Comm comm_mat)
{
int num_procs;
int rank;
RAPtor_MPI_Comm_size(comm_mat, &num_procs);
RAPtor_MPI_Comm_rank(comm_mat, &rank);
hypre_CSRMatrix* A_hypre_diag = hypre_ParCSRMatrixDiag(A_hypre);
HYPRE_Real* diag_data = hypre_CSRMatrixData(A_hypre_diag);
HYPRE_Int* diag_i = hypre_CSRMatrixI(A_hypre_diag);
HYPRE_Int* diag_j = hypre_CSRMatrixJ(A_hypre_diag);
HYPRE_Int diag_nnz = hypre_CSRMatrixNumNonzeros(A_hypre_diag);
HYPRE_Int diag_rows = hypre_CSRMatrixNumRows(A_hypre_diag);
HYPRE_Int diag_cols = hypre_CSRMatrixNumCols(A_hypre_diag);
hypre_CSRMatrix* A_hypre_offd = hypre_ParCSRMatrixOffd(A_hypre);
HYPRE_Int num_cols_offd = hypre_CSRMatrixNumCols(A_hypre_offd);
HYPRE_Int* offd_i = hypre_CSRMatrixI(A_hypre_offd);
HYPRE_Int* offd_j = hypre_CSRMatrixJ(A_hypre_offd);
HYPRE_Real* offd_data;
if (num_cols_offd)
{
offd_data = hypre_CSRMatrixData(A_hypre_offd);
}
HYPRE_Int first_local_row = hypre_ParCSRMatrixFirstRowIndex(A_hypre);
HYPRE_Int first_local_col = hypre_ParCSRMatrixFirstColDiag(A_hypre);
HYPRE_Int* col_map_offd = hypre_ParCSRMatrixColMapOffd(A_hypre);
HYPRE_Int global_rows = hypre_ParCSRMatrixGlobalNumRows(A_hypre);
HYPRE_Int global_cols = hypre_ParCSRMatrixGlobalNumCols(A_hypre);
ParCSRMatrix* A = new ParCSRMatrix(global_rows, global_cols,
diag_rows, diag_cols,
first_local_row, first_local_col);
A->on_proc->idx1[0] = 0;
for (int i = 0; i < diag_rows; i++)
{
int row_start = diag_i[i];
int row_end = diag_i[i+1];
for (int j = row_start; j < row_end; j++)
{
A->on_proc->idx2.emplace_back(diag_j[j]);
A->on_proc->vals.emplace_back(diag_data[j]);
}
A->on_proc->idx1[i+1] = A->on_proc->idx2.size();
}
A->on_proc->nnz = A->on_proc->idx2.size();
A->off_proc->idx1[0] = 0;
for (int i = 0; i < diag_rows; i++)
{
if (num_cols_offd)
{
int row_start = offd_i[i];
int row_end = offd_i[i+1];
for (int j = row_start; j < row_end; j++)
{
int global_col = col_map_offd[offd_j[j]];
A->off_proc->idx2.emplace_back(global_col);
A->off_proc->vals.emplace_back(offd_data[j]);
}
}
A->off_proc->idx1[i+1] = A->off_proc->idx2.size();
}
A->off_proc->nnz = A->off_proc->idx2.size();
A->finalize();
return A;
}
HYPRE_Solver hypre_create_hierarchy(hypre_ParCSRMatrix* A,
hypre_ParVector* b,
hypre_ParVector* x,
HYPRE_Int coarsen_type,
HYPRE_Int interp_type,
HYPRE_Int p_max_elmts,
HYPRE_Int agg_num_levels,
HYPRE_Real strong_threshold,
HYPRE_Real filter_threshold,
HYPRE_Int num_functions)
{
// Create AMG solver struct
HYPRE_Solver amg_data;
HYPRE_BoomerAMGCreate(&amg_data);
// Set Boomer AMG Parameters
HYPRE_BoomerAMGSetMaxRowSum(amg_data, 1);
HYPRE_BoomerAMGSetCoarsenType(amg_data, coarsen_type);
HYPRE_BoomerAMGSetInterpType(amg_data, interp_type);
HYPRE_BoomerAMGSetPMaxElmts(amg_data, p_max_elmts);
HYPRE_BoomerAMGSetAggNumLevels(amg_data, agg_num_levels);
HYPRE_BoomerAMGSetStrongThreshold(amg_data, strong_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(amg_data, 50);
HYPRE_BoomerAMGSetRelaxType(amg_data, 3);
HYPRE_BoomerAMGSetRelaxOrder(amg_data, 0);
// HYPRE_BoomerAMGSetRelaxWt(amg_data, 3.0/4); // set omega for SOR
HYPRE_BoomerAMGSetNumFunctions(amg_data, num_functions);
//HYPRE_BoomerAMGSetRAP2(amg_data, 1);
HYPRE_BoomerAMGSetTruncFactor(amg_data, filter_threshold);
HYPRE_BoomerAMGSetPrintLevel(amg_data, 0);
HYPRE_BoomerAMGSetMaxIter(amg_data, 1000);
// Setup AMG
HYPRE_BoomerAMGSetup(amg_data, A, b, x);
return amg_data;
}
HYPRE_Solver hypre_create_GMRES(hypre_ParCSRMatrix* A,
hypre_ParVector* b,
hypre_ParVector* x, HYPRE_Solver* precond_ptr,
HYPRE_Int coarsen_type,
HYPRE_Int interp_type,
HYPRE_Int p_max_elmts,
HYPRE_Int agg_num_levels,
HYPRE_Real strong_threshold,
HYPRE_Int num_functions)
{
// Create AMG solver struct
HYPRE_Solver gmres_data;
HYPRE_ParCSRGMRESCreate(RAPtor_MPI_COMM_WORLD, &gmres_data);
HYPRE_Solver amg_data;
HYPRE_BoomerAMGCreate(&amg_data);
// Set Boomer AMG Parameters
HYPRE_BoomerAMGSetMaxRowSum(amg_data, 1);
HYPRE_BoomerAMGSetCoarsenType(amg_data, coarsen_type);
HYPRE_BoomerAMGSetInterpType(amg_data, interp_type);
HYPRE_BoomerAMGSetPMaxElmts(amg_data, p_max_elmts);
HYPRE_BoomerAMGSetAggNumLevels(amg_data, agg_num_levels);
HYPRE_BoomerAMGSetStrongThreshold(amg_data, strong_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(amg_data, 50);
HYPRE_BoomerAMGSetRelaxType(amg_data, 3);
HYPRE_BoomerAMGSetNumFunctions(amg_data, num_functions);
HYPRE_BoomerAMGSetPrintLevel(amg_data, 0);
HYPRE_BoomerAMGSetMaxIter(amg_data, 1);
HYPRE_BoomerAMGSetRelaxOrder(amg_data, 1);
HYPRE_BoomerAMGSetTruncFactor(amg_data, 0.3);
// Set GMRES Parameters
HYPRE_GMRESSetMaxIter(gmres_data, 100);
HYPRE_GMRESSetTol(gmres_data, 1e-6);
HYPRE_GMRESSetPrintLevel(gmres_data, 2);
// Setup AMG
HYPRE_ParCSRGMRESSetPrecond(gmres_data, HYPRE_BoomerAMGSolve,
HYPRE_BoomerAMGSetup, amg_data);
HYPRE_ParCSRGMRESSetup(gmres_data, A, b, x);
*precond_ptr = amg_data;
return gmres_data;
}
HYPRE_Solver hypre_create_BiCGSTAB(hypre_ParCSRMatrix* A,
hypre_ParVector* b,
hypre_ParVector* x, HYPRE_Solver* precond_ptr,
HYPRE_Int coarsen_type,
HYPRE_Int interp_type,
HYPRE_Int p_max_elmts,
HYPRE_Int agg_num_levels,
HYPRE_Real strong_threshold,
HYPRE_Int num_functions)
{
// Create AMG solver struct
HYPRE_Solver bicgstab_data;
HYPRE_ParCSRBiCGSTABCreate(RAPtor_MPI_COMM_WORLD, &bicgstab_data);
HYPRE_Solver amg_data;
HYPRE_BoomerAMGCreate(&amg_data);
// Set Boomer AMG Parameters
HYPRE_BoomerAMGSetMaxRowSum(amg_data, 1);
HYPRE_BoomerAMGSetCoarsenType(amg_data, coarsen_type);
HYPRE_BoomerAMGSetInterpType(amg_data, interp_type);
HYPRE_BoomerAMGSetPMaxElmts(amg_data, p_max_elmts);
HYPRE_BoomerAMGSetAggNumLevels(amg_data, agg_num_levels);
HYPRE_BoomerAMGSetStrongThreshold(amg_data, strong_threshold);
HYPRE_BoomerAMGSetMaxCoarseSize(amg_data, 50);
HYPRE_BoomerAMGSetRelaxType(amg_data, 3);
HYPRE_BoomerAMGSetNumFunctions(amg_data, num_functions);
HYPRE_BoomerAMGSetPrintLevel(amg_data, 0);
HYPRE_BoomerAMGSetMaxIter(amg_data, 1);
// Set GMRES Parameters
HYPRE_BiCGSTABSetMaxIter(bicgstab_data, 100);
HYPRE_BiCGSTABSetTol(bicgstab_data, 1e-6);
HYPRE_BiCGSTABSetPrintLevel(bicgstab_data, 2);
// Setup AMG
HYPRE_ParCSRBiCGSTABSetPrecond(bicgstab_data, HYPRE_BoomerAMGSolve,
HYPRE_BoomerAMGSetup, amg_data);
HYPRE_ParCSRBiCGSTABSetup(bicgstab_data, A, b, x);
*precond_ptr = amg_data;
return bicgstab_data;
}
| 35.808955
| 133
| 0.652634
|
lukeolson
|
fca76201a8f28c73583fc244019de92973547be7
| 221
|
cpp
|
C++
|
chapter 2/2.cpp
|
lyhlyhl/cpp_Primer_Plus_tasks
|
0b966ec8216ac9bb8baffe462e15317c2d98c5de
|
[
"MIT"
] | null | null | null |
chapter 2/2.cpp
|
lyhlyhl/cpp_Primer_Plus_tasks
|
0b966ec8216ac9bb8baffe462e15317c2d98c5de
|
[
"MIT"
] | null | null | null |
chapter 2/2.cpp
|
lyhlyhl/cpp_Primer_Plus_tasks
|
0b966ec8216ac9bb8baffe462e15317c2d98c5de
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
int main()
{
int distance;
cout << "please input the distance(long):";
cin >> distance;
cout << distance * 220 << " yard" << endl;
cin.get();
cin.get();
}
| 17
| 47
| 0.570136
|
lyhlyhl
|
fcaecfedb90217f34201526356e1650d389b8c20
| 952
|
cpp
|
C++
|
engine/src/common/clock.cpp
|
justinvh/raptr
|
b6f8c9badbf2731f555ec05d54d5865627af6022
|
[
"MIT"
] | 3
|
2018-07-03T16:08:26.000Z
|
2018-07-15T01:18:15.000Z
|
engine/src/common/clock.cpp
|
justinvh/raptr
|
b6f8c9badbf2731f555ec05d54d5865627af6022
|
[
"MIT"
] | null | null | null |
engine/src/common/clock.cpp
|
justinvh/raptr
|
b6f8c9badbf2731f555ec05d54d5865627af6022
|
[
"MIT"
] | null | null | null |
#include <chrono>
#include <raptr/common/clock.hpp>
#include <raptr/common/logging.hpp>
namespace {
auto logger = raptr::_get_logger(__FILE__);
};
namespace raptr::clock {
namespace {
auto clock_last = Time::now();
auto paused_time = Time::now();
int64_t offset_us = 0;
bool paused = false;
using us = std::chrono::microseconds;
}
int64_t ticks()
{
auto now = Time::now();
if (paused) {
now = paused_time;
}
return std::chrono::duration_cast<us>(now - clock_last - us(offset_us)).count();
}
void start()
{
if (paused) {
toggle();
}
}
void stop()
{
if (!paused) {
toggle();
}
}
bool toggle()
{
paused = !paused;
if (!paused) {
auto now = Time::now();
offset_us += std::chrono::duration_cast<us>(now - paused_time).count();
logger->debug("Clock is now offset by {}us", offset_us);
} else {
paused_time = Time::now();
}
return paused;
}
}
| 17
| 84
| 0.591387
|
justinvh
|
fcb27c2e5c398e88e00d3d801cf7b69940818caa
| 6,942
|
hpp
|
C++
|
src/restio_api_mapper.hpp
|
Ri0n/restio
|
20e0324645fece1cbef43a740e52023c9e255c15
|
[
"BSD-2-Clause"
] | null | null | null |
src/restio_api_mapper.hpp
|
Ri0n/restio
|
20e0324645fece1cbef43a740e52023c9e255c15
|
[
"BSD-2-Clause"
] | null | null | null |
src/restio_api_mapper.hpp
|
Ri0n/restio
|
20e0324645fece1cbef43a740e52023c9e255c15
|
[
"BSD-2-Clause"
] | null | null | null |
/*
Copyright (c) 2021, Sergei Ilinykh <rion4ik@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <boost/algorithm/string.hpp>
#include <boost/asio/awaitable.hpp>
#include <nlohmann/json.hpp>
#include <span>
#include "restio_common.hpp"
#include "restio_properties.hpp"
#include <type_traits>
namespace restio::api {
using namespace ::nlohmann;
namespace http = ::boost::beast::http; // from <boost/beast/http.hpp>
using ::boost::asio::awaitable;
struct API {
struct Method {
using Handler
= std::function<awaitable<void>(Request &request, Response &response, const Properties &properties)>;
// using SyncHandler = std::function<void(Request &request, Response &response, const Properties &properties)>;
http::verb method;
std::string uri;
std::string comment;
json inputExample;
json outputExample;
std::string responseStatus;
Handler handler;
// Wrapping hardler to an async func if it's synchronous
template <typename HandlerType>
inline static Handler wrapHandler(
HandlerType &&handler,
typename std::enable_if<
std::is_same<typename std::invoke_result<HandlerType, Request &, Response &, const Properties &>::type,
awaitable<void>>::value>::type * = 0)
{
return handler;
}
template <typename HandlerType>
inline static Handler wrapHandler(
HandlerType &&handler,
typename std::enable_if<
std::is_same<typename std::invoke_result<HandlerType, Request &, Response &, const Properties &>::type,
void>::value>::type * = 0)
{
return [handler = std::move(handler)](
Request &request, Response &response, const Properties &properties) -> awaitable<void> {
handler(request, response, properties);
co_return;
};
}
template <typename RequestMessage, typename ResponseMessage, typename HandlerType>
inline static Method sample(http::verb method,
std::string &&uri,
std::string &&desc,
std::string &&responseStatus,
HandlerType &&handler)
{
return Method {
method,
std::move(uri),
std::move(desc),
RequestMessage::docSample(),
ResponseMessage::docSample(),
std::move(responseStatus),
std::move(wrapHandler(std::move(handler))),
};
}
struct Dummy {
static json docSample() { return nullptr; }
};
template <typename ResponseMessage, typename... Args> inline static Method get(Args &&...args)
{
return sample<Dummy, ResponseMessage>(http::verb::get, std::forward<Args>(args)...);
}
template <typename RequestMessage, typename ResponseMessage, typename... Args>
inline static Method post(Args &&...args)
{
return sample<RequestMessage, ResponseMessage>(http::verb::post, std::forward<Args>(args)...);
}
template <typename RequestMessage, typename ResponseMessage = Dummy, typename... Args>
inline static Method put(Args &&...args)
{
return sample<RequestMessage, ResponseMessage>(http::verb::put, std::forward<Args>(args)...);
}
template <typename... Args> inline static Method delete_(Args &&...args)
{
return sample<Dummy, Dummy>(http::verb::delete_, std::forward<Args>(args)...);
}
};
struct ParsedNode {
enum class Type : std::uint8_t { ConstString, VarString, Integer };
Type type;
std::string id; // var name or const string value
std::vector<std::reference_wrapper<const Method>> methods;
std::vector<ParsedNode> children;
bool operator==(const ParsedNode &other) const { return type == other.type && id == other.id; }
};
struct LookupResult {
Properties properties;
std::reference_wrapper<const Method> method;
};
inline API(int version = 1) : version(version) { }
template <typename ResponseMessage, typename... Args> inline API &get(Args &&...args)
{
methods.push_back(Method::get<ResponseMessage>(std::forward<Args>(args)...));
return *this;
}
template <typename RequestMessage, typename ResponseMessage, typename... Args> inline API &post(Args &&...args)
{
methods.push_back(Method::post<RequestMessage, ResponseMessage>(std::forward<Args>(args)...));
return *this;
}
template <typename RequestMessage, typename ResponseMessage = Method::Dummy, typename... Args>
inline API &put(Args &&...args)
{
methods.push_back(Method::put<RequestMessage, ResponseMessage>(std::forward<Args>(args)...));
return *this;
}
template <typename... Args> inline API &delete_(Args &&...args)
{
methods.push_back(Method::delete_(std::forward<Args>(args)...));
return *this;
}
void buildParser();
std::optional<LookupResult> lookup(http::verb method, std::string_view target) const;
int version = 1;
std::vector<Method> methods;
std::vector<ParsedNode> roots;
};
} // namespace restio::api
| 39
| 119
| 0.612215
|
Ri0n
|
fcb4b834718298760214e85fa27f2830f9835767
| 1,823
|
hpp
|
C++
|
includes/eeros/control/SignalChecker.hpp
|
RicoPauli/eeros
|
3cc2802253c764b16c6368ad7bdaef1e3c683367
|
[
"Apache-2.0"
] | null | null | null |
includes/eeros/control/SignalChecker.hpp
|
RicoPauli/eeros
|
3cc2802253c764b16c6368ad7bdaef1e3c683367
|
[
"Apache-2.0"
] | null | null | null |
includes/eeros/control/SignalChecker.hpp
|
RicoPauli/eeros
|
3cc2802253c764b16c6368ad7bdaef1e3c683367
|
[
"Apache-2.0"
] | null | null | null |
#ifndef ORG_EEROS_SIGNAL_CHECKER_HPP_
#define ORG_EEROS_SIGNAL_CHECKER_HPP_
#include <eeros/control/Block1i.hpp>
#include <eeros/safety/SafetyLevel.hpp>
#include <eeros/safety/SafetySystem.hpp>
#include <eeros/logger/Logger.hpp>
namespace eeros {
namespace control {
using namespace safety;
template <typename T = double>
class SignalChecker : public Block1i<T> {
public:
SignalChecker(T lowerLimit, T upperLimit) :
lowerLimit(lowerLimit),
upperLimit(upperLimit),
fired(false),
safetySystem(nullptr),
safetyEvent(nullptr),
activeLevel(nullptr)
{ }
virtual void run() override {
auto val = this->in.getSignal().getValue();
if (!fired) {
if (!((val > lowerLimit) && (val < upperLimit))) {
if (safetySystem != nullptr && safetyEvent != nullptr) {
if (activeLevel == nullptr || (activeLevel != nullptr && safetySystem->getCurrentLevel() >= *activeLevel)) {
log.warn() << "Signal checker \'" + this->getName() + "\' fires!";
safetySystem->triggerEvent(*safetyEvent);
fired = true;
}
}
}
}
}
virtual void setLimits(T lowerLimit, T upperLimit) {
this->lowerLimit = lowerLimit;
this->upperLimit = upperLimit;
}
virtual void reset() {
fired = false;
}
virtual void registerSafetyEvent(SafetySystem& ss, SafetyEvent& e) {
safetySystem = &ss;
safetyEvent = &e;
}
virtual void setActiveLevel(SafetyLevel& level) {
activeLevel = &level;
}
protected:
T lowerLimit, upperLimit;
bool fired;
SafetySystem* safetySystem;
SafetyEvent* safetyEvent;
SafetyLevel* activeLevel;
eeros::logger::Logger log;
};
};
};
#endif /* ORG_EEROS_SIGNAL_CHECKER_HPP_ */
| 25.319444
| 116
| 0.625343
|
RicoPauli
|
fcb8ea4db8b19c244bd8788132101f9b0777f038
| 2,385
|
cpp
|
C++
|
Sethi/DivisionWithSubraction.cpp
|
przet/CppProgramming
|
042aff253988b74db47659d36806912ce84dd8bc
|
[
"MIT"
] | null | null | null |
Sethi/DivisionWithSubraction.cpp
|
przet/CppProgramming
|
042aff253988b74db47659d36806912ce84dd8bc
|
[
"MIT"
] | null | null | null |
Sethi/DivisionWithSubraction.cpp
|
przet/CppProgramming
|
042aff253988b74db47659d36806912ce84dd8bc
|
[
"MIT"
] | null | null | null |
// m div n
#include <iostream>
int main()
{
// initialise the two integers to be stored from input
int m = 0, n = 0;
std::cout << "Please enter two integers \n";
// read in two inputs
std::cin >> m;
std::cin >> n;
// store m - n. Will be useful for the loop later on, and some preliminary checks
int store = (m - n);
// check if store > n. If it is continue, if not we return m div n = 1
if (n > store && m > n)
std::cout << "m div n = " << 1 << "\n";
// check if m == n and return m div n = 1
else if (m == n)
std::cout << "m div n = " << 1 << "\n"; // I am assuming it is safe just to return "1" without any declaration before hand? Or should I store it first?
// check if m < n and return m div n = 0
else if (m < n)
std::cout << "m div n = " << 0 << "\n"; // same comment applies for returnin "0" direct. We do so in a main funciton (return(0)) so should be fine....?
//otherwise, execute the (integer) division
else if (m > n) // STRANGE. I just did else before, and if m == n, this else loop is still entered. But if m < n then 0 is returned correctly and program terminates.
{
// setting a counter and store variable for use in a loop
int count = 1;
int i = 1;
// the loop with the logic of division via subtraction
for (store, i = 1; store >= n; ++i) // Thanks for tutorial point for firming up the basics for me - the condition gets evaluated second and if it is true, the loop executes, otherwise the next statement after the loop (so no looping) occurs.
// I had store == 0 - this was false! store != 0 is the right way. However I need to change this to not equal to less than zero. I had it the wrong way around, and this just firms up my fundamentals, my concepts :)
{
// the count until store equals zero or less is the div result (after we add one to it after the loop as we are starting at (m-n) instead of m. Yes we could of started the for loop at i =2, but we didn't)
count = i;
// n is subrtacted from (m-n) until store = 0 or less
store -= n;
}
// output the div result to screen
std::cout << "m div n = " << count + 1;
}
}
| 41.842105
| 258
| 0.568134
|
przet
|
fcbf95c0792d9a2c75c07942340771c0d80af552
| 24,990
|
cpp
|
C++
|
src/contours.cpp
|
jvo203/FITSWebQL
|
59a98bc1916ce5b5d88ec1ee1986009f47a76e8b
|
[
"MIT"
] | 1
|
2022-03-09T07:21:48.000Z
|
2022-03-09T07:21:48.000Z
|
src/contours.cpp
|
jvo203/FITSWebQL
|
59a98bc1916ce5b5d88ec1ee1986009f47a76e8b
|
[
"MIT"
] | 1
|
2020-06-04T08:12:36.000Z
|
2020-06-08T06:20:06.000Z
|
src/contours.cpp
|
jvo203/FITSWebQL
|
59a98bc1916ce5b5d88ec1ee1986009f47a76e8b
|
[
"MIT"
] | null | null | null |
/***************************************************************************
* Copyright (C) 2007 by Bjorn Harpe,,, *
* bjorn@ouelong.com *
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
// based on the work of Paul Bourke and Nicholas Yue
#include <stdio.h>
#include <math.h>
#include "contours.h"
//bool operator <(SPoint p1,SPoint p2){return((p1.x<p2.x));}
bool operator <(SPoint p1, SPoint p2){return(((p1.x*(unsigned int)0xFFFFFFFF)+p1.y)<((p2.x*(unsigned int)0xFFFFFFFF)+p2.y));}
bool operator <(SPair p1,SPair p2){return(p1.p1<p2.p1);}
bool operator ==(SPoint p1,SPoint p2){return((EQ(p1.x,p2.x))&&(EQ(p1.y,p2.y)));}
bool operator !=(SPoint p1,SPoint p2){return(!(EQ(p1.x,p2.x)&&!(EQ(p1.y,p2.y))));}
SPoint operator +=(SPoint p, SVector v){return(SPoint(p.x+=v.dx,p.y+=v.dy));}
int CContourMap::contour(CRaster *r)
{
/*
this routine is coppied almost verbatim form Nicholas Yue's C++ implememtation
of Paul bourkes CONREC routine. for deatails on the theory and implementation
of this routine visit http://local.wasp.uwa.edu.au/~pbourke/papers/conrec/
quick summary of the changes made
- all the data passed in to the function is in a CRaster object and accessed
thru a method (double value(double x, double y)). This class can be subclassed
to calculate values based on a formula or retrieve values from a table.
- as retrieval of values is now in the class supplied by the user we don't care
if the data is regularly spaced or not, we assume that the class takes care of
these details.
- upper and lower bounds are similarly provided but the upper_bound and lower_bound
methods in the class.
- it is not assumed that this data is being immediatly output, rather it is all stored
in a structure for later processing/display.
yet to be done
- realisticly we should replace the i and j indices with iterators, decouple this
function from any sort of assumption entirely. this would require being able to
retrieve x and y values from the iterator as well as the value. something like
returning a pointer to a structure that contains the x and y values of the given
point as well as the value. As this is not really required in my application it
may or may not be done.
//=============================================================================
//
// CONREC is a contouring subroutine for rectangularily spaced data.
//
// It emits calls to a line drawing subroutine supplied by the user
// which draws a contour map corresponding to real*4data on a randomly
// spaced rectangular grid. The coordinates emitted are in the same
// units given in the x() and y() arrays.
//
// Any number of contour levels may be specified but they must be
// in order of increasing value.
//
// As this code is ported from FORTRAN-77, please be very careful of the
// various indices like ilb,iub,jlb and jub, remeber that C/C++ indices
// starts from zero (0)
//
//===========================================================================*/
int m1,m2,m3,case_value;
double dmin,dmax,x1,x2,y1,y2;
register int i,j,k,m;
double h[5];
int sh[5];
double xh[5],yh[5];
//===========================================================================
// The indexing of im and jm should be noted as it has to start from zero
// unlike the fortran counter part
//===========================================================================
int im[4] = {0,1,1,0},jm[4]={0,0,1,1};
//===========================================================================
// Note that castab is arranged differently from the FORTRAN code because
// Fortran and C/C++ arrays are transposed of each other, in this case
// it is more tricky as castab is in 3 dimension
//===========================================================================
int castab[3][3][3] =
{
{
{0,0,8},{0,2,5},{7,6,9}
},
{
{0,3,4},{1,3,1},{4,3,0}
},
{
{9,6,7},{5,2,0},{8,0,0}
}
};
for (j=((int)r->upper_bound().x-1);j>=(int)r->lower_bound().x;j--) {
for (i=(int)r->lower_bound().y;i<=(int)r->upper_bound().y-1;i++) {
double temp1,temp2;
temp1 = min(r->value(i,j),r->value(i,j+1));
temp2 = min(r->value(i+1,j),r->value(i+1,j+1));
dmin = min(temp1,temp2);
temp1 = max(r->value(i,j),r->value(i,j+1));
temp2 = max(r->value(i+1,j),r->value(i+1,j+1));
dmax = max(temp1,temp2);
if (dmax>=levels[0]&&dmin<=levels[n_levels-1]) {
for (k=0;k<n_levels;k++) {
if (levels[k]>=dmin&&levels[k]<=dmax) {
for (m=4;m>=0;m--) {
if (m>0) {
//=============================================================
// The indexing of im and jm should be noted as it has to
// start from zero
//=============================================================
h[m] = r->value(i+im[m-1],j+jm[m-1])-levels[k];
xh[m] = i+im[m-1];
yh[m] = j+jm[m-1];
} else {
h[0] = 0.25*(h[1]+h[2]+h[3]+h[4]);
xh[0]=0.5*(i+i+1);
yh[0]=0.5*(j+j+1);
}
if (h[m]>0.0) {
sh[m] = 1;
} else if (h[m]<0.0) {
sh[m] = -1;
} else
sh[m] = 0;
}
//=================================================================
//
// Note: at this stage the relative heights of the corners and the
// centre are in the h array, and the corresponding coordinates are
// in the xh and yh arrays. The centre of the box is indexed by 0
// and the 4 corners by 1 to 4 as shown below.
// Each triangle is then indexed by the parameter m, and the 3
// vertices of each triangle are indexed by parameters m1,m2,and
// m3.
// It is assumed that the centre of the box is always vertex 2
// though this isimportant only when all 3 vertices lie exactly on
// the same contour level, in which case only the side of the box
// is drawn.
//
//
// vertex 4 +-------------------+ vertex 3
// | \ / |
// | \ m-3 / |
// | \ / |
// | \ / |
// | m=2 X m=2 | the centre is vertex 0
// | / \ |
// | / \ |
// | / m=1 \ |
// | / \ |
// vertex 1 +-------------------+ vertex 2
//
//
//
// Scan each triangle in the box
//
//=================================================================
for (m=1;m<=4;m++) {
m1 = m;
m2 = 0;
if (m!=4)
m3 = m+1;
else
m3 = 1;
case_value = castab[sh[m1]+1][sh[m2]+1][sh[m3]+1];
if (case_value!=0) {
switch (case_value) {
//===========================================================
// Case 1 - Line between vertices 1 and 2
//===========================================================
case 1:
x1=xh[m1];
y1=yh[m1];
x2=xh[m2];
y2=yh[m2];
break;
//===========================================================
// Case 2 - Line between vertices 2 and 3
//===========================================================
case 2:
x1=xh[m2];
y1=yh[m2];
x2=xh[m3];
y2=yh[m3];
break;
//===========================================================
// Case 3 - Line between vertices 3 and 1
//===========================================================
case 3:
x1=xh[m3];
y1=yh[m3];
x2=xh[m1];
y2=yh[m1];
break;
//===========================================================
// Case 4 - Line between vertex 1 and side 2-3
//===========================================================
case 4:
x1=xh[m1];
y1=yh[m1];
x2=xsect(m2,m3);
y2=ysect(m2,m3);
break;
//===========================================================
// Case 5 - Line between vertex 2 and side 3-1
//===========================================================
case 5:
x1=xh[m2];
y1=yh[m2];
x2=xsect(m3,m1);
y2=ysect(m3,m1);
break;
//===========================================================
// Case 6 - Line between vertex 3 and side 1-2
//===========================================================
case 6:
x1=xh[m3];
y1=yh[m3];
x2=xsect(m1,m2);
y2=ysect(m1,m2);
break;
//===========================================================
// Case 7 - Line between sides 1-2 and 2-3
//===========================================================
case 7:
x1=xsect(m1,m2);
y1=ysect(m1,m2);
x2=xsect(m2,m3);
y2=ysect(m2,m3);
break;
//===========================================================
// Case 8 - Line between sides 2-3 and 3-1
//===========================================================
case 8:
x1=xsect(m2,m3);
y1=ysect(m2,m3);
x2=xsect(m3,m1);
y2=ysect(m3,m1);
break;
//===========================================================
// Case 9 - Line between sides 3-1 and 1-2
//===========================================================
case 9:
x1=xsect(m3,m1);
y1=ysect(m3,m1);
x2=xsect(m1,m2);
y2=ysect(m1,m2);
break;
default:
break;
}
//=============================================================
// Put your processing code here and comment out the printf
//=============================================================
add_segment(SPair(SPoint(x1,y1),SPoint(x2,y2)),k);
}
}
}
}
}
}
}
return 0;
}
int CContourMap::generate_levels(double min, double max, int num)
{
double step=(max-min)/(num-1);
if(levels) delete levels;
levels=new double[num];
n_levels=num;
for(int i=0;i<num;i++)
{
levels[i]=min+step*i;
}
return num;
}
CContourMap::CContourMap()
{
levels=NULL;
n_levels=0;
contour_level=NULL;
}
int CContourMap::add_segment(SPair t, int level)
{
// ensure that the object hierarchy has been allocated
if(!contour_level) contour_level=new vector<CContourLevel*>(n_levels);
if(!(*contour_level)[level])
(*contour_level)[level]=new CContourLevel;
if(!(*contour_level)[level]->raw)
(*contour_level)[level]->raw=new vector<SPair>;
// push the value onto the end of the vector
(*contour_level)[level]->raw->push_back(t);
return(0);
}
int CContourMap::dump()
{
//sort the raw vectors if they exist
vector<CContourLevel*>::iterator it=contour_level->begin();
int l=0;
while(it!=contour_level->end())
{
printf("Contour data at level %d [%f]\n",l,levels[l]);
if(*it) (*it)->dump();
it++;l++;
}
fflush(NULL);
return(0);
}
int CContourMap::consolidate()
{
//sort the raw vectors if they exist
vector<CContourLevel*>::iterator it=contour_level->begin();
while(it!=contour_level->end())
{
if(*it) (*it)->consolidate();
it++;
}
return(0);
}
CContourMap::~CContourMap()
{
if(levels) delete levels;
if(contour_level)
{
vector<CContourLevel*>::iterator it=contour_level->begin();
while(it!=contour_level->end())
{
delete(*it);
it=contour_level->erase(it);
}
contour_level->clear();
delete contour_level;
}
}
/*
===============================================================================
the CContourLevel class contains all the contour data for any given contour
level. initially this data is storred in point to point format in the raw
vector, however functions exist to combine these vectors into groups (CContour)
representing lines.
*/
int CContourLevel::dump()
{
// iterate thru the vector dumping values to STDOUT as we go
// this function is intended for debugging purposes only
printf("======================================================================\n");
if(raw)
{
printf("Raw vector data\n\n");
vector<SPair>::iterator it;
it=raw->begin();
while(it!=raw->end())
{
SPair t=*it;
printf("\t(%f, %f)\t(%f, %f)\n",t.p1.x,t.p1.y,t.p2.x,t.p2.y);
it++;
}
}
if(contour_lines)
{
printf("Processed contour lines\n\n");
vector<CContour*>::iterator it=contour_lines->begin();
int c=1;
while(it!=contour_lines->end())
{
printf("Contour line %d:\n",c);
(*it)->dump();
c++;it++;
}
}
printf("======================================================================\n");
return(0);
}
int CContourLevel::consolidate()
{
vector<SPair>::iterator it;
CContour *contour;
int c=0;
if(!raw) return(0);
if (!contour_lines) contour_lines=new vector<CContour*>;
std::sort(raw->begin(),raw->end());
while(!raw->empty())
{
c++;
it=raw->begin();
contour=new CContour();
contour->add_vector((*it).p1,(*it).p2);
it=raw->erase(it);
while(it!=raw->end())
{
if((*it).p1==contour->end())
{
contour->add_vector((*it).p1,(*it).p2);
raw->erase(it);
it=raw->begin();
}
else it++;
}
contour_lines->push_back(contour);
}
delete raw;raw=NULL;
fflush(NULL);
c-=merge();
vector<CContour*>::iterator cit=contour_lines->begin();
while(cit!=contour_lines->end())
{
(*cit)->condense();
cit++;
}
return(c);
}
int CContourLevel::merge()
{
vector<CContour*>::iterator it,jt;
int c=0;
if(contour_lines->size()<2) return(0);
it=contour_lines->begin();
/*
using two iterators we walk through the entire vector testing to
see if some combination of the start and end points match. If we
find matching points the two vectorsrs are merged. since when we go
thru the vector once we are garanteed that all vectors that can
connect to that oone have been merged we only have to merge the
vector less the processed nodes at the begining. every merge does
force jt back to the beginning of the search tho since a merge will
change either the start or the end of the vector
*/
while(it!=contour_lines->end())
{
jt=it+1;
while(jt!=contour_lines->end())
{
/*
if the end of *it matches the start ot *jt we can copy
*jt to the end of *it and remove jt, the erase funtion
does us a favour and increments the iterator to the
next element so we continue to test the next element
*/
if((*it)->end()==(*jt)->start())
{
(*it)->merge(*jt);
delete(*jt);
contour_lines->erase(jt);
jt=it+1;
c++;
}
/*
similarily if the end of *jt matches the start ot *it we can copy
*it to the end of *jt and remove it,replacing it with jt, we then
neet to update it to point at the just inserted record.
*/
else if((*jt)->end()==(*it)->start())
{
(*jt)->merge(*it);
delete(*it);
(*it)=(*jt);
contour_lines->erase(jt);
jt=it+1;
c++;
}
/*
if both segments end at the same point we reverse one and merge
it to the other, then remove the one we merged.
*/
else if((*it)->end()==((*jt)->end()))
{
(*jt)->reverse();
(*it)->merge(*jt);
delete(*jt);
contour_lines->erase(jt);
jt=it+1;
c++;
}
/*
if both segments start at the same point reverse it, then merge
it with jt, removing jt and reseting jt to the start of the search
sequence
*/
else if((*it)->start()==((*jt)->start()))
{
(*it)->reverse();
(*it)->merge(*jt);
delete(*jt);
jt=contour_lines->erase(jt);
c++;
}
else
{
jt++;
}
}
it++;
}
return(c);
}
CContourLevel::~CContourLevel()
{
if(raw)
{
raw->clear();
delete raw;
}
if(contour_lines)
{
vector<CContour*>::iterator it=contour_lines->begin();
while(it!=contour_lines->end())
{
delete (*it);
it=contour_lines->erase(it);
}
contour_lines->clear();
delete contour_lines;
}
}
/*
===============================================================================
the CContour class stores actual individual contour lines in a vector,addition
to the vector is handled by the add_vector function for individual vector
components. in the case that one contour needs to be coppied to the end of
another contour there is a merge function that will copy the second onto the
end of the first. individual accessors are provided for the start and end points
and the actual vector is publicly available.
*/
int CContour::add_vector(SPoint p1, SPoint p2)
{
// move the vector to the orgin
SVector v;
v.dx=p2.x-p1.x;
v.dy=p2.y-p1.y;
// if the contour vector does not exist create it
// and set the starting point for this contour
if(!contour)
{
contour=new vector<SVector>;
_start=p1;
}
// insert the new vector to the end of the contour
// and update the end point for this contour
contour->push_back(v);
_end=p2;
return(0);
}
int CContour::reverse()
{
// swap the start and end points
SPoint t=_end;
_end=_start;
_start=t;
// iterate thru the entire vector and reverse each individual element
// inserting them into a new vector as we go
vector<SVector> *tmp=new vector<SVector>;
vector<SVector>::iterator it=contour->begin();
while(it!=contour->end())
{
(*it).dx*=-1;
(*it).dy*=-1;
tmp->insert(tmp->begin(),(*it));
it++;
}
// swap the old contour vector with the new reversed one we just generated
delete contour;
contour=tmp;
return (0);
}
int CContour::merge(CContour *c)
{
this->contour->insert(this->contour->end(),c->contour->begin(),c->contour->end());
this->_end=c->_end;
return(0);
}
int CContour::dump()
{
printf("\tStart: [%f, %f]\n\tEnd: [%f, %f]\n\tComponents>\n",
_start.x,_start.y,_end.x,_end.y);
vector<SVector>::iterator cit=contour->begin();
int c=1;
SPoint p=_start;
while(cit!=contour->end())
{
p.x+=(*cit).dx;
p.y+=(*cit).dy;
printf("\t\t{%f, %f}\t[%f,%f]\n",(*cit).dx,(*cit).dy,p.x,p.y);
c++,cit++;
}
return(0);
}
int CContour::condense(double difference)
{
/*
at this time we potentially have multiple SVectors in the contour vector that
are colinear and could be condensed into one SVector with, to determine if two
successive vectors are colinear we take each vector and divide the y component
of the vector by the x component, giving us the slope. we pass in a difference
if the difference between th two slopes is less than the difference that we
pass in and since we already know that both segments share a common point they
can obviously be condensed. in the sample code on this page this is evident it
the bounding rectangle. another possibility is modifying the code to allow
point intersections on the plane. In this instance we may have multiple
identical vectors with no magnitude that can be reduced to a single data point.
*/
vector<SVector>::iterator it,jt;
double m1,m2;
it=contour->begin();
jt=it+1;
while(jt!=contour->end())
{
if(((*jt).dx)&&((*it).dx))
{
m1=(*jt).dy/(*jt).dx;
m2=(*it).dy/(*jt).dx;
}
else if(((*jt).dy)&&((*it).dy))
{
m1=(*jt).dx/(*jt).dy;
m2=(*it).dx/(*jt).dy;
}
else
{
it++;jt++;
continue;
}
if ((m1-m2<difference)&&(m2-m1<difference))
{
(*it).dy+=(*jt).dy;
(*it).dx+=(*jt).dx;
jt=contour->erase(jt);
}
else
{
it++;jt++;
}
}
return(0);
}
CContour::~CContour()
{
this->contour->clear();
delete this->contour;
}
#ifdef STANDALONE
/*
=============================================================================
the following is just test code to try to test that everything works together
alright, we need to create an object that inherits from CRaster (ToMap in
this case) that defines three functions, two returning each the lower and
upper bounds respectively, and a third that returns the value at a given
point. As we are assuming that data is regularly spaced we do not need to
determine the x or y coordinate at this point as the original code did,
rather we leave that for the rendering step to do by scaling the values as
needed.
=============================================================================
*/
class ToMap:public CRaster
{
public:
double value(double x,double y);
SPoint upper_bound();
SPoint lower_bound();
};
double ToMap::value(double x, double y)
{
if(((int)x==1)&&((int)y==1)) return 1;
else return 0;
}
SPoint ToMap::lower_bound()
{
return SPoint(0,0);
}
SPoint ToMap::upper_bound()
{
return SPoint(2,2);
}
int main(int argc, char *argv[])
{
ToMap *m=new ToMap;
CContourMap *map=new CContourMap;
map->generate_levels(0,1,3);
printf("Attempting to contour \n");
map->contour(m);
map->dump();
printf("Consolidating Vectors\n");
map->consolidate();
printf("\n\n\n\t\tDumping Contour Map\n");
map->dump();
}
#endif
| 34.326923
| 125
| 0.461024
|
jvo203
|
fcc8ff13d2044831c93f6a11cd4f8cf07c051dc0
| 752
|
hpp
|
C++
|
include/ParseEntry.hpp
|
astrowar/Cinform
|
f7fb7fcc3c3f83e1ee2691d968086e37faed038b
|
[
"MIT"
] | null | null | null |
include/ParseEntry.hpp
|
astrowar/Cinform
|
f7fb7fcc3c3f83e1ee2691d968086e37faed038b
|
[
"MIT"
] | null | null | null |
include/ParseEntry.hpp
|
astrowar/Cinform
|
f7fb7fcc3c3f83e1ee2691d968086e37faed038b
|
[
"MIT"
] | null | null | null |
#ifndef PARSEENTRY_HPP
#define PARSEENTRY_HPP
#include <preprocess.hpp>
#include <pmatch_baseClass.hpp>
#include <list>
using namespace std;
namespace CInform
{
using namespace Match;
namespace CodeParser
{
class MatchedParagraph
{
public:
SParagraph* paragraph;
list< MatchResult > mList;
MatchedParagraph(SParagraph* _paragraph, list< MatchResult > _mList);
};
class ParserEntry
{
public:
HMatchExpended patten;
string entryName;
ParserEntry(string _entryName, HMatchExpended _patten);
};
class ParserEntryGroup
{
public:
std::list< std::pair< std::string, HMatch > > entryName_patten;
ParserEntryGroup(list< ParserEntry> parserentries);
void Add(ParserEntry p);
};
}
}
#endif
| 14.745098
| 74
| 0.712766
|
astrowar
|
fcc95daaf86110f91a6d4456599568060fc64b4d
| 1,242
|
cpp
|
C++
|
Game/Source/ThroneAngel.cpp
|
aNnAm2606/PROJECT-II-BAKARA-SAN
|
84bbc8cc9f7ea9f5b1b3ece4ea4053c74e7ece7f
|
[
"MIT"
] | null | null | null |
Game/Source/ThroneAngel.cpp
|
aNnAm2606/PROJECT-II-BAKARA-SAN
|
84bbc8cc9f7ea9f5b1b3ece4ea4053c74e7ece7f
|
[
"MIT"
] | 7
|
2022-03-19T21:14:34.000Z
|
2022-03-19T21:53:13.000Z
|
Game/Source/ThroneAngel.cpp
|
aNnAm2606/PROJECT-II-BAKARA-SAN
|
84bbc8cc9f7ea9f5b1b3ece4ea4053c74e7ece7f
|
[
"MIT"
] | 1
|
2022-03-08T12:25:02.000Z
|
2022-03-08T12:25:02.000Z
|
#include "ThroneAngel.h"
#include "App.h"
#include "Textures.h"
#include "Render.h"
#include "ATearsInHeaven.h"
#include "AAngeleyes.h"
#include "Audio.h"
ThroneAngel::ThroneAngel(iPoint g_pos) : Enemy(g_pos)
{
p_CharacterName = "throne angel";
p_CharacterId = ECharacterType::ECHARACTER_MIPHARESH;
p_Stats.health = 120;
p_Stats.maxHealth = 120;
p_Stats.damage = 15;
p_Stats.speed = 10;
p_CharacterFX = app->audio->LoadFx("Assets/Audio/Fx/dead2.wav");
p_CharacterSpriteSheet = app->tex->Load("Assets/Art/Enemies/final_boss_battle.png");
p_CharacterRect = {
0, 0,
128, 128
};
p_Abilities.push_back(new ATearsInHeaven(this));
p_Abilities.push_back(new AAngeleyes(this));
p_AttackAnimations.emplace_back();
p_AttackAnimations[0].PushBack({ 0, 0, 128, 128 });
p_AttackAnimations[0].speed = 0.2f;
p_AttackAnimations[0].loop = false;
p_AttackAnimations.emplace_back();
p_AttackAnimations[1].PushBack({ 0, 0, 128, 128 });
p_AttackAnimations[1].speed = 0.2f;
p_AttackAnimations[1].loop = false;
SDL_Rect rect = { 0, 256, 128, 128 };
for (int i = 0; i < 6; i++) {
rect.x = i * 128;
p_DeadAnimation.PushBack(rect);
}
p_DeadAnimation.speed = 0.2f;
p_DeadAnimation.loop = false;
}
ThroneAngel::~ThroneAngel()
{
}
| 24.352941
| 85
| 0.714976
|
aNnAm2606
|
fccfe36132cf37ca81ba1440cf3ce6cc63e27f79
| 12,137
|
cpp
|
C++
|
tools/manager/src/user_config_descriptions.cpp
|
SleepKiller/swbfii-shaderpatch
|
b49ce3349d4dd09b19237ff4766652166ba1ffd4
|
[
"MIT"
] | 5
|
2018-03-02T04:02:39.000Z
|
2018-08-07T19:36:50.000Z
|
tools/manager/src/user_config_descriptions.cpp
|
SleepKiller/swbfii-shaderpatch
|
b49ce3349d4dd09b19237ff4766652166ba1ffd4
|
[
"MIT"
] | 27
|
2018-03-10T20:37:38.000Z
|
2018-10-08T11:10:34.000Z
|
tools/manager/src/user_config_descriptions.cpp
|
SleepKiller/swbfii-shaderpatch
|
b49ce3349d4dd09b19237ff4766652166ba1ffd4
|
[
"MIT"
] | null | null | null |
#include "framework.hpp"
#include "user_config_descriptions.hpp"
using namespace std::literals;
auto load_user_config_descriptions()
-> std::unordered_map<std::wstring_view, std::wstring_view>
{
return {
// clang-format off
{
L"Display"sv,
LR"(Settings for controlling the display of the game.)"sv
},
{
L"Screen Percent"sv,
LR"(Precentage of the sceen the game's window will take up. Value from 10 to 100.)"sv
},
{
L"Resolution Scale"sv,
LR"(Render resolution scale, as a percentage. This controls the resolution the game will be rendered at but does not affect window size.
For instance if your desktop resolution is 3840 x 2160 (4K) setting this to 50 will render the game at 1920 x 1080.
The game will be upscaled back to 3840 x 2160 by the GPU when it is sent to the display.
Lowering this can boost perforomance. Usage of an Anti-Aliasing Method with this option is highly reccomended.)"sv
},
{
L"Scale UI with Resolution Scale"sv,
LR"(Keeps the game's UI and HUD from becoming illegible when Resolution Scale is used. This only has an effect if Display Scaling is 'yes'.)"sv
},
{
L"Allow Tearing"sv,
LR"(Allow tearing when displaying frames. This can allow lower latency and is also required for variable refresh rate technologies to work.)"sv
},
{
L"Centred"sv,
LR"(Whether to centre the window or not. If `ScreenPercent` is 100 there will be no difference between a centred and uncentred window.)"sv
},
{
L"Treat 800x600 As Interface"sv,
LR"(Whether 800x600 will be treated as the resolution used by the game's main menu interface. When enabled causes Shader Patch to override the game's resolution without informing the game it has done so. Doing this keeps the interface usable while still letting you enjoy fullscreen ingame.)"sv
},
{
L"Windowed Interface"sv,
LR"(When `Treat 800x600 As Interface` is `yes` controls whether the game's interface will be rendered fullscreen (which can lead to stretching on the UI) or if it'll be kept in a 800x600 window.)"sv
},
{
L"Display Scaling Aware"sv,
LR"(Whether to mark the game DPI aware or not. When your display scaling is not at 100% having this be `yes` keeps the game being drawn at native resolution and stops Windows' upscaling it after the fact.)"sv
},
{
L"Display Scaling"sv,
LR"(When `Display Scaling Aware` is `yes` controls if the game's perceived resolution will be scaled based on the display scaling factor. This effectively adjusts the scale UI and HUD elements are positioned and drawn with to match the display's scale.)"sv
},
{
L"Scalable Fonts"sv,
LR"(Whether to replace the game's core fonts with ones that can be scaled. If you have any mods installed that also replace the game's fonts when this setting is enabled then they will be superseded by Shader Patch's fonts.)"sv
},
{
L"Enable Game Perceived Resolution Override"sv,
LR"(Enables the overriding the resolution the game thinks it is rendering at, without changing the resolution it is actually rendered at. This can have the affect of altering the aspect ratio of the game and the scaling and position of UI/HUD elements.
When set to `yes` causes `Display Scaling` to be ignored.
If you're unsure what this is useful for then **leave** it set to "no".)"sv
},
{
L"Game Perceived Resolution Override"sv,
LR"(The override for the game's perceived resolution, for use with `Enable Game Perceived Resolution Override`.)"sv
},
{
L"User Interface"sv,
LR"(Settings affecting the user interface/HUD of the game.
Note that Friend-Foe color changes do not work when a unit flashes on the minimap. They do work for everything else.)"sv
},
{
L"Extra UI Scaling"sv,
LR"(Extra scaling for the UI/HUD on top of normal display scaling. As a percentage. This can be used to make text larger if it is too small but only has effect when Display Scaling is enabled.
Note that the trick Shader Patch uses to scale the game's UI (lowering the resolution the game thinks it's rendering at) can't scale indefinitely, if changing this has to effect and you're on a high DPI screen it's possible you've hit the limit for how much scaling Shader Patch can allow.)"sv
},
{
L"Friend Color"sv,
LR"(Color to use for Friend HUD and world elemenets. (Command Posts, crosshair, etc))"sv
},
{
L"Foe Color"sv,
LR"(Color to use for Foe HUD and world elemenets. (Command Posts, crosshair, etc))"sv
},
{
L"Graphics"sv,
LR"(Settings directly affecting the rendering of the game.)"sv
},
{
L"GPU Selection Method"sv,
LR"(How to select the GPU to use. Can be "Highest Performance", "Lowest Power Usage", "Highest Feature Level", "Most Memory" or "Use CPU".)"sv
},
{
L"Anti-Aliasing Method"sv,
LR"(Anti-Aliasing method to use, can be "none", "CMAA2", "MSAAx4" or "MSAAx8".)"sv
},
{
L"Supersample Alpha Test"sv,
LR"(Enables supersampling the alpha test for hardedged transparency/alpha cutouts when Multisampling Anti-Aliasing is enabled.
This provides excellent anti-aliasing for alpha cutouts (foliage, flat fences, etc) and should be much cheaper than general supersampling. It however does raise the number of texture samples that need to be taken by however many rendertarget samples there are - fast high end GPUs may not even notice this, low power mobile GPUs may struggle more.
If enabling this causes performance issues but you'd still really like it then lowering the level of Anisotropic Filtering may help make reduce the performance cost of this option.)"sv
},
{
L"Anisotropic Filtering"sv,
LR"(Anisotropic Filtering level for textures, can be "off", "x2", "x4", "x8" or "x16".)"sv
},
{
L"Enable 16-Bit Color Channel Rendering"sv,
LR"(Controls whether R1G16B16A16 rendertargets will be used or not. Due to the way SWBFII is drawn using them can cut down significantly on banding. Additionally when they are enabled dithering will be applied when they are copied into R8G8B8A8 textures for display to further reduce banding.
If Effects are enabled and HDR rendering is enabled by a map then this setting has no effect.)"sv
},
{
L"Enable Order-Independent Transparency"sv,
LR"(Enables the use of an Order-Independent Transparency approximation. It should go without saying that this increases the cost of rendering. Requires a GPU with support for Rasterizer Ordered Views and typed Unordered Access View loads.
When this is enabled transparent objects will no longer be affected by Multisample Anti-Aliasing (MSAA), this can be especially noticeable when using resolution scaling - although it does depend on the map. Postprocessing Anti-Aliasing options like CMAA2 are unaffected.
Known to be buggy on old NVIDIA drivers. Try updating your GPU driver if you encounter issues.)"sv
},
{
L"Enable Alternative Post Processing"sv,
LR"(Enables the use of an alternative post processing path for some of the game's post processing effects. The benefit to this is the alternative path is designed to be independent of the game's resolution and is unaffected by bugs the vanilla path suffers from relating to high resolutions.
In some cases the alternative path may produce results that do not exactly match the intended look of a map.)"sv
},
{
L"Enable Scene Blur"sv,
LR"(Enables maps to make use of the game's scene blur effect. Has a performance cost but using it will keep the map's artwork more inline with the creators vision. Note this is **unrelated** to the Effects system and also only takes effect when `Enable Alternative Post Processing` is `yes`.)"sv
},
{
L"Refraction Quality"sv,
LR"(Quality level of refractions. Can be "Low", "Medium", "High" or "Ultra".
"Low" sets the resolution of the refractions to 1/4 screen resolution, Medium 1/2, High 1/2 and Ultra matches screen resolution.
On "High" or "Ultra" refractions will also be masked using the depth buffer.)"sv
},
{
L"Disable Light Brightness Rescaling"sv,
LR"(In the vanilla shaders for most surfaces after calculating incoming light for a surface the brightness of the light is rescaled to keep it from being too dark or too bright. (Or at least that is what I *assume* the reason to be.)
Disabling this can increase the realism and correctness of lighting for objects lit by the affected shaders. But for maps/mods that have had their lighting carefully balanced by the author it could do more harm than good. It is also likely to increase the amount of surfaces that are bright enough to cause light bloom in a scene.
This setting has no affect on custom materials or when Effects are enabled. (Effects have an equivalent setting however.))"sv
},
{
L"Enable User Effects Config"sv,
LR"(When a map or mod has not loaded an Effects Config Shader Patch can use a user specified config.)"sv
},
{
L"User Effects Config"sv,
LR"(The name of the Effects Config to load when `Enable User Effects Config` is true. The config should be in the same directory as the game's executable.)"sv
},
{
L"Effects"sv,
LR"(Settings for the Effects system, which allows modders to apply various effects to their mods at their discretion and configuration. Below are options provided to tweak the performance of this system for low-end/older GPUs.)"sv
},
{
L"Bloom"sv,
LR"(Enable or disable a mod using the Bloom effect. This effect is can have a slight performance impact.)"sv
},
{
L"Vignette"sv,
LR"(Enable or disable a mod using the Vignette effect. This effect is really cheap.)"sv
},
{
L"Film Grain"sv,
LR"(Enable or disable a mod using the Film Grain effect. This effect is fairly cheap.)"sv
},
{
L"Allow Colored Film Grain"sv,
LR"(Enable or disable a mod using being allowed to use Colored Film Grain. Slightly more expensive than just regular Film Grain, if a mod is using it.)"sv
},
{
L"SSAO"sv,
LR"(Enable or disable a mod using Screen Space Ambient Occlusion. (Not actually true Ambient Occlusion as it is applied indiscriminately to opaque surfaces.)
Has anywhere from a slight performance impact to significant performance impact depending on the quality setting.)"sv
},
{
L"SSAO Quality"sv,
LR"(Quality of SSAO when enabled. Can be "Fastest", "Fast", Medium", "High" or "Highest". Each step up is usually 1.5x-2.0x more expensive than the last setting.)"sv
},
{
L"Developer"sv,
LR"(Settings for both mod makers and Shader Patch developers. If you don't fall into those groups these settings likely aren't useful.)"sv
},
{
L"Screen Toggle"sv,
LR"(Toggle key for the developer screen. Giving access to useful things for mod makers and Shader Patch developers alike.
The value identifies the virtual key that activates the debug screen, below are some common values for you to choose from. (Copy and paste the value on the right of your desired key.)
'~': 0xC0
'\': 0xDC
'Backspace': 0x08
'F12': 0x7B)"sv
},
{
L"Monitor BFront2.log"sv,
LR"(Enables the monitoring, filtering and display of "BFront2.log" ingame. Can not be changed ingame. Only useful to modders.)"sv
},
{
L"Allow Event Queries"sv,
LR"(Controls whether or not Shader Patch will allow the game to use GPU event queries.)"sv
},
{
L"Use D3D11 Debug Layer"sv,
LR"(Enable the D3D11 debug layer, typically requires the Windows SDK to be installed to work.
Even if this flag is true the debug layer will only be enabled if a debugger is attached to the game.)"sv
},
{
L"Use DXGI 1.2 Factory"sv,
LR"(Limit Shader Patch to using a DXGI 1.2 factory to work around a crash in the Visual Studio Graphics Debugger. This also bypasses all GPU selection logic.)"sv
},
{
L"Shader Cache Path"sv,
LR"(Path for shader cache file.)"sv
},
{
L"Shader Definitions Path"sv,
LR"(Path to shader definitions. (.json files describing shader entrypoints and variations within a file))"sv
},
{
L"Shader Source Path"sv,
LR"(Path to shader HLSL source files.)"sv
},
{
L"Material Scripts Path"sv,
LR"(Path to material types Lua scripts.)"sv
},
{
L"Scalable Font Name"sv,
LR"(Name of the font to use when Scalable Fonts are enabled.)"sv
},
// clang-format on
};
}
| 40.456667
| 347
| 0.7445
|
SleepKiller
|
fcd2cf26083ee49eefd2636c16d5414e6467837c
| 2,089
|
hpp
|
C++
|
include/ezdxf/acdb/object.hpp
|
mozman/ezdxf.cpp
|
09295f7dafe2a76253807fccd92560fd45eb97a5
|
[
"MIT"
] | 2
|
2021-02-10T08:14:59.000Z
|
2021-12-09T08:55:01.000Z
|
include/ezdxf/acdb/object.hpp
|
mozman/ezdxf.cpp
|
09295f7dafe2a76253807fccd92560fd45eb97a5
|
[
"MIT"
] | null | null | null |
include/ezdxf/acdb/object.hpp
|
mozman/ezdxf.cpp
|
09295f7dafe2a76253807fccd92560fd45eb97a5
|
[
"MIT"
] | 1
|
2021-02-10T08:25:20.000Z
|
2021-02-10T08:25:20.000Z
|
// Copyright (c) 2021, Manfred Moitzi
// License: MIT License
//
#ifndef EZDXF_OBJECT_HPP
#define EZDXF_OBJECT_HPP
#include <stdexcept>
#include "ezdxf/type.hpp"
namespace ezdxf::acdb {
using ezdxf::Handle;
// acdb::Object is the base class for all DXF entities in a DXF Document
// which have a handle.
// The handle can only be assigned once!
class Object {
private:
unsigned int status_{0}; // status flags
Handle handle_{0}; // 0 represents an unassigned handle
Handle owner_{0}; // 0 represents no owner
public:
enum class Status {
kErased = 1
};
Object() = default;
explicit Object(Handle handle, Handle owner = 0) : Object{} {
set_handle(handle);
if (owner) set_owner(owner);
}
virtual ~Object() = default;
// Returns the DXF type as specified in the DXF file:
// Object is not a real DXF object, it is the base class for all
// DXF entities.
virtual DXFType dxf_type() { return DXFType::None; }
// Returns the corresponding ObjectARX® type:
virtual ARXType arx_type() { return ARXType::AcDbObject; }
[[nodiscard]] bool is_erased() const {
return status_ & static_cast<unsigned int>(Status::kErased);
}
[[nodiscard]] bool is_alive() const {
return !is_erased();
}
[[nodiscard]] Handle get_handle() const { return handle_; }
void set_handle(Handle h) {
if (handle_) // handle is immutable if != 0
throw std::invalid_argument("assigned handle is immutable");
handle_ = h;
}
[[nodiscard]] Handle get_owner() const { return owner_; }
void set_owner(Handle o) { owner_ = o; }
virtual void erase() {
// Set object status to erased, DXF objects will not be destroyed at
// the lifetime of a DXF document!
status_ |= static_cast<unsigned int>(Status::kErased);
}
};
}
#endif //EZDXF_OBJECT_HPP
| 28.616438
| 80
| 0.589756
|
mozman
|
fcd35c88697a8f366574654be0f2823e1a878233
| 8,815
|
cc
|
C++
|
misc/slowlink/slowlink.cc
|
flipk/pfkutils
|
d8f6c22720b6fcc44a882927c745a822282d1f69
|
[
"Unlicense"
] | 4
|
2015-06-12T05:08:56.000Z
|
2017-11-13T11:34:27.000Z
|
misc/slowlink/slowlink.cc
|
flipk/pfkutils
|
d8f6c22720b6fcc44a882927c745a822282d1f69
|
[
"Unlicense"
] | null | null | null |
misc/slowlink/slowlink.cc
|
flipk/pfkutils
|
d8f6c22720b6fcc44a882927c745a822282d1f69
|
[
"Unlicense"
] | 1
|
2021-10-20T02:04:53.000Z
|
2021-10-20T02:04:53.000Z
|
#include "LockWait.h"
#include "thread_slinger.h"
#include "pfkposix.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#define BAIL(condition,what) \
if (condition) { \
int e = errno; \
fprintf(stderr, what ": %d:%s\n", e, strerror(e)); \
return 1; \
}
//#define PRINTF(x...)
#define PRINTF(x...) printf(x)
#define PRINTF2(x...)
//#define PRINTF2(x...) printf(x)
struct fdBuffer : public ThreadSlinger::thread_slinger_message
{
fdBuffer(void) { buffer = NULL; }
~fdBuffer(void) { if (buffer != NULL) delete[] buffer; }
static int BUFFERSIZE;
pfk_timeval stamp; // the time at which this should be sent.
int length;
char * buffer;
void init(void) {
if (buffer == NULL)
buffer = new char[BUFFERSIZE];
}
};
int fdBuffer::BUFFERSIZE = 0; // must be initialized
typedef ThreadSlinger::thread_slinger_pool<fdBuffer> fdBufPool;
typedef ThreadSlinger::thread_slinger_queue<fdBuffer> fdBufQ;
struct connection_config
{
uint32_t latency;
int server_fd;
int client_fd;
bool reader0_running;
bool reader1_running;
bool writer0_running;
bool writer1_running;
bool die;
bool doServer;
WaitUtil::Semaphore thread_init_sem;
WaitUtil::Semaphore client_tokens;
WaitUtil::Semaphore server_tokens;
fdBufPool ctsPool;
fdBufPool stcPool;
fdBufQ ctsQ;
fdBufQ stcQ;
};
#define TICKS_PER_SECOND 20
void * reader_thread_routine( void * );
void * writer_thread_routine( void * );
int
main(int argc, char ** argv)
{
if (argc != 6)
{
fprintf(stderr,
"usage: slowlink bytes_per_second latency_in_mS "
"listen_port remote_ip remote_port\n");
return 1;
}
try {
connection_config cfg;
fdBuffer::BUFFERSIZE = atoi(argv[1]) / TICKS_PER_SECOND;
cfg.latency = atoi(argv[2]);
uint16_t listen_port = atoi(argv[3]);
char * remote_ip = argv[4];
uint16_t remote_port = atoi(argv[5]);
int v = 1, listen_fd = -1;
struct sockaddr_in sa;
struct in_addr remote_inaddr;
pthread_t id;
pthread_attr_t pthattr;
if (!inet_aton(remote_ip, &remote_inaddr))
{
fprintf(stderr, "unable to parse ip address '%s'\n", remote_ip);
return 1;
}
listen_fd = socket(AF_INET, SOCK_STREAM, 0);
BAIL(listen_fd < 0, "socket");
cfg.client_fd = socket(AF_INET, SOCK_STREAM, 0);
BAIL(cfg.client_fd < 0, "socket");
v = 1;
setsockopt( listen_fd, SOL_SOCKET, SO_REUSEADDR,
(void*) &v, sizeof( v ));
sa.sin_family = AF_INET;
sa.sin_port = htons(listen_port);
sa.sin_addr.s_addr = htonl(INADDR_ANY);
v = bind( listen_fd, (struct sockaddr *) &sa, sizeof(sa));
BAIL(v < 0, "bind");
listen( listen_fd, 1 );
socklen_t salen = sizeof(sa);
cfg.server_fd = accept( listen_fd, (struct sockaddr *) &sa, &salen );
BAIL( cfg.server_fd < 0, "accept" );
close( listen_fd );
sa.sin_port = htons(remote_port);
sa.sin_addr = remote_inaddr;
v = connect(cfg.client_fd, (struct sockaddr *) &sa, sizeof(sa));
BAIL(v < 0, "connect");
cfg.thread_init_sem.init(0);
cfg.ctsPool.add(100);
cfg.stcPool.add(100);
cfg.reader0_running = false;
cfg.reader1_running = false;
cfg.writer0_running = false;
cfg.writer1_running = false;
cfg.die = false;
pthread_attr_init( &pthattr );
pthread_attr_setdetachstate( &pthattr, PTHREAD_CREATE_DETACHED );
cfg.doServer = true;
pthread_create(&id, &pthattr, reader_thread_routine, &cfg);
cfg.thread_init_sem.take();
cfg.doServer = false;
pthread_create(&id, &pthattr, reader_thread_routine, &cfg);
cfg.thread_init_sem.take();
cfg.doServer = true;
pthread_create(&id, &pthattr, writer_thread_routine, &cfg);
cfg.thread_init_sem.take();
cfg.doServer = false;
pthread_create(&id, &pthattr, writer_thread_routine, &cfg);
cfg.thread_init_sem.take();
pthread_attr_destroy( &pthattr );
while (cfg.reader0_running == true &&
cfg.reader1_running == true &&
cfg.writer0_running == true &&
cfg.writer1_running == true)
{
usleep(1000000 / TICKS_PER_SECOND);
// issue tokens
cfg.client_tokens.give();
cfg.server_tokens.give();
PRINTF2("%d %d %d %d\n",
cfg.reader0_running, cfg.reader1_running,
cfg.writer0_running, cfg.writer1_running);
};
// we got here because one of the connections
// apparently died. attempt to clean up.
// note: this part doesn't seem to work worth a damn.
cfg.die = true;
if (cfg.client_fd != -1)
close(cfg.client_fd);
if (cfg.server_fd != -1)
close(cfg.server_fd);
cfg.client_tokens.give();
cfg.server_tokens.give();
while (cfg.reader0_running == true ||
cfg.reader1_running == true ||
cfg.writer0_running == true ||
cfg.writer1_running == true)
{
usleep(1);
}
}
catch (WaitUtil::LockableError e) {
fprintf(stderr, "LockableError: %s\n", e.Format().c_str());
}
catch (DLL3::ListError e) {
fprintf(stderr, "DLL3 error: %s\n", e.Format().c_str());
}
return 0;
}
void * reader_thread_routine( void * _cfg )
{
connection_config * cfg = (connection_config *) _cfg;
bool doServer = cfg->doServer;
bool *myRunning = doServer ? &cfg->reader0_running : &cfg->reader1_running;
int myfd = doServer ? cfg->server_fd : cfg->client_fd;
fdBufPool *myPool = doServer ? &cfg->stcPool : &cfg->ctsPool;
fdBufQ *myQ = doServer ? &cfg->stcQ : &cfg->ctsQ;
fdBuffer * buf;
pfk_timeval latency;
latency.tv_sec = cfg->latency / 1000; // ms to sec
latency.tv_usec = (cfg->latency % 1000) * 1000; // ms to us
*myRunning = true;
cfg->thread_init_sem.give();
while (cfg->die == false)
{
PRINTF("reader %d trying to alloc\n", doServer);
buf = myPool->alloc(-1);
buf->init();
PRINTF("reader %d got a buffer, attempting read\n", doServer);
buf->length = read(myfd, buf->buffer, fdBuffer::BUFFERSIZE);
PRINTF("reader %d got read of %d\n", doServer, buf->length);
if (buf->length <= 0)
{
fprintf(stderr, "got read of %d on fd %d\n", buf->length, myfd);
break;
}
gettimeofday(&buf->stamp, NULL);
buf->stamp += latency;
myQ->enqueue(buf);
}
*myRunning = false;
return NULL;
}
void * writer_thread_routine( void * _cfg )
{
connection_config * cfg = (connection_config *) _cfg;
bool doServer = cfg->doServer;
bool *myRunning = doServer ? &cfg->writer0_running : &cfg->writer1_running;
pfk_timeval now;
WaitUtil::Semaphore *myTokens =
doServer ? &cfg->server_tokens : &cfg->client_tokens;
fdBufQ *myQ = doServer ? &cfg->stcQ : &cfg->ctsQ;
fdBufPool *myPool = doServer ? &cfg->stcPool : &cfg->ctsPool;
int myfd = doServer ? cfg->client_fd : cfg->server_fd;
fdBuffer * buf;
*myRunning = true;
cfg->thread_init_sem.give();
while (cfg->die == false && myTokens->take())
{
gettimeofday(&now, NULL);
buf = myQ->get_head();
if (buf == NULL)
// queue empty, nothing to do.
continue;
if (buf->stamp > now)
{
// packet not old enough, let it age.
PRINTF2("writer %d now %d.%06d < stamp %d.%06d\n",
doServer,
(int)now.tv_sec, (int)now.tv_usec,
(int)buf->stamp.tv_sec, (int)buf->stamp.tv_usec);
continue;
}
buf = myQ->dequeue();
PRINTF("writer %d attempting %d\n", doServer, buf->length);
int cc = write(myfd, buf->buffer, buf->length);
PRINTF("writer %d attempt %d returns %d\n",
doServer, buf->length, cc);
if (cc != buf->length)
{
fprintf(stderr, "write attempt %d returns %d on fd %d\n",
buf->length, cc, myfd);
cfg->die = true;
break;
}
myPool->release(buf);
}
*myRunning = false;
return NULL;
}
| 32.054545
| 79
| 0.5789
|
flipk
|
fcd47b2b032bd3c6cb3ff077f8124968c2d8b4a5
| 5,206
|
hpp
|
C++
|
src/include/duckdb/function/table/arrow.hpp
|
taniabogatsch/duckdb
|
dbb043b1149bdd70feec5cce131222d7897a3b91
|
[
"MIT"
] | null | null | null |
src/include/duckdb/function/table/arrow.hpp
|
taniabogatsch/duckdb
|
dbb043b1149bdd70feec5cce131222d7897a3b91
|
[
"MIT"
] | null | null | null |
src/include/duckdb/function/table/arrow.hpp
|
taniabogatsch/duckdb
|
dbb043b1149bdd70feec5cce131222d7897a3b91
|
[
"MIT"
] | null | null | null |
//===----------------------------------------------------------------------===//
// DuckDB
//
// duckdb/function/table/arrow.hpp
//
//
//===----------------------------------------------------------------------===//
#pragma once
#include "duckdb/function/table_function.hpp"
#include "duckdb/common/arrow_wrapper.hpp"
#include "duckdb/common/atomic.hpp"
#include "duckdb/common/mutex.hpp"
#include "duckdb/common/pair.hpp"
#include "duckdb/common/thread.hpp"
#include "duckdb/common/unordered_map.hpp"
namespace duckdb {
//===--------------------------------------------------------------------===//
// Arrow Variable Size Types
//===--------------------------------------------------------------------===//
enum class ArrowVariableSizeType : uint8_t { FIXED_SIZE = 0, NORMAL = 1, SUPER_SIZE = 2 };
//===--------------------------------------------------------------------===//
// Arrow Time/Date Types
//===--------------------------------------------------------------------===//
enum class ArrowDateTimeType : uint8_t {
MILLISECONDS = 0,
MICROSECONDS = 1,
NANOSECONDS = 2,
SECONDS = 3,
DAYS = 4,
MONTHS = 5
};
struct ArrowConvertData {
ArrowConvertData(LogicalType type) : dictionary_type(type) {};
ArrowConvertData() {};
//! Hold type of dictionary
LogicalType dictionary_type;
//! If its a variable size type (e.g., strings, blobs, lists) holds which type it is
vector<pair<ArrowVariableSizeType, idx_t>> variable_sz_type;
//! If this is a date/time holds its precision
vector<ArrowDateTimeType> date_time_precision;
};
typedef unique_ptr<ArrowArrayStreamWrapper> (*stream_factory_produce_t)(
uintptr_t stream_factory_ptr, pair<unordered_map<idx_t, string>, vector<string>> &project_columns,
TableFilterSet *filters);
typedef void (*stream_factory_get_schema_t)(uintptr_t stream_factory_ptr, ArrowSchemaWrapper &schema);
struct ArrowScanFunctionData : public TableFunctionData {
ArrowScanFunctionData(idx_t rows_per_thread_p, stream_factory_produce_t scanner_producer_p,
uintptr_t stream_factory_ptr_p)
: lines_read(0), rows_per_thread(rows_per_thread_p), stream_factory_ptr(stream_factory_ptr_p),
scanner_producer(scanner_producer_p), number_of_rows(0) {
}
//! This holds the original list type (col_idx, [ArrowListType,size])
unordered_map<idx_t, unique_ptr<ArrowConvertData>> arrow_convert_data;
atomic<idx_t> lines_read;
ArrowSchemaWrapper schema_root;
idx_t rows_per_thread;
//! Pointer to the scanner factory
uintptr_t stream_factory_ptr;
//! Pointer to the scanner factory produce
stream_factory_produce_t scanner_producer;
//! Number of rows (Used in cardinality and progress bar)
int64_t number_of_rows;
};
struct ArrowScanLocalState : public LocalTableFunctionState {
explicit ArrowScanLocalState(unique_ptr<ArrowArrayWrapper> current_chunk) : chunk(move(current_chunk)) {
}
unique_ptr<ArrowArrayStreamWrapper> stream;
shared_ptr<ArrowArrayWrapper> chunk;
idx_t chunk_offset = 0;
vector<column_t> column_ids;
//! Store child vectors for Arrow Dictionary Vectors (col-idx,vector)
unordered_map<idx_t, unique_ptr<Vector>> arrow_dictionary_vectors;
TableFilterSet *filters = nullptr;
};
struct ArrowScanGlobalState : public GlobalTableFunctionState {
unique_ptr<ArrowArrayStreamWrapper> stream;
mutex main_mutex;
bool ready = false;
idx_t max_threads = 1;
idx_t MaxThreads() const override {
return max_threads;
}
};
struct ArrowTableFunction {
public:
static void RegisterFunction(BuiltinFunctions &set);
private:
//! Binds an arrow table
static unique_ptr<FunctionData> ArrowScanBind(ClientContext &context, TableFunctionBindInput &input,
vector<LogicalType> &return_types, vector<string> &names);
//! Actual conversion from Arrow to DuckDB
static void ArrowToDuckDB(ArrowScanLocalState &scan_state,
std::unordered_map<idx_t, unique_ptr<ArrowConvertData>> &arrow_convert_data,
DataChunk &output, idx_t start);
//! Initialize Global State
static unique_ptr<GlobalTableFunctionState> ArrowScanInitGlobal(ClientContext &context,
TableFunctionInitInput &input);
//! Initialize Local State
static unique_ptr<LocalTableFunctionState> ArrowScanInitLocal(ClientContext &context, TableFunctionInitInput &input,
GlobalTableFunctionState *global_state);
//! Scan Function
static void ArrowScanFunction(ClientContext &context, TableFunctionInput &data, DataChunk &output);
//! Defines Maximum Number of Threads
static idx_t ArrowScanMaxThreads(ClientContext &context, const FunctionData *bind_data);
//! -----Utility Functions:-----
//! Gets Arrow Table's Cardinality
static unique_ptr<NodeStatistics> ArrowScanCardinality(ClientContext &context, const FunctionData *bind_data);
//! Gets the progress on the table scan, used for Progress Bars
static double ArrowProgress(ClientContext &context, const FunctionData *bind_data,
const GlobalTableFunctionState *global_state);
};
} // namespace duckdb
| 39.439394
| 117
| 0.673838
|
taniabogatsch
|
fcd918f9674ae48735def26586888e3eac1c701a
| 3,018
|
cpp
|
C++
|
Source/AsteroidShooter/Laser.cpp
|
goatryder/asteroidShooter
|
501b181ab7ccfe98f77b2426e858f3d68aba0b8b
|
[
"MIT"
] | null | null | null |
Source/AsteroidShooter/Laser.cpp
|
goatryder/asteroidShooter
|
501b181ab7ccfe98f77b2426e858f3d68aba0b8b
|
[
"MIT"
] | null | null | null |
Source/AsteroidShooter/Laser.cpp
|
goatryder/asteroidShooter
|
501b181ab7ccfe98f77b2426e858f3d68aba0b8b
|
[
"MIT"
] | null | null | null |
// Fill out your copyright notice in the Description page of Project Settings.
#include "Laser.h"
#include "UObject/ConstructorHelpers.h"
#include "Components/StaticMeshComponent.h"
#include "Components/AudioComponent.h"
// Sets default values
ALaser::ALaser()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
struct FConstructorStatics {
ConstructorHelpers::FObjectFinderOptional<UStaticMesh> LaserMesh;
ConstructorHelpers::FObjectFinderOptional<USoundBase> LaserSound;
FConstructorStatics() :
LaserMesh(TEXT("/Game/Geometry/Meshes/Laser.Laser")),
LaserSound(TEXT("/Game/Sound/Laser.Laser"))
{}
};
static FConstructorStatics ConstructorStatics;
LaserMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Laser Mesh"));
LaserMesh->SetStaticMesh(ConstructorStatics.LaserMesh.Get());
LaserMesh->SetWorldScale3D(FVector(0.5f));
RootComponent = LaserMesh;
// add material to mesh
UMaterial* TempMaterial = CreateDefaultSubobject<UMaterial>(TEXT("Laser Material"));
TempMaterial = ConstructorHelpers::FObjectFinderOptional<UMaterial>(
TEXT("/Game/Geometry/Materials/LaserMaterial.LaserMaterial")).Get();
LaserMesh->SetMaterial(int32(), TempMaterial);
Sound = CreateDefaultSubobject<UAudioComponent>(TEXT("Laser Sound"));
Sound->SetSound(ConstructorStatics.LaserSound.Get());
Sound->Play();
// Use this component to drive this projectile's movement.
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComponent"));
ProjectileMovementComponent->SetUpdatedComponent(RootComponent);
ProjectileMovementComponent->InitialSpeed = 3000.0f;
ProjectileMovementComponent->MaxSpeed = 3000.0f;
ProjectileMovementComponent->bRotationFollowsVelocity = true;
ProjectileMovementComponent->bShouldBounce = true;
ProjectileMovementComponent->Bounciness = 0.3f;
// Initial values
Direction = FVector(1.0f, 0.0f, 0.0f);
LaunchSpeed = 10000.0f;
SurvivalTime = 5.0f;
TimeElapsed = 0.0f;
Tags.Add(TEXT("Laser"));
} // constructor
// Called when the game starts or when spawned
void ALaser::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ALaser::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
TimeElapsed += DeltaTime;
if (TimeElapsed > SurvivalTime)
Destroy();
const FVector LocalMove = Direction * DeltaTime * LaunchSpeed;
AddActorLocalOffset(LocalMove, true);
} // tick
void ALaser::NotifyHit(UPrimitiveComponent* MyComp, AActor* Other, UPrimitiveComponent* OtherComp,
bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit)
{
// if (!Other->ActorHasTag("Player"))
// Destroy();
// else
// AddActorLocalOffset(FVector(10.0f, 0.0f, 0.0f), false);
if (Other->ActorHasTag("Player"))
AddActorLocalOffset(FVector(10.0f, 0.0f, 0.0f), false);
}
void ALaser::OnBeginOverlap(AActor* ProjectileActor, AActor* OtherActor)
{
}
| 27.944444
| 121
| 0.765408
|
goatryder
|
fcd97e4cf10acbe5abf8b388a2c35d5f4e63d5f2
| 8,818
|
cpp
|
C++
|
src/nyx/features/caliper_feret.cpp
|
sameeul/nyxus
|
46210ac218b456f822139e884dfed4bd2fdbbfce
|
[
"MIT"
] | null | null | null |
src/nyx/features/caliper_feret.cpp
|
sameeul/nyxus
|
46210ac218b456f822139e884dfed4bd2fdbbfce
|
[
"MIT"
] | 6
|
2022-02-09T20:42:43.000Z
|
2022-03-24T20:14:47.000Z
|
src/nyx/features/caliper_feret.cpp
|
sameeul/nyxus
|
46210ac218b456f822139e884dfed4bd2fdbbfce
|
[
"MIT"
] | 4
|
2022-02-03T20:26:23.000Z
|
2022-02-17T02:59:27.000Z
|
#include "caliper.h"
#include "../parallel.h"
#include "rotation.h"
CaliperFeretFeature::CaliperFeretFeature() : FeatureMethod("CaliperFeretFeature")
{
// Letting the feature dependency manager know
provide_features({
MIN_FERET_DIAMETER,
MAX_FERET_DIAMETER,
MIN_FERET_ANGLE,
MAX_FERET_ANGLE,
STAT_FERET_DIAM_MIN,
STAT_FERET_DIAM_MAX,
STAT_FERET_DIAM_MEAN,
STAT_FERET_DIAM_MEDIAN,
STAT_FERET_DIAM_STDDEV,
STAT_FERET_DIAM_MODE});
}
void CaliperFeretFeature::calculate(LR& r)
{
if (r.has_bad_data())
return;
std::vector<double> allD; // Diameters at 0-180 degrees rotation
calculate_imp(r.convHull_CH, allD);
// Calculate statistics of diameters
auto s = ComputeCommonStatistics2(allD);
_min = (double)s.min;
_max = (double)s.max;
_mean = s.mean;
_median = s.median;
_stdev = s.stdev;
_mode = (double)s.mode;
// Calculate angles at min- and max- diameter
if (allD.size() > 0)
{
// Min and max
auto itr_min_d = std::min_element(allD.begin(), allD.end());
auto itr_max_d = std::max_element(allD.begin(), allD.end());
minFeretDiameter = *itr_min_d;
maxFeretDiameter = *itr_max_d;
// Angles
auto idxMin = std::distance(allD.begin(), itr_min_d);
minFeretAngle = (double)idxMin / 2.0;
auto idxMax = std::distance(allD.begin(), itr_max_d);
maxFeretAngle = (double)idxMax / 2.0;
}
else
{
// Degenerate case
minFeretDiameter =
maxFeretDiameter =
minFeretAngle =
maxFeretAngle = 0.0;
}
}
void CaliperFeretFeature::save_value(std::vector<std::vector<double>>& fvals)
{
fvals[MIN_FERET_DIAMETER][0] = minFeretDiameter;
fvals[MAX_FERET_DIAMETER][0] = maxFeretDiameter;
fvals[MIN_FERET_ANGLE][0] = minFeretAngle;
fvals[MAX_FERET_ANGLE][0] = maxFeretAngle;
fvals[STAT_FERET_DIAM_MIN][0] = _min;
fvals[STAT_FERET_DIAM_MAX][0] = _max;
fvals[STAT_FERET_DIAM_MEAN][0] = _mean;
fvals[STAT_FERET_DIAM_MEDIAN][0] = _median;
fvals[STAT_FERET_DIAM_STDDEV][0] = _stdev;
fvals[STAT_FERET_DIAM_MODE][0] = _mode;
}
void CaliperFeretFeature::calculate_imp(const std::vector<Pixel2>& convex_hull, std::vector<double>& all_D)
{
// Rotated convex hull
std::vector<Pixel2> CH_rot;
CH_rot.reserve(convex_hull.size());
// Rotate and calculate the diameter
all_D.clear();
for (float theta = 0.f; theta < 180.f; theta += rot_angle_increment)
{
Rotation::rotate_around_center(convex_hull, theta, CH_rot);
auto [minX, minY, maxX, maxY] = AABB::from_pixelcloud(CH_rot);
// Diameters at this angle
std::vector<float> DA;
// Iterate the y-grid
float stepY = (maxY - minY) / float(n_steps);
for (int iy = 1; iy <= n_steps; iy++)
{
float chord_y = minY + iy * stepY;
// Find convex hull segments intersecting 'y'
std::vector<std::pair<float, float>> X; // intersection points
for (int iH = 1; iH < CH_rot.size(); iH++)
{
// The convex hull points are guaranteed to be consecutive
auto& a = CH_rot[iH - 1],
& b = CH_rot[iH];
// Chord's Y is between segment AB's Ys ?
if ((a.y >= chord_y && b.y <= chord_y) || (b.y >= chord_y && a.y <= chord_y))
{
auto chord_x = b.y != a.y ?
(b.x - a.x) * (chord_y - a.y) / (b.y - a.y) + a.x
: (b.y + a.y) / 2;
auto tup = std::make_pair(chord_x, chord_y);
X.push_back(tup);
}
}
// Save the length of this chord. There must be 2 items in 'chordEnds' because we don't allow uniformative chords of zero length
if (X.size() >= 2)
{
// for N segments
auto compareFunc = [](const std::pair<float, float>& p1, const std::pair<float, float>& p2) { return p1.first < p2.first; };
auto idx_minX = std::distance(X.begin(), std::min_element(X.begin(), X.end(), compareFunc));
auto idx_maxX = std::distance(X.begin(), std::max_element(X.begin(), X.end(), compareFunc));
// left X and right X segments
auto& e1 = X[idx_minX], & e2 = X[idx_maxX];
auto x1 = e1.first, y1 = e1.second, x2 = e2.first, y2 = e2.second;
// save this chord
auto dist = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); // Squared distance
DA.push_back(dist);
}
}
if (DA.size() > 0)
{
// Find the shortest and longest chords (diameters)
double minD2 = *std::min_element(DA.begin(), DA.end()),
maxD2 = *std::max_element(DA.begin(), DA.end()),
min_ = sqrt(minD2),
max_ = sqrt(maxD2);
// Save them
all_D.push_back(min_);
all_D.push_back(max_);
}
}
}
void CaliperFeretFeature::osized_calculate(LR& r, ImageLoader&)
{
// Rotated convex hull
std::vector<Pixel2> CH_rot;
CH_rot.reserve(r.convHull_CH.size());
// Rotate and calculate the diameter
std::vector<double> all_D;
for (float theta = 0.f; theta < 180.f; theta += rot_angle_increment)
{
Rotation::rotate_around_center(r.convHull_CH, theta, CH_rot);
auto [minX, minY, maxX, maxY] = AABB::from_pixelcloud(CH_rot);
std::vector<float> DA; // Diameters at this angle
// Iterate y-grid
float stepY = (maxY - minY) / float(n_steps);
for (int iy = 1; iy <= n_steps; iy++)
{
float chord_y = minY + iy * stepY;
// Find convex hull segments intersecting 'y'
std::vector<std::pair<float, float>> X; // intersection points
for (int iH = 1; iH < CH_rot.size(); iH++)
{
// The convex hull points are guaranteed to be consecutive
auto& a = CH_rot[iH - 1],
& b = CH_rot[iH];
// Chord's Y is between segment AB's Ys ?
if ((a.y >= chord_y && b.y <= chord_y) || (b.y >= chord_y && a.y <= chord_y))
{
auto chord_x = b.y != a.y ?
(b.x - a.x) * (chord_y - a.y) / (b.y - a.y) + a.x
: (b.y + a.y) / 2;
auto tup = std::make_pair(chord_x, chord_y);
X.push_back(tup);
}
}
// Save the length of this chord. There must be 2 items in 'chordEnds' because we don't allow uniformative chords of zero length
if (X.size() >= 2)
{
// for N segments
auto compareFunc = [](const std::pair<float, float>& p1, const std::pair<float, float>& p2) { return p1.first < p2.first; };
auto idx_minX = std::distance(X.begin(), std::min_element(X.begin(), X.end(), compareFunc));
auto idx_maxX = std::distance(X.begin(), std::max_element(X.begin(), X.end(), compareFunc));
// left X and right X segments
auto& e1 = X[idx_minX], & e2 = X[idx_maxX];
auto x1 = e1.first, y1 = e1.second, x2 = e2.first, y2 = e2.second;
// save this chord
auto dist = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); // Squared distance
DA.push_back(dist);
}
}
if (DA.size() > 0)
{
// Find the shortest and longest chords (diameters)
double minD2 = *std::min_element(DA.begin(), DA.end()),
maxD2 = *std::max_element(DA.begin(), DA.end()),
min_ = sqrt(minD2),
max_ = sqrt(maxD2);
// Save them
all_D.push_back(min_);
all_D.push_back(max_);
}
}
// Calculate statistics of diameters
auto s = ComputeCommonStatistics2(all_D);
_min = (double)s.min;
_max = (double)s.max;
_mean = s.mean;
_median = s.median;
_stdev = s.stdev;
_mode = (double)s.mode;
// Calculate angles at min- and max- diameter
if (all_D.size() > 0)
{
// Min and max
auto itr_min_d = std::min_element(all_D.begin(), all_D.end());
auto itr_max_d = std::max_element(all_D.begin(), all_D.end());
minFeretDiameter = *itr_min_d;
maxFeretDiameter = *itr_max_d;
// Angles
auto idxMin = std::distance(all_D.begin(), itr_min_d);
minFeretAngle = (double)idxMin / 2.0;
auto idxMax = std::distance(all_D.begin(), itr_max_d);
maxFeretAngle = (double)idxMax / 2.0;
}
else
{
// Degenerate case
minFeretDiameter =
maxFeretDiameter =
minFeretAngle =
maxFeretAngle = 0.0;
}
}
void CaliperFeretFeature::parallel_process(std::vector<int>& roi_labels, std::unordered_map <int, LR>& roiData, int n_threads)
{
size_t jobSize = roi_labels.size(),
workPerThread = jobSize / n_threads;
runParallel(CaliperFeretFeature::parallel_process_1_batch, n_threads, workPerThread, jobSize, &roi_labels, &roiData);
}
void CaliperFeretFeature::parallel_process_1_batch(size_t firstitem, size_t lastitem, std::vector<int>* ptrLabels, std::unordered_map <int, LR>* ptrLabelData)
{
// Calculate the feature for each batch ROI item
for (auto i = firstitem; i < lastitem; i++)
{
// Get ahold of ROI's label and cache
int roiLabel = (*ptrLabels)[i];
LR& r = (*ptrLabelData)[roiLabel];
// Skip the ROI if its data is invalid to prevent nans and infs in the output
if (r.has_bad_data())
continue;
// Calculate the feature and save it in ROI's csv-friendly buffer 'fvals'
CaliperFeretFeature f;
f.calculate(r);
f.save_value(r.fvals);
}
}
| 31.492857
| 159
| 0.634838
|
sameeul
|
fcd9ec6cbf5478073b2597d02abc03fea35aff22
| 973
|
hpp
|
C++
|
inc/shader_program.hpp
|
tuxerr/lvr
|
16555daf7c52d10c16243b0e1b30cccee4e306a5
|
[
"MIT"
] | null | null | null |
inc/shader_program.hpp
|
tuxerr/lvr
|
16555daf7c52d10c16243b0e1b30cccee4e306a5
|
[
"MIT"
] | null | null | null |
inc/shader_program.hpp
|
tuxerr/lvr
|
16555daf7c52d10c16243b0e1b30cccee4e306a5
|
[
"MIT"
] | null | null | null |
#ifndef DEF_SHADER_PROGRAM
#define DEF_SHADER_PROGRAM
#include <iostream>
#include <map>
#include <list>
#include <string>
#define GLFW_INCLUDE_GLCOREARB
//#include <GLFW/glfw3.h>
#include <stdio.h>
#include <string.h>
#include "matrix4.hpp"
#include "uniform.hpp"
#include "uniformblock.hpp"
class Program {
public:
Program();
~Program();
void load_shaders(const char *vertex_shader_path,const char *fragment_shader_path,const char *tessellation_control_shader_path,const char *tessellation_evaluator_shader_path,const char *geometry_shader_path);
GLuint compile_shader(const char *path,GLenum shader_type);
void subscribe_to_uniform(Uniform *uni);
void subscribe_to_uniformblock(UniformBlock *uni);
void use();
void bind_texture(Texture* tex);
void unuse();
GLuint id();
bool isBinded();
private:
GLuint program_id;
std::map<Uniform*,bool> uniforms;
std::list<Texture*> textures;
bool binded;
};
#endif
| 25.605263
| 212
| 0.736896
|
tuxerr
|
fcdc43ad4ea14d6e37156ec1f8d3f2ba83726154
| 1,231
|
hpp
|
C++
|
third_party/boost/simd/function/ceil.hpp
|
SylvainCorlay/pythran
|
908ec070d837baf77d828d01c3e35e2f4bfa2bfa
|
[
"BSD-3-Clause"
] | 6
|
2018-02-25T22:23:33.000Z
|
2021-01-15T15:13:12.000Z
|
third_party/boost/simd/function/ceil.hpp
|
SylvainCorlay/pythran
|
908ec070d837baf77d828d01c3e35e2f4bfa2bfa
|
[
"BSD-3-Clause"
] | null | null | null |
third_party/boost/simd/function/ceil.hpp
|
SylvainCorlay/pythran
|
908ec070d837baf77d828d01c3e35e2f4bfa2bfa
|
[
"BSD-3-Clause"
] | 7
|
2017-12-12T12:36:31.000Z
|
2020-02-10T14:27:07.000Z
|
//==================================================================================================
/*!
@file
@copyright 2016 NumScale SAS
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#ifndef BOOST_SIMD_FUNCTION_CEIL_HPP_INCLUDED
#define BOOST_SIMD_FUNCTION_CEIL_HPP_INCLUDED
#if defined(DOXYGEN_ONLY)
namespace boost { namespace simd
{
/*!
@ingroup group-arithmetic
This function object computes the smallest integral representable value of
its parameter type which is greater or equal to it.
@par Header <boost/simd/function/ceil.hpp>
@par Notes
- @c ceil is also used as parameter to pass to @ref div or @ref rem
@par Decorators
- std_ for floating entries call std::ceil
@see floor, round, nearbyint, trunc, iceil
@par Example:
@snippet ceil.cpp ceil
@par Possible output:
@snippet ceil.txt ceil
**/
Value ceil(Value const& x);
} }
#endif
#include <boost/simd/function/scalar/ceil.hpp>
#include <boost/simd/function/simd/ceil.hpp>
#endif
| 23.673077
| 100
| 0.594639
|
SylvainCorlay
|
fcdf07281d87a6fb2dbc66af290b8c63a6d78166
| 340
|
cpp
|
C++
|
codeforces/helpmaths.cpp
|
dhwanisanmukhani/competitive-coding
|
5392dea65b6ac370ac641c993120d7f252f5b1ac
|
[
"MIT"
] | null | null | null |
codeforces/helpmaths.cpp
|
dhwanisanmukhani/competitive-coding
|
5392dea65b6ac370ac641c993120d7f252f5b1ac
|
[
"MIT"
] | null | null | null |
codeforces/helpmaths.cpp
|
dhwanisanmukhani/competitive-coding
|
5392dea65b6ac370ac641c993120d7f252f5b1ac
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
string s;
cin>>s;
int f=0;
int n=s.length();
std::vector<char> v(0);
for(int i=0;i<n;i=i+2)
{
v.push_back(s[i]);
}
sort(v.begin(),v.end());
for(int k=0;k<((n+1)/2-1);k++)
cout<<v[k]<<"+";
cout<<v[(n+1)/2-1]<<endl;
return 0;
}
| 14.782609
| 32
| 0.555882
|
dhwanisanmukhani
|
fcdf9b78850292ca27b80d06b170c601df129373
| 7,773
|
cpp
|
C++
|
libs/renderer/src/pass.cpp
|
blagodarin/yttrium
|
534289c3082355e5537a03c0b5855b60f0c344ad
|
[
"Apache-2.0"
] | null | null | null |
libs/renderer/src/pass.cpp
|
blagodarin/yttrium
|
534289c3082355e5537a03c0b5855b60f0c344ad
|
[
"Apache-2.0"
] | null | null | null |
libs/renderer/src/pass.cpp
|
blagodarin/yttrium
|
534289c3082355e5537a03c0b5855b60f0c344ad
|
[
"Apache-2.0"
] | null | null | null |
// This file is part of the Yttrium toolkit.
// Copyright (C) Sergei Blagodarin.
// SPDX-License-Identifier: Apache-2.0
#include "pass.h"
#include <yttrium/base/buffer_appender.h>
#include <yttrium/base/string.h>
#include <yttrium/geometry/line.h>
#include <yttrium/geometry/matrix.h>
#include <yttrium/geometry/quad.h>
#include <yttrium/renderer/metrics.h>
#include <yttrium/renderer/program.h>
#include "backend/backend.h"
#include "builtin.h"
#include "texture.h"
#include <cassert>
#ifndef NDEBUG
# include <algorithm>
#endif
namespace
{
// Makes Y point forward and Z point up.
const Yt::Matrix4 _3d_directions{
1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0, 0,
0, 0, 0, 1
};
}
namespace Yt
{
RenderPassData::RenderPassData() = default;
RenderPassData::~RenderPassData() noexcept = default;
RenderPassImpl::RenderPassImpl(RenderBackend& backend, RenderBuiltin& builtin, RenderPassData& data, const Size& viewport_size, RenderMetrics& metrics)
: _backend{ backend }
, _builtin{ builtin }
, _data{ data }
, _viewport_size{ viewport_size }
, _metrics{ metrics }
{
_backend.clear();
}
RenderPassImpl::~RenderPassImpl() noexcept
{
#ifndef NDEBUG
_data._seen_textures.clear();
_data._seen_programs.clear();
#endif
}
void RenderPassImpl::draw_mesh(const Mesh& mesh)
{
update_state();
_metrics._triangles += _backend.draw_mesh(mesh);
++_metrics._draw_calls;
}
Matrix4 RenderPassImpl::full_matrix() const
{
const auto current_projection = std::find_if(_data._matrix_stack.rbegin(), _data._matrix_stack.rend(), [](const auto& m) { return m.second == RenderMatrixType::Projection; });
assert(current_projection != _data._matrix_stack.rend());
const auto current_view = current_projection.base();
assert(current_view != _data._matrix_stack.end());
assert(current_view->second == RenderMatrixType::View);
return current_projection->first * current_view->first * model_matrix();
}
Matrix4 RenderPassImpl::model_matrix() const
{
assert(!_data._matrix_stack.empty());
assert(_data._matrix_stack.back().second == RenderMatrixType::Model);
return _data._matrix_stack.back().first;
}
Line3 RenderPassImpl::pixel_ray(const Vector2& v) const
{
// Move each coordinate to the center of the pixel (by adding 0.5), then normalize from [0, D] to [-1, 1].
const auto xn = (2 * v.x + 1) / static_cast<float>(_viewport_size._width) - 1;
const auto yn = 1 - (2 * v.y + 1) / static_cast<float>(_viewport_size._height);
const auto m = inverse(full_matrix());
return { m * Vector3{ xn, yn, 0 }, m * Vector3{ xn, yn, 1 } };
}
RectF RenderPassImpl::viewport_rect() const
{
return RectF{ _viewport_size };
}
void RenderPassImpl::pop_program() noexcept
{
assert(_data._program_stack.size() > 1 || (_data._program_stack.size() == 1 && _data._program_stack.back().second > 1));
if (_data._program_stack.back().second > 1)
{
--_data._program_stack.back().second;
return;
}
_data._program_stack.pop_back();
_reset_program = true;
}
void RenderPassImpl::pop_projection() noexcept
{
assert(_data._matrix_stack.size() >= 3);
assert(_data._matrix_stack.back().second == RenderMatrixType::Model);
_data._matrix_stack.pop_back();
assert(_data._matrix_stack.back().second == RenderMatrixType::View);
_data._matrix_stack.pop_back();
assert(_data._matrix_stack.back().second == RenderMatrixType::Projection);
_data._matrix_stack.pop_back();
if (_data._matrix_stack.empty())
return;
assert(_data._matrix_stack.back().second == RenderMatrixType::Model);
#ifndef NDEBUG
const auto last_view = std::find_if(_data._matrix_stack.rbegin(), _data._matrix_stack.rend(), [](const auto& m) { return m.second == RenderMatrixType::View; });
assert(last_view != _data._matrix_stack.rend());
const auto last_projection = std::next(last_view);
assert(last_projection != _data._matrix_stack.rend());
assert(last_projection->second == RenderMatrixType::Projection);
#endif
}
void RenderPassImpl::pop_texture(Flags<Texture2D::Filter> filter) noexcept
{
assert(_data._texture_stack.size() > 1 || (_data._texture_stack.size() == 1 && _data._texture_stack.back().second > 1));
if (_data._texture_stack.back().second == 1)
{
_data._texture_stack.pop_back();
_reset_texture = true;
}
else
--_data._texture_stack.back().second;
_current_texture_filter = filter;
}
void RenderPassImpl::pop_transformation() noexcept
{
assert(_data._matrix_stack.size() > 3);
assert(_data._matrix_stack.back().second == RenderMatrixType::Model);
_data._matrix_stack.pop_back();
assert(_data._matrix_stack.back().second == RenderMatrixType::Model);
}
void RenderPassImpl::push_program(const RenderProgram* program)
{
assert(!_data._program_stack.empty());
if (_data._program_stack.back().first == program)
{
++_data._program_stack.back().second;
return;
}
_data._program_stack.emplace_back(program, 1);
_reset_program = true;
}
void RenderPassImpl::push_projection_2d(const Matrix4& matrix)
{
_data._matrix_stack.emplace_back(matrix, RenderMatrixType::Projection);
_data._matrix_stack.emplace_back(Matrix4::identity(), RenderMatrixType::View);
_data._matrix_stack.emplace_back(Matrix4::identity(), RenderMatrixType::Model);
}
void RenderPassImpl::push_projection_3d(const Matrix4& projection, const Matrix4& view)
{
_data._matrix_stack.emplace_back(projection, RenderMatrixType::Projection);
_data._matrix_stack.emplace_back(::_3d_directions * view, RenderMatrixType::View);
_data._matrix_stack.emplace_back(Matrix4::identity(), RenderMatrixType::Model);
}
Flags<Texture2D::Filter> RenderPassImpl::push_texture(const Texture2D* texture, Flags<Texture2D::Filter> filter)
{
if (!texture)
{
texture = _builtin._white_texture.get();
filter = Texture2D::NearestFilter;
}
assert(!_data._texture_stack.empty());
if (_data._texture_stack.back().first != texture)
{
_data._texture_stack.emplace_back(texture, 1);
_reset_texture = true;
}
else
++_data._texture_stack.back().second;
return std::exchange(_current_texture_filter, filter);
}
void RenderPassImpl::push_transformation(const Matrix4& matrix)
{
assert(!_data._matrix_stack.empty());
assert(_data._matrix_stack.back().second == RenderMatrixType::Model);
_data._matrix_stack.emplace_back(_data._matrix_stack.back().first * matrix, RenderMatrixType::Model);
}
void RenderPassImpl::flush_2d(const Buffer& vertices, const Buffer& indices) noexcept
{
update_state();
_backend.flush_2d(vertices, indices);
_metrics._triangles += indices.size() / sizeof(uint16_t) - 2;
++_metrics._draw_calls;
}
void RenderPassImpl::update_state()
{
if (_reset_program)
{
_reset_program = false;
const auto program = _data._program_stack.back().first;
if (program != _current_program)
{
_current_program = program;
_backend.set_program(program);
++_metrics._shader_switches;
#ifndef NDEBUG
if (std::none_of(_data._seen_programs.begin(), _data._seen_programs.end(), [program](const auto seen_program) { return program == seen_program; }))
_data._seen_programs.emplace_back(program);
else
++_metrics._extra_shader_switches;
#endif
}
}
if (_reset_texture)
{
_reset_texture = false;
const auto texture = _data._texture_stack.back().first;
if (texture != _current_texture)
{
_current_texture = texture;
_backend.set_texture(*texture, _current_texture_filter);
++_metrics._texture_switches;
#ifndef NDEBUG
if (std::none_of(_data._seen_textures.begin(), _data._seen_textures.end(), [texture](const auto seen_texture) { return texture == seen_texture; }))
_data._seen_textures.emplace_back(texture);
else
++_metrics._extra_texture_switches;
#endif
}
}
}
}
| 31.216867
| 177
| 0.726875
|
blagodarin
|
fcdfe4d385d44b2bce4f9af8b28af515c744ae9f
| 3,672
|
hpp
|
C++
|
source/application/plugins/qcan-peak/qcan_plugin_peak.hpp
|
canpie/canpie
|
330acb5e041bee7e7a865e3242fd89c9fe07f5ce
|
[
"Apache-2.0"
] | 36
|
2016-08-23T13:05:02.000Z
|
2022-02-13T07:11:05.000Z
|
source/application/plugins/qcan-peak/qcan_plugin_peak.hpp
|
canpie/canpie
|
330acb5e041bee7e7a865e3242fd89c9fe07f5ce
|
[
"Apache-2.0"
] | 19
|
2017-01-30T08:59:40.000Z
|
2018-10-30T07:55:33.000Z
|
source/application/plugins/qcan-peak/qcan_plugin_peak.hpp
|
canpie/canpie
|
330acb5e041bee7e7a865e3242fd89c9fe07f5ce
|
[
"Apache-2.0"
] | 16
|
2016-06-02T11:15:02.000Z
|
2020-07-10T11:49:12.000Z
|
//============================================================================//
// File: qcan_plugin_peak.hpp //
// Description: CAN plugin for PEAK devices //
// //
// Copyright (C) MicroControl GmbH & Co. KG //
// 53842 Troisdorf - Germany //
// www.microcontrol.net //
// //
//----------------------------------------------------------------------------//
// Redistribution and use in source and binary forms, with or without //
// modification, are permitted provided that the following conditions //
// are met: //
// 1. Redistributions of source code must retain the above copyright //
// notice, this list of conditions, the following disclaimer and //
// the referenced file 'COPYING'. //
// 2. Redistributions in binary form must reproduce the above copyright //
// notice, this list of conditions and the following disclaimer in the //
// documentation and/or other materials provided with the distribution. //
// 3. Neither the name of MicroControl nor the names of its contributors //
// may be used to endorse or promote products derived from this software //
// without specific prior written permission. //
// //
// Provided that this notice is retained in full, this software may be //
// distributed under the terms of the GNU Lesser General Public License //
// ("LGPL") version 3 as distributed in the 'COPYING' file. //
// //
//============================================================================//
#ifndef QCAN_PLUGIN_PEAK_H_
#define QCAN_PLUGIN_PEAK_H_
#include <QtCore/QLibrary>
#include <QtCore/QObject>
#include <QtCore/QtPlugin>
#include <QtWidgets/QWidget>
#include "qcan_plugin.hpp"
#include "qcan_pcan_basic.hpp"
#include "qcan_interface_peak.hpp"
//-----------------------------------------------------------------------------
/*!
** \class QCanPluginPeak
** \brief Peak PCAN
**
*/
class QCanPluginPeak : public QCanPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QCanPlugin_iid FILE "plugin.json")
Q_INTERFACES(QCanPlugin)
private:
/*!
* \brief auwPCanChannelP
* Contains all PCAN Channels that should be handled
* by this plugin.
*/
QList<uint16_t> auwPCanChannelP;
/*!
* \brief Paramter to indentify an interface
*/
typedef struct {
uint16_t uwPCanChannel;
QCanInterfacePeak * pclQCanInterfacePeak;
} QCanIf_ts;
/*!
* \brief atsQCanIfPeakP
* Contains list of available QCAN Interfaces
*/
QList<QCanIf_ts> atsQCanIfPeakP;
/*!
* \brief pclPcanBasicP
* Reference to the static PCAN Basic lib
*/
QCanPcanBasic &pclPcanBasicP = QCanPcanBasic::getInstance();
public:
QCanPluginPeak();
~QCanPluginPeak();
QIcon icon(void) Q_DECL_OVERRIDE;
uint8_t interfaceCount(void) Q_DECL_OVERRIDE;
QCanInterface * getInterface(uint8_t ubInterfaceV) Q_DECL_OVERRIDE;
QString name(void) Q_DECL_OVERRIDE;
};
#endif /*QCAN_PLUGIN_PEAK_H_*/
| 37.85567
| 80
| 0.498911
|
canpie
|
fce26744053549d6ee11415c3e2d63ff64ac9fac
| 19,171
|
cpp
|
C++
|
libnaucrates/src/statistics/CJoinStatsProcessor.cpp
|
acmnu/gporca
|
22e0442576c7e9c578a2a7d6182007ca045baedd
|
[
"ECL-2.0",
"Apache-2.0"
] | 1
|
2019-03-05T10:08:56.000Z
|
2019-03-05T10:08:56.000Z
|
libnaucrates/src/statistics/CJoinStatsProcessor.cpp
|
ppmht/gporca
|
7131e3e134e6e608f7e9fef9152a8b5d71e6a59e
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
libnaucrates/src/statistics/CJoinStatsProcessor.cpp
|
ppmht/gporca
|
7131e3e134e6e608f7e9fef9152a8b5d71e6a59e
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright 2018 Pivotal, Inc.
//
// @filename:
// CJoinStatsProcessor.cpp
//
// @doc:
// Statistics helper routines for processing all join types
//---------------------------------------------------------------------------
#include "gpopt/operators/ops.h"
#include "gpopt/optimizer/COptimizerConfig.h"
#include "naucrates/statistics/CStatisticsUtils.h"
#include "naucrates/statistics/CJoinStatsProcessor.h"
#include "naucrates/statistics/CLeftAntiSemiJoinStatsProcessor.h"
#include "naucrates/statistics/CFilterStatsProcessor.h"
#include "naucrates/statistics/CScaleFactorUtils.h"
using namespace gpopt;
// helper for joining histograms
void
CJoinStatsProcessor::JoinHistograms
(
IMemoryPool *pmp,
const CHistogram *phist1,
const CHistogram *phist2,
CStatsPredJoin *pstatsjoin,
CDouble dRows1,
CDouble dRows2,
CHistogram **pphist1, // output: histogram 1 after join
CHistogram **pphist2, // output: histogram 2 after join
CDouble *pdScaleFactor, // output: scale factor based on the join
BOOL fEmptyInput,
IStatistics::EStatsJoinType eStatsJoinType,
BOOL fIgnoreLasjHistComputation
)
{
GPOS_ASSERT(NULL != phist1);
GPOS_ASSERT(NULL != phist2);
GPOS_ASSERT(NULL != pstatsjoin);
GPOS_ASSERT(NULL != pphist1);
GPOS_ASSERT(NULL != pphist2);
GPOS_ASSERT(NULL != pdScaleFactor);
if (IStatistics::EsjtLeftAntiSemiJoin == eStatsJoinType)
{
CLeftAntiSemiJoinStatsProcessor::JoinHistogramsLASJ
(
pmp,
phist1,
phist2,
pstatsjoin,
dRows1,
dRows2,
pphist1,
pphist2,
pdScaleFactor,
fEmptyInput,
eStatsJoinType,
fIgnoreLasjHistComputation
);
return;
}
if (fEmptyInput)
{
// use Cartesian product as scale factor
*pdScaleFactor = dRows1 * dRows2;
*pphist1 = GPOS_NEW(pmp) CHistogram(GPOS_NEW(pmp) DrgPbucket(pmp));
*pphist2 = GPOS_NEW(pmp) CHistogram(GPOS_NEW(pmp) DrgPbucket(pmp));
return;
}
*pdScaleFactor = CScaleFactorUtils::DDefaultScaleFactorJoin;
CStatsPred::EStatsCmpType escmpt = pstatsjoin->Escmpt();
BOOL fEmptyHistograms = phist1->FEmpty() || phist2->FEmpty();
if (fEmptyHistograms)
{
// if one more input has no histograms (due to lack of statistics
// for table columns or computed columns), we estimate
// the join cardinality to be the max of the two rows.
// In other words, the scale factor is equivalent to the
// min of the two rows.
*pdScaleFactor = std::min(dRows1, dRows2);
}
else if (CHistogram::FSupportsJoinPred(escmpt))
{
CHistogram *phistJoin = phist1->PhistJoinNormalized
(
pmp,
escmpt,
dRows1,
phist2,
dRows2,
pdScaleFactor
);
if (CStatsPred::EstatscmptEq == escmpt || CStatsPred::EstatscmptINDF == escmpt || CStatsPred::EstatscmptEqNDV == escmpt)
{
if (phist1->FScaledNDV())
{
phistJoin->SetNDVScaled();
}
*pphist1 = phistJoin;
*pphist2 = (*pphist1)->PhistCopy(pmp);
if (phist2->FScaledNDV())
{
(*pphist2)->SetNDVScaled();
}
return;
}
// note that for IDF and Not Equality predicate, we do not generate histograms but
// just the scale factors.
GPOS_ASSERT(phistJoin->FEmpty());
GPOS_DELETE(phistJoin);
// TODO: Feb 21 2014, for all join condition except for "=" join predicate
// we currently do not compute new histograms for the join columns
}
// for an unsupported join predicate operator or in the case of
// missing histograms, copy input histograms and use default scale factor
*pphist1 = phist1->PhistCopy(pmp);
*pphist2 = phist2->PhistCopy(pmp);
}
// derive statistics for the given join's predicate(s)
IStatistics *
CJoinStatsProcessor::PstatsJoinArray
(
IMemoryPool *pmp,
DrgPstat *pdrgpstat,
CExpression *pexprScalar,
IStatistics::EStatsJoinType eStatsJoinType
)
{
GPOS_ASSERT(NULL != pexprScalar);
GPOS_ASSERT(NULL != pdrgpstat);
GPOS_ASSERT(0 < pdrgpstat->UlLength());
BOOL fLeftOuterJoin = IStatistics::EsjtLeftOuterJoin == eStatsJoinType;
GPOS_ASSERT_IMP(fLeftOuterJoin, 2 == pdrgpstat->UlLength());
// create an empty set of outer references for statistics derivation
CColRefSet *pcrsOuterRefs = GPOS_NEW(pmp) CColRefSet(pmp);
// join statistics objects one by one using relevant predicates in given scalar expression
const ULONG ulStats = pdrgpstat->UlLength();
IStatistics *pstats = (*pdrgpstat)[0]->PstatsCopy(pmp);
CDouble dRowsOuter = pstats->DRows();
for (ULONG ul = 1; ul < ulStats; ul++)
{
IStatistics *pstatsCurrent = (*pdrgpstat)[ul];
DrgPcrs *pdrgpcrsOutput= GPOS_NEW(pmp) DrgPcrs(pmp);
pdrgpcrsOutput->Append(pstats->Pcrs(pmp));
pdrgpcrsOutput->Append(pstatsCurrent->Pcrs(pmp));
CStatsPred *pstatspredUnsupported = NULL;
DrgPstatspredjoin *pdrgpstatspredjoin = CStatsPredUtils::PdrgpstatspredjoinExtract
(
pmp,
pexprScalar,
pdrgpcrsOutput,
pcrsOuterRefs,
&pstatspredUnsupported
);
IStatistics *pstatsNew = NULL;
if (fLeftOuterJoin)
{
pstatsNew = pstats->PstatsLOJ(pmp, pstatsCurrent, pdrgpstatspredjoin);
}
else
{
pstatsNew = pstats->PstatsInnerJoin(pmp, pstatsCurrent, pdrgpstatspredjoin);
}
pstats->Release();
pstats = pstatsNew;
if (NULL != pstatspredUnsupported)
{
// apply the unsupported join filters as a filter on top of the join results.
// TODO, June 13 2014 we currently only cap NDVs for filters
// immediately on top of tables.
IStatistics *pstatsAfterJoinFilter = CFilterStatsProcessor::PstatsFilter(pmp, dynamic_cast<CStatistics *>(pstats), pstatspredUnsupported, false /* fCapNdvs */);
// If it is outer join and the cardinality after applying the unsupported join
// filters is less than the cardinality of outer child, we don't use this stats.
// Because we need to make sure that Card(LOJ) >= Card(Outer child of LOJ).
if (fLeftOuterJoin && pstatsAfterJoinFilter->DRows() < dRowsOuter)
{
pstatsAfterJoinFilter->Release();
}
else
{
pstats->Release();
pstats = pstatsAfterJoinFilter;
}
pstatspredUnsupported->Release();
}
pdrgpstatspredjoin->Release();
pdrgpcrsOutput->Release();
}
// clean up
pcrsOuterRefs->Release();
return pstats;
}
// main driver to generate join stats
CStatistics *
CJoinStatsProcessor::PstatsJoinDriver
(
IMemoryPool *pmp,
CStatisticsConfig *pstatsconf,
const IStatistics *pistatsOuter,
const IStatistics *pistatsInner,
DrgPstatspredjoin *pdrgppredInfo,
IStatistics::EStatsJoinType eStatsJoinType,
BOOL fIgnoreLasjHistComputation
)
{
GPOS_ASSERT(NULL != pmp);
GPOS_ASSERT(NULL != pistatsInner);
GPOS_ASSERT(NULL != pistatsOuter);
GPOS_ASSERT(NULL != pdrgppredInfo);
BOOL fLASJ = (IStatistics::EsjtLeftAntiSemiJoin == eStatsJoinType);
BOOL fSemiJoin = IStatistics::FSemiJoin(eStatsJoinType);
// Extract stat objects for inner and outer child.
// Historically, IStatistics was meant to have multiple derived classes
// However, currently only CStatistics implements IStatistics
// Until this changes, the interfaces have been designed to take IStatistics as parameters
// In the future, IStatistics should be removed, as it is not being utilized as designed
const CStatistics *pstatsOuter = dynamic_cast<const CStatistics *> (pistatsOuter);
const CStatistics *pstatsInner = dynamic_cast<const CStatistics *> (pistatsInner);
// create hash map from colid -> histogram for resultant structure
HMUlHist *phmulhistJoin = GPOS_NEW(pmp) HMUlHist(pmp);
// build a bitset with all join columns
CBitSet *pbsJoinColIds = GPOS_NEW(pmp) CBitSet(pmp);
for (ULONG ul = 0; ul < pdrgppredInfo->UlLength(); ul++)
{
CStatsPredJoin *pstatsjoin = (*pdrgppredInfo)[ul];
(void) pbsJoinColIds->FExchangeSet(pstatsjoin->UlColId1());
if (!fSemiJoin)
{
(void) pbsJoinColIds->FExchangeSet(pstatsjoin->UlColId2());
}
}
// histograms on columns that do not appear in join condition will
// be copied over to the result structure
pstatsOuter->AddNotExcludedHistograms(pmp, pbsJoinColIds, phmulhistJoin);
if (!fSemiJoin)
{
pstatsInner->AddNotExcludedHistograms(pmp, pbsJoinColIds, phmulhistJoin);
}
DrgPdouble *pdrgpd = GPOS_NEW(pmp) DrgPdouble(pmp);
const ULONG ulJoinConds = pdrgppredInfo->UlLength();
BOOL fEmptyOutput = false;
CDouble dRowsJoin = 0;
// iterate over join's predicate(s)
for (ULONG ul = 0; ul < ulJoinConds; ul++)
{
CStatsPredJoin *ppredInfo = (*pdrgppredInfo)[ul];
ULONG ulColId1 = ppredInfo->UlColId1();
ULONG ulColId2 = ppredInfo->UlColId2();
GPOS_ASSERT(ulColId1 != ulColId2);
// find the histograms corresponding to the two columns
const CHistogram *phistOuter = pstatsOuter->Phist(ulColId1);
// are column id1 and 2 always in the order of outer inner?
const CHistogram *phistInner = pstatsInner->Phist(ulColId2);
GPOS_ASSERT(NULL != phistOuter);
GPOS_ASSERT(NULL != phistInner);
BOOL fEmptyInput = CStatistics::FEmptyJoinInput(pstatsOuter, pstatsInner, fLASJ);
CDouble dScaleFactorLocal(1.0);
CHistogram *phistOuterAfter = NULL;
CHistogram *phistInnerAfter = NULL;
JoinHistograms
(
pmp,
phistOuter,
phistInner,
ppredInfo,
pstatsOuter->DRows(),
pstatsInner->DRows(),
&phistOuterAfter,
&phistInnerAfter,
&dScaleFactorLocal,
fEmptyInput,
eStatsJoinType,
fIgnoreLasjHistComputation
);
fEmptyOutput = FEmptyJoinStats(pstatsOuter->FEmpty(), fEmptyOutput, phistOuter, phistInner, phistOuterAfter, eStatsJoinType);
CStatisticsUtils::AddHistogram(pmp, ulColId1, phistOuterAfter, phmulhistJoin);
if (!fSemiJoin)
{
CStatisticsUtils::AddHistogram(pmp, ulColId2, phistInnerAfter, phmulhistJoin);
}
GPOS_DELETE(phistOuterAfter);
GPOS_DELETE(phistInnerAfter);
pdrgpd->Append(GPOS_NEW(pmp) CDouble(dScaleFactorLocal));
}
dRowsJoin = CStatistics::DMinRows;
if (!fEmptyOutput)
{
dRowsJoin = DJoinCardinality(pstatsconf, pstatsOuter->DRows(), pstatsInner->DRows(), pdrgpd, eStatsJoinType);
}
// clean up
pdrgpd->Release();
pbsJoinColIds->Release();
HMUlDouble *phmuldoubleWidthResult = pstatsOuter->CopyWidths(pmp);
if (!fSemiJoin)
{
pstatsInner->CopyWidthsInto(pmp, phmuldoubleWidthResult);
}
// create an output stats object
CStatistics *pstatsJoin = GPOS_NEW(pmp) CStatistics
(
pmp,
phmulhistJoin,
phmuldoubleWidthResult,
dRowsJoin,
fEmptyOutput,
pstatsOuter->UlNumberOfPredicates()
);
// In the output statistics object, the upper bound source cardinality of the join column
// cannot be greater than the upper bound source cardinality information maintained in the input
// statistics object. Therefore we choose CStatistics::EcbmMin the bounding method which takes
// the minimum of the cardinality upper bound of the source column (in the input hash map)
// and estimated join cardinality.
CStatisticsUtils::ComputeCardUpperBounds(pmp, pstatsOuter, pstatsJoin, dRowsJoin, CStatistics::EcbmMin /* ecbm */);
if (!fSemiJoin)
{
CStatisticsUtils::ComputeCardUpperBounds(pmp, pstatsInner, pstatsJoin, dRowsJoin, CStatistics::EcbmMin /* ecbm */);
}
return pstatsJoin;
}
// return join cardinality based on scaling factor and join type
CDouble
CJoinStatsProcessor::DJoinCardinality
(
CStatisticsConfig *pstatsconf,
CDouble dRowsLeft,
CDouble dRowsRight,
DrgPdouble *pdrgpd,
IStatistics::EStatsJoinType eStatsJoinType
)
{
GPOS_ASSERT(NULL != pstatsconf);
GPOS_ASSERT(NULL != pdrgpd);
CDouble dScaleFactor = CScaleFactorUtils::DCumulativeJoinScaleFactor(pstatsconf, pdrgpd);
CDouble dCartesianProduct = dRowsLeft * dRowsRight;
if (IStatistics::EsjtLeftAntiSemiJoin == eStatsJoinType || IStatistics::EsjtLeftSemiJoin == eStatsJoinType)
{
CDouble dRows = dRowsLeft;
if (IStatistics::EsjtLeftAntiSemiJoin == eStatsJoinType)
{
dRows = dRowsLeft / dScaleFactor;
}
else
{
// semi join results cannot exceed size of outer side
dRows = std::min(dRowsLeft.DVal(), (dCartesianProduct / dScaleFactor).DVal());
}
return std::max(DOUBLE(1.0), dRows.DVal());
}
GPOS_ASSERT(CStatistics::DMinRows <= dScaleFactor);
return std::max(CStatistics::DMinRows.DVal(), (dCartesianProduct / dScaleFactor).DVal());
}
// check if the join statistics object is empty output based on the input
// histograms and the join histograms
BOOL
CJoinStatsProcessor::FEmptyJoinStats
(
BOOL fEmptyOuter,
BOOL fEmptyOutput,
const CHistogram *phistOuter,
const CHistogram *phistInner,
CHistogram *phistJoin,
IStatistics::EStatsJoinType eStatsJoinType
)
{
GPOS_ASSERT(NULL != phistOuter);
GPOS_ASSERT(NULL != phistInner);
GPOS_ASSERT(NULL != phistJoin);
BOOL fLASJ = IStatistics::EsjtLeftAntiSemiJoin == eStatsJoinType;
return fEmptyOutput ||
(!fLASJ && fEmptyOuter) ||
(!phistOuter->FEmpty() && !phistInner->FEmpty() && phistJoin->FEmpty());
}
// Derive statistics for join operation given array of statistics object
IStatistics *
CJoinStatsProcessor::PstatsJoin
(
IMemoryPool *pmp,
CExpressionHandle &exprhdl,
DrgPstat *pdrgpstatCtxt
)
{
GPOS_ASSERT(CLogical::EspNone < CLogical::PopConvert(exprhdl.Pop())->Esp(exprhdl));
DrgPstat *pdrgpstat = GPOS_NEW(pmp) DrgPstat(pmp);
const ULONG ulArity = exprhdl.UlArity();
for (ULONG ul = 0; ul < ulArity - 1; ul++)
{
IStatistics *pstatsChild = exprhdl.Pstats(ul);
pstatsChild->AddRef();
pdrgpstat->Append(pstatsChild);
}
CExpression *pexprJoinPred = NULL;
if (exprhdl.Pdpscalar(ulArity - 1)->FHasSubquery())
{
// in case of subquery in join predicate, assume join condition is True
pexprJoinPred = CUtils::PexprScalarConstBool(pmp, true /*fVal*/);
}
else
{
// remove implied predicates from join condition to avoid cardinality under-estimation
pexprJoinPred = CPredicateUtils::PexprRemoveImpliedConjuncts(pmp, exprhdl.PexprScalarChild(ulArity - 1), exprhdl);
}
// split join predicate into local predicate and predicate involving outer references
CExpression *pexprLocal = NULL;
CExpression *pexprOuterRefs = NULL;
// get outer references from expression handle
CColRefSet *pcrsOuter = exprhdl.Pdprel()->PcrsOuter();
CPredicateUtils::SeparateOuterRefs(pmp, pexprJoinPred, pcrsOuter, &pexprLocal, &pexprOuterRefs);
pexprJoinPred->Release();
COperator::EOperatorId eopid = exprhdl.Pop()->Eopid();
GPOS_ASSERT(COperator::EopLogicalLeftOuterJoin == eopid ||
COperator::EopLogicalInnerJoin == eopid ||
COperator::EopLogicalNAryJoin == eopid);
// we use Inner Join semantics here except in the case of Left Outer Join
IStatistics::EStatsJoinType eStatsJoinType = IStatistics::EsjtInnerJoin;
if (COperator::EopLogicalLeftOuterJoin == eopid)
{
eStatsJoinType = IStatistics::EsjtLeftOuterJoin;
}
// derive stats based on local join condition
IStatistics *pstatsJoin = CJoinStatsProcessor::PstatsJoinArray(pmp, pdrgpstat, pexprLocal, eStatsJoinType);
if (exprhdl.FHasOuterRefs() && 0 < pdrgpstatCtxt->UlLength())
{
// derive stats based on outer references
IStatistics *pstats = PstatsDeriveWithOuterRefs(pmp, exprhdl, pexprOuterRefs, pstatsJoin, pdrgpstatCtxt, eStatsJoinType);
pstatsJoin->Release();
pstatsJoin = pstats;
}
pexprLocal->Release();
pexprOuterRefs->Release();
pdrgpstat->Release();
return pstatsJoin;
}
// Derives statistics when the scalar expression contains one or more outer references.
// This stats derivation mechanism passes around a context array onto which
// operators append their stats objects as they get derived. The context array is
// filled as we derive stats on the children of a given operator. This gives each
// operator access to the stats objects of its previous siblings as well as to the outer
// operators in higher levels.
// For example, in this expression:
//
// JOIN
// |--Get(R)
// +--Select(R.r=S.s)
// +-- Get(S)
//
// We start by deriving stats on JOIN's left child (Get(R)) and append its
// stats to the context. Then, we call stats derivation on JOIN's right child
// (SELECT), passing it the current context. This gives SELECT access to the
// histogram on column R.r--which is an outer reference in this example. After
// JOIN's children's stats are computed, JOIN combines them into a parent stats
// object, which is passed upwards to JOIN's parent. This mechanism gives any
// operator access to the histograms of outer references defined anywhere in
// the logical tree. For example, we also support the case where outer
// reference R.r is defined two levels upwards:
//
// JOIN
// |---Get(R)
// +--JOIN
// |--Get(T)
// +--Select(R.r=S.s)
// +--Get(S)
//
//
//
// The next step is to combine the statistics objects of the outer references
// with those of the local columns. You can think of this as a correlated
// expression, where for each outer tuple, we need to extract the outer ref
// value and re-execute the inner expression using the current outer ref value.
// This has the same semantics as a Join from a statistics perspective.
//
// We pull statistics for outer references from the passed statistics context,
// using Join statistics derivation in this case.
//
// For example:
//
// Join
// |--Get(R)
// +--Join
// |--Get(S)
// +--Select(T.t=R.r)
// +--Get(T)
//
// when deriving statistics on 'Select(T.t=R.r)', we join T with the cross
// product (R x S) based on the condition (T.t=R.r)
IStatistics *
CJoinStatsProcessor::PstatsDeriveWithOuterRefs
(
IMemoryPool *pmp,
CExpressionHandle &
#ifdef GPOS_DEBUG
exprhdl // handle attached to the logical expression we want to derive stats for
#endif // GPOS_DEBUG
,
CExpression *pexprScalar, // scalar condition to be used for stats derivation
IStatistics *pstats, // statistics object of the attached expression
DrgPstat *pdrgpstatOuter, // array of stats objects where outer references are defined
IStatistics::EStatsJoinType eStatsJoinType
)
{
GPOS_ASSERT(exprhdl.FHasOuterRefs() && "attached expression does not have outer references");
GPOS_ASSERT(NULL != pexprScalar);
GPOS_ASSERT(NULL != pstats);
GPOS_ASSERT(NULL != pdrgpstatOuter);
GPOS_ASSERT(0 < pdrgpstatOuter->UlLength());
GPOS_ASSERT(IStatistics::EstiSentinel != eStatsJoinType);
// join outer stats object based on given scalar expression,
// we use inner join semantics here to consider all relevant combinations of outer tuples
IStatistics *pstatsOuter = CJoinStatsProcessor::PstatsJoinArray(pmp, pdrgpstatOuter, pexprScalar, IStatistics::EsjtInnerJoin);
CDouble dRowsOuter = pstatsOuter->DRows();
// join passed stats object and outer stats based on the passed join type
DrgPstat *pdrgpstat = GPOS_NEW(pmp) DrgPstat(pmp);
pdrgpstat->Append(pstatsOuter);
pstats->AddRef();
pdrgpstat->Append(pstats);
IStatistics *pstatsJoined = CJoinStatsProcessor::PstatsJoinArray(pmp, pdrgpstat, pexprScalar, eStatsJoinType);
pdrgpstat->Release();
// scale result using cardinality of outer stats and set number of rebinds of returned stats
IStatistics *pstatsResult = pstatsJoined->PstatsScale(pmp, CDouble(1.0/dRowsOuter));
pstatsResult->SetRebinds(dRowsOuter);
pstatsJoined->Release();
return pstatsResult;
}
// EOF
| 31.583196
| 163
| 0.728496
|
acmnu
|
fce55c2356000aeaf2a0e541199038c14ec5ffd6
| 4,268
|
cpp
|
C++
|
src/othello/stats/StatisticsManager.cpp
|
Orfby/Othello-MMP
|
72be0ee38a329eff536b17d1e5334353cfd58c6f
|
[
"MIT"
] | null | null | null |
src/othello/stats/StatisticsManager.cpp
|
Orfby/Othello-MMP
|
72be0ee38a329eff536b17d1e5334353cfd58c6f
|
[
"MIT"
] | null | null | null |
src/othello/stats/StatisticsManager.cpp
|
Orfby/Othello-MMP
|
72be0ee38a329eff536b17d1e5334353cfd58c6f
|
[
"MIT"
] | null | null | null |
//Standard C++:
#include <iostream>
#include <iomanip>
//Othello headers:
#include <othello/stats/StatisticsManager.hpp>
namespace othello
{
namespace stats
{
////////////////////////////////////////////////////////////////
StatisticsManager::StatisticsManager(const std::string& outFilePath, const std::string& infoString)
{
//Open the file and delete anything that's already there
outFile.open(outFilePath, std::ios::trunc);
//Output the header
outFile << infoString << std::endl;
outFile << "CSV START" << std::endl;
outFile << "batch,p1AvgWins,p1AvgScore,p2AvgWins,p2AvgScore,avgGameLen,elapsed" << std::endl;
}
////////////////////////////////////////////////////////////////
void StatisticsManager::gameEnd(const std::pair<uint8_t, uint8_t>& score, const unsigned int& gameLength)
{
//Increase the number of games
++numGames;
//Increase the game length
totalGameLength += gameLength;
//Increase the score
totalScore.first += score.first;
totalScore.second += score.second;
//Increase the number of wins for the winner
if (score.first > score.second) {++numWins.first;}
else if (score.second > score.first) {++numWins.second;}
}
////////////////////////////////////////////////////////////////
void StatisticsManager::output()
{
//Get the time now
auto end = std::chrono::system_clock::now();
//Calculate the elapsed time
std::chrono::duration<double> elapsed = end - start;
//Calculate the average wins
std::pair<double, double> avgWins = {
(double)numWins.first / numGames,
(double)numWins.second / numGames
};
//Calculate the average score
std::pair<double, double> avgScore = {
(double)totalScore.first / numGames,
(double)totalScore.second / numGames
};
//Calculate the average game length
double avgGameLen = (double)totalGameLength / numGames;
//Output to the csv
outFile << batchCounter << ",";
outFile << avgWins.first << "," << avgScore.first << ",";
outFile << avgWins.second << "," << avgScore.second << ",";
outFile << avgGameLen << "," << elapsed.count() << std::endl;
//Output to stdout
std::cout << "======================" << std::endl;
std::cout << "Statistics of " << numGames << " games:" << std::endl;
std::cout << "Win Rate: ";
std::cout << std::setprecision(6) << avgWins.first * 100 << " vs ";
std::cout << std::setprecision(6) << avgWins.second * 100 << std::endl;
std::cout << "Avg Score: ";
std::cout << std::setprecision(6) << avgScore.first << " vs ";
std::cout << std::setprecision(6) << avgScore.second << std::endl;
std::cout << "Avg Game Length: ";
std::cout << std::setprecision(6) << avgGameLen << std::endl;
std::cout << "Elapsed Time: ";
std::cout << std::setprecision(6) << elapsed.count() << std::endl;
std::cout << "======================" << std::endl;
}
////////////////////////////////////////////////////////////////
void StatisticsManager::reset()
{
//Reset the stats
numGames = 0;
numWins = {0, 0};
totalScore = {0, 0};
totalGameLength = 0;
start = std::chrono::system_clock::now();
}
////////////////////////////////////////////////////////////////
void StatisticsManager::nextBatch()
{
//Reset the stats
reset();
//Increase the batch counter
++batchCounter;
}
}
}
| 36.793103
| 113
| 0.446579
|
Orfby
|
fcefdd9ebef6a8c97be2492bdc4d718aaabff697
| 8,847
|
hpp
|
C++
|
test/io/rgba_test_pixels.hpp
|
cynodelic/tesela
|
3b86a7b9501c7136d5168c7e314740fa7f72f7a7
|
[
"BSL-1.0"
] | null | null | null |
test/io/rgba_test_pixels.hpp
|
cynodelic/tesela
|
3b86a7b9501c7136d5168c7e314740fa7f72f7a7
|
[
"BSL-1.0"
] | null | null | null |
test/io/rgba_test_pixels.hpp
|
cynodelic/tesela
|
3b86a7b9501c7136d5168c7e314740fa7f72f7a7
|
[
"BSL-1.0"
] | null | null | null |
// Copyright (c) 2019 Álvaro Ceballos
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt
#ifndef CYNODLEIC_TESELA_TEST_IO_RGBA_TEST_PIXELS_HPP
#define CYNODLEIC_TESELA_TEST_IO_RGBA_TEST_PIXELS_HPP
std::uint8_t png_rgba_test_pixels[16][16][4] = {
{{211,126,54,133},{186,17,154,60},{157,30,158,61},{132,99,179,91},{137,126,124,133},{152,181,139,206},{172,200,209,172},{186,141,198,70},{196,126,56,133},{201,150,104,201},{191,129,82,214},{191,96,25,172},{196,126,24,133},{186,149,49,179},{142,143,151,70},{83,170,225,71}},
{{255,184,28,255},{226,123,142,206},{177,106,212,45},{132,109,229,9},{118,103,214,14},{128,135,210,74},{152,124,199,107},{186,83,161,39},{216,47,102,57},{226,61,4,163},{216,59,31,180},{211,44,35,203},{206,53,94,201},{196,77,166,187},{157,159,246,140},{103,202,255,208}},
{{255,176,30,248},{245,181,126,249},{196,147,184,176},{142,153,182,26},{103,178,190,29},{98,181,205,24},{118,141,171,7},{162,105,108,0},{206,30,138,16},{230,24,120,157},{226,30,46,193},{211,36,21,233},{206,32,73,236},{191,2,173,223},{152,97,224,232},{103,152,249,230}},
{{245,141,33,223},{240,140,133,249},{211,152,218,241},{162,162,203,172},{113,179,117,60},{88,200,55,2},{93,147,71,0},{128,112,89,7},{177,73,136,68},{206,64,157,144},{201,71,105,171},{186,74,42,236},{172,61,71,234},{157,33,138,225},{123,65,123,225},{78,102,110,196}},
{{196,126,79,133},{216,108,119,198},{216,161,211,214},{196,143,213,225},{157,126,85,133},{118,175,63,21},{98,126,37,31},{103,118,25,66},{128,126,45,133},{147,111,114,133},{142,120,118,180},{128,137,76,219},{118,126,10,133},{108,114,102,136},{78,94,107,133},{39,96,23,60}},
{{142,115,127,82},{181,97,176,186},{216,102,203,220},{226,74,195,233},{211,106,114,205},{172,165,19,103},{128,149,24,87},{93,144,25,111},{83,129,78,87},{78,131,29,68},{74,138,10,63},{64,135,59,52},{64,167,70,41},{59,143,42,48},{34,99,56,43},{0,114,29,39}},
{{108,90,179,118},{157,71,213,205},{206,47,172,230},{240,0,152,235},{240,70,125,236},{211,129,47,225},{152,114,41,198},{93,140,41,210},{54,147,38,161},{34,181,60,66},{29,197,32,36},{34,138,26,1},{44,162,60,16},{44,141,71,41},{20,111,146,50},{0,138,164,70}},
{{118,68,184,71},{157,56,132,153},{196,30,67,215},{226,24,40,237},{230,97,60,249},{211,126,86,239},{162,91,81,220},{108,90,61,206},{69,146,12,100},{49,219,71,53},{44,235,43,24},{54,178,2,0},{69,131,84,15},{69,120,188,54},{49,126,246,167},{20,112,255,147}},
{{162,126,40,133},{177,91,24,111},{186,26,60,172},{186,56,65,171},{181,126,35,133},{172,150,147,172},{152,134,138,214},{128,67,97,208},{108,126,26,133},{98,219,110,85},{93,217,143,31},{98,199,84,39},{113,126,51,133},{113,108,174,100},{103,126,255,140},{88,114,251,187}},
{{226,187,35,96},{211,93,103,124},{181,24,155,147},{147,46,123,74},{123,88,34,54},{118,115,74,190},{123,115,147,224},{137,85,157,217},{152,150,99,172},{157,216,46,91},{147,199,145,43},{142,197,126,74},{152,175,21,220},{167,165,167,203},{167,143,199,161},{162,167,151,124}},
{{255,159,70,129},{230,83,54,192},{181,93,45,179},{123,109,26,100},{83,120,17,136},{74,112,4,219},{93,106,79,153},{132,109,113,129},{172,178,55,103},{186,252,14,61},{172,255,95,60},{162,216,97,39},{172,182,62,118},{196,213,190,161},{206,182,126,111},{206,187,19,74}},
{{235,123,30,163},{221,100,67,183},{177,135,115,195},{128,146,82,196},{88,131,22,179},{74,71,12,176},{88,83,46,61},{128,128,54,63},{167,179,19,85},{186,255,81,68},{177,255,128,140},{167,217,74,82},{177,181,88,45},{196,226,152,68},{206,214,88,66},{196,187,7,70}},
{{167,126,62,133},{172,111,149,118},{172,131,155,183},{152,146,98,215},{128,126,26,133},{108,15,41,96},{103,30,3,87},{123,102,32,100},{152,126,4,133},{177,176,77,68},{172,194,99,161},{167,137,69,210},{172,126,28,133},{181,159,69,136},{172,147,52,100},{147,158,45,70}},
{{88,99,128,39},{118,68,153,32},{152,126,113,63},{177,181,54,129},{177,168,24,53},{157,82,71,78},{132,52,101,203},{123,83,44,236},{137,99,48,230},{162,114,95,200},{172,150,69,198},{177,105,46,215},{181,73,7,190},{172,115,58,100},{137,97,49,66},{88,115,64,41}},
{{25,76,168,16},{74,0,171,11},{132,61,125,43},{186,138,16,147},{206,134,83,113},{191,143,53,96},{147,131,12,205},{118,138,4,255},{118,147,41,245},{147,114,128,245},{177,172,113,240},{201,158,38,217},{211,123,30,172},{186,161,82,39},{123,120,48,41},{49,109,67,36}},
{{0,85,122,39},{44,0,152,26},{113,18,95,61},{181,102,8,195},{216,129,85,221},{196,191,8,203},{147,220,139,171},{103,191,151,195},{103,178,48,205},{137,167,98,242},{186,181,94,255},{226,161,1,220},{240,162,57,151},{211,168,76,71},{128,115,2,43},{39,121,32,39}}
};
std::uint8_t tiff_rgba_test_pixels[16][16][4] = {
{{110,66,28,133},{44,4,36,60},{38,7,38,61},{47,35,64,91},{71,66,65,133},{123,146,112,206},{116,135,141,172},{51,39,54,70},{102,66,29,133},{158,118,82,201},{160,108,69,214},{129,65,17,172},{102,66,13,133},{131,105,34,179},{39,39,41,70},{23,47,63,71}},
{{255,184,28,255},{183,99,115,206},{31,19,37,45},{5,4,8,9},{6,6,12,14},{37,39,61,74},{64,52,84,107},{28,13,25,39},{48,11,23,57},{144,39,3,163},{152,42,22,180},{168,35,28,203},{162,42,74,201},{144,56,122,187},{86,87,135,140},{84,165,208,208}},
{{248,171,29,248},{239,177,123,249},{135,101,127,176},{14,16,19,26},{12,20,22,29},{9,17,19,24},{3,4,5,7},{0,0,0,0},{13,2,9,16},{142,15,74,157},{171,23,35,193},{193,33,19,233},{191,30,68,236},{167,2,151,223},{138,88,204,232},{93,137,225,230}},
{{214,123,29,223},{234,137,130,249},{199,144,206,241},{109,109,137,172},{27,42,28,60},{1,2,0,2},{0,0,0,0},{4,3,2,7},{47,19,36,68},{116,36,89,144},{135,48,70,171},{172,68,39,236},{158,56,65,234},{139,29,122,225},{109,57,109,225},{60,78,85,196}},
{{102,66,41,133},{168,84,92,198},{181,135,177,214},{173,126,188,225},{82,66,44,133},{10,14,5,21},{12,15,4,31},{27,31,6,66},{67,66,23,133},{77,58,59,133},{100,85,83,180},{110,118,65,219},{62,66,5,133},{58,61,54,136},{41,49,56,133},{9,23,5,60}},
{{46,37,41,82},{132,71,128,186},{186,88,175,220},{207,68,178,233},{170,85,92,205},{69,67,8,103},{44,51,8,87},{40,63,11,111},{28,44,27,87},{21,35,8,68},{18,34,2,63},{13,28,12,52},{10,27,11,41},{11,27,8,48},{6,17,9,43},{0,17,4,39}},
{{50,42,83,118},{126,57,171,205},{186,42,155,230},{221,0,140,235},{222,65,116,236},{186,114,41,225},{118,89,32,198},{77,115,34,210},{34,93,24,161},{9,47,16,66},{4,28,5,36},{0,1,0,1},{3,10,4,16},{7,23,11,41},{4,22,29,50},{0,38,45,70}},
{{33,19,51,71},{94,34,79,153},{165,25,56,215},{210,22,37,237},{225,95,59,249},{198,118,81,239},{140,79,70,220},{87,73,49,206},{27,57,5,100},{10,46,15,53},{4,22,4,24},{0,0,0,0},{4,8,5,15},{15,25,40,54},{32,83,161,167},{12,65,147,147}},
{{84,66,21,133},{77,40,10,111},{125,18,40,172},{125,38,44,171},{94,66,18,133},{116,101,99,172},{128,112,116,214},{104,55,79,208},{56,66,14,133},{33,73,37,85},{11,26,17,31},{15,30,13,39},{59,66,27,133},{44,42,68,100},{57,69,140,140},{65,84,184,187}},
{{85,70,13,96},{103,45,50,124},{104,14,89,147},{43,13,36,74},{26,19,7,54},{88,86,55,190},{108,101,129,224},{117,72,134,217},{103,101,67,172},{56,77,16,91},{25,34,24,43},{41,57,37,74},{131,151,18,220},{133,131,133,203},{105,90,126,161},{79,81,73,124}},
{{129,80,35,129},{173,62,41,192},{127,65,32,179},{48,43,10,100},{44,64,9,136},{64,96,3,219},{56,64,47,153},{67,55,57,129},{69,72,22,103},{44,60,3,61},{40,60,22,60},{25,33,15,39},{80,84,29,118},{124,134,120,161},{90,79,55,111},{60,54,6,74}},
{{150,79,19,163},{159,72,48,183},{135,103,88,195},{98,112,63,196},{62,92,15,179},{51,49,8,176},{21,20,11,61},{32,32,13,63},{56,60,6,85},{50,68,22,68},{97,140,70,140},{54,70,24,82},{31,32,16,45},{52,60,41,68},{53,55,23,66},{54,51,2,70}},
{{87,66,32,133},{80,51,69,118},{123,94,111,183},{128,123,83,215},{67,66,14,133},{41,6,15,96},{35,10,1,87},{48,40,13,100},{79,66,2,133},{47,47,21,68},{109,122,63,161},{138,113,57,210},{90,66,15,133},{97,85,37,136},{67,58,20,100},{40,43,12,70}},
{{13,15,20,39},{15,9,19,32},{38,31,28,63},{90,92,27,129},{37,35,5,53},{48,25,22,78},{105,41,80,203},{114,77,41,236},{124,89,43,230},{127,89,75,200},{134,116,54,198},{149,89,39,215},{135,54,5,190},{67,45,23,100},{35,25,13,66},{14,18,10,41}},
{{2,5,11,16},{3,0,7,11},{22,10,21,43},{107,80,9,147},{91,59,37,113},{72,54,20,96},{118,105,10,205},{118,138,4,255},{113,141,39,245},{141,110,123,245},{167,162,106,240},{171,134,32,217},{142,83,20,172},{28,25,13,39},{20,19,8,41},{7,15,9,36}},
{{0,13,19,39},{4,0,15,26},{27,4,23,61},{138,78,6,195},{187,112,74,221},{156,152,6,203},{99,148,93,171},{79,146,115,195},{83,143,39,205},{130,158,93,242},{186,181,94,255},{195,139,1,220},{142,96,34,151},{59,47,21,71},{22,19,0,43},{6,19,5,39}}
};
#endif // CYNODLEIC_TESELA_TEST_IO_RGBA_TEST_PIXELS_HPP
| 176.94
| 281
| 0.602464
|
cynodelic
|
fcf04f7ac5bb72d29befbcdf4528f6127e1387be
| 29,879
|
cc
|
C++
|
Grpc/serverfeatures.pb.cc
|
tomasruizr/EventStoreDb
|
645fefe9fa5be274e6f61abe59708458620b8047
|
[
"MIT"
] | null | null | null |
Grpc/serverfeatures.pb.cc
|
tomasruizr/EventStoreDb
|
645fefe9fa5be274e6f61abe59708458620b8047
|
[
"MIT"
] | null | null | null |
Grpc/serverfeatures.pb.cc
|
tomasruizr/EventStoreDb
|
645fefe9fa5be274e6f61abe59708458620b8047
|
[
"MIT"
] | null | null | null |
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: serverfeatures.proto
#include "serverfeatures.pb.h"
#include <algorithm>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.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_serverfeatures_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SupportedMethod_serverfeatures_2eproto;
namespace event_store {
namespace client {
namespace server_features {
class SupportedMethodsDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<SupportedMethods> _instance;
} _SupportedMethods_default_instance_;
class SupportedMethodDefaultTypeInternal {
public:
::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<SupportedMethod> _instance;
} _SupportedMethod_default_instance_;
} // namespace server_features
} // namespace client
} // namespace event_store
static void InitDefaultsscc_info_SupportedMethod_serverfeatures_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::event_store::client::server_features::_SupportedMethod_default_instance_;
new (ptr) ::event_store::client::server_features::SupportedMethod();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::event_store::client::server_features::SupportedMethod::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_SupportedMethod_serverfeatures_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_SupportedMethod_serverfeatures_2eproto}, {}};
static void InitDefaultsscc_info_SupportedMethods_serverfeatures_2eproto() {
GOOGLE_PROTOBUF_VERIFY_VERSION;
{
void* ptr = &::event_store::client::server_features::_SupportedMethods_default_instance_;
new (ptr) ::event_store::client::server_features::SupportedMethods();
::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
}
::event_store::client::server_features::SupportedMethods::InitAsDefaultInstance();
}
::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_SupportedMethods_serverfeatures_2eproto =
{{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_SupportedMethods_serverfeatures_2eproto}, {
&scc_info_SupportedMethod_serverfeatures_2eproto.base,}};
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_serverfeatures_2eproto[2];
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_serverfeatures_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_serverfeatures_2eproto = nullptr;
const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_serverfeatures_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::event_store::client::server_features::SupportedMethods, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::event_store::client::server_features::SupportedMethods, methods_),
PROTOBUF_FIELD_OFFSET(::event_store::client::server_features::SupportedMethods, event_store_server_version_),
~0u, // no _has_bits_
PROTOBUF_FIELD_OFFSET(::event_store::client::server_features::SupportedMethod, _internal_metadata_),
~0u, // no _extensions_
~0u, // no _oneof_case_
~0u, // no _weak_field_map_
PROTOBUF_FIELD_OFFSET(::event_store::client::server_features::SupportedMethod, method_name_),
PROTOBUF_FIELD_OFFSET(::event_store::client::server_features::SupportedMethod, service_name_),
PROTOBUF_FIELD_OFFSET(::event_store::client::server_features::SupportedMethod, features_),
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{ 0, -1, sizeof(::event_store::client::server_features::SupportedMethods)},
{ 7, -1, sizeof(::event_store::client::server_features::SupportedMethod)},
};
static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::event_store::client::server_features::_SupportedMethods_default_instance_),
reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::event_store::client::server_features::_SupportedMethod_default_instance_),
};
const char descriptor_table_protodef_serverfeatures_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\024serverfeatures.proto\022\"event_store.clie"
"nt.server_features\032\014shared.proto\"|\n\020Supp"
"ortedMethods\022D\n\007methods\030\001 \003(\01323.event_st"
"ore.client.server_features.SupportedMeth"
"od\022\"\n\032event_store_server_version\030\002 \001(\t\"N"
"\n\017SupportedMethod\022\023\n\013method_name\030\001 \001(\t\022\024"
"\n\014service_name\030\002 \001(\t\022\020\n\010features\030\003 \003(\t2x"
"\n\016ServerFeatures\022f\n\023GetSupportedMethods\022"
"\031.event_store.client.Empty\0324.event_store"
".client.server_features.SupportedMethods"
"B.\n,com.eventstore.dbclient.proto.server"
"featuresb\006proto3"
;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_serverfeatures_2eproto_deps[1] = {
&::descriptor_table_shared_2eproto,
};
static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_serverfeatures_2eproto_sccs[2] = {
&scc_info_SupportedMethod_serverfeatures_2eproto.base,
&scc_info_SupportedMethods_serverfeatures_2eproto.base,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_serverfeatures_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_serverfeatures_2eproto = {
false, false, descriptor_table_protodef_serverfeatures_2eproto, "serverfeatures.proto", 456,
&descriptor_table_serverfeatures_2eproto_once, descriptor_table_serverfeatures_2eproto_sccs, descriptor_table_serverfeatures_2eproto_deps, 2, 1,
schemas, file_default_instances, TableStruct_serverfeatures_2eproto::offsets,
file_level_metadata_serverfeatures_2eproto, 2, file_level_enum_descriptors_serverfeatures_2eproto, file_level_service_descriptors_serverfeatures_2eproto,
};
// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_serverfeatures_2eproto = (static_cast<void>(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_serverfeatures_2eproto)), true);
namespace event_store {
namespace client {
namespace server_features {
// ===================================================================
void SupportedMethods::InitAsDefaultInstance() {
}
class SupportedMethods::_Internal {
public:
};
SupportedMethods::SupportedMethods(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena),
methods_(arena) {
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:event_store.client.server_features.SupportedMethods)
}
SupportedMethods::SupportedMethods(const SupportedMethods& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
methods_(from.methods_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
event_store_server_version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_event_store_server_version().empty()) {
event_store_server_version_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_event_store_server_version(),
GetArena());
}
// @@protoc_insertion_point(copy_constructor:event_store.client.server_features.SupportedMethods)
}
void SupportedMethods::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_SupportedMethods_serverfeatures_2eproto.base);
event_store_server_version_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
SupportedMethods::~SupportedMethods() {
// @@protoc_insertion_point(destructor:event_store.client.server_features.SupportedMethods)
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
void SupportedMethods::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
event_store_server_version_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
void SupportedMethods::ArenaDtor(void* object) {
SupportedMethods* _this = reinterpret_cast< SupportedMethods* >(object);
(void)_this;
}
void SupportedMethods::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void SupportedMethods::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const SupportedMethods& SupportedMethods::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_SupportedMethods_serverfeatures_2eproto.base);
return *internal_default_instance();
}
void SupportedMethods::Clear() {
// @@protoc_insertion_point(message_clear_start:event_store.client.server_features.SupportedMethods)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
methods_.Clear();
event_store_server_version_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* SupportedMethods::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// repeated .event_store.client.server_features.SupportedMethod methods = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
ptr -= 1;
do {
ptr += 1;
ptr = ctx->ParseMessage(_internal_add_methods(), ptr);
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
} else goto handle_unusual;
continue;
// string event_store_server_version = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
auto str = _internal_mutable_event_store_server_version();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "event_store.client.server_features.SupportedMethods.event_store_server_version"));
CHK_(ptr);
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* SupportedMethods::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:event_store.client.server_features.SupportedMethods)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// repeated .event_store.client.server_features.SupportedMethod methods = 1;
for (unsigned int i = 0,
n = static_cast<unsigned int>(this->_internal_methods_size()); i < n; i++) {
target = stream->EnsureSpace(target);
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
InternalWriteMessage(1, this->_internal_methods(i), target, stream);
}
// string event_store_server_version = 2;
if (this->event_store_server_version().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_event_store_server_version().data(), static_cast<int>(this->_internal_event_store_server_version().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"event_store.client.server_features.SupportedMethods.event_store_server_version");
target = stream->WriteStringMaybeAliased(
2, this->_internal_event_store_server_version(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:event_store.client.server_features.SupportedMethods)
return target;
}
size_t SupportedMethods::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:event_store.client.server_features.SupportedMethods)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated .event_store.client.server_features.SupportedMethod methods = 1;
total_size += 1UL * this->_internal_methods_size();
for (const auto& msg : this->methods_) {
total_size +=
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
}
// string event_store_server_version = 2;
if (this->event_store_server_version().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_event_store_server_version());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void SupportedMethods::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:event_store.client.server_features.SupportedMethods)
GOOGLE_DCHECK_NE(&from, this);
const SupportedMethods* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<SupportedMethods>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:event_store.client.server_features.SupportedMethods)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:event_store.client.server_features.SupportedMethods)
MergeFrom(*source);
}
}
void SupportedMethods::MergeFrom(const SupportedMethods& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:event_store.client.server_features.SupportedMethods)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
methods_.MergeFrom(from.methods_);
if (from.event_store_server_version().size() > 0) {
_internal_set_event_store_server_version(from._internal_event_store_server_version());
}
}
void SupportedMethods::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:event_store.client.server_features.SupportedMethods)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void SupportedMethods::CopyFrom(const SupportedMethods& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:event_store.client.server_features.SupportedMethods)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool SupportedMethods::IsInitialized() const {
return true;
}
void SupportedMethods::InternalSwap(SupportedMethods* other) {
using std::swap;
_internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
methods_.InternalSwap(&other->methods_);
event_store_server_version_.Swap(&other->event_store_server_version_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
}
::PROTOBUF_NAMESPACE_ID::Metadata SupportedMethods::GetMetadata() const {
return GetMetadataStatic();
}
// ===================================================================
void SupportedMethod::InitAsDefaultInstance() {
}
class SupportedMethod::_Internal {
public:
};
SupportedMethod::SupportedMethod(::PROTOBUF_NAMESPACE_ID::Arena* arena)
: ::PROTOBUF_NAMESPACE_ID::Message(arena),
features_(arena) {
SharedCtor();
RegisterArenaDtor(arena);
// @@protoc_insertion_point(arena_constructor:event_store.client.server_features.SupportedMethod)
}
SupportedMethod::SupportedMethod(const SupportedMethod& from)
: ::PROTOBUF_NAMESPACE_ID::Message(),
features_(from.features_) {
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
method_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_method_name().empty()) {
method_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_method_name(),
GetArena());
}
service_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
if (!from._internal_service_name().empty()) {
service_name_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_service_name(),
GetArena());
}
// @@protoc_insertion_point(copy_constructor:event_store.client.server_features.SupportedMethod)
}
void SupportedMethod::SharedCtor() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_SupportedMethod_serverfeatures_2eproto.base);
method_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
service_name_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
SupportedMethod::~SupportedMethod() {
// @@protoc_insertion_point(destructor:event_store.client.server_features.SupportedMethod)
SharedDtor();
_internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
void SupportedMethod::SharedDtor() {
GOOGLE_DCHECK(GetArena() == nullptr);
method_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
service_name_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}
void SupportedMethod::ArenaDtor(void* object) {
SupportedMethod* _this = reinterpret_cast< SupportedMethod* >(object);
(void)_this;
}
void SupportedMethod::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void SupportedMethod::SetCachedSize(int size) const {
_cached_size_.Set(size);
}
const SupportedMethod& SupportedMethod::default_instance() {
::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_SupportedMethod_serverfeatures_2eproto.base);
return *internal_default_instance();
}
void SupportedMethod::Clear() {
// @@protoc_insertion_point(message_clear_start:event_store.client.server_features.SupportedMethod)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
features_.Clear();
method_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
service_name_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
_internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}
const char* SupportedMethod::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
while (!ctx->Done(&ptr)) {
::PROTOBUF_NAMESPACE_ID::uint32 tag;
ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
CHK_(ptr);
switch (tag >> 3) {
// string method_name = 1;
case 1:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
auto str = _internal_mutable_method_name();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "event_store.client.server_features.SupportedMethod.method_name"));
CHK_(ptr);
} else goto handle_unusual;
continue;
// string service_name = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
auto str = _internal_mutable_service_name();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "event_store.client.server_features.SupportedMethod.service_name"));
CHK_(ptr);
} else goto handle_unusual;
continue;
// repeated string features = 3;
case 3:
if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
ptr -= 1;
do {
ptr += 1;
auto str = _internal_add_features();
ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "event_store.client.server_features.SupportedMethod.features"));
CHK_(ptr);
if (!ctx->DataAvailable(ptr)) break;
} while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
} else goto handle_unusual;
continue;
default: {
handle_unusual:
if ((tag & 7) == 4 || tag == 0) {
ctx->SetLastTag(tag);
goto success;
}
ptr = UnknownFieldParse(tag,
_internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
ptr, ctx);
CHK_(ptr != nullptr);
continue;
}
} // switch
} // while
success:
return ptr;
failure:
ptr = nullptr;
goto success;
#undef CHK_
}
::PROTOBUF_NAMESPACE_ID::uint8* SupportedMethod::_InternalSerialize(
::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
// @@protoc_insertion_point(serialize_to_array_start:event_store.client.server_features.SupportedMethod)
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
// string method_name = 1;
if (this->method_name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_method_name().data(), static_cast<int>(this->_internal_method_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"event_store.client.server_features.SupportedMethod.method_name");
target = stream->WriteStringMaybeAliased(
1, this->_internal_method_name(), target);
}
// string service_name = 2;
if (this->service_name().size() > 0) {
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
this->_internal_service_name().data(), static_cast<int>(this->_internal_service_name().length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"event_store.client.server_features.SupportedMethod.service_name");
target = stream->WriteStringMaybeAliased(
2, this->_internal_service_name(), target);
}
// repeated string features = 3;
for (int i = 0, n = this->_internal_features_size(); i < n; i++) {
const auto& s = this->_internal_features(i);
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
s.data(), static_cast<int>(s.length()),
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
"event_store.client.server_features.SupportedMethod.features");
target = stream->WriteString(3, s, target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
}
// @@protoc_insertion_point(serialize_to_array_end:event_store.client.server_features.SupportedMethod)
return target;
}
size_t SupportedMethod::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:event_store.client.server_features.SupportedMethod)
size_t total_size = 0;
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
// Prevent compiler warnings about cached_has_bits being unused
(void) cached_has_bits;
// repeated string features = 3;
total_size += 1 *
::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(features_.size());
for (int i = 0, n = features_.size(); i < n; i++) {
total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
features_.Get(i));
}
// string method_name = 1;
if (this->method_name().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_method_name());
}
// string service_name = 2;
if (this->service_name().size() > 0) {
total_size += 1 +
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
this->_internal_service_name());
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
_internal_metadata_, total_size, &_cached_size_);
}
int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
SetCachedSize(cached_size);
return total_size;
}
void SupportedMethod::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:event_store.client.server_features.SupportedMethod)
GOOGLE_DCHECK_NE(&from, this);
const SupportedMethod* source =
::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<SupportedMethod>(
&from);
if (source == nullptr) {
// @@protoc_insertion_point(generalized_merge_from_cast_fail:event_store.client.server_features.SupportedMethod)
::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
} else {
// @@protoc_insertion_point(generalized_merge_from_cast_success:event_store.client.server_features.SupportedMethod)
MergeFrom(*source);
}
}
void SupportedMethod::MergeFrom(const SupportedMethod& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:event_store.client.server_features.SupportedMethod)
GOOGLE_DCHECK_NE(&from, this);
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
(void) cached_has_bits;
features_.MergeFrom(from.features_);
if (from.method_name().size() > 0) {
_internal_set_method_name(from._internal_method_name());
}
if (from.service_name().size() > 0) {
_internal_set_service_name(from._internal_service_name());
}
}
void SupportedMethod::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:event_store.client.server_features.SupportedMethod)
if (&from == this) return;
Clear();
MergeFrom(from);
}
void SupportedMethod::CopyFrom(const SupportedMethod& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:event_store.client.server_features.SupportedMethod)
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool SupportedMethod::IsInitialized() const {
return true;
}
void SupportedMethod::InternalSwap(SupportedMethod* other) {
using std::swap;
_internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
features_.InternalSwap(&other->features_);
method_name_.Swap(&other->method_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
service_name_.Swap(&other->service_name_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
}
::PROTOBUF_NAMESPACE_ID::Metadata SupportedMethod::GetMetadata() const {
return GetMetadataStatic();
}
// @@protoc_insertion_point(namespace_scope)
} // namespace server_features
} // namespace client
} // namespace event_store
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::event_store::client::server_features::SupportedMethods* Arena::CreateMaybeMessage< ::event_store::client::server_features::SupportedMethods >(Arena* arena) {
return Arena::CreateMessageInternal< ::event_store::client::server_features::SupportedMethods >(arena);
}
template<> PROTOBUF_NOINLINE ::event_store::client::server_features::SupportedMethod* Arena::CreateMaybeMessage< ::event_store::client::server_features::SupportedMethod >(Arena* arena) {
return Arena::CreateMessageInternal< ::event_store::client::server_features::SupportedMethod >(arena);
}
PROTOBUF_NAMESPACE_CLOSE
// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
| 44.796102
| 188
| 0.762174
|
tomasruizr
|
fcf641ad6349c31321ed91a8b6f670f1547414e2
| 546
|
hpp
|
C++
|
include/termui/window_resize.hpp
|
numerodix/bmon-cpp
|
fae0613776b879a33e327f9ccf1d3819383634dd
|
[
"MIT"
] | 1
|
2020-07-31T01:34:47.000Z
|
2020-07-31T01:34:47.000Z
|
include/termui/window_resize.hpp
|
numerodix/bmon-cpp
|
fae0613776b879a33e327f9ccf1d3819383634dd
|
[
"MIT"
] | null | null | null |
include/termui/window_resize.hpp
|
numerodix/bmon-cpp
|
fae0613776b879a33e327f9ccf1d3819383634dd
|
[
"MIT"
] | null | null | null |
#ifndef WINDOW_RESIZE_H
#define WINDOW_RESIZE_H
#include "dimensions.hpp"
namespace bandwit {
namespace termui {
class WindowResizeReceiver {
public:
WindowResizeReceiver() = default;
virtual ~WindowResizeReceiver() = default;
CLASS_DISABLE_COPIES(WindowResizeReceiver)
CLASS_DISABLE_MOVES(WindowResizeReceiver)
virtual void on_window_resize(const Dimensions &win_dim_old,
const Dimensions &win_dim_new) = 0;
};
} // namespace termui
} // namespace bandwit
#endif // WINDOW_RESIZE_H
| 21.84
| 69
| 0.723443
|
numerodix
|
1e02cb66d96eafdf12b13d7df22a6c3997f42770
| 23,078
|
cpp
|
C++
|
rw_ray_tracing_lib/bvh_builder.cpp
|
HermanLederer/gtaRenderHook
|
2ce53ce954c2d298717119dd6d02a2e58fff3aed
|
[
"MIT"
] | null | null | null |
rw_ray_tracing_lib/bvh_builder.cpp
|
HermanLederer/gtaRenderHook
|
2ce53ce954c2d298717119dd6d02a2e58fff3aed
|
[
"MIT"
] | null | null | null |
rw_ray_tracing_lib/bvh_builder.cpp
|
HermanLederer/gtaRenderHook
|
2ce53ce954c2d298717119dd6d02a2e58fff3aed
|
[
"MIT"
] | null | null | null |
#include "bvh_builder.h"
#include <DebugUtils/DebugLogger.h>
#include <Engine/Common/IRenderingContext.h>
#include <Engine/IRenderer.h>
#include <algorithm>
#include <chrono>
#include <limits>
#include <sstream>
#include <ray_tracing_texture_cache.h>
#include <rw_engine/global_definitions.h>
#include <rw_engine/rw_rh_pipeline.h>
using namespace rw_raytracing_lib;
// Expands a 10-bit integer into 30 bits
// by inserting 2 zeros after each bit.
uint32_t expandBits( uint32_t v )
{
v = ( v * 0x00010001u ) & 0xFF0000FFu;
v = ( v * 0x00000101u ) & 0x0F00F00Fu;
v = ( v * 0x00000011u ) & 0xC30C30C3u;
v = ( v * 0x00000005u ) & 0x49249249u;
return v;
}
// Generates
uint32_t morton3D( float x, float y, float z )
{
x = min( max( x * 1024.0f, 0.0f ), 1023.0f );
y = min( max( y * 1024.0f, 0.0f ), 1023.0f );
z = min( max( z * 1024.0f, 0.0f ), 1023.0f );
uint32_t xx = expandBits( static_cast<uint32_t>( x ) );
uint32_t yy = expandBits( static_cast<uint32_t>( y ) );
uint32_t zz = expandBits( static_cast<uint32_t>( z ) );
return ( ( zz << 2 ) | ( yy << 1 ) | xx );
}
constexpr auto MORTON_CODE_START = 29;
BVHBuilder::BVHBuilder() {}
static inline uint32_t getDimForMorton3D( uint32_t idx )
{
return idx % 3;
}
constexpr auto AAC_DELTA = 20;
constexpr auto AAC_EPSILON = 0.1f; // 0.1f for HQ, 0.2 for fast
constexpr auto AAC_ALPHA = ( 0.5f - AAC_EPSILON );
static inline float AAC_C()
{
return ( 0.5f * powf( AAC_DELTA, 0.5f + AAC_EPSILON ) );
}
static inline uint32_t AAC_F( uint32_t x )
{
return static_cast<uint32_t>( ceil( AAC_C() * powf( x, AAC_ALPHA ) ) );
}
// Searches for the best candidate to merge i-th cluster with,
// using surface area heuristic
// O(n)
uint32_t GetClosestCluster( std::vector<BVHBuildNode *> &clusters, uint32_t i )
{
float closestDist = INFINITY;
uint32_t idx = i;
for ( uint32_t j = 0; j < clusters.size(); ++j ) {
if ( i == j )
continue;
BBox combined = BBox::Merge( clusters[i]->bounds, clusters[j]->bounds );
float d = combined.SurfaceArea();
// search for minimal surface area of combined bboxes
if ( d < closestDist ) {
closestDist = d;
idx = j;
}
}
return idx;
}
std::vector<BVHBuildNode *> combineCluster( std::vector<BVHBuildNode *> &clusters,
uint32_t n,
uint32_t &totalNodes,
uint32_t dim )
{
std::vector<uint32_t> closest( clusters.size(), 0 );
// O(n^2)
// Build closest clusters lookup table
for ( uint32_t i = 0; i < clusters.size(); ++i ) {
closest[i] = GetClosestCluster( clusters, i );
}
while ( clusters.size() > n ) {
float bestDist = INFINITY;
uint32_t leftIdx = 0;
uint32_t rightIdx = 0;
// Search for 2 closest clusters to merge
for ( uint32_t i = 0; i < clusters.size(); ++i ) {
BBox combined = BBox::Merge( clusters[i]->bounds, clusters[closest[i]]->bounds );
float d = combined.SurfaceArea();
if ( d < bestDist ) {
bestDist = d;
leftIdx = i;
rightIdx = closest[i];
}
}
totalNodes++;
// Create new cluster node
BVHBuildNode *node = new BVHBuildNode();
node->InitInterior( dim, clusters[leftIdx], clusters[rightIdx] );
clusters[leftIdx] = node;
clusters[rightIdx] = clusters.back();
closest[rightIdx] = closest.back();
clusters.pop_back();
closest.pop_back();
closest[leftIdx] = GetClosestCluster( clusters, leftIdx );
for ( uint32_t i = 0; i < clusters.size(); ++i ) {
if ( closest[i] == leftIdx || closest[i] == rightIdx )
closest[i] = GetClosestCluster( clusters, i );
else if ( closest[i] == closest.size() ) {
closest[i] = rightIdx;
}
}
}
return clusters;
}
uint32_t makePartition( std::vector<std::pair<uint32_t, uint32_t>> sortedMC,
uint32_t start,
uint32_t end,
uint32_t partitionbit )
{
uint32_t curFind = ( 1 << partitionbit );
if ( ( sortedMC[start].first & curFind ) == ( sortedMC[end - 1].first & curFind ) ) {
return start + ( end - start ) / 2;
}
uint32_t lower = start;
uint32_t upper = end;
while ( lower < upper ) {
uint32_t mid = lower + ( upper - lower ) / 2;
if ( ( sortedMC[mid].first & curFind ) == 0 ) {
lower = mid + 1;
} else {
upper = mid;
}
}
return lower;
}
void BVHBuilder::RecursiveBuildAAC( std::vector<BVHPrimitive> &buildData,
std::vector<std::pair<uint32_t, uint32_t>> mortonCodes,
uint32_t start,
uint32_t end,
uint32_t &totalNodes,
uint32_t partitionBit,
std::vector<BVHBuildNode *> *clusterData )
{
if ( end - start == 0 ) {
return;
}
uint32_t dim = getDimForMorton3D( partitionBit );
if ( end - start < AAC_DELTA ) {
std::vector<BVHBuildNode *> clusters;
totalNodes += ( end - start );
for ( uint32_t i = start; i < end; ++i ) {
// Create leaf _BVHBuildNode_
BVHBuildNode *node = new BVHBuildNode();
uint32_t primIdx = mortonCodes[i].second;
node->InitLeaf( primIdx, 1, buildData[primIdx].boundBox );
// deal with firstPrimOffset later with DFS
clusters.push_back( node );
}
*clusterData = combineCluster( clusters, AAC_F( AAC_DELTA ), totalNodes, dim );
return;
}
uint32_t splitIdx = makePartition( mortonCodes, start, end, partitionBit );
uint32_t newPartionBit = partitionBit - 1;
std::vector<BVHBuildNode *> leftC;
std::vector<BVHBuildNode *> rightC;
uint32_t rightTotalnodes = 0;
RecursiveBuildAAC( buildData, mortonCodes, start, splitIdx, totalNodes, newPartionBit, &leftC );
RecursiveBuildAAC( buildData,
mortonCodes,
splitIdx,
end,
rightTotalnodes,
newPartionBit,
&rightC );
totalNodes += rightTotalnodes;
leftC.insert( leftC.end(), rightC.begin(), rightC.end() );
*clusterData = combineCluster( leftC, AAC_F( end - start ), totalNodes, dim );
}
std::vector<BVHPrimitive> BVHBuilder::GenerateBVHPrimitiveList(
rh::rw::engine::RpGeometryInterface *geometry )
{
std::vector<BVHPrimitive> result;
result.reserve( static_cast<size_t>( geometry->GetTriangleCount() ) );
for ( size_t i = 0; i < static_cast<size_t>( geometry->GetTriangleCount() ); i++ ) {
auto triangle_ids = geometry->GetTrianglePtr()[i].vertIndex;
RwV3d v1 = geometry->GetMorphTarget( 0 )->verts[triangle_ids[0]];
RwV3d v2 = geometry->GetMorphTarget( 0 )->verts[triangle_ids[1]];
RwV3d v3 = geometry->GetMorphTarget( 0 )->verts[triangle_ids[2]];
BBox bbox( v1, v2, v3 );
DirectX::XMVECTOR centroid = bbox.GetCenter();
result.push_back( {bbox, centroid, static_cast<uint32_t>( i ), {0, 0, 0}} );
}
return result;
}
BBox::BBox( const RwV3d &a, const RwV3d &b, const RwV3d &c )
{
const float min_f = -( std::numeric_limits<float>::max )();
const float max_f = ( std::numeric_limits<float>::max )();
DirectX::XMVECTOR max_xm = {min_f, min_f, min_f, 1.0f};
DirectX::XMVECTOR min_xm = {max_f, max_f, max_f, 1.0f};
min_xm = DirectX::XMVectorMin( min_xm, {a.x, a.y, a.z, 1.0f} );
min_xm = DirectX::XMVectorMin( min_xm, {b.x, b.y, b.z, 1.0f} );
min_xm = DirectX::XMVectorMin( min_xm, {c.x, c.y, c.z, 1.0f} );
max_xm = DirectX::XMVectorMax( max_xm, {a.x, a.y, a.z, 1.0f} );
max_xm = DirectX::XMVectorMax( max_xm, {b.x, b.y, b.z, 1.0f} );
max_xm = DirectX::XMVectorMax( max_xm, {c.x, c.y, c.z, 1.0f} );
DirectX::XMStoreFloat4( &max, max_xm );
DirectX::XMStoreFloat4( &min, min_xm );
}
BBox::BBox()
{
const float min_f = -( std::numeric_limits<float>::max )();
const float max_f = ( std::numeric_limits<float>::max )();
max = {min_f, min_f, min_f, 0};
min = {max_f, max_f, max_f, 0};
}
void BBox::Merge( const DirectX::XMVECTOR &vec )
{
DirectX::XMVECTOR max_xm = DirectX::XMLoadFloat4( &max );
DirectX::XMVECTOR min_xm = DirectX::XMLoadFloat4( &min );
min_xm = DirectX::XMVectorMin( min_xm, vec );
max_xm = DirectX::XMVectorMax( max_xm, vec );
DirectX::XMStoreFloat4( &max, max_xm );
DirectX::XMStoreFloat4( &min, min_xm );
}
BBox BBox::Merge( const BBox &a, const BBox &b )
{
BBox c;
DirectX::XMStoreFloat4( &c.min,
DirectX::XMVectorMin( DirectX::XMVectorMin( a.GetMinXm(), b.GetMinXm() ),
c.GetMinXm() ) );
DirectX::XMStoreFloat4( &c.max,
DirectX::XMVectorMax( DirectX::XMVectorMax( a.GetMaxXm(), b.GetMaxXm() ),
c.GetMaxXm() ) );
return c;
}
uint32_t bvhDfs( std::vector<LinearBVHNode> &flat_tree,
RpTriangle *&primitives,
std::vector<RpTriangle> &orderedPrims,
BVHBuildNode *node,
std::vector<BVHPrimitive> &buildData,
uint32_t &offset )
{
LinearBVHNode &linearNode = flat_tree[offset];
linearNode.bounds = node->bounds;
uint32_t myOffset = offset++;
if ( node->nPrimitives > 0 ) {
assert( !node->children[0] && !node->children[1] );
uint32_t firstPrimOffset = orderedPrims.size();
uint32_t primNum = buildData[node->firstPrimOffset].triangleId;
orderedPrims.push_back( primitives[primNum] );
node->firstPrimOffset = firstPrimOffset;
linearNode.primitivesOffset = node->firstPrimOffset;
linearNode.nPrimitives = node->nPrimitives;
} else {
linearNode.nPrimitives = 0;
linearNode.axis = node->splitAxis;
bvhDfs( flat_tree, primitives, orderedPrims, node->children[0], buildData, offset );
linearNode.secondChildOffset
= bvhDfs( flat_tree, primitives, orderedPrims, node->children[1], buildData, offset );
}
delete node;
return myOffset;
}
uint32_t bvhDfsTlas( std::vector<LinearBVHNodeTLAS> &flat_tree,
const std::vector<BLAS_Instance> &instances,
uint32_t &inst_offset,
BVHBuildNode *node,
std::vector<BVHPrimitive> &buildData,
uint32_t &offset )
{
LinearBVHNodeTLAS &linearNode = flat_tree[offset];
linearNode.bounds = node->bounds;
uint32_t myOffset = offset++;
if ( node->nPrimitives > 0 ) {
assert( !node->children[0] && !node->children[1] );
uint32_t firstPrimOffset = inst_offset;
uint32_t primNum = buildData[node->firstPrimOffset].triangleId;
inst_offset++;
node->firstPrimOffset = firstPrimOffset;
linearNode.blasBVHOffset = primNum;
linearNode.lowLevel_a = 1;
} else {
linearNode.lowLevel_a = 0;
linearNode.axis = node->splitAxis;
bvhDfsTlas( flat_tree, instances, inst_offset, node->children[0], buildData, offset );
linearNode.secondChildOffset
= bvhDfsTlas( flat_tree, instances, inst_offset, node->children[1], buildData, offset );
}
delete node;
return myOffset;
}
BLAS_BVH BVHBuilder::BuildBVH( rh::rw::engine::RpGeometryInterface *geometry,
RayTracingTextureCache *texture_cache )
{
RpTriangle *tri_list = geometry->GetTrianglePtr();
auto s = std::chrono::high_resolution_clock::now();
auto bvh_prim_list = GenerateBVHPrimitiveList( geometry );
BBox centerBBox;
for ( uint32_t i = 0; i < bvh_prim_list.size(); ++i )
centerBBox.Merge( bvh_prim_list[i].centroid );
std::vector<std::pair<uint32_t, uint32_t>> mortonCodes;
mortonCodes.reserve( bvh_prim_list.size() );
for ( uint32_t i = 0; i < bvh_prim_list.size(); ++i ) {
auto c = bvh_prim_list[i].centroid;
float newX = ( DirectX::XMVectorGetX( c ) - centerBBox.min.x )
/ ( centerBBox.max.x - centerBBox.min.x );
float newY = ( DirectX::XMVectorGetY( c ) - centerBBox.min.y )
/ ( centerBBox.max.y - centerBBox.min.y );
float newZ = ( DirectX::XMVectorGetZ( c ) - centerBBox.min.z )
/ ( centerBBox.max.z - centerBBox.min.z );
uint32_t mc = morton3D( newX, newY, newZ );
mortonCodes.push_back( std::make_pair( mc, i ) );
}
std::sort( mortonCodes.begin(), mortonCodes.end() );
auto bv_bs = std::chrono::high_resolution_clock::now();
std::vector<BVHBuildNode *> clusters;
uint32_t totalNodes = 0;
RecursiveBuildAAC( bvh_prim_list,
mortonCodes,
0,
bvh_prim_list.size(),
totalNodes,
MORTON_CODE_START,
&clusters );
BVHBuildNode *root = combineCluster( clusters, 1, totalNodes, 2 )[0];
auto bv_be = std::chrono::high_resolution_clock::now();
std::vector<LinearBVHNode> bvh_tree_flat;
bvh_tree_flat.reserve( totalNodes );
for ( uint32_t i = 0; i < totalNodes; ++i )
bvh_tree_flat.push_back( {} );
std::vector<RpTriangle> ordered_tri_list;
uint32_t offset = 0;
bvhDfs( bvh_tree_flat, tri_list, ordered_tri_list, root, bvh_prim_list, offset );
auto e = std::chrono::high_resolution_clock::now();
std::stringstream ss;
ss << "bvh build time without morton codes: "
<< std::chrono::duration_cast<std::chrono::milliseconds>( e - bv_bs ).count() << " ms.\n"
<< "bvh build time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>( e - s ).count() << " ms.\n"
<< "bvh recursive aac build time: "
<< std::chrono::duration_cast<std::chrono::milliseconds>( bv_be - bv_bs ).count()
<< " ms.\n";
rh::debug::DebugLogger::Log( ss.str() );
std::vector<RTVertex> verts;
verts.reserve( static_cast<uint32_t>( geometry->GetVertexCount() ) );
for ( auto i = 0; i < geometry->GetVertexCount(); i++ ) {
uint32_t color = geometry->GetVertexColorPtr() != nullptr
? *reinterpret_cast<uint32_t *>( &geometry->GetVertexColorPtr()[i] )
: 0xFF000000;
RwTexCoords texcoords = geometry->GetTexCoordSetPtr( 0 ) != nullptr
? geometry->GetTexCoordSetPtr( 0 )[i]
: RwTexCoords{0, 0};
verts.push_back( {{geometry->GetMorphTarget( 0 )->verts[i].x,
geometry->GetMorphTarget( 0 )->verts[i].y,
geometry->GetMorphTarget( 0 )->verts[i].z},
color,
{texcoords.u, texcoords.v, 0, 0}} );
}
std::vector<MaterialInfo> materials;
RpMeshHeader *header = geometry->GetMeshHeader();
RpMesh *mesh_array = reinterpret_cast<RpMesh *>( reinterpret_cast<uint8_t *>( header )
+ sizeof( RpMeshHeader ) );
materials.reserve( header->numMeshes );
for ( auto i = 0; i < header->numMeshes; i++ ) {
const RpMesh &mesh = mesh_array[i];
MaterialInfo info{};
info.textureId = -1;
if ( mesh.material && mesh.material->texture && mesh.material->texture->raster ) {
info.transparency = mesh.material->color.alpha;
auto address = texture_cache->GetTextureAddress(
rh::rw::engine::GetInternalRaster( mesh.material->texture->raster ) );
if ( address != nullptr ) {
info.textureId = address->id;
info.mipLevel = address->mip_level;
info.xScale = address->scaleX;
info.yScale = address->scaleY;
}
}
materials.push_back( info );
}
return {bvh_tree_flat, ordered_tri_list, verts, materials};
}
void BVHBuilder::PackBLASBVH( PackedBLAS_BVH &result,
const std::vector<BLAS_BVH *> &new_blas,
uint32_t last_id_offset )
{
auto s = std::chrono::high_resolution_clock::now();
uint32_t blas_bvh_nodes_size = result.blas.nodes.size();
uint32_t blas_triangle_lists_size = result.blas.ordered_triangles.size();
uint32_t blas_vertex_lists_size = result.blas.vertices.size();
uint32_t blas_material_lists_size = result.blas.materials.size();
for ( size_t i = 0; i < new_blas.size(); i++ ) {
result.blas_offsets_map[last_id_offset + i].blasBVHOffset = blas_bvh_nodes_size;
result.blas_offsets_map[last_id_offset + i].primitiveOffset = blas_triangle_lists_size;
result.blas_offsets_map[last_id_offset + i].vertexOffset = blas_vertex_lists_size;
result.blas_offsets_map[last_id_offset + i].materialOffset = blas_material_lists_size;
blas_bvh_nodes_size += new_blas[i]->nodes.size();
blas_triangle_lists_size += new_blas[i]->ordered_triangles.size();
blas_vertex_lists_size += new_blas[i]->vertices.size();
blas_material_lists_size += new_blas[i]->materials.size();
}
// res.blas.ordered_triangles.reserve( blas_triangle_lists_size );
// res.blas.nodes.reserve( blas_bvh_nodes_size );
// res.blas.vertices.reserve( blas_vertex_lists_size );
for ( size_t i = 0; i < new_blas.size(); i++ ) {
result.blas.vertices.insert( result.blas.vertices.end(),
new_blas[i]->vertices.begin(),
new_blas[i]->vertices.end() );
result.blas.ordered_triangles.insert( result.blas.ordered_triangles.end(),
new_blas[i]->ordered_triangles.begin(),
new_blas[i]->ordered_triangles.end() );
result.blas.nodes.insert( result.blas.nodes.end(),
new_blas[i]->nodes.begin(),
new_blas[i]->nodes.end() );
result.blas.materials.insert( result.blas.materials.end(),
new_blas[i]->materials.begin(),
new_blas[i]->materials.end() );
}
auto e = std::chrono::high_resolution_clock::now();
std::stringstream ss;
ss << "bvh pack time : "
<< std::chrono::duration_cast<std::chrono::milliseconds>( e - s ).count() << " ms.\n"
<< "bvh new node count : " << new_blas.size() << "\nbvh packed blas size: "
<< ( result.blas.materials.size() * sizeof( MaterialInfo )
+ result.blas.ordered_triangles.size() * sizeof( RpTriangle )
+ result.blas.vertices.size() * sizeof( RTVertex )
+ result.blas.nodes.size() * sizeof( LinearBVHNode ) )
<< " bytes.\n";
rh::debug::DebugLogger::Log( ss.str() );
}
TLAS_BVH BVHBuilder::BuildTLASBVH( PackedBLAS_BVH &packed_blas,
const std::vector<BLAS_BVH> &blas,
const std::vector<BLAS_Instance> &instances )
{
auto s = std::chrono::high_resolution_clock::now();
std::vector<BVHPrimitive> bvh_prim_list;
bvh_prim_list.reserve( instances.size() );
for ( size_t i = 0; i < instances.size(); i++ ) {
DirectX::XMMATRIX ws = DirectX::XMLoadFloat4x4( &instances[i].world_transform );
BBox ws_bbox = blas[instances[i].blas_id].nodes[0].bounds.Transform( ws );
DirectX::XMVECTOR centroid = ws_bbox.GetCenter();
bvh_prim_list.push_back( {ws_bbox, centroid, static_cast<uint32_t>( i ), {0, 0, 0}} );
}
BBox centerBBox;
for ( uint32_t i = 0; i < bvh_prim_list.size(); ++i )
centerBBox = BBox::Merge( bvh_prim_list[i].boundBox, centerBBox );
std::vector<std::pair<uint32_t, uint32_t>> mortonCodes;
mortonCodes.reserve( bvh_prim_list.size() );
for ( uint32_t i = 0; i < bvh_prim_list.size(); ++i ) {
auto c = bvh_prim_list[i].centroid;
float newX = ( DirectX::XMVectorGetX( c ) - centerBBox.min.x )
/ ( centerBBox.max.x - centerBBox.min.x );
float newY = ( DirectX::XMVectorGetY( c ) - centerBBox.min.y )
/ ( centerBBox.max.y - centerBBox.min.y );
float newZ = ( DirectX::XMVectorGetZ( c ) - centerBBox.min.z )
/ ( centerBBox.max.z - centerBBox.min.z );
uint32_t mc = morton3D( newX, newY, newZ );
mortonCodes.push_back( std::make_pair( mc, i ) );
}
std::sort( mortonCodes.begin(), mortonCodes.end() );
std::vector<BVHBuildNode *> clusters;
uint32_t totalNodes = 0;
RecursiveBuildAAC( bvh_prim_list,
mortonCodes,
0,
bvh_prim_list.size(),
totalNodes,
MORTON_CODE_START,
&clusters );
BVHBuildNode *root = combineCluster( clusters, 1, totalNodes, 2 )[0];
TLAS_BVH tlas;
tlas.tlas.reserve( totalNodes );
for ( uint32_t i = 0; i < totalNodes; ++i )
tlas.tlas.push_back( {} );
std::vector<BLAS_Instance> ordered_blas_list;
uint32_t offset = 0;
uint32_t inst_offset = 0;
bvhDfsTlas( tlas.tlas, instances, inst_offset, root, bvh_prim_list, offset );
for ( size_t i = 0; i < tlas.tlas.size(); i++ ) {
if ( tlas.tlas[i].lowLevel_a > 0 ) {
uint32_t blas_id = instances[tlas.tlas[i].blasBVHOffset].blas_id;
DirectX::XMMATRIX ws = DirectX::XMLoadFloat4x4(
&instances[tlas.tlas[i].blasBVHOffset].world_transform );
DirectX::XMStoreFloat4x4( &tlas.tlas[i].world_transform,
DirectX::XMMatrixInverse( nullptr, ws ) );
tlas.tlas[i].blasBVHOffset = packed_blas.blas_offsets_map[blas_id].blasBVHOffset;
tlas.tlas[i].primitiveOffset = packed_blas.blas_offsets_map[blas_id].primitiveOffset;
tlas.tlas[i].vertexOffset = packed_blas.blas_offsets_map[blas_id].vertexOffset;
tlas.tlas[i].materialOffset = packed_blas.blas_offsets_map[blas_id].materialOffset;
}
}
auto e = std::chrono::high_resolution_clock::now();
std::stringstream ss;
ss << "tlas build time : "
<< std::chrono::duration_cast<std::chrono::milliseconds>( e - s ).count() << " ms.\n"
<< "tlas node count : " << tlas.tlas.size() << ".\n";
rh::debug::DebugLogger::Log( ss.str() );
return tlas;
}
| 39.858377
| 101
| 0.580943
|
HermanLederer
|
1e042b146202b0bb3b0b41544c871b7995b30b11
| 679
|
hpp
|
C++
|
src/sdk/data/LimitedTupleDatabase.hpp
|
psettle/sudoku
|
ea0040f3a9c1c093fa9ece851d2ec4104760e97a
|
[
"MIT"
] | 1
|
2020-10-11T06:54:04.000Z
|
2020-10-11T06:54:04.000Z
|
src/sdk/data/LimitedTupleDatabase.hpp
|
psettle/sudoku
|
ea0040f3a9c1c093fa9ece851d2ec4104760e97a
|
[
"MIT"
] | null | null | null |
src/sdk/data/LimitedTupleDatabase.hpp
|
psettle/sudoku
|
ea0040f3a9c1c093fa9ece851d2ec4104760e97a
|
[
"MIT"
] | null | null | null |
/**
* LimitedTupleDatabase.hpp - Limit Tuple Database
*
* Collection of limited tuples that have been identified
*/
#ifndef _SDK_LIMITEDTUPLEDATABASE
#define _SDK_LIMITEDTUPLEDATABASE
#include <memory>
#include <vector>
#include "sdk/data/LimitedTuple.hpp"
namespace sdk {
namespace data {
class LimitedTupleDatabase {
public:
LimitedTupleDatabase();
bool Add(LimitedTuple* limited_tuple);
void Remove(std::unique_ptr<LimitedTuple> const& tuple);
std::vector<std::unique_ptr<LimitedTuple>> const& GetTuples() const;
private:
std::vector<std::unique_ptr<LimitedTuple>> tuples_;
};
} // namespace data
} // namespace sdk
#endif /* _SDK_LIMITEDTUPLEDATABASE */
| 24.25
| 70
| 0.756996
|
psettle
|
1e0553cd57ddb4ac7a88abd158009dae1bea4015
| 6,495
|
cc
|
C++
|
src/cross_point_detect/cross_points_detector.cc
|
FlyAlCode/RCLGeolocalization-2.0
|
2325fd11b23789630b6c12ecd0258c9dec84644a
|
[
"MIT"
] | 4
|
2021-02-06T07:59:14.000Z
|
2022-02-22T10:58:27.000Z
|
src/cross_point_detect/cross_points_detector.cc
|
FlyAlCode/RCLGeolocalization-2.0
|
2325fd11b23789630b6c12ecd0258c9dec84644a
|
[
"MIT"
] | null | null | null |
src/cross_point_detect/cross_points_detector.cc
|
FlyAlCode/RCLGeolocalization-2.0
|
2325fd11b23789630b6c12ecd0258c9dec84644a
|
[
"MIT"
] | 1
|
2021-09-15T13:48:00.000Z
|
2021-09-15T13:48:00.000Z
|
#include "cross_points_detector.h"
// debug
#include <iostream>
namespace rcll{
CrossPointDetector::CrossPointDetector(int min_cross_point_distance){
min_cross_point_distance_ = min_cross_point_distance;
}
CrossPointDetector::~CrossPointDetector(){
}
int CrossPointDetector::CountDisconnectPoints(const cv::Mat& local_image){
int w = local_image.cols;
int h = local_image.rows;
std::vector<uchar> around_pixel;
for(int i = 0; i<w; i++)
around_pixel.push_back(local_image.at<uchar>(0,i));
for(int i=1; i<h; i++)
around_pixel.push_back(local_image.at<uchar>(i,w-1));
for(int i=w-2; i>=0; i--)
around_pixel.push_back(local_image.at<uchar>(h-1, i));
for(int i=h-2; i>0; i--)
around_pixel.push_back(local_image.at<uchar>(i,0));
const int max_step = 1; // max number of points to skip to avoid adjacent point
int num = 0;
int connected_points_num = 0;
int points_num = around_pixel.size();
for(int i=0; i<points_num-1; i++){
if(around_pixel[i]==1){
if(connected_points_num == 0){
++num;
}
++connected_points_num;
if(connected_points_num > max_step)
connected_points_num = 0;
}
else{
connected_points_num = 0;
}
}
if(around_pixel[points_num-1]==1){ // deal with the last which is special for adjance with first point
if(connected_points_num==0 && around_pixel[0]==0)
++num;
}
return num;
}
void CrossPointDetector::CountDisconnectPointsForAllPoints(const cv::Mat &input_img, cv::Mat &output_img){
cv::Mat tmp = cv::Mat::zeros(input_img.size(), input_img.type());
for(int i=1; i<tmp.rows-1; i++){
for(int j=1; j<tmp.cols-1; j++){
if(input_img.at<uchar>(i,j)==1)
tmp.at<uchar>(i,j) = CountDisconnectPoints(input_img(cv::Rect(j-1,i-1,3,3)));
else
tmp.at<uchar>(i,j) = 0;
}
}
tmp.copyTo(output_img);
}
/* @ 1. When encountering a point with value larger than 2, a neighbor area with radius r(3)
* @ is search to find all points with value larger than 2; after than, the max/min in x/y
* @ are calculated to find the boundary, and a rect area is formed, which is treated as the keypoint.
* @ 2. Then a new search around the area is performed,to find the how many lines connected to the keypoint.
*/
void CrossPointDetector::MergeCrossPoints(const cv::Mat &src, const cv::Mat &neighbor_img, cv::Mat &output_img, std::vector<cv::Rect> &keypoint_area){
const int max_keypoint_radius = min_cross_point_distance_; // the radius to search to form a keypoint
neighbor_img.copyTo(output_img);
keypoint_area.clear();
cv::Mat point_visited_map = cv::Mat::zeros(neighbor_img.size(), neighbor_img.type());
for(int i=0; i<neighbor_img.rows; i++){
for(int j=0; j<neighbor_img.cols; j++){
if(point_visited_map.at<uchar>(i,j)==0 && neighbor_img.at<uchar>(i,j)>2){ // unvisited cross points
int max_i = i;
int min_i = i;
int max_j = j;
int min_j = j;
for(int di=0; di<=max_keypoint_radius; di++){ // points above the current are all visited, thus are not need to search
for(int dj=-max_keypoint_radius; dj<=max_keypoint_radius; dj++){
int search_i = i+di;
int search_j = j+dj;
if(search_i<0 || search_i>neighbor_img.rows-1 || search_j<0 ||search_j >neighbor_img.cols-1)
continue;
if(neighbor_img.at<uchar>(search_i, search_j)>2){
if(search_i>max_i)
max_i = search_i;
if(search_j>max_j)
max_j = search_j;
if(search_j<min_j)
min_j = search_j;
}
}
}
// record the cross point
keypoint_area.push_back(cv::Rect(min_j, min_i, max_j-min_j+1, max_i-min_i+1));
// redefine the type of the point
int type = CountDisconnectPoints(src(cv::Rect(min_j-1, min_i-1, max_j-min_j+1+2, max_i-min_i+1+2)));
for(int di=min_i; di<=max_i; di++){
for(int dj=min_j; dj<=max_j; dj++){
point_visited_map.at<uchar>(di, dj) = 1; // mark all points belong the keypoint as visited to avoid forming more than once
output_img.at<uchar>(di, dj) = type; // refine the type for the point
}
}
}
}
}
}
void CrossPointDetector::Run(const cv::Mat &input_img, cv::Mat &cross_points_img, std::vector<cv::Rect> &keypoint_area){
cv::Mat tmp;
CountDisconnectPointsForAllPoints(input_img, tmp);
MergeCrossPoints(input_img, tmp, cross_points_img, keypoint_area);
}
/* @Used just for debug
*/
void CrossPointDetector::ColorNeighborImage(const cv::Mat &neighbor_img, cv::Mat &colored_neighbor_img){
cv::Mat show_img(neighbor_img.size(), CV_8UC3);
for(int i=0; i<neighbor_img.rows; i++){
for(int j=0; j<neighbor_img.cols; j++){
switch(neighbor_img.at<uchar>(i,j)){
case 0:
show_img.at<cv::Vec3b>(i,j) = cv::Vec3b(0, 0, 0);
break;
case 1:
show_img.at<cv::Vec3b>(i,j) = cv::Vec3b(255, 0, 0);
break;
case 2:
show_img.at<cv::Vec3b>(i,j) = cv::Vec3b(0, 255, 0);
break;
case 3:
show_img.at<cv::Vec3b>(i,j) = cv::Vec3b(0, 0, 255);
break;
case 4:
show_img.at<cv::Vec3b>(i,j) = cv::Vec3b(255,255,0);
break;
default:
show_img.at<cv::Vec3b>(i,j) = cv::Vec3b(255,255,255);
}
}
}
show_img.copyTo(colored_neighbor_img);
}
} // road_match
| 40.092593
| 165
| 0.529484
|
FlyAlCode
|
1e08a1480140ffd104e047a84a24dea75d5ebaa7
| 1,110
|
cpp
|
C++
|
codes/HDU/hdu4462.cpp
|
JeraKrs/ACM
|
edcd61ec6764b8cd804bf1538dfde53d0ff572b5
|
[
"Apache-2.0"
] | null | null | null |
codes/HDU/hdu4462.cpp
|
JeraKrs/ACM
|
edcd61ec6764b8cd804bf1538dfde53d0ff572b5
|
[
"Apache-2.0"
] | null | null | null |
codes/HDU/hdu4462.cpp
|
JeraKrs/ACM
|
edcd61ec6764b8cd804bf1538dfde53d0ff572b5
|
[
"Apache-2.0"
] | null | null | null |
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <set>
#include <bitset>
#include <algorithm>
using namespace std;
const int maxn = 55;
const int maxm = 15;
const int inf = 0x3f3f3f3f;
bitset<maxn * maxn> s, p[maxm];
int N, K, R[maxm], C[maxm], D[maxm];
int g[maxn][maxn];
void init () {
memset(g, 0, sizeof(g));
scanf("%d", &K);
for (int i = 0; i < K; i++) {
scanf("%d%d", &R[i], &C[i]);
g[R[i]][C[i]] = 1;
}
for (int i = 0; i < K; i++)
scanf("%d", &D[i]);
for (int i = 0; i < K; i++) {
p[i].reset();
for (int x = 1; x <= N; x++) {
for (int y = 1; y <= N; y++) {
if (g[x][y])
continue;
if (abs(x - R[i]) + abs(y - C[i]) <= D[i])
p[i].set( (x-1) * N + y-1);
}
}
}
}
int solve() {
int ans = inf;
for (int i = 0; i < (1<<K); i++) {
int cnt = 0;
s.reset();
for (int j = 0; j < K; j++) {
if (i&(1<<j)) {
cnt++;
s |= p[j];
}
}
if (s.count() == N * N - K)
ans = min(ans, cnt);
}
return ans == inf ? -1 : ans;
}
int main () {
while (scanf("%d", &N) == 1 && N) {
init();
printf("%d\n", solve());
}
return 0;
}
| 16.086957
| 46
| 0.452252
|
JeraKrs
|
1e0b264189a1521697792d610ec30c1f37317b0f
| 2,369
|
cpp
|
C++
|
HackerEarth/Graph/Just shortest distance problem.cpp
|
Gmaurya/data-structure-and-algorithms
|
9f9790140719d24d15ee401e0d11a99dedde4235
|
[
"MIT"
] | 3
|
2017-12-27T04:58:16.000Z
|
2018-02-05T14:11:06.000Z
|
HackerEarth/Graph/Just shortest distance problem.cpp
|
Gmaurya/data-structure-and-algorithms
|
9f9790140719d24d15ee401e0d11a99dedde4235
|
[
"MIT"
] | 4
|
2018-10-04T07:45:07.000Z
|
2018-11-23T17:36:20.000Z
|
HackerEarth/Graph/Just shortest distance problem.cpp
|
Gmaurya/data-structure-and-algorithms
|
9f9790140719d24d15ee401e0d11a99dedde4235
|
[
"MIT"
] | 8
|
2018-10-02T20:34:58.000Z
|
2018-10-07T14:27:53.000Z
|
/*
You are given an empty graph of N vertices and M queries of two types:
Given a number X answer what is the shortest distance from the vertex 1 to the vertex X.
Given two integers X, Y add the new oriented edge from X to Y.
Input
The first line contains two integers N and M. The following M lines describe queries in the format mentioned above
Output
For each query of the first type output one integer on a separate line - answer for the corresponding query. Output -1 if it's impossible to get to the vertex in this query from the vertex 1.
Constraints
1 <= N <= 1000
1 <= M <= 500 000
1 <= X, Y <= N
Subtasks
N <= 500, M <= 5 000 in 50 % of test data
SAMPLE INPUT
4 7
1 4
2 1 2
2 2 3
2 3 4
1 4
2 2 4
1 4
SAMPLE OUTPUT
-1
3
2
*/
/*************************************************************************/
#include<bits/stdc++.h>
#define ll long long
#define FOR(i,s,n) for(ll i = s; i < (n); i++)
#define FORD(i,s,n) for(ll i=(n)-1;i>=s;i--)
#define mp(x,y) make_pair(x,y)
#define scan(n) scanf("%d",&n)
#define print(n) printf("%d",n)
#define println(n) printf("%d\n",n)
#define printsp(n) printf("%d ",n)
using namespace std;
vector<ll> adj[1005];
ll height[1005];
ll visited[1005] = {0};
void BFS(ll s);
int main()
{
FOR(i,0,1005)
height[i] = 10000;
height[1] = 0;
ll n,m,x,y,type;
cin>>n>>m;
FOR(i,0,m)
{
cin>>type;
if(type == 2)
{
cin>>x>>y;
adj[x].push_back(y);
if((height[x]+1)<=height[y])
{
height[y] = height[x]+1;
BFS(y);
}
}
else
{
cin>>x;
if(height[x] == 10000)
cout<<-1<<endl;
else
cout<<height[x]<<endl;
}
}
return 0;
}
void BFS(ll s)
{
ll v;
queue <ll> q;
q.push(s);
visited[s] = 1;
while(!q.empty())
{
v = q.front();
q.pop();
FOR(i,0,adj[v].size())
{
if(visited[adj[v][i]])
continue;
visited[adj[v][i]] = 1;
ll p = height[adj[v][i]];
height[adj[v][i]] = min(height[adj[v][i]],height[v]+1);
if(p != height[adj[v][i]])
q.push(adj[v][i]);
}
}
memset(visited,0,sizeof(visited));
}
| 18.952
| 191
| 0.493879
|
Gmaurya
|
1f63afd604f068b46005bd634af66015ac2795ba
| 3,904
|
cpp
|
C++
|
cli/src/sync_dat.cpp
|
BOBBYWY/exodusdb
|
cfe8a3452480af90071dd10cefeed58299eed4e7
|
[
"MIT"
] | null | null | null |
cli/src/sync_dat.cpp
|
BOBBYWY/exodusdb
|
cfe8a3452480af90071dd10cefeed58299eed4e7
|
[
"MIT"
] | null | null | null |
cli/src/sync_dat.cpp
|
BOBBYWY/exodusdb
|
cfe8a3452480af90071dd10cefeed58299eed4e7
|
[
"MIT"
] | null | null | null |
#include <exodus/program.h>
programinit()
var last_sync_date;
var last_sync_time;
function main() {
var datpath = COMMAND.a(2);
if (not datpath) {
//datpath = osgetenv("EXO_HOME") ^ "/dat";
if (not datpath.osgetenv("EXO_HOME"))
datpath = osgetenv("HOME");
datpath ^= "/dat";
}
var force = index(OPTIONS, "F");
var verbose = index(OPTIONS, "V");
// Skip if no definitions file
var definitions;
if (not open("DEFINITIONS",definitions)) {
//abort("Error: sync_dat - No DEFINITIONS file");
definitions = "";
}
// Get the date and time of last sync
var last_sync;
var definitions_key = "LAST_SYNC_DATE_TIME*DAT";
if (not definitions or not read(last_sync,definitions, definitions_key))
last_sync = "";
last_sync_date = last_sync.a(1);
last_sync_time = last_sync.a(2);
// Skip if nothing new
var datinfo = osdir(datpath);
var dirtext = "sync_dat: " ^ datpath ^ " " ^ datinfo.a(2).oconv("D-Y") ^ " " ^ datinfo.a(3).oconv("MTS");
if (not force and not is_newer(datinfo)) {
if (verbose)
printl(dirtext, "No change.");
return 0;
}
printl(dirtext,"Scanning ...");
begintrans();
// Process each subdir in turn. each one represents a db file.
var dirnames = oslistd(datpath ^ "/*");
for (var dirname : dirnames) {
var dirpath = datpath ^ "/" ^ dirname ^ "/";
// // Skip dirs which are not newer i.e. have no newer records
// if (not force) {
// var dirinfo = osdir(dirpath);
// if (not is_newer(dirinfo)) {
// if (verbose)
// printl("Nothing new in", dirpath, dirinfo.a(2).oconv("D-Y"), dirinfo.a(3).oconv("MTS"));
// continue;
// }
// }
// Open or create the target db file
var dbfile;
var dbfilename = dirname;
if (not open(dbfilename, dbfile)) {
createfile(dbfilename);
if (not open(dbfilename, dbfile)) {
errputl("Error: sync_dat cannot create " ^ dbfilename);
continue;
}
}
// Process each file/record in the subdir
var osfilenames = oslistf(dirpath ^ "*");
for (var osfilename : osfilenames) {
ID = osfilename;
if (not ID)
continue;
if (ID.starts(".") or ID.ends(".swp"))
continue;
// Skip files/records which are not newer
var filepath = dirpath ^ ID;
if (not force and not is_newer(osfile(filepath))) {
if (verbose)
printl("Not newer", dbfilename, ID);
continue;
}
if (not osread(RECORD from filepath)) {
errputl("Error: sync_dat cannot read " ^ ID ^ " from " ^ filepath);
continue;
}
gosub unescape_text(RECORD);
//get any existing record
var oldrecord;
if (not read(oldrecord from dbfile, ID)) {
oldrecord = "";
}
if (RECORD eq oldrecord) {
if (verbose)
printl("Not changed", dbfilename, ID);
} else {
// Write the RECORD
write(RECORD on dbfile, ID);
printl("sync_dat:", dbfilename, ID, "WRITTEN");
}
// Create pgsql using dict2sql
// DONT SKIP SINCE PGSQL FUNCTIONS MUST BE IN EVERY DATABASE
if (dbfilename.starts("dict.") and RECORD.index("/" "*pgsql")) {
var cmd = "dict2sql " ^ dbfilename ^ " " ^ ID;
//cmd ^= " {V}";
if (not osshell(cmd))
errputl("Error: sync_dat: In dict2sql for " ^ ID ^ " in " ^ dbfilename);
}
}
}
// Record the current sync date and time
if (definitions)
write(date() ^ FM ^ time() on definitions, definitions_key);
committrans();
return 0;
}
function is_newer(in fsinfo) {
int fsinfo_date = fsinfo.a(2);
if (fsinfo_date > last_sync_date)
return true;
if (fsinfo_date < last_sync_date)
return false;
return fsinfo.a(3) > last_sync_time;
}
//WARNING: KEEP AS REVERSE OF escape_text() IN COPYFILE
//identical code in copyfile and sync_dat
subroutine unescape_text(io record) {
//replace new lines with FM
record.converter("\n", FM);
//unescape new lines
record.swapper("\\n", "\n");
//unescape backslashes
record.swapper("\\\\", "\\");
return;
}
programexit()
| 23.238095
| 106
| 0.633453
|
BOBBYWY
|
1f65131beb18d615a01ac1fa1c699cb7042bee92
| 533
|
hpp
|
C++
|
sgreader/exception/RuntimeException.hpp
|
Vinorcola/citybuilding-tools
|
df91d8106987af45f1d11a34470acadb3873a91a
|
[
"MIT"
] | null | null | null |
sgreader/exception/RuntimeException.hpp
|
Vinorcola/citybuilding-tools
|
df91d8106987af45f1d11a34470acadb3873a91a
|
[
"MIT"
] | null | null | null |
sgreader/exception/RuntimeException.hpp
|
Vinorcola/citybuilding-tools
|
df91d8106987af45f1d11a34470acadb3873a91a
|
[
"MIT"
] | null | null | null |
#ifndef RUNTIMEEXCEPTION_HPP
#define RUNTIMEEXCEPTION_HPP
#include <QtCore/QException>
class RuntimeException : public QException
{
private:
const QString message;
const std::string standardFormatMessage;
public:
RuntimeException(const QString& message);
const QString& getMessage() const;
virtual void raise() const override;
virtual RuntimeException* clone() const override;
virtual const char* what() const noexcept override;
};
#endif // RUNTIMEEXCEPTION_HPP
| 23.173913
| 59
| 0.707317
|
Vinorcola
|
1f670fa59096390aa78f4f05c0360763b39347a4
| 25,751
|
cpp
|
C++
|
src/libs/plugins/pokey/pokeyDevice.cpp
|
mteichtahl/simhub
|
4c409c61e38bb5deeb58a09c6cb89730d38280e1
|
[
"MIT"
] | 3
|
2018-03-19T18:09:12.000Z
|
2021-06-17T03:56:05.000Z
|
src/libs/plugins/pokey/pokeyDevice.cpp
|
mteichtahl/simhub
|
4c409c61e38bb5deeb58a09c6cb89730d38280e1
|
[
"MIT"
] | 19
|
2017-04-29T11:25:52.000Z
|
2021-05-07T14:48:59.000Z
|
src/libs/plugins/pokey/pokeyDevice.cpp
|
mteichtahl/simhub
|
4c409c61e38bb5deeb58a09c6cb89730d38280e1
|
[
"MIT"
] | 9
|
2017-04-26T22:45:06.000Z
|
2022-02-27T01:08:54.000Z
|
#include <string.h>
#include "elements/attributes/attribute.h"
#include "main.h"
#include "pokeyDevice.h"
using namespace std::chrono_literals;
PokeyDevice::PokeyDevice(PokeyDevicePluginStateManager *owner, sPoKeysNetworkDeviceSummary deviceSummary, uint8_t index)
{
_callbackArg = NULL;
_enqueueCallback = NULL;
_owner = owner;
_pokey = PK_ConnectToNetworkDevice(&deviceSummary);
if (!_pokey) {
throw std::exception();
}
_index = index;
_userId = deviceSummary.UserID;
_serialNumber = std::to_string(deviceSummary.SerialNumber);
_firwareVersionMajorMajor = (deviceSummary.FirmwareVersionMajor >> 4) + 1;
_firwareVersionMajor = deviceSummary.FirmwareVersionMajor & 0x0F;
_firwareVersionMinor = deviceSummary.FirmwareVersionMinor;
memcpy(&_ipAddress, &deviceSummary.IPaddress, 4);
_hardwareType = deviceSummary.HWtype;
_dhcp = deviceSummary.DHCP;
_intToDisplayRow[0] = 0b11111100;
_intToDisplayRow[1] = 0b01100000;
_intToDisplayRow[2] = 0b11011010;
_intToDisplayRow[3] = 0b11110010;
_intToDisplayRow[4] = 0b01100110;
_intToDisplayRow[5] = 0b10110110;
_intToDisplayRow[6] = 0b10111110;
_intToDisplayRow[7] = 0b11100000;
_intToDisplayRow[8] = 0b11111110;
_intToDisplayRow[9] = 0b11100110;
_switchMatrixManager = std::make_shared<PokeySwitchMatrixManager>(_pokey);
loadPinConfiguration();
if (makeAllPinsInactive()) {
_pollTimer.data = this;
_pollLoop = uv_loop_new();
uv_timer_init(_pollLoop, &_pollTimer);
int ret = uv_timer_start(&_pollTimer, (uv_timer_cb)&PokeyDevice::DigitalIOTimerCallback, DEVICE_START_DELAY, DEVICE_READ_INTERVAL);
if (ret == 0) {
_pollThread = std::make_shared<std::thread>([=] { uv_run(_pollLoop, UV_RUN_DEFAULT); });
}
}
else {
printf("Failed to make all pins inactive - pokey polling loop inactive");
}
}
bool PokeyDevice::ownsPin(std::string pinName)
{
for (int i = 0; i < _pokey->info.iPinCount; i++) {
if (_pins[i].pinName == pinName) {
return true;
}
}
return false;
}
bool PokeyDevice::makeAllPinsInactive()
{
bool retVal = true;
for (int i = 0; i < _pokey->info.iPinCount; i++) {
int ret = inactivePin(i);
if (ret != PK_OK) {
retVal = false;
break;
}
}
return retVal;
}
void PokeyDevice::setCallbackInfo(EnqueueEventHandler enqueueCallback, void *callbackArg, SPHANDLE pluginInstance)
{
_enqueueCallback = enqueueCallback;
_callbackArg = callbackArg;
_pluginInstance = pluginInstance;
}
void PokeyDevice::DigitalIOTimerCallback(uv_timer_t *timer, int status)
{
PokeyDevice *self = static_cast<PokeyDevice *>(timer->data);
assert(self);
// only run if we have complete our preflight
if (!self->_owner->successfulPreflightCompleted()) {
return;
}
// Process the encoders
int encoderRetValue = PK_EncoderValuesGet(self->_pokey);
if (encoderRetValue == PK_OK) {
GenericTLV *el = NULL;
for (int i = 0; i < self->_encoderMap.size(); i++) {
uint32_t step = self->_encoders[i].step;
uint32_t newEncoderValue = self->_pokey->Encoders[i].encoderValue;
uint32_t previousEncoderValue = self->_encoders[i].previousEncoderValue;
uint32_t currentValue = self->_encoders[i].value;
uint32_t min = self->_encoders[i].min;
uint32_t max = self->_encoders[i].max;
if (previousEncoderValue != newEncoderValue) {
if (newEncoderValue < previousEncoderValue) {
// values are decreasing
// absolute encoders send 1 or -1
if (self->_encoders[i].type == "absolute") {
self->_encoders[i].value = 1;
}
else {
if (currentValue <= min) {
self->_encoders[i].previousValue = min;
self->_encoders[i].value = min;
}
else {
self->_encoders[i].value = currentValue - step;
}
}
}
else {
// values are increasing
if (self->_encoders[i].type == "absolute") {
// absolute encoders send 1 or -1
self->_encoders[i].value = -1;
}
else {
if (currentValue >= max) {
self->_encoders[i].previousValue = max;
self->_encoders[i].value = max;
}
else {
self->_encoders[i].value = currentValue + step;
}
}
}
el = make_generic(self->_encoders[i].name.c_str(), self->_encoders[i].description.c_str());
el->ownerPlugin = self->_owner;
el->type = CONFIG_INT;
el->value.int_value = (int)self->_encoders[i].value;
el->length = sizeof(uint32_t);
dupe_string(&(el->units), self->_encoders[i].units.c_str());
// enqueue the element
self->_enqueueCallback(self, (void *)el, self->_callbackArg);
// set previous to equal new
self->_encoders[i].previousEncoderValue = newEncoderValue;
}
}
}
// Finish processing the encoders
int retVal = PK_DigitalIOGet(self->_pokey);
if (retVal == PK_OK) {
self->_owner->pinRemappingMutex().lock();
for (int i = 0; i < self->_pokey->info.iPinCount; i++) {
GenericTLV *el = make_generic((const char *)"-", (const char *)"-");
if (self->_pins[i].type == "DIGITAL_INPUT") {
int sourcePinNumber = self->_pins[i].pinNumber;
if (self->_pins[i].value != self->_pokey->Pins[sourcePinNumber - 1].DigitalValueGet && !self->_pins[i].skipNext) {
// data has changed so send it off for processing
printf("DIN pin-index %i - %i\n", sourcePinNumber - 1, self->_pokey->Pins[sourcePinNumber - 1].DigitalValueGet);
el->ownerPlugin = self->_owner;
el->type = CONFIG_BOOL;
bool hackSkip = false;
el->length = sizeof(uint8_t);
if (self->_owner->pinRemapped(self->_pins[i].pinName)) {
// KLUDGE: as each device has its own polling
// thread, the logic below is a
// critical section because it can
// touch the state of multiple device
// pins
std::pair<std::shared_ptr<PokeyDevice>, std::string> remappedPinInfo = self->_owner->remappedPinDetails(self->_pins[i].pinName);
int remappedPinIndex = remappedPinInfo.first->pinIndexFromName(remappedPinInfo.second);
// remappedPinInfo.first->pins()[remappedPinIndex].previousValue = self->_pins[self->_pins[i].pinNumber - 1].value;
self->_pins[i].previousValue = self->_pins[self->_pins[i].pinNumber - 1].value;
remappedPinInfo.first->_pins[remappedPinIndex].previousValue = self->_pokey->Pins[sourcePinNumber - 1].DigitalValueGet;
remappedPinInfo.first->_pins[remappedPinIndex].value = self->_pokey->Pins[sourcePinNumber - 1].DigitalValueGet;
self->_pins[i].value = self->_pokey->Pins[sourcePinNumber - 1].DigitalValueGet;
dupe_string(&(el->name), remappedPinInfo.second.c_str());
el->value.bool_value = self->_pokey->Pins[sourcePinNumber - 1].DigitalValueGet;
if (el->value.bool_value == 0) {
remappedPinInfo.first->_pins[remappedPinIndex].skipNext = true;
}
else {
if (!remappedPinInfo.first->_pins[remappedPinIndex].skipNext) {
self->_owner->pinRemappingMutex().unlock();
std::this_thread::sleep_for(250ms);
// give any other remapped polling
// threads a chance to send a state
// change
if (remappedPinInfo.first->_pins[remappedPinIndex].skipNext) {
hackSkip = true;
}
}
remappedPinInfo.first->_pins[remappedPinIndex].skipNext = false;
}
printf("--> remapping %s to %s\n", self->_pins[i].pinName.c_str(), remappedPinInfo.first->pins()[remappedPinIndex].pinName.c_str());
}
else {
dupe_string(&(el->name), self->_pins[i].pinName.c_str());
el->value.bool_value = self->_pins[i].value;
self->_pins[i].previousValue = self->_pins[i].value;
self->_pins[i].value = self->_pokey->Pins[self->_pins[i].pinNumber - 1].DigitalValueGet;
}
if (hackSkip) {
printf("HACKSKIP, %s, %i\n", self->_pins[i].pinName.c_str(), self->_pins[i].value);
release_generic(el);
self->_owner->pinRemappingMutex().unlock();
return;
}
if (self->_pins[i].description.size() > 0) {
dupe_string(&(el->description), self->_pins[i].description.c_str());
}
if (self->_pins[i].units.size() > 0) {
dupe_string(&(el->units), self->_pins[i].units.c_str());
}
std::shared_ptr<Attribute> attribute = AttributeFromCGeneric(el);
TransformFunction transformer = self->_owner->transformForPinName(self->_pins[i].pinName);
if (transformer) {
std::string transformedValue = transformer(attribute->valueToString(), "NULL", "NULL");
attribute->setType(STRING_ATTRIBUTE);
attribute->setValue(transformedValue);
GenericTLV *transformedGeneric = AttributeToCGeneric(attribute);
printf("---> %s: %s\n", (char *)self->_pins[i].pinName.c_str(), transformedValue.c_str());
self->_enqueueCallback(self, (void *)transformedGeneric, self->_callbackArg);
}
else {
printf("---> %s\n", (char *)self->_pins[i].pinName.c_str());
self->_enqueueCallback(self, (void *)el, self->_callbackArg);
}
}
}
}
// -- process all switch matrix
std::vector<GenericTLV *> matrixResult = self->_switchMatrixManager->readAll();
for (auto &res : matrixResult) {
res->ownerPlugin = self->_owner;
self->_enqueueCallback(self, (void *)res, self->_callbackArg);
}
// -- end process all switch matrix
self->_owner->pinRemappingMutex().unlock();
}
else {
if (retVal == PK_ERR_TRANSFER) {
printf("----> PK_ERR_TRANSFER %i\n\n", retVal);
}
else if (retVal == PK_ERR_GENERIC) {
printf("----> PK_ERR_GENERIC %i\n\n", retVal);
}
else if (retVal == PK_ERR_PARAMETER) {
printf("----> PK_ERR_PARAMETER %i\n\n", retVal);
}
}
}
void PokeyDevice::addPin(int pinIndex, std::string pinName, int pinNumber, std::string pinType, int defaultValue, std::string description, bool invert)
{
if (pinType == "DIGITAL_OUTPUT")
outputPin(pinNumber);
if (pinType == "DIGITAL_INPUT")
inputPin(pinNumber, invert);
mapNameToPin(pinName.c_str(), pinNumber);
_pins[pinIndex].pinName = pinName;
_pins[pinIndex].pinIndex = pinIndex;
_pins[pinIndex].type = pinType.c_str();
_pins[pinIndex].pinNumber = pinNumber;
_pins[pinIndex].defaultValue = defaultValue;
_pins[pinIndex].value = defaultValue;
_pins[pinIndex].description = description;
}
void PokeyDevice::startPolling()
{
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
}
void PokeyDevice::stopPolling()
{
assert(_pollLoop);
uv_stop(_pollLoop);
if (_pollThread->joinable())
_pollThread->join();
}
/**
* @brief Default destructor for PokeyDevice
*
* @return nothing
*/
PokeyDevice::~PokeyDevice()
{
stopPolling();
if (_pollThread) {
if (_pollThread->joinable()) {
_pollThread->join();
}
}
PK_DisconnectDevice(_pokey);
}
std::string PokeyDevice::name()
{
std::string tmp((char *)deviceData().DeviceName);
return tmp;
}
std::string PokeyDevice::hardwareTypeString()
{
if (_hardwareType == 31) {
return "Pokey 57E";
}
return "Unknown";
}
bool PokeyDevice::validatePinCapability(int pin, std::string type)
{
assert(_pokey);
bool retVal = false;
if (type == "DIGITAL_OUTPUT") {
retVal = isPinDigitalOutput(pin - 1);
}
else if (type == "DIGITAL_INPUT") {
retVal = isPinDigitalInput(pin - 1);
}
return retVal;
}
bool PokeyDevice::validateEncoder(int encoderNumber)
{
assert(_pokey);
bool retVal = false;
if (encoderNumber == ENCODER_1) {
//! TODO: Check pins 1 and 2 are not allocated already
retVal = isEncoderCapable(1) && isEncoderCapable(2);
}
else if (encoderNumber == ENCODER_2) {
//! TODO: Check pins 5 and 6 are not allocated already
retVal = isEncoderCapable(5) && isEncoderCapable(6);
}
else if (encoderNumber == ENCODER_3) {
//! TODO: Check pins 15 and 16 are not allocated already
retVal = isEncoderCapable(15) && isEncoderCapable(16);
}
return retVal;
}
bool PokeyDevice::isEncoderCapable(int pin)
{
switch (pin) {
case 1:
return (bool)PK_CheckPinCapability(_pokey, 0, PK_AllPinCap_fastEncoder1A);
case 2:
return (bool)PK_CheckPinCapability(_pokey, 1, PK_AllPinCap_fastEncoder1B);
case 5:
return true; //! this is here because the pokeys library is broken
return (bool)PK_CheckPinCapability(_pokey, 5, PK_AllPinCap_fastEncoder2A);
case 6:
return true; // this is here because the pokeys library is broken
return (bool)PK_CheckPinCapability(_pokey, 6, PK_AllPinCap_fastEncoder2B);
case 15:
return (bool)PK_CheckPinCapability(_pokey, 14, PK_AllPinCap_fastEncoder3A);
case 16:
return (bool)PK_CheckPinCapability(_pokey, 15, PK_AllPinCap_fastEncoder3B);
default:
return false;
}
return false;
}
void PokeyDevice::addEncoder(
int encoderNumber, uint32_t defaultValue, std::string name, std::string description, int min, int max, int step, int invertDirection, std::string units, std::string type)
{
assert(encoderNumber >= 1);
PK_EncoderConfigurationGet(_pokey);
int encoderIndex = encoderNumber - 1;
_pokey->Encoders[encoderIndex].encoderValue = defaultValue;
_pokey->Encoders[encoderIndex].encoderOptions = 0b11;
if (encoderNumber == 1) {
if (invertDirection) {
_pokey->Encoders[encoderIndex].channelApin = 1;
_pokey->Encoders[encoderIndex].channelBpin = 0;
}
else {
_pokey->Encoders[encoderIndex].channelApin = 1;
_pokey->Encoders[encoderIndex].channelBpin = 0;
}
}
else if (encoderNumber == 2) {
if (invertDirection) {
_pokey->Encoders[encoderIndex].channelApin = 5;
_pokey->Encoders[encoderIndex].channelBpin = 4;
}
else {
_pokey->Encoders[encoderIndex].channelApin = 4;
_pokey->Encoders[encoderIndex].channelBpin = 5;
}
}
else if (encoderNumber == 3) {
if (invertDirection) {
_pokey->Encoders[encoderIndex].channelApin = 15;
_pokey->Encoders[encoderIndex].channelBpin = 14;
}
else {
_pokey->Encoders[encoderIndex].channelApin = 14;
_pokey->Encoders[encoderIndex].channelBpin = 15;
}
}
_encoders[encoderIndex].name = name;
_encoders[encoderIndex].number = encoderNumber;
_encoders[encoderIndex].defaultValue = defaultValue;
_encoders[encoderIndex].value = defaultValue;
_encoders[encoderIndex].previousValue = defaultValue;
_encoders[encoderIndex].previousEncoderValue = defaultValue;
_encoders[encoderIndex].min = min;
_encoders[encoderIndex].max = max;
_encoders[encoderIndex].step = step;
_encoders[encoderIndex].units = units;
_encoders[encoderIndex].description = description;
_encoders[encoderIndex].type = type;
int val = PK_EncoderConfigurationSet(_pokey);
if (val == PK_OK) {
PK_EncoderValuesSet(_pokey);
mapNameToEncoder(name.c_str(), encoderNumber);
}
else {
// throw exception
}
}
void PokeyDevice::addMatrixLED(int id, std::string name, std::string type)
{
PK_MatrixLEDConfigurationGet(_pokey);
_matrixLED[id].name = name;
_matrixLED[id].type = type;
mapNameToMatrixLED(name, id);
}
void PokeyDevice::addGroupToMatrixLED(int id, int displayId, std::string name, int digits, int position)
{
_matrixLED[displayId].group[position].name = name;
_matrixLED[displayId].group[position].position = position;
_matrixLED[displayId].group[position].length = digits;
_matrixLED[displayId].group[position].value = 0;
}
void PokeyDevice::configMatrixLED(int id, int rows, int cols, int enabled)
{
_pokey->MatrixLED[id].rows = rows;
_pokey->MatrixLED[id].columns = cols;
_pokey->MatrixLED[id].displayEnabled = enabled;
_pokey->MatrixLED[id].RefreshFlag = 1;
_pokey->MatrixLED[id].data[0] = 0;
_pokey->MatrixLED[id].data[1] = 0;
_pokey->MatrixLED[id].data[2] = 0;
_pokey->MatrixLED[id].data[3] = 0;
_pokey->MatrixLED[id].data[4] = 0;
_pokey->MatrixLED[id].data[5] = 0;
_pokey->MatrixLED[id].data[6] = 0;
_pokey->MatrixLED[id].data[7] = 0;
int32_t ret = PK_MatrixLEDConfigurationSet(_pokey);
PK_MatrixLEDUpdate(_pokey);
}
void PokeyDevice::configMatrix(int id, uint8_t chipSelect, std::string type, uint8_t enabled, std::string name, std::string description)
{
_pokeyMax7219Manager = std::make_shared<PokeyMAX7219Manager>(_pokey);
if (enabled) {
_pokeyMax7219Manager->addMatrix(id, chipSelect, type, enabled, name, description);
}
}
void PokeyDevice::addLedToLedMatrix(int ledMatrixIndex, uint8_t ledIndex, std::string name, std::string description, uint8_t enabled, uint8_t row, uint8_t col)
{
assert(_pokeyMax7219Manager);
_pokeyMax7219Manager->addLedToMatrix(ledMatrixIndex, ledIndex, name, description, enabled, row, col);
}
uint32_t PokeyDevice::targetValue(std::string targetName, int value)
{
uint8_t displayNum = displayFromName(targetName);
displayNumber(displayNum, targetName, value);
return 0;
}
uint32_t PokeyDevice::targetValue(std::string targetName, bool value)
{
uint32_t retValue = PK_OK;
uint32_t result = PK_OK;
uint8_t pin = pinFromName(targetName) - 1;
if (pin >= 0 && pin <= 55) {
result = PK_DigitalIOSetSingle(_pokey, pin, value);
}
else {
// we have output matrix - so deliver there
_pokeyMax7219Manager->setLedByName(targetName, value);
}
if (result == PK_ERR_TRANSFER) {
printf("----> PK_ERR_TRANSFER pin %d --> %d %d (pokey: %s)\n\n", pin, (uint8_t)value, result, name().c_str());
}
else if (result == PK_ERR_GENERIC) {
printf("----> PK_ERR_GENERIC pin %d --> %d %d (pokey: %s)\n\n", pin, (uint8_t)value, result, name().c_str());
}
else if (result == PK_ERR_PARAMETER) {
printf("----> PK_ERR_PARAMETER pin %d --> %d %d (pokey: %s)\n\n", pin, (uint8_t)value, result, name().c_str());
}
// for now always return succes as we don't want to terminate
// eveinting on setsingle error
return retValue;
}
uint8_t PokeyDevice::displayNumber(uint8_t displayNumber, std::string targetName, int value)
{
int groupIndex = 0;
for (int i = 0; i < MAX_MATRIX_LED_GROUPS; i++) {
if (_matrixLED[displayNumber].group[i].name == targetName) {
groupIndex = i;
}
}
// we should only display +ve values
if (value < -1) {
value = value * -1;
}
std::string charString = std::to_string(value);
int numberOfChars = charString.length();
int groupLength = _matrixLED[displayNumber].group[groupIndex].length;
if (value == 0) {
int position = _matrixLED[displayNumber].group[groupIndex].position;
for (int i = position; i < (groupLength + position); i++) {
_pokey->MatrixLED[displayNumber].data[i] = 0b00000000;
}
_pokey->MatrixLED[displayNumber].data[(position + groupLength) - 1] = _intToDisplayRow[0];
}
if (numberOfChars <= groupLength) {
for (int i = 0; i < numberOfChars; i++) {
int displayOffset = (int)charString.at(i) - 48;
int convertedValue = _intToDisplayRow[displayOffset];
int position = groupIndex + i;
if (value > 0) {
_matrixLED[displayNumber].group[groupIndex].value = convertedValue;
_pokey->MatrixLED[displayNumber].data[position] = convertedValue;
}
else if (value == -1) {
for (int i = groupIndex; i < groupLength + groupIndex; i++) {
_pokey->MatrixLED[displayNumber].data[i] = 0b00000000;
}
}
}
}
_pokey->MatrixLED[displayNumber].RefreshFlag = 1;
int retValue = PK_MatrixLEDUpdate(_pokey);
if (retValue == PK_ERR_TRANSFER) {
printf("----> PK_ERR_TRANSFER %i\n\n", retValue);
}
else if (retValue == PK_ERR_GENERIC) {
printf("----> PK_ERR_GENERIC %i\n\n", retValue);
}
else if (retValue == PK_ERR_PARAMETER) {
printf("----> PK_ERR_PARAMETER pin %i\n\n", retValue);
}
return retValue;
}
int PokeyDevice::configSwitchMatrix(int id, std::string name, std::string type, bool enabled)
{
int retVal = -1;
_switchMatrixManager->addMatrix(id, name, type, enabled);
return retVal;
}
int PokeyDevice::configSwitchMatrixSwitch(int switchMatrixId, int switchId, std::string name, int pin, int enablePin, bool invert, bool invertEnablePin)
{
std::shared_ptr<PokeySwitchMatrix> matrix = _switchMatrixManager->matrix(switchMatrixId);
matrix->addSwitch(switchId, name, pin, enablePin, invert, invertEnablePin);
return 0;
}
int PokeyDevice::configSwitchMatrixVirtualPin(int switchMatrixId, std::string name, bool invert, PinMaskMap &virtualPinMask, std::map<int, std::string> &valueTransforms)
{
std::shared_ptr<PokeySwitchMatrix> matrix = _switchMatrixManager->matrix(switchMatrixId);
matrix->addVirtualPin(name, invert, virtualPinMask, valueTransforms);
return 0;
}
uint32_t PokeyDevice::outputPin(uint8_t pin)
{
_pokey->Pins[--pin].PinFunction = PK_PinCap_digitalOutput | PK_PinCap_invertPin;
return PK_PinConfigurationSet(_pokey);
}
uint32_t PokeyDevice::inputPin(uint8_t pin, bool invert)
{
int pinSetting = PK_PinCap_digitalInput;
if (invert) {
pinSetting = pinSetting | PK_PinCap_invertPin;
}
_pokey->Pins[--pin].PinFunction = pinSetting;
return PK_PinConfigurationSet(_pokey);
}
uint32_t PokeyDevice::inactivePin(uint8_t pin)
{
int pinSetting = PK_PinCap_pinRestricted;
return PK_PinConfigurationSet(_pokey);
}
int32_t PokeyDevice::name(std::string name)
{
strncpy((char *)_pokey->DeviceData.DeviceName, name.c_str(), 30);
return PK_DeviceNameSet(_pokey);
}
uint8_t PokeyDevice::displayFromName(std::string targetName)
{
std::map<std::string, int>::iterator it;
it = _displayMap.find(targetName);
if (it != _displayMap.end()) {
return it->second;
}
else {
printf("---> cant find display\n");
return -1;
}
}
int PokeyDevice::pinIndexFromName(std::string targetName)
{
for (size_t i = 0; i < MAX_PINS; i++) {
if (_pins[i].pinName == targetName) {
return _pins[i].pinIndex;
}
}
return -1;
}
int PokeyDevice::pinFromName(std::string targetName)
{
std::map<std::string, int>::iterator it;
it = _pinMap.find(targetName);
if (it != _pinMap.end()) {
return it->second;
}
else
return -1;
}
void PokeyDevice::mapNameToPin(std::string name, int pin)
{
_pinMap.emplace(name, pin);
}
void PokeyDevice::mapNameToEncoder(std::string name, int encoderNumber)
{
_encoderMap.emplace(name, encoderNumber);
}
void PokeyDevice::mapNameToMatrixLED(std::string name, int id)
{
_displayMap.emplace(name, id);
}
bool PokeyDevice::isPinDigitalOutput(uint8_t pin)
{
return (bool)PK_CheckPinCapability(_pokey, pin, PK_AllPinCap_digitalOutput);
}
bool PokeyDevice::isPinDigitalInput(uint8_t pin)
{
return (bool)PK_CheckPinCapability(_pokey, pin, PK_AllPinCap_digitalInput);
}
| 33.972296
| 174
| 0.597841
|
mteichtahl
|
1f685bfe9060adfa2833fb81f48d6f6b2ca4fb54
| 421
|
hpp
|
C++
|
src/serialization/spatial.hpp
|
thanhndv212/pinocchio
|
3b4d272bf4e8a231954b71201ee7e0963c944aef
|
[
"BSD-2-Clause-FreeBSD"
] | 716
|
2015-03-30T16:26:45.000Z
|
2022-03-30T12:26:58.000Z
|
src/serialization/spatial.hpp
|
thanhndv212/pinocchio
|
3b4d272bf4e8a231954b71201ee7e0963c944aef
|
[
"BSD-2-Clause-FreeBSD"
] | 1,130
|
2015-02-21T17:30:44.000Z
|
2022-03-30T09:06:22.000Z
|
src/serialization/spatial.hpp
|
thanhndv212/pinocchio
|
3b4d272bf4e8a231954b71201ee7e0963c944aef
|
[
"BSD-2-Clause-FreeBSD"
] | 239
|
2015-02-05T14:15:14.000Z
|
2022-03-14T23:51:47.000Z
|
//
// Copyright (c) 2019 INRIA
//
#ifndef __pinocchio_serialization_spatial_hpp__
#define __pinocchio_serialization_spatial_hpp__
#include "pinocchio/serialization/se3.hpp"
#include "pinocchio/serialization/motion.hpp"
#include "pinocchio/serialization/force.hpp"
#include "pinocchio/serialization/symmetric3.hpp"
#include "pinocchio/serialization/inertia.hpp"
#endif // ifndef __pinocchio_serialization_spatial_hpp__
| 28.066667
| 56
| 0.831354
|
thanhndv212
|
1f6ad8649c57098ed589225627b04f177fad1348
| 12,610
|
cc
|
C++
|
wrappers/7.0.0/vtkUniformGridAMRDataIteratorWrap.cc
|
axkibe/node-vtk
|
900ad7b5500f672519da5aa24c99aa5a96466ef3
|
[
"BSD-3-Clause"
] | 6
|
2016-02-03T12:48:36.000Z
|
2020-09-16T15:07:51.000Z
|
wrappers/7.0.0/vtkUniformGridAMRDataIteratorWrap.cc
|
axkibe/node-vtk
|
900ad7b5500f672519da5aa24c99aa5a96466ef3
|
[
"BSD-3-Clause"
] | 4
|
2016-02-13T01:30:43.000Z
|
2020-03-30T16:59:32.000Z
|
wrappers/7.0.0/vtkUniformGridAMRDataIteratorWrap.cc
|
axkibe/node-vtk
|
900ad7b5500f672519da5aa24c99aa5a96466ef3
|
[
"BSD-3-Clause"
] | null | null | null |
/* this file has been autogenerated by vtkNodeJsWrap */
/* editing this might proof futile */
#define VTK_WRAPPING_CXX
#define VTK_STREAMS_FWD_ONLY
#include <nan.h>
#include "vtkCompositeDataIteratorWrap.h"
#include "vtkUniformGridAMRDataIteratorWrap.h"
#include "vtkObjectWrap.h"
#include "vtkInformationWrap.h"
#include "vtkDataObjectWrap.h"
#include "../../plus/plus.h"
using namespace v8;
extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap;
Nan::Persistent<v8::FunctionTemplate> VtkUniformGridAMRDataIteratorWrap::ptpl;
VtkUniformGridAMRDataIteratorWrap::VtkUniformGridAMRDataIteratorWrap()
{ }
VtkUniformGridAMRDataIteratorWrap::VtkUniformGridAMRDataIteratorWrap(vtkSmartPointer<vtkUniformGridAMRDataIterator> _native)
{ native = _native; }
VtkUniformGridAMRDataIteratorWrap::~VtkUniformGridAMRDataIteratorWrap()
{ }
void VtkUniformGridAMRDataIteratorWrap::Init(v8::Local<v8::Object> exports)
{
Nan::SetAccessor(exports, Nan::New("vtkUniformGridAMRDataIterator").ToLocalChecked(), ConstructorGetter);
Nan::SetAccessor(exports, Nan::New("UniformGridAMRDataIterator").ToLocalChecked(), ConstructorGetter);
}
void VtkUniformGridAMRDataIteratorWrap::ConstructorGetter(
v8::Local<v8::String> property,
const Nan::PropertyCallbackInfo<v8::Value>& info)
{
InitPtpl();
info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction());
}
void VtkUniformGridAMRDataIteratorWrap::InitPtpl()
{
if (!ptpl.IsEmpty()) return;
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
VtkCompositeDataIteratorWrap::InitPtpl( );
tpl->Inherit(Nan::New<FunctionTemplate>(VtkCompositeDataIteratorWrap::ptpl));
tpl->SetClassName(Nan::New("VtkUniformGridAMRDataIteratorWrap").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
Nan::SetPrototypeMethod(tpl, "GetClassName", GetClassName);
Nan::SetPrototypeMethod(tpl, "getClassName", GetClassName);
Nan::SetPrototypeMethod(tpl, "GetCurrentDataObject", GetCurrentDataObject);
Nan::SetPrototypeMethod(tpl, "getCurrentDataObject", GetCurrentDataObject);
Nan::SetPrototypeMethod(tpl, "GetCurrentFlatIndex", GetCurrentFlatIndex);
Nan::SetPrototypeMethod(tpl, "getCurrentFlatIndex", GetCurrentFlatIndex);
Nan::SetPrototypeMethod(tpl, "GetCurrentIndex", GetCurrentIndex);
Nan::SetPrototypeMethod(tpl, "getCurrentIndex", GetCurrentIndex);
Nan::SetPrototypeMethod(tpl, "GetCurrentLevel", GetCurrentLevel);
Nan::SetPrototypeMethod(tpl, "getCurrentLevel", GetCurrentLevel);
Nan::SetPrototypeMethod(tpl, "GetCurrentMetaData", GetCurrentMetaData);
Nan::SetPrototypeMethod(tpl, "getCurrentMetaData", GetCurrentMetaData);
Nan::SetPrototypeMethod(tpl, "GoToFirstItem", GoToFirstItem);
Nan::SetPrototypeMethod(tpl, "goToFirstItem", GoToFirstItem);
Nan::SetPrototypeMethod(tpl, "GoToNextItem", GoToNextItem);
Nan::SetPrototypeMethod(tpl, "goToNextItem", GoToNextItem);
Nan::SetPrototypeMethod(tpl, "HasCurrentMetaData", HasCurrentMetaData);
Nan::SetPrototypeMethod(tpl, "hasCurrentMetaData", HasCurrentMetaData);
Nan::SetPrototypeMethod(tpl, "IsA", IsA);
Nan::SetPrototypeMethod(tpl, "isA", IsA);
Nan::SetPrototypeMethod(tpl, "IsDoneWithTraversal", IsDoneWithTraversal);
Nan::SetPrototypeMethod(tpl, "isDoneWithTraversal", IsDoneWithTraversal);
Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance);
Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance);
Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast);
Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast);
#ifdef VTK_NODE_PLUS_VTKUNIFORMGRIDAMRDATAITERATORWRAP_INITPTPL
VTK_NODE_PLUS_VTKUNIFORMGRIDAMRDATAITERATORWRAP_INITPTPL
#endif
ptpl.Reset( tpl );
}
void VtkUniformGridAMRDataIteratorWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
if(!info.IsConstructCall())
{
Nan::ThrowError("Constructor not called in a construct call.");
return;
}
if(info.Length() == 0)
{
vtkSmartPointer<vtkUniformGridAMRDataIterator> native = vtkSmartPointer<vtkUniformGridAMRDataIterator>::New();
VtkUniformGridAMRDataIteratorWrap* obj = new VtkUniformGridAMRDataIteratorWrap(native);
obj->Wrap(info.This());
}
else
{
if(info[0]->ToObject() != vtkNodeJsNoWrap )
{
Nan::ThrowError("Parameter Error");
return;
}
}
info.GetReturnValue().Set(info.This());
}
void VtkUniformGridAMRDataIteratorWrap::GetClassName(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
char const * r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->GetClassName();
info.GetReturnValue().Set(Nan::New(r).ToLocalChecked());
}
void VtkUniformGridAMRDataIteratorWrap::GetCurrentDataObject(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
vtkDataObject * r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->GetCurrentDataObject();
VtkDataObjectWrap::InitPtpl();
v8::Local<v8::Value> argv[1] =
{ Nan::New(vtkNodeJsNoWrap) };
v8::Local<v8::Function> cons =
Nan::New<v8::FunctionTemplate>(VtkDataObjectWrap::ptpl)->GetFunction();
v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
VtkDataObjectWrap *w = new VtkDataObjectWrap();
w->native = r;
w->Wrap(wo);
info.GetReturnValue().Set(wo);
}
void VtkUniformGridAMRDataIteratorWrap::GetCurrentFlatIndex(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
unsigned int r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->GetCurrentFlatIndex();
info.GetReturnValue().Set(Nan::New(r));
}
void VtkUniformGridAMRDataIteratorWrap::GetCurrentIndex(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
unsigned int r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->GetCurrentIndex();
info.GetReturnValue().Set(Nan::New(r));
}
void VtkUniformGridAMRDataIteratorWrap::GetCurrentLevel(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
unsigned int r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->GetCurrentLevel();
info.GetReturnValue().Set(Nan::New(r));
}
void VtkUniformGridAMRDataIteratorWrap::GetCurrentMetaData(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
vtkInformation * r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->GetCurrentMetaData();
VtkInformationWrap::InitPtpl();
v8::Local<v8::Value> argv[1] =
{ Nan::New(vtkNodeJsNoWrap) };
v8::Local<v8::Function> cons =
Nan::New<v8::FunctionTemplate>(VtkInformationWrap::ptpl)->GetFunction();
v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
VtkInformationWrap *w = new VtkInformationWrap();
w->native = r;
w->Wrap(wo);
info.GetReturnValue().Set(wo);
}
void VtkUniformGridAMRDataIteratorWrap::GoToFirstItem(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
native->GoToFirstItem();
}
void VtkUniformGridAMRDataIteratorWrap::GoToNextItem(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
native->GoToNextItem();
}
void VtkUniformGridAMRDataIteratorWrap::HasCurrentMetaData(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
int r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->HasCurrentMetaData();
info.GetReturnValue().Set(Nan::New(r));
}
void VtkUniformGridAMRDataIteratorWrap::IsA(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
if(info.Length() > 0 && info[0]->IsString())
{
Nan::Utf8String a0(info[0]);
int r;
if(info.Length() != 1)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->IsA(
*a0
);
info.GetReturnValue().Set(Nan::New(r));
return;
}
Nan::ThrowError("Parameter mismatch");
}
void VtkUniformGridAMRDataIteratorWrap::IsDoneWithTraversal(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
int r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->IsDoneWithTraversal();
info.GetReturnValue().Set(Nan::New(r));
}
void VtkUniformGridAMRDataIteratorWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
vtkUniformGridAMRDataIterator * r;
if(info.Length() != 0)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->NewInstance();
VtkUniformGridAMRDataIteratorWrap::InitPtpl();
v8::Local<v8::Value> argv[1] =
{ Nan::New(vtkNodeJsNoWrap) };
v8::Local<v8::Function> cons =
Nan::New<v8::FunctionTemplate>(VtkUniformGridAMRDataIteratorWrap::ptpl)->GetFunction();
v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
VtkUniformGridAMRDataIteratorWrap *w = new VtkUniformGridAMRDataIteratorWrap();
w->native = r;
w->Wrap(wo);
info.GetReturnValue().Set(wo);
}
void VtkUniformGridAMRDataIteratorWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
VtkUniformGridAMRDataIteratorWrap *wrapper = ObjectWrap::Unwrap<VtkUniformGridAMRDataIteratorWrap>(info.Holder());
vtkUniformGridAMRDataIterator *native = (vtkUniformGridAMRDataIterator *)wrapper->native.GetPointer();
if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectWrap::ptpl))->HasInstance(info[0]))
{
VtkObjectWrap *a0 = ObjectWrap::Unwrap<VtkObjectWrap>(info[0]->ToObject());
vtkUniformGridAMRDataIterator * r;
if(info.Length() != 1)
{
Nan::ThrowError("Too many parameters.");
return;
}
r = native->SafeDownCast(
(vtkObject *) a0->native.GetPointer()
);
VtkUniformGridAMRDataIteratorWrap::InitPtpl();
v8::Local<v8::Value> argv[1] =
{ Nan::New(vtkNodeJsNoWrap) };
v8::Local<v8::Function> cons =
Nan::New<v8::FunctionTemplate>(VtkUniformGridAMRDataIteratorWrap::ptpl)->GetFunction();
v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
VtkUniformGridAMRDataIteratorWrap *w = new VtkUniformGridAMRDataIteratorWrap();
w->native = r;
w->Wrap(wo);
info.GetReturnValue().Set(wo);
return;
}
Nan::ThrowError("Parameter mismatch");
}
| 35.72238
| 124
| 0.765583
|
axkibe
|
1f6d1c213f0ae2f58da5b768a4b9c8c9b8aeab83
| 1,204
|
cpp
|
C++
|
Greed-is-Good.cpp
|
EdvinAlvarado/Code-Wars
|
a3a06a44cda004052b5c0930f3693678c5c92e21
|
[
"BSD-2-Clause"
] | null | null | null |
Greed-is-Good.cpp
|
EdvinAlvarado/Code-Wars
|
a3a06a44cda004052b5c0930f3693678c5c92e21
|
[
"BSD-2-Clause"
] | null | null | null |
Greed-is-Good.cpp
|
EdvinAlvarado/Code-Wars
|
a3a06a44cda004052b5c0930f3693678c5c92e21
|
[
"BSD-2-Clause"
] | null | null | null |
#include <vector>
#include <map>
#include <iostream>
int score(const std::vector<int>& dice) {
std::map<int,int> dvalue_counter;
int result = 0;
for (const int& dvalue: dice) {
std::cout << dvalue << " ";
dvalue_counter[dvalue]++;
}
for (auto it = dvalue_counter.begin(); it != dvalue_counter.end(); it++) {
// std::cout << it->first << "\t" << it->second << std::endl;
if (it->second == 3) {
if (it->first == 1) {
result += 1000;
dvalue_counter[it->first] -= 3;
} else if (it->first == 6) {
result += 600;
// dvalue_counter[it->first] -= 3;
} else if (it->first == 5) {
result += 500;
dvalue_counter[it->first] -= 3;
} else if (it->first == 4) {
result += 400;
// dvalue_counter[it->first] -= 3;
} else if (it->first == 3) {
result += 300;
// dvalue_counter[it->first] -= 3;
} else if (it->first == 2) {
result += 200;
// dvalue_counter[it->first] -= 3;
}
}
if (it->first == 1) {
result += it->second * 100;
} else if (it->first == 5) {
result += it->second * 50;
}
}
return result;
}
int main() {
const std::vector<int> dice_throws = {3, 3, 3, 3, 3};
std::cout << score(dice_throws) << std::endl;
}
| 25.083333
| 75
| 0.542359
|
EdvinAlvarado
|
1f718d971c81e0fdf3cf645269132c27308f8042
| 20,284
|
cpp
|
C++
|
silkopter/fc/src/simulator/Multirotor_Simulator.cpp
|
jeanleflambeur/silkopter
|
cdbc67ee2c85f5c95eb4f52e2e0ba24514962dd8
|
[
"BSD-3-Clause"
] | 36
|
2015-03-09T16:47:14.000Z
|
2021-02-04T08:32:04.000Z
|
silkopter/fc/src/simulator/Multirotor_Simulator.cpp
|
jeanlemotan/silkopter
|
cdbc67ee2c85f5c95eb4f52e2e0ba24514962dd8
|
[
"BSD-3-Clause"
] | 42
|
2017-02-11T11:15:51.000Z
|
2019-12-28T16:00:44.000Z
|
silkopter/fc/src/simulator/Multirotor_Simulator.cpp
|
jeanleflambeur/silkopter
|
cdbc67ee2c85f5c95eb4f52e2e0ba24514962dd8
|
[
"BSD-3-Clause"
] | 5
|
2015-10-15T05:46:48.000Z
|
2020-05-11T17:40:36.000Z
|
#include "FCStdAfx.h"
#include "Multirotor_Simulator.h"
#include "uav_properties/IMultirotor_Properties.h"
#include "hal.def.h"
#include "messages.def.h"
//#include "sz_Multirotor_Simulator.hpp"
//#include "sz_Multirotor_Simulator_Structs.hpp"
namespace silk
{
namespace node
{
Multirotor_Simulator::Multirotor_Simulator(HAL& hal)
: m_hal(hal)
, m_descriptor(new hal::Multirotor_Simulator_Descriptor())
, m_config(new hal::Multirotor_Simulator_Config())
{
m_angular_velocity_stream = std::make_shared<Angular_Velocity>();
m_acceleration_stream = std::make_shared<Acceleration>();
m_magnetic_field_stream = std::make_shared<Magnetic_Field>();
m_pressure_stream = std::make_shared<Pressure>();
m_temperature_stream = std::make_shared<Temperature>();
m_distance_stream = std::make_shared<Distance>();
m_gps_info_stream = std::make_shared<GPS_Info>();
m_ecef_position_stream = std::make_shared<ECEF_Position>();
m_ecef_velocity_stream = std::make_shared<ECEF_Velocity>();
m_simulator_state_stream = std::make_shared<Simulator_State_Stream>();
}
ts::Result<void> Multirotor_Simulator::init(hal::INode_Descriptor const& descriptor)
{
QLOG_TOPIC("multirotor_simulator::init");
auto specialized = dynamic_cast<hal::Multirotor_Simulator_Descriptor const*>(&descriptor);
if (!specialized)
{
return make_error("Wrong descriptor type");
}
*m_descriptor = *specialized;
return init();
}
ts::Result<void> Multirotor_Simulator::init()
{
std::shared_ptr<const IMultirotor_Properties> multirotor_properties = m_hal.get_specialized_uav_properties<IMultirotor_Properties>();
if (!multirotor_properties)
{
return make_error("No multi properties found");
}
if (!m_simulation.init(1000))
{
return make_error("Cannot initialize simulator world");
}
if (!m_simulation.init_uav(multirotor_properties))
{
return make_error("Cannot initialize UAV simulator");
}
m_input_throttle_streams.resize(multirotor_properties->get_motors().size());
m_input_throttle_stream_paths.resize(multirotor_properties->get_motors().size());
m_angular_velocity_stream->rate = m_descriptor->get_angular_velocity_rate();
m_angular_velocity_stream->dt = std::chrono::microseconds(1000000 / m_angular_velocity_stream->rate);
m_acceleration_stream->rate = m_descriptor->get_acceleration_rate();
m_acceleration_stream->dt = std::chrono::microseconds(1000000 / m_acceleration_stream->rate);
m_magnetic_field_stream->rate = m_descriptor->get_magnetic_field_rate();
m_magnetic_field_stream->dt = std::chrono::microseconds(1000000 / m_magnetic_field_stream->rate);
m_pressure_stream->rate = m_descriptor->get_pressure_rate();
m_pressure_stream->dt = std::chrono::microseconds(1000000 / m_pressure_stream->rate);
m_temperature_stream->rate = m_descriptor->get_temperature_rate();
m_temperature_stream->dt = std::chrono::microseconds(1000000 / m_temperature_stream->rate);
m_distance_stream->rate = m_descriptor->get_distance_rate();
m_distance_stream->dt = std::chrono::microseconds(1000000 / m_distance_stream->rate);
m_gps_info_stream->rate = m_descriptor->get_gps_rate();
m_gps_info_stream->dt = std::chrono::microseconds(1000000 / m_gps_info_stream->rate);
m_ecef_position_stream->rate = m_descriptor->get_gps_rate();
m_ecef_position_stream->dt = std::chrono::microseconds(1000000 / m_ecef_position_stream->rate);
m_ecef_velocity_stream->rate = m_descriptor->get_gps_rate();
m_ecef_velocity_stream->dt = std::chrono::microseconds(1000000 / m_ecef_velocity_stream->rate);
m_simulator_state_stream->set_rate(30);
return ts::success;
}
ts::Result<void> Multirotor_Simulator::start(Clock::time_point tp)
{
m_last_tp = tp;
m_simulator_state_stream->set_tp(tp);
return ts::success;
}
std::vector<INode::Input> Multirotor_Simulator::get_inputs() const
{
std::vector<Input> inputs(m_input_throttle_streams.size() + 1);
for (size_t i = 0; i < m_input_throttle_streams.size(); i++)
{
inputs[i].type = stream::IThrottle::TYPE;
inputs[i].rate = m_descriptor->get_throttle_rate();
inputs[i].name = q::util::format<std::string>("throttle_{}", i);
inputs[i].stream_path = m_input_throttle_stream_paths[i];
}
inputs.back().type = stream::IMultirotor_State::TYPE;
inputs.back().rate = m_descriptor->get_state_rate();
inputs.back().name = "state";
inputs.back().stream_path = m_input_state_stream_path;
return inputs;
}
std::vector<INode::Output> Multirotor_Simulator::get_outputs() const
{
std::vector<Output> outputs =
{
{"angular_velocity", m_angular_velocity_stream},
{"acceleration", m_acceleration_stream},
{"magnetic_field", m_magnetic_field_stream},
{"pressure", m_pressure_stream},
{"temperature", m_temperature_stream},
{"sonar_distance", m_distance_stream},
{"gps_info", m_gps_info_stream},
{"gps_position", m_ecef_position_stream},
{"gps_velocity", m_ecef_velocity_stream},
{"simulator_state", m_simulator_state_stream},
};
return outputs;
}
void Multirotor_Simulator::process()
{
QLOG_TOPIC("multirotor_simulator::process");
m_angular_velocity_stream->samples.clear();
m_acceleration_stream->samples.clear();
m_magnetic_field_stream->samples.clear();
m_pressure_stream->samples.clear();
m_temperature_stream->samples.clear();
m_distance_stream->samples.clear();
m_gps_info_stream->samples.clear();
m_ecef_position_stream->samples.clear();
m_ecef_velocity_stream->samples.clear();
m_simulator_state_stream->clear();
for (size_t i = 0; i < m_input_throttle_streams.size(); i++)
{
std::shared_ptr<stream::IThrottle> stream = m_input_throttle_streams[i].lock();
if (stream)
{
std::vector<stream::IThrottle::Sample> const& samples = stream->get_samples();
if (!samples.empty())
{
m_simulation.set_motor_throttle(i, samples.back().value);
}
}
}
{
std::shared_ptr<stream::IMultirotor_State> stream = m_input_state_stream.lock();
if (stream)
{
std::vector<stream::IMultirotor_State::Sample> const& samples = stream->get_samples();
if (!samples.empty())
{
m_multirotor_state = samples.back().value;
}
}
}
Clock::time_point now = Clock::now();
Clock::duration dt = now - m_last_tp;
if (dt < std::chrono::milliseconds(1))
{
return;
}
m_last_tp = now;
static const util::coordinates::LLA origin_lla(math::radians(41.390205), math::radians(2.154007), 37.5);
math::trans3dd enu_to_ecef_trans = util::coordinates::enu_to_ecef_transform(origin_lla);
math::mat3d enu_to_ecef_rotation = util::coordinates::enu_to_ecef_rotation(origin_lla);
m_simulation.process(dt, [this, &enu_to_ecef_trans, &enu_to_ecef_rotation](Multirotor_Simulation& simulation, Clock::duration simulation_dt)
{
Multirotor_Simulation::State const& uav_state = simulation.get_state();
{
Angular_Velocity& stream = *m_angular_velocity_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
math::vec3f noise(m_noise.angular_velocity(m_noise.generator), m_noise.angular_velocity(m_noise.generator), m_noise.angular_velocity(m_noise.generator));
stream.accumulated_dt -= stream.dt;
stream.last_sample.value = uav_state.angular_velocity + noise;
stream.last_sample.is_healthy = true;
stream.samples.push_back(stream.last_sample);
}
}
{
Acceleration& stream = *m_acceleration_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
math::vec3f noise(m_noise.acceleration(m_noise.generator), m_noise.acceleration(m_noise.generator), m_noise.acceleration(m_noise.generator));
stream.accumulated_dt -= stream.dt;
stream.last_sample.value = uav_state.acceleration + noise;
stream.last_sample.is_healthy = true;
stream.samples.push_back(stream.last_sample);
}
}
{
Magnetic_Field& stream = *m_magnetic_field_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
math::vec3f noise(m_noise.magnetic_field(m_noise.generator), m_noise.magnetic_field(m_noise.generator), m_noise.magnetic_field(m_noise.generator));
stream.accumulated_dt -= stream.dt;
QASSERT(math::is_finite(uav_state.magnetic_field));
QASSERT(!math::is_zero(uav_state.magnetic_field, math::epsilon<float>()));
stream.last_sample.value = uav_state.magnetic_field + noise;
stream.last_sample.is_healthy = true;
stream.samples.push_back(stream.last_sample);
}
}
{
Pressure& stream = *m_pressure_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
double noise = m_noise.pressure(m_noise.generator);
stream.accumulated_dt -= stream.dt;
stream.last_sample.value = uav_state.pressure + noise;
stream.last_sample.is_healthy = true;
stream.samples.push_back(stream.last_sample);
}
}
{
Temperature& stream = *m_temperature_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
float noise = m_noise.temperature(m_noise.generator);
stream.accumulated_dt -= stream.dt;
stream.last_sample.value = uav_state.temperature + noise;
stream.last_sample.is_healthy = true;
stream.samples.push_back(stream.last_sample);
}
}
{
Distance& stream = *m_distance_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
float noise = m_noise.ground_distance(m_noise.generator);
stream.accumulated_dt -= stream.dt;
stream.last_sample.value = uav_state.proximity_distance + noise;
stream.last_sample.is_healthy = !math::is_zero(uav_state.proximity_distance, std::numeric_limits<float>::epsilon());
stream.samples.push_back(stream.last_sample);
}
}
{
GPS_Info& stream = *m_gps_info_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
stream.accumulated_dt -= stream.dt;
stream.last_sample.value.fix = stream::IGPS_Info::Value::Fix::FIX_3D;
stream.last_sample.value.visible_satellites = 4;
stream.last_sample.value.fix_satellites = 4;
stream.last_sample.value.pacc = m_noise.gps_pacc(m_noise.generator);
stream.last_sample.value.vacc = m_noise.gps_vacc(m_noise.generator);
stream.last_sample.is_healthy = true;
stream.samples.push_back(stream.last_sample);
}
}
{
ECEF_Position& stream = *m_ecef_position_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
math::vec3d noise(m_noise.gps_position(m_noise.generator), m_noise.gps_position(m_noise.generator), m_noise.gps_position(m_noise.generator));
stream.accumulated_dt -= stream.dt;
stream.last_sample.value = math::transform(enu_to_ecef_trans, math::vec3d(uav_state.enu_position)) + noise;
stream.last_sample.is_healthy = true;
stream.samples.push_back(stream.last_sample);
}
}
{
ECEF_Velocity& stream = *m_ecef_velocity_stream;
stream.accumulated_dt += simulation_dt;
while (stream.accumulated_dt >= stream.dt)
{
math::vec3f noise(m_noise.gps_velocity(m_noise.generator), m_noise.gps_velocity(m_noise.generator), m_noise.gps_velocity(m_noise.generator));
stream.accumulated_dt -= stream.dt;
stream.last_sample.value = math::vec3f(math::transform(enu_to_ecef_rotation, math::vec3d(uav_state.enu_velocity))) + noise;
stream.last_sample.is_healthy = true;
stream.samples.push_back(stream.last_sample);
}
}
});
{
size_t samples_needed = m_simulator_state_stream->compute_samples_needed();
Multirotor_Simulation::State simulation_state = m_simulation.get_state();
simulation_state.multirotor_state = m_multirotor_state;
for (size_t i = 0; i < samples_needed; i++)
{
m_simulator_state_stream->push_sample(simulation_state, true);
}
}
}
ts::Result<void> Multirotor_Simulator::set_input_stream_path(size_t idx, std::string const& path)
{
if (idx < m_input_throttle_streams.size())
{
m_input_throttle_streams[idx].reset();
m_input_throttle_stream_paths[idx].clear();
if (!path.empty())
{
std::shared_ptr<stream::IThrottle> input_stream = m_hal.get_stream_registry().find_by_name<stream::IThrottle>(path);
if (input_stream)
{
uint32_t rate = input_stream->get_rate();
if (rate != m_descriptor->get_throttle_rate())
{
return make_error("Bad input stream '{}'. Expected rate {}Hz, got {}Hz", path, m_descriptor->get_throttle_rate(), rate);
}
else
{
m_input_throttle_streams[idx] = input_stream;
m_input_throttle_stream_paths[idx] = path;
}
}
else
{
return make_error("Cannot find stream '{}'", path);
}
}
}
else
{
m_input_state_stream.reset();
m_input_state_stream_path.clear();
if (!path.empty())
{
std::shared_ptr<stream::IMultirotor_State> input_stream = m_hal.get_stream_registry().find_by_name<stream::IMultirotor_State>(path);
if (input_stream)
{
uint32_t rate = input_stream->get_rate();
if (rate != m_descriptor->get_state_rate())
{
return make_error("Bad input stream '{}'. Expected rate {}Hz, got {}Hz", path, m_descriptor->get_state_rate(), rate);
}
else
{
m_input_state_stream = input_stream;
m_input_state_stream_path = path;
}
}
else
{
return make_error("Cannot find stream '{}'", path);
}
}
}
return ts::success;
}
ts::Result<void> Multirotor_Simulator::set_config(hal::INode_Config const& config)
{
QLOG_TOPIC("multirotor_simulator::set_config");
auto specialized = dynamic_cast<hal::Multirotor_Simulator_Config const*>(&config);
if (!specialized)
{
return make_error("Wrong config type");
}
// Simulation::UAV_Config uav_config;
// uav_config.mass = sz.uav.mass;
// uav_config.radius = sz.uav.radius;
// uav_config.height = sz.uav.height;
// uav_config.motors.resize(sz.motors.size());
// for (size_t i = 0; i < uav_config.motors.size(); i++)
// {
// uav_config.motors[i].position = sz.motors[i].position;
// uav_config.motors[i].clockwise = sz.motors[i].clockwise;
// uav_config.motors[i].max_thrust = sz.motors[i].max_thrust;
// uav_config.motors[i].max_rpm = sz.motors[i].max_rpm;
// uav_config.motors[i].acceleration = sz.motors[i].acceleration;
// uav_config.motors[i].deceleration = sz.motors[i].deceleration;
// }
std::shared_ptr<const IMultirotor_Properties> multirotor_properties = m_hal.get_specialized_uav_properties<IMultirotor_Properties>();
if (!multirotor_properties)
{
return make_error("No multi properties found");
}
if (!m_simulation.init_uav(multirotor_properties))
{
return make_error("Cannot configure UAV simulator");
}
*m_config = *specialized;
m_simulation.set_gravity_enabled(m_config->get_gravity_enabled());
m_simulation.set_ground_enabled(m_config->get_ground_enabled());
m_simulation.set_drag_enabled(m_config->get_drag_enabled());
m_simulation.set_simulation_enabled(m_config->get_simulation_enabled());
auto const& noise = m_config->get_noise();
m_noise.gps_position = Noise::Distribution<float>(-noise.get_gps_position()*0.5f, noise.get_gps_position()*0.5f);
m_noise.gps_velocity = Noise::Distribution<float>(-noise.get_gps_velocity()*0.5f, noise.get_gps_velocity()*0.5f);
m_noise.gps_pacc = Noise::Distribution<float>(-noise.get_gps_pacc()*0.5f, noise.get_gps_pacc()*0.5f);
m_noise.gps_vacc = Noise::Distribution<float>(-noise.get_gps_vacc()*0.5f, noise.get_gps_vacc()*0.5f);
m_noise.acceleration = Noise::Distribution<float>(-noise.get_acceleration()*0.5f, noise.get_acceleration()*0.5f);
m_noise.angular_velocity = Noise::Distribution<float>(-noise.get_angular_velocity()*0.5f, noise.get_angular_velocity()*0.5f);
m_noise.magnetic_field = Noise::Distribution<float>(-noise.get_magnetic_field()*0.5f, noise.get_magnetic_field()*0.5f);
m_noise.pressure = Noise::Distribution<float>(-noise.get_pressure()*0.5f, noise.get_pressure()*0.5f);
m_noise.temperature = Noise::Distribution<float>(-noise.get_temperature()*0.5f, noise.get_temperature()*0.5f);
m_noise.ground_distance = Noise::Distribution<float>(-noise.get_ground_distance()*0.5f, noise.get_ground_distance()*0.5f);
return ts::success;
}
std::shared_ptr<const hal::INode_Config> Multirotor_Simulator::get_config() const
{
return m_config;
}
std::shared_ptr<const hal::INode_Descriptor> Multirotor_Simulator::get_descriptor() const
{
return m_descriptor;
}
ts::Result<std::shared_ptr<messages::INode_Message>> Multirotor_Simulator::send_message(messages::INode_Message const& _message)
{
if (dynamic_cast<messages::Multirotor_Simulator_Reset_Message const*>(&_message))
{
m_simulation.reset();
return nullptr;
}
else if (dynamic_cast<messages::Multirotor_Simulator_Stop_Motion_Message const*>(&_message))
{
m_simulation.stop_motion();
return nullptr;
}
else if (messages::Multirotor_Simulator_Set_Gravity_Enabled_Message const* message = dynamic_cast<messages::Multirotor_Simulator_Set_Gravity_Enabled_Message const*>(&_message))
{
m_simulation.set_gravity_enabled(message->get_enabled());
return nullptr;
}
else if (messages::Multirotor_Simulator_Set_Ground_Enabled_Message const* message = dynamic_cast<messages::Multirotor_Simulator_Set_Ground_Enabled_Message const*>(&_message))
{
m_simulation.set_ground_enabled(message->get_enabled());
return nullptr;
}
else if (messages::Multirotor_Simulator_Set_Simulation_Enabled_Message const* message = dynamic_cast<messages::Multirotor_Simulator_Set_Simulation_Enabled_Message const*>(&_message))
{
m_simulation.set_simulation_enabled(message->get_enabled());
return nullptr;
}
else if (messages::Multirotor_Simulator_Set_Drag_Enabled_Message const* message = dynamic_cast<messages::Multirotor_Simulator_Set_Drag_Enabled_Message const*>(&_message))
{
m_simulation.set_drag_enabled(message->get_enabled());
return nullptr;
}
else
{
return make_error("Unknown message");
}
}
}
}
| 41.650924
| 186
| 0.659288
|
jeanleflambeur
|
1f76750029ddeb8f5cbc496a2c559c72fafceb3d
| 452
|
hpp
|
C++
|
cpp-projects/nodes/nodes/ConnectionPainter.hpp
|
FlorianLance/toolbox
|
87882a14ec86852d90527c81475b451b9f6e12cf
|
[
"MIT"
] | null | null | null |
cpp-projects/nodes/nodes/ConnectionPainter.hpp
|
FlorianLance/toolbox
|
87882a14ec86852d90527c81475b451b9f6e12cf
|
[
"MIT"
] | null | null | null |
cpp-projects/nodes/nodes/ConnectionPainter.hpp
|
FlorianLance/toolbox
|
87882a14ec86852d90527c81475b451b9f6e12cf
|
[
"MIT"
] | 1
|
2021-07-06T14:47:41.000Z
|
2021-07-06T14:47:41.000Z
|
#pragma once
// Qt
#include <QtGui/QPainter>
#include <QIcon>
namespace QtNodes{
class ConnectionGeometry;
class ConnectionState;
class Connection;
class ConnectionPainter{
public:
static void paint(QPainter* painter, Connection const& connection);
static QPainterPath getPainterStroke(ConnectionGeometry const& geom);
static inline QIcon icon = QIcon(":convert.png");
static inline std::unique_ptr<QPixmap> pixmap = nullptr;
};
}
| 20.545455
| 73
| 0.75885
|
FlorianLance
|
1f7774d46f44223449aabf9c5a31c523abc5ae16
| 27,947
|
cpp
|
C++
|
EncodePNG/main.cpp
|
cdyk/debris
|
cb820b54f5d541d18fb9c3058afbe0dd7670da8b
|
[
"MIT"
] | null | null | null |
EncodePNG/main.cpp
|
cdyk/debris
|
cb820b54f5d541d18fb9c3058afbe0dd7670da8b
|
[
"MIT"
] | null | null | null |
EncodePNG/main.cpp
|
cdyk/debris
|
cb820b54f5d541d18fb9c3058afbe0dd7670da8b
|
[
"MIT"
] | null | null | null |
#if 0
// FIXME: add zlib dependency.
#include <vector>
#include <zlib.h>
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <stdexcept>
#include <time.h>
#include <xmmintrin.h>
#include <smmintrin.h>
#define WIDTH 1024 //6
#define HEIGHT 768
class TimeStamp
{
public:
TimeStamp()
{
clock_gettime(CLOCK_MONOTONIC, &m_time);
}
static
double
delta(const TimeStamp& start, const TimeStamp& stop)
{
timespec delta;
if ((stop.m_time.tv_nsec - start.m_time.tv_nsec) < 0) {
delta.tv_sec = stop.m_time.tv_sec - start.m_time.tv_sec - 1;
delta.tv_nsec = 1000000000 + stop.m_time.tv_nsec - start.m_time.tv_nsec;
}
else {
delta.tv_sec = stop.m_time.tv_sec - start.m_time.tv_sec;
delta.tv_nsec = stop.m_time.tv_nsec - start.m_time.tv_nsec;
}
return delta.tv_sec + 1e-9*delta.tv_nsec;
}
protected:
timespec m_time;
};
class BitPusher
{
public:
BitPusher(std::vector<unsigned char>& data)
: m_data(data),
m_pending_data(0u),
m_pending_count(0u)
{}
~BitPusher()
{
while (m_pending_count >= 8u) {
m_data.push_back(m_pending_data);
m_pending_data = m_pending_data >> 8u;
m_pending_count -= 8u;
}
if (m_pending_count) {
m_data.push_back(m_pending_data);
}
}
void
pushBits(unsigned long long int bits, unsigned int count)
{
m_pending_data = m_pending_data | (bits << m_pending_count);
m_pending_count += count;
while (m_pending_count >= 8u) {
m_data.push_back(m_pending_data);
m_pending_data = m_pending_data >> 8u;
m_pending_count -= 8u;
}
}
void
pushBitsReverse(unsigned long long int bits, unsigned int count)
{
//std::cerr << "pushing " << count << " bits:\t";
//for(int i=0; i<count; i++) {
// std::cerr << ((bits>>(count-i-1))&1);
//}
//std::cerr << "\n";
bits = bits << (64 - count);
bits = ((bits & 0x5555555555555555ull) << 1) | ((bits >> 1) & 0x5555555555555555ull);
bits = ((bits & 0x3333333333333333ull) << 2) | ((bits >> 2) & 0x3333333333333333ull);
bits = ((bits & 0x0F0F0F0F0F0F0F0Full) << 4) | ((bits >> 4) & 0x0F0F0F0F0F0F0F0Full);
bits = ((bits & 0x00FF00FF00FF00FFull) << 8) | ((bits >> 8) & 0x00FF00FF00FF00FFull);
bits = ((bits & 0x0000FFFF0000FFFFull) << 16) | ((bits >> 16) & 0x0000FFFF0000FFFFull);
bits = ((bits & 0x00000000FFFFFFFFull) << 32) | ((bits >> 32) & 0x00000000FFFFFFFFull);
pushBits(bits, count);
}
protected:
std::vector<unsigned char>& m_data;
unsigned long long int m_pending_data;
unsigned int m_pending_count;
};
void
encodeCount(unsigned int& bits, unsigned int& bits_n, unsigned int count)
{
//std::cerr << "count=" << count << " ";
uint q = 0;
if (count < 3) {
abort();
// no copies, 1 or 2 never occurs.
}
else if (count < 11) {
unsigned int t = count - 3;
t = (t & 0x07u) + ((257 - 256) << 0);
bits = (bits << 7) | t; // 7-bit count code
bits_n += 7;
}
else if (count < 19) { // count=11..18, code=265..268, 1 extra bit
int t = count - 11;
q = (t & 0x01u) << (8 - 1);
t = (t & 0x06u) + ((265 - 256) << 1);
bits = (bits << 8) | t;
bits_n += 8;
}
else if (count < 35) { // count=19..34, code=269..272, 2 extra bits
int t = count - 19;
q = (t & 0x03u) << (8 - 2);
t = (t & 0x0Cu) + ((269 - 256) << 2);
bits = (bits << 9) | t;
bits_n += 9;
}
else if (count < 67) { // c=35..66, code=273..276, 3 extra bits
int t = count - 35;
q = (t & 0x07u) << (8 - 3);
t = (t & 0x18u) + ((273 - 256) << 3);
bits = (bits << 10) | t;
bits_n += 10;
}
else if (count < 115) { // c=67..114, 7-bit code=277..279, 4 extra bits
int t = count - 67;
q = (t & 0x0Fu) << (8 - 4);
t = (t & 0x30u) + ((277 - 256) << 4);
bits = (bits << 11) | t;
bits_n += 11;
}
else if (count < 131) { // c=115..130, 8-bit code=280, 4 extra bits
int t = count - 115;
q = (t & 0x0Fu) << (8 - 4);
t = (t & 0x30u) + ((280 - 280 + 0xc0) << 4);
bits = (bits << 12) | t;
bits_n += 12;
}
else if (count < 258) { // c=131..257, code=281..284, 5 extra bits
int t = count - 131;
bits = (bits << 12) | ((t&(0xff << 5)) + ((281 - 280 + 0xc0) << 5));
q = (t & 0x1Fu) << (8 - 5);
bits_n += 13;
}
else if (count < 259) {
bits = (bits << 8) | (285 - 280 + 0xc0);
bits_n += 8;
}
else {
std::cerr << "unsupported count " << count << "\n";
abort();
}
q = ((q & 0x55u) << 1) | ((q >> 1) & 0x55u);
q = ((q & 0x33u) << 2) | ((q >> 2) & 0x33u);
q = ((q & 0x0Fu) << 4) | ((q >> 4) & 0x0Fu);
bits = bits | q;
}
void
encodeDistance(unsigned int& bits, unsigned int& bits_n, unsigned int distance)
{
//std::cerr << "distance=" << distance << " ";
uint q = 0;
if (distance < 1) {
std::cerr << "unsupported distance " << distance << "\n";
abort();
}
else if (distance < 5) { // d=1..4, code=0..3, 0 extra bits
bits = (bits << 5) | (distance - 1);
bits_n += 5;
}
else if (distance < 9) { // d=5..8, code=4..5, 1 extra bit
unsigned int t = distance - 5;
bits = (bits << 6) | ((t&(0x1f << 1)) + (4 << 1));
q = (t & 1u) << (32 - 1);
bits_n += 6;
}
else if (distance < 17) { // d=9..16, code=6..7, 2 extra bits
unsigned int t = distance - 9;
bits = (bits << 7) | ((t&(0x1 << 2)) + (6 << 2));
q = (t & 3u) << (32 - 2);
bits_n += 7;
}
else if (distance < 33) { // d=17..32, code=8..9, 3 extra bits
unsigned int t = distance - 17;
bits = (bits << 8) | ((t&(0x1 << 3)) + (8 << 3));
q = (t & 7u) << (32 - 3);
bits_n += 8;
}
else if (distance < 65) { // d=33..64, code=10..11, 4 extra bits
unsigned int t = distance - 33;
bits = (bits << 9) | ((t&(0x1 << 4)) + (10 << 4));
q = (t & 0xFu) << (32 - 4);
bits_n += 9;
}
else if (distance < 129) { // d=65..128, code=12..13, 5 extra bits
unsigned int t = distance - 65;
bits = (bits << 10) | ((t&(0x1 << 5)) + (12 << 5));
q = (t & 0x1Fu) << (32 - 5);
bits_n += 10;
}
else if (distance < 257) { // d=129..256, code=14,15, 6 extra bits
unsigned int t = distance - 129;
q = (t & 0x3Fu) << (32 - 6);
t = (t & 0x40u) + (14 << 6);
bits = (bits << 11) | t;
bits_n += 11;
}
else if (distance < 513) { // d=257..512, code 16..17, 7 extra bits
unsigned int t = distance - 257;
q = (t & 0x7Fu) << (32 - 7);
t = (t & 0x80u) + (16 << 7);
bits = (bits << 12) | t;
bits_n += 12;
}
else if (distance < 1025) { // d=257..512, code 18..19, 8 extra bits
unsigned int t = distance - 513;
q = (t & 0x0FFu) << (32 - 8);
t = (t & 0x100u) + (18 << 8);
bits = (bits << 13) | t;
bits_n += 13;
}
else if (distance < 2049) { // d=1025..2048, code 20..21, 9 extra bits
unsigned int t = distance - 1025;
q = (t & 0x1FFu) << (32 - 9);
t = (t & 0x200u) + (20 << 9);
bits = (bits << 14) | t;
bits_n += 14;
}
else if (distance < 4097) { // d=2049..4096, code 22..23, 10 extra bits
unsigned int t = distance - 2049;
q = (t & 0x3FFu) << (32 - 10);
t = (t & 0x400u) + (22 << 10);
bits = (bits << 15) | t;
bits_n += 15;
}
else if (distance < 8193) { // d=4097..8192, code 24..25, 11 extra bits
unsigned int t = distance - 4097;
q = (t & 0x7FFu) << (32 - 11);
t = (t & 0x800u) + (24 << 11);
bits = (bits << 16) | t;
bits_n += 16;
}
else if (distance < 16385) { // d=8193..16384, code 26..27, 12 extra bits
unsigned int t = distance - 8193;
q = (t & 0x0FFFu) << (32 - 12);
t = (t & 0x1000u) + (26 << 12);
bits = (bits << 17) | t;
bits_n += 17;
}
else if (distance < 32769) { // d=16385..32768, code 28..29, 13 extra bits
unsigned int t = distance - 16385;
q = (t & 0x1FFFu) << (32 - 13);
t = (t & 0x2000u) + (28 << 13);
bits = (bits << 18) | t;
bits_n += 18;
}
else {
std::cerr << "Illegal " << distance << "\n";
abort();
}
q = ((q & 0x55555555u) << 1) | ((q >> 1) & 0x55555555u);
q = ((q & 0x33333333u) << 2) | ((q >> 2) & 0x33333333u);
q = ((q & 0x0F0F0F0Fu) << 4) | ((q >> 4) & 0x0F0F0F0Fu);
q = ((q & 0x00FF00FFu) << 8) | ((q >> 8) & 0x00FF00FFu);
q = ((q & 0x0000FFFFu) << 16) | ((q >> 16) & 0x0000FFFFu);
bits = bits | q;
}
void
encodeLiteralTriplet(unsigned int& bits, unsigned int& bits_n, unsigned int rgb)
{
//std::cerr << "literal=" << rgb << " ";
unsigned int t = (rgb >> 16) & 0xffu;
if (t < 144) {
bits = (t + 48);
bits_n = 8;
}
else {
bits = (t + 256);
bits_n = 9;
}
t = (rgb >> 8) & 0xffu;
if (t < 144) {
bits = (bits << 8) | (t + 48);
bits_n += 8;
}
else {
bits = (bits << 9) | (t + 256);
bits_n += 9;
}
t = (rgb) & 0xffu;
if (t < 144) {
bits = (bits << 8) | (t + 48);
bits_n += 8;
}
else {
bits = (bits << 9) | (t + 256);
bits_n += 9;
}
}
unsigned long int
CRC(const std::vector<unsigned long>& crc_table, const unsigned char* p, size_t length)
{
size_t i;
unsigned long int crc = 0xffffffffl;
for (i = 0; i < length; i++) {
unsigned int ix = (p[i] ^ crc) & 0xff;
crc = crc_table[ix] ^ ((crc >> 8));
}
return ~crc;
}
void
writeIDAT3(std::ofstream& file, const std::vector<unsigned char>& img, const std::vector<unsigned long>& crc_table)
{
TimeStamp start;
std::vector<unsigned char> IDAT(8);
// IDAT chunk header
IDAT[4] = 'I';
IDAT[5] = 'D';
IDAT[6] = 'A';
IDAT[7] = 'T';
// --- create deflate chunk ------------------------------------------------
IDAT.push_back(8 + (7 << 4)); // CM=8=deflate, CINFO=7=32K window size = 112
IDAT.push_back(94 /* 28*/); // FLG
unsigned int dat_size;
unsigned int s1 = 1;
unsigned int s2 = 0;
{
BitPusher pusher(IDAT);
pusher.pushBitsReverse(6, 3); // 5 = 101
std::vector<unsigned int> buffer(WIDTH * 5, ~0u);
unsigned int* zrows[4] = {
buffer.data(),
buffer.data() + WIDTH,
buffer.data() + 2 * WIDTH,
buffer.data() + 3 * WIDTH,
};
unsigned int o = 0;
for (int j = 0; j < HEIGHT; j++) {
unsigned int* rows[4] = {
zrows[(j + 3) & 1],
zrows[(j + 2) & 1],
zrows[(j + 1) & 1],
zrows[j & 1]
};
// unsigned int* p_row = rows[ j&1 ];
//unsigned int* c_row = rows[ (j+1)&1 ];
pusher.pushBitsReverse(0 + 48, 8); // Push png scanline filter
s1 += 0; // update adler 1 & 2
s2 += s1;
int match_src_i = 0;
int match_src_j = 0;
int match_dst_i = 0;
int match_dst_o = 0; // used for debugging
int match_length = 0;
//std::cerr << o << "---\n";
o++;
for (int i = 0; i < WIDTH; i++) {
unsigned int R = img[3 * (WIDTH*j + i) + 0];
unsigned int G = img[3 * (WIDTH*j + i) + 1];
unsigned int B = img[3 * (WIDTH*j + i) + 2];
unsigned int RGB = (R << 16) | (G << 8) | B;
s1 = (s1 + R);
s2 = (s2 + s1);
s1 = (s1 + G);
s2 = (s2 + s1);
s1 = (s1 + B);
s2 = (s2 + s1);
//std::cerr << o << ":\t" << RGB << "\t";
rows[0][i] = RGB;
bool redo;
do {
redo = false;
bool emit_match = false;
bool emit_verbatim = false;
if (match_length == 0) {
// We have no running matching, try to find candidate
int k;
match_src_j = 0;
for (k = i - 1; (k >= 0) && (rows[0][k] != RGB); k--) {}
if (k < 0) {
match_src_j = 1;
for (k = WIDTH - 1; (k >= 0) && (rows[1][k] != RGB); k--) {}
}
if (k >= 0) {
// Found match,
match_src_i = k;
match_dst_i = i;
match_dst_o = o;
match_length = 1;
if (i == WIDTH - 1) {
emit_match = true;
}
}
else {
emit_verbatim = true;
}
}
else {
// We are matching
if (match_length >= 86) {
// Max matchlength is 86*3=258, flush and continue
emit_match = true;
redo = true;
}
else if ((match_src_i + match_length < WIDTH) && // don't match outside scanline
(rows[match_src_j][match_src_i + match_length] == RGB)) // check if matching
{
match_length = match_length + 1;
if (i == WIDTH - 1) {
emit_match = true;
}
}
else {
emit_match = true;
redo = true;
// try to find new match source
int k = match_src_i - 1;
for (int m = match_src_j; (emit_match) && (m < 2); m++) {
for (; (emit_match) && (k >= 0); k--) {
bool fail = false;
for (int l = 0; l <= match_length; l++) {
if (rows[0][match_dst_i + l] != rows[m][k + l]) {
fail = true;
break;
}
}
if (!fail) {
match_src_j = m;
match_src_i = k;
match_length = match_length + 1;
emit_match = false;
redo = false;
break;
}
}
k = WIDTH - 1;
}
}
}
if (((i == WIDTH - 1) && (match_length)) || emit_match) {
unsigned int bits = 0;
unsigned int bits_n = 0;
unsigned int count = 3 * match_length;
encodeCount(bits, bits_n, count);
pusher.pushBitsReverse(bits, bits_n);
bits = 0;
bits_n = 0;
unsigned int distance = 3 * (match_dst_i - match_src_i);
if (match_src_j > 0) {
distance += 3 * WIDTH + 1;
}
encodeDistance(bits, bits_n, distance);
pusher.pushBitsReverse(bits, bits_n);
match_length = 0;
}
if (emit_verbatim) {
unsigned int bits = 0;
unsigned int bits_n = 0;
encodeLiteralTriplet(bits, bits_n, RGB);
pusher.pushBitsReverse(bits, bits_n);
}
} while (redo);
o += 3;
}
s1 = s1 % 65521;
s2 = s2 % 65521;
}
pusher.pushBits(0, 7); // EOB
}
unsigned int adler = (s2 << 16) + s1;
IDAT.push_back(((adler) >> 24) & 0xffu); // Adler32
IDAT.push_back(((adler) >> 16) & 0xffu);
IDAT.push_back(((adler) >> 8) & 0xffu);
IDAT.push_back(((adler) >> 0) & 0xffu);
// --- end deflate chunk --------------------------------------------------
// Update PNG chunk content size for IDAT
dat_size = IDAT.size() - 8u;
IDAT[0] = ((dat_size) >> 24) & 0xffu;
IDAT[1] = ((dat_size) >> 16) & 0xffu;
IDAT[2] = ((dat_size) >> 8) & 0xffu;
IDAT[3] = ((dat_size) >> 0) & 0xffu;
unsigned long crc = CRC(crc_table, IDAT.data() + 4, dat_size + 4);
IDAT.resize(IDAT.size() + 4u); // make room for CRC
IDAT[dat_size + 8] = ((crc) >> 24) & 0xffu;
IDAT[dat_size + 9] = ((crc) >> 16) & 0xffu;
IDAT[dat_size + 10] = ((crc) >> 8) & 0xffu;
IDAT[dat_size + 11] = ((crc) >> 0) & 0xffu;
TimeStamp stop;
std::cerr << "IDAT3 used " << TimeStamp::delta(start, stop) << "\n";
if (1) {
std::vector<unsigned char> quux(10 * 1024 * 1024);
z_stream stream;
int err;
stream.next_in = (z_const Bytef *)IDAT.data() + 8;
stream.avail_in = (uInt)IDAT.size() - 8;
stream.next_out = quux.data();
stream.avail_out = quux.size();
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
err = inflateInit(&stream);
if (err != Z_OK) {
std::cerr << "inflateInit failed: " << err << "\n";
abort();
}
err = inflate(&stream, Z_FINISH);
if (stream.msg != NULL) {
std::cerr << stream.msg << "\n";
}
uLongf quux_size = quux.size();
err = uncompress(quux.data(), &quux_size, IDAT.data() + 8, IDAT.size() - 8);
if (err != Z_OK) {
std::cerr << "uncompress="
<< err
<< "\n";
}
if (quux_size != ((3 * WIDTH + 1)*HEIGHT)) {
std::cerr << "uncompress_size=" << quux_size
<< ", should be=" << ((3 * WIDTH + 1)*HEIGHT) << "\n";
}
}
file.write(reinterpret_cast<char*>(IDAT.data()), dat_size + 12);
}
void
createCRCTable(std::vector<unsigned long>& crc_table)
{
crc_table.resize(256);
for (int j = 0; j < 256; j++) {
unsigned long int c = j;
for (int i = 0; i < 8; i++) {
if (c & 0x1) {
c = 0xedb88320ul ^ (c >> 1);
}
else {
c = c >> 1;
}
}
crc_table[j] = c;
}
}
void
createDummyImage(std::vector<unsigned char>& img)
{
img.resize(3 * WIDTH*HEIGHT);
for (int j = 0; j < HEIGHT; j++) {
for (int i = 0; i < WIDTH; i++) {
float x = i / (WIDTH / 2.f) - 1.f;
float y = j / (HEIGHT / 2.f) - 1.f;
float r = sqrt(x*x + y * y);
if (r < 0.9f) {
img[3 * (WIDTH*j + i) + 0] = 255;
img[3 * (WIDTH*j + i) + 1] = 255 * 0.5f*(sinf(30 * r) + 1.f);;
img[3 * (WIDTH*j + i) + 2] = 255 * 0.5f*(sinf(40 * r) + 1.f);
}
else if (r < 1.f) {
int q = (int)(200 * r);
if (q & 1) {
img[3 * (WIDTH*j + i) + 0] = q;
img[3 * (WIDTH*j + i) + 1] = 255;
img[3 * (WIDTH*j + i) + 2] = 255;
}
else {
img[3 * (WIDTH*j + i) + 0] = 0;
img[3 * (WIDTH*j + i) + 1] = q;
img[3 * (WIDTH*j + i) + 2] = 0;
}
}
else {
img[3 * (WIDTH*j + i) + 0] = 255;
img[3 * (WIDTH*j + i) + 1] = 255;
img[3 * (WIDTH*j + i) + 2] = 0;
}
}
}
}
void
writeSignature(std::ofstream& file)
{
unsigned char signature[8] =
{
137, 80, 78, 71, 13, 10, 26, 10
};
file.write(reinterpret_cast<char*>(signature), sizeof(signature));
}
void
writeIHDR(std::ofstream& file, const std::vector<unsigned long>& crc_table)
{
// IHDR chunk, 13 + 12 (length, type, crc) = 25 bytes
unsigned char IHDR[25] =
{
// Chunk length (4 bytes)
((13) >> 24) & 0xffu,((13) >> 16) & 0xffu, ((13) >> 8) & 0xffu, ((13) >> 0) & 0xffu,
// Chunk type (4 bytes)
'I', 'H', 'D', 'R',
// Image width (4 bytes)
((WIDTH) >> 24) & 0xffu,((WIDTH) >> 16) & 0xffu, ((WIDTH) >> 8) & 0xffu, ((WIDTH) >> 0) & 0xffu,
// Image height
((HEIGHT) >> 24) & 0xffu,((HEIGHT) >> 16) & 0xffu, ((HEIGHT) >> 8) & 0xffu, ((HEIGHT) >> 0) & 0xffu,
// bits per channel, RGB triple, ..., .., image not interlaced (5 bytes)
8, 2, 0, 0, 0,
// CRC of 13+4 bytes
0, 0, 0, 0
};
unsigned long crc = CRC(crc_table, IHDR + 4, 13 + 4);
IHDR[21] = ((crc) >> 24) & 0xffu; // image width
IHDR[22] = ((crc) >> 16) & 0xffu;
IHDR[23] = ((crc) >> 8) & 0xffu;
IHDR[24] = ((crc) >> 0) & 0xffu;
file.write(reinterpret_cast<char*>(IHDR), sizeof(IHDR));
}
void
writeIDAT(std::ofstream& file, const std::vector<unsigned char>& img, const std::vector<unsigned long>& crc_table)
{
TimeStamp start;
std::vector<unsigned char> filtered((3 * WIDTH + 1)*HEIGHT);
for (int j = 0; j < HEIGHT; j++) {
filtered[(3 * WIDTH + 1)*j + 0] = 0;
for (int i = 0; i < WIDTH; i++) {
filtered[(3 * WIDTH + 1)*j + 1 + 3 * i + 0] = img[3 * WIDTH*j + 3 * i + 0];
filtered[(3 * WIDTH + 1)*j + 1 + 3 * i + 1] = img[3 * WIDTH*j + 3 * i + 1];
filtered[(3 * WIDTH + 1)*j + 1 + 3 * i + 2] = img[3 * WIDTH*j + 3 * i + 2];
}
}
std::vector<unsigned char> IDAT(16 * 1024 * 1024);
uLongf dat_size = IDAT.size() - 12;
TimeStamp c_start;
int c = compress((Bytef*)(IDAT.data() + 8), &dat_size, (Bytef*)filtered.data(), filtered.size());
TimeStamp c_stop;
if (c == Z_MEM_ERROR) {
std::cerr << "Z_MEM_ERROR\n";
exit(EXIT_FAILURE);
}
else if (c == Z_BUF_ERROR) {
std::cerr << "Z_BUF_ERROR\n";
exit(EXIT_FAILURE);
}
IDAT[0] = ((dat_size) >> 24) & 0xffu;
IDAT[1] = ((dat_size) >> 16) & 0xffu;
IDAT[2] = ((dat_size) >> 8) & 0xffu;
IDAT[3] = ((dat_size) >> 0) & 0xffu;
IDAT[4] = 'I';
IDAT[5] = 'D';
IDAT[6] = 'A';
IDAT[7] = 'T';
unsigned long crc = CRC(crc_table, IDAT.data() + 4, dat_size + 4);
IDAT[dat_size + 8] = ((crc) >> 24) & 0xffu; // image width
IDAT[dat_size + 9] = ((crc) >> 16) & 0xffu;
IDAT[dat_size + 10] = ((crc) >> 8) & 0xffu;
IDAT[dat_size + 11] = ((crc) >> 0) & 0xffu;
TimeStamp stop;
std::cerr << "IDAT used " << TimeStamp::delta(start, stop)
<< ", compress used " << TimeStamp::delta(c_start, c_stop) << "\n";
file.write(reinterpret_cast<char*>(IDAT.data()), dat_size + 12);
}
void
writeIDAT2(std::ofstream& file, const std::vector<unsigned char>& img, const std::vector<unsigned long>& crc_table)
{
TimeStamp start;
std::vector<unsigned char> IDAT(8);
// IDAT chunk header
IDAT[4] = 'I';
IDAT[5] = 'D';
IDAT[6] = 'A';
IDAT[7] = 'T';
// --- create deflate chunk ------------------------------------------------
IDAT.push_back(8 + (7 << 4)); // CM=8=deflate, CINFO=7=32K window size = 112
IDAT.push_back(94 /* 28*/); // FLG
unsigned int dat_size;
unsigned int s1 = 1;
unsigned int s2 = 0;
{
BitPusher pusher(IDAT);
pusher.pushBitsReverse(6, 3); // 5 = 101
for (int j = 0; j < HEIGHT; j++) {
// push scan-line filter type
pusher.pushBitsReverse(1 + 48, 8); // Push a 1 (diff with left)
s1 += 1; // update adler 1 & 2
s2 += s1;
#if 1
unsigned int trgb_p = 0xffffffff;
unsigned int c = 0;
for (int i = 0; i < WIDTH; i++) {
unsigned int trgb_l = 0;
for (int k = 0; k < 3; k++) {
unsigned int t = (img[3 * WIDTH*j + 3 * i + k]
- (i == 0 ? 0 : img[3 * WIDTH*j + 3 * (i - 1) + k])) & 0xffu;
s1 = (s1 + t); // update adler 1 & 2
s2 = (s2 + s1);
trgb_l = (trgb_l << 8) | t;
}
if ((i == 0) || (i == WIDTH - 1) || (trgb_l != trgb_p) || (c >= 66)) {
// flush copies
if (c == 0) {
// no copies, 1 or 2 never occurs.
}
else if (c < 11) {
pusher.pushBitsReverse(c - 2, 7);
pusher.pushBitsReverse(2, 5);
}
else if (c < 19) {
int t = c - 11;
pusher.pushBitsReverse((t >> 1) + 9, 7);
pusher.pushBitsReverse((t & 1), 1);
pusher.pushBitsReverse(2, 5);
}
else if (c < 35) {
int t = c - 19;
pusher.pushBitsReverse((t >> 2) + 13, 7);
pusher.pushBits((t & 3), 2);
pusher.pushBitsReverse(2, 5);
}
else if (c < 67) {
int t = c - 35;
pusher.pushBitsReverse((t >> 3) + 17, 7);
pusher.pushBits((t & 7), 3);
pusher.pushBitsReverse(2, 5);
}
c = 0;
// need to write literal
int r = (trgb_l >> 16) & 0xffu;
if (r < 144) {
pusher.pushBitsReverse(r + 48, 8);
}
else {
pusher.pushBitsReverse(r + (400 - 144), 9);
}
int g = (trgb_l >> 8) & 0xffu;
if (g < 144) {
pusher.pushBitsReverse(g + 48, 8);
}
else {
pusher.pushBitsReverse(g + (400 - 144), 9);
}
int b = (trgb_l >> 0) & 0xffu;
if (b < 144) {
pusher.pushBitsReverse(b + 48, 8);
}
else {
pusher.pushBitsReverse(b + (400 - 144), 9);
}
trgb_p = trgb_l;
}
else {
c += 3;
}
}
#else
for (int i = 0; i < WIDTH; i++) {
for (int k = 0; k < 3; k++) {
int q = img[3 * WIDTH*j + 3 * i + k];
s1 = (s1 + q); // update adler 1 & 2
s2 = (s2 + s1);
if (q < 144) {
pusher.pushBitsReverse(q + 48, 8); // 48 = 00110000
}
else {
pusher.pushBitsReverse(q + (400 - 144), 9); // 400 = 110010000
}
}
}
#endif
// We can do up to 5552 iterations before we need to run the modulo,
// see comment on NMAX adler32.c in zlib.
s1 = s1 % 65521;
s2 = s2 % 65521;
}
pusher.pushBits(0, 7); // EOB
}
unsigned int adler = (s2 << 16) + s1;
IDAT.push_back(((adler) >> 24) & 0xffu); // Adler32
IDAT.push_back(((adler) >> 16) & 0xffu);
IDAT.push_back(((adler) >> 8) & 0xffu);
IDAT.push_back(((adler) >> 0) & 0xffu);
// --- end deflate chunk --------------------------------------------------
// Update PNG chunk content size for IDAT
dat_size = IDAT.size() - 8u;
IDAT[0] = ((dat_size) >> 24) & 0xffu;
IDAT[1] = ((dat_size) >> 16) & 0xffu;
IDAT[2] = ((dat_size) >> 8) & 0xffu;
IDAT[3] = ((dat_size) >> 0) & 0xffu;
unsigned long crc = CRC(crc_table, IDAT.data() + 4, dat_size + 4);
IDAT.resize(IDAT.size() + 4u); // make room for CRC
IDAT[dat_size + 8] = ((crc) >> 24) & 0xffu;
IDAT[dat_size + 9] = ((crc) >> 16) & 0xffu;
IDAT[dat_size + 10] = ((crc) >> 8) & 0xffu;
IDAT[dat_size + 11] = ((crc) >> 0) & 0xffu;
TimeStamp stop;
std::cerr << "IDAT2 used " << TimeStamp::delta(start, stop) << "\n";
if (1) {
std::vector<unsigned char> quux(10 * 1024 * 1024);
z_stream stream;
int err;
stream.next_in = (z_const Bytef *)IDAT.data() + 8;
stream.avail_in = (uInt)IDAT.size() - 8;
stream.next_out = quux.data();
stream.avail_out = quux.size();
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
err = inflateInit(&stream);
if (err != Z_OK) {
std::cerr << "inflateInit failed: " << err << "\n";
abort();
}
err = inflate(&stream, Z_FINISH);
if (stream.msg != NULL) {
std::cerr << stream.msg << "\n";
}
uLongf quux_size = quux.size();
err = uncompress(quux.data(), &quux_size, IDAT.data() + 8, IDAT.size() - 8);
if (err != Z_OK) {
std::cerr << "uncompress="
<< err
<< "\n";
}
if (quux_size != ((3 * WIDTH + 1)*HEIGHT)) {
std::cerr << "uncompress_size=" << quux_size
<< ", should be=" << ((3 * WIDTH + 1)*HEIGHT) << "\n";
}
}
file.write(reinterpret_cast<char*>(IDAT.data()), dat_size + 12);
}
void
writeIEND(std::ofstream& file, const std::vector<unsigned long>& crc_table)
{
unsigned char IEND[12] = {
0, 0, 0, 0, // payload size
'I', 'E', 'N', 'D', // chunk id
174, 66, 96, 130 // chunk crc
};
file.write(reinterpret_cast<char*>(IEND), 12);
}
#endif
int
main(int argc, char **argv)
{
#if 0
std::vector<unsigned long> crc_table;
createCRCTable(crc_table);
std::vector<unsigned char> img;
createDummyImage(img);
std::ofstream png("img.png");
writeSignature(png);
writeIHDR(png, crc_table);
writeIDAT(png, img, crc_table);
writeIEND(png, crc_table);
png.close();
std::ofstream png2("img2.png");
writeSignature(png2);
writeIHDR(png2, crc_table);
writeIDAT2(png2, img, crc_table);
writeIEND(png2, crc_table);
png2.close();
std::ofstream png3("img3.png");
writeSignature(png3);
writeIHDR(png3, crc_table);
writeIDAT3(png3, img, crc_table);
writeIEND(png3, crc_table);
png3.close();
{
std::ofstream png2("img2.png");
writeSignature(png2);
writeIHDR(png2, crc_table);
writeIDAT2(png2, img, crc_table);
writeIEND(png2, crc_table);
png2.close();
}
#endif
return 0;
}
| 26.872115
| 115
| 0.482198
|
cdyk
|
1f78534c6ac29c1c1f4ff42b8aa284c7e0d7c508
| 8,886
|
cpp
|
C++
|
miniapps/mhd/imScale.cpp
|
fanronghong/mfem
|
5bc8d5ea1b7e3a0b377423773e78428bf7160612
|
[
"BSD-3-Clause"
] | 1
|
2020-04-28T05:08:24.000Z
|
2020-04-28T05:08:24.000Z
|
miniapps/mhd/imScale.cpp
|
fanronghong/mfem
|
5bc8d5ea1b7e3a0b377423773e78428bf7160612
|
[
"BSD-3-Clause"
] | null | null | null |
miniapps/mhd/imScale.cpp
|
fanronghong/mfem
|
5bc8d5ea1b7e3a0b377423773e78428bf7160612
|
[
"BSD-3-Clause"
] | null | null | null |
// MFEM modified from Example 10 and 16
//
// Compile with: make imMHDp
//
// Description: It solves a time dependent resistive MHD problem
// There three versions:
// 1. explicit scheme
// 2. implicit scheme using a very simple linear preconditioner
// 3. implicit scheme using physcis-based preconditioner
// Author: QT
#include "mfem.hpp"
#include "myCoefficient.hpp"
#include "myIntegrator.hpp"
#include "imScale.hpp"
#include "PCSolver.hpp"
#include "InitialConditions.hpp"
#include <memory>
#include <iostream>
#include <fstream>
#ifndef MFEM_USE_PETSC
#error This example requires that MFEM is built with MFEM_USE_PETSC=YES
#endif
int main(int argc, char *argv[])
{
int num_procs, myid;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
//++++Parse command-line options.
const char *mesh_file = "./Meshes/xperiodic-square.mesh";
int ser_ref_levels = 2;
int par_ref_levels = 0;
int order = 2;
int ode_solver_type = 3;
double t_final = 5.0;
double dt = 0.0001;
double visc = 1e-3;
double resi = 1e-3;
bool visit = false;
bool use_petsc = false;
bool use_factory = false;
const char *petscrc_file = "";
beta = 0.001;
Lx=3.0;
lambda=5.0;
int vis_steps = 1;
OptionsParser args(argc, argv);
args.AddOption(&mesh_file, "-m", "--mesh",
"Mesh file to use.");
args.AddOption(&ser_ref_levels, "-rs", "--refine",
"Number of times to refine the mesh uniformly in serial.");
args.AddOption(&par_ref_levels, "-rp", "--refineP",
"Number of times to refine the mesh uniformly in parallel.");
args.AddOption(&order, "-o", "--order",
"Order (degree) of the finite elements.");
args.AddOption(&ode_solver_type, "-s", "--ode-solver",
"ODE solver: 1 - Backward Euler, 2 - Brailovskaya,\n\t"
" 3 - L-stable SDIRK23, 4 - L-stable SDIRK33,\n\t"
" 22 - Implicit Midpoint, 23 - SDIRK23, 24 - SDIRK34.");
args.AddOption(&t_final, "-tf", "--t-final",
"Final time; start time is 0.");
args.AddOption(&dt, "-dt", "--time-step",
"Time step.");
args.AddOption(&visc, "-visc", "--viscosity",
"Viscosity coefficient.");
args.AddOption(&resi, "-resi", "--resistivity",
"Resistivity coefficient.");
args.AddOption(&vis_steps, "-vs", "--visualization-steps",
"Visualize every n-th timestep.");
args.AddOption(&use_petsc, "-usepetsc", "--usepetsc", "-no-petsc",
"--no-petsc",
"Use or not PETSc to solve the nonlinear system.");
args.AddOption(&use_factory, "-shell", "--shell", "-no-shell",
"--no-shell",
"Use user-defined preconditioner factory (PCSHELL).");
args.AddOption(&petscrc_file, "-petscopts", "--petscopts",
"PetscOptions file to use.");
args.Parse();
if (!args.Good())
{
if (myid == 0)
{
args.PrintUsage(cout);
}
MPI_Finalize();
return 1;
}
lambda=.5/M_PI;
resiG=resi;
if (myid == 0) args.PrintOptions(cout);
if (use_petsc)
{
MFEMInitializePetsc(NULL,NULL,petscrc_file,NULL);
}
//+++++Read the mesh from the given mesh file.
Mesh *mesh = new Mesh(mesh_file, 1, 1);
int dim = mesh->Dimension();
//++++Define the ODE solver used for time integration. Several implicit
// singly diagonal implicit Runge-Kutta (SDIRK) methods, as well as
// backward Euler methods are available.
PCSolver *ode_solver=NULL;
ODESolver *ode_solver2=NULL;
bool explicitSolve=false;
switch (ode_solver_type)
{
//Explicit methods (first-order Predictor-Corrector)
case 2: ode_solver = new PCSolver; explicitSolve = true; break;
//Implict L-stable methods
case 1: ode_solver2 = new BackwardEulerSolver; break;
case 3: ode_solver2 = new SDIRK23Solver(2); break;
case 4: ode_solver2 = new SDIRK33Solver; break;
// Implicit A-stable methods (not L-stable)
case 12: ode_solver2 = new ImplicitMidpointSolver; break;
case 13: ode_solver2 = new SDIRK23Solver; break;
case 14: ode_solver2 = new SDIRK34Solver; break;
default:
if (myid == 0) cout << "Unknown ODE solver type: " << ode_solver_type << '\n';
delete mesh;
MPI_Finalize();
return 3;
}
//++++++Refine the mesh to increase the resolution.
for (int lev = 0; lev < ser_ref_levels; lev++)
{
mesh->UniformRefinement();
}
ParMesh *pmesh = new ParMesh(MPI_COMM_WORLD, *mesh);
delete mesh;
for (int lev = 0; lev < par_ref_levels; lev++)
{
pmesh->UniformRefinement();
}
//+++++Define the vector finite element spaces representing [Psi, Phi, w]
// in block vector bv, with offsets given by the fe_offset array.
// All my fespace is 1D but the problem is multi-dimensional
H1_FECollection fe_coll(order, dim);
ParFiniteElementSpace fespace(pmesh, &fe_coll);
HYPRE_Int global_size = fespace.GlobalTrueVSize();
if (myid == 0)
{
cout << "Number of total scalar unknowns: " << global_size << endl;
}
int fe_size = fespace.TrueVSize();
Array<int> fe_offset(4);
fe_offset[0] = 0;
fe_offset[1] = fe_size;
fe_offset[2] = 2*fe_size;
fe_offset[3] = 3*fe_size;
BlockVector vx(fe_offset);
ParGridFunction psi, phi, w;
phi.MakeTRef(&fespace, vx, fe_offset[0]);
psi.MakeTRef(&fespace, vx, fe_offset[1]);
w.MakeTRef(&fespace, vx, fe_offset[2]);
//+++++Set the initial conditions, and the boundary conditions
FunctionCoefficient phiInit(InitialPhi);
phi.ProjectCoefficient(phiInit);
phi.SetTrueVector();
FunctionCoefficient psiInit3(InitialPsi3);
psi.ProjectCoefficient(psiInit3);
psi.SetTrueVector();
FunctionCoefficient wInit(InitialW);
w.ProjectCoefficient(wInit);
w.SetTrueVector();
//this step is necessary to make sure unknows are updated!
phi.SetFromTrueVector(); psi.SetFromTrueVector(); w.SetFromTrueVector();
//++++++this is a periodic boundary condition in x and Direchlet in y
Array<int> ess_bdr(fespace.GetMesh()->bdr_attributes.Max());
ess_bdr = 0;
ess_bdr[0] = 1; //set attribute 1 to Direchlet boundary fixed
if(ess_bdr.Size()!=1 || false)
{
if (myid==0) cout <<"ess_bdr size should be 1 but it is "<<ess_bdr.Size()<<endl;
delete ode_solver;
delete ode_solver2;
delete mesh;
delete pmesh;
MPI_Finalize();
return 2;
}
//++++Initialize the MHD operator, the GLVis visualization
ResistiveMHDOperator oper(fespace, ess_bdr, visc, resi, use_petsc, use_factory);
FunctionCoefficient e0(E0rhs3);
oper.SetRHSEfield(e0);
//set initial J
FunctionCoefficient jInit3(InitialJ3);
oper.SetInitialJ(jInit3);
double t = 0.0;
oper.SetTime(t);
ode_solver2->Init(oper);
MPI_Barrier(MPI_COMM_WORLD);
double start = MPI_Wtime();
//++++Perform time-integration (looping over the time iterations, ti, with a
// time-step dt).
bool last_step = false;
for (int ti = 1; !last_step; ti++)
{
//ignore the first time step
if (ti==2)
{
MPI_Barrier(MPI_COMM_WORLD);
start = MPI_Wtime();
}
ode_solver2->Step(vx, t, dt);
last_step = (t >= t_final - 1e-8*dt);
if (last_step || (ti % vis_steps) == 0)
{
if (myid==0) cout << "step " << ti << ", t = " << t <<endl;
}
}
MPI_Barrier(MPI_COMM_WORLD);
double end = MPI_Wtime();
if (myid == 0)
cout <<"######Runtime = "<<end-start<<" ######"<<endl;
//++++++Save the solutions.
{
phi.SetFromTrueVector(); psi.SetFromTrueVector(); w.SetFromTrueVector();
ostringstream mesh_name, phi_name, psi_name, w_name,j_name;
mesh_name << "mesh." << setfill('0') << setw(6) << myid;
phi_name << "sol_phi." << setfill('0') << setw(6) << myid;
psi_name << "sol_psi." << setfill('0') << setw(6) << myid;
w_name << "sol_omega." << setfill('0') << setw(6) << myid;
ofstream omesh(mesh_name.str().c_str());
omesh.precision(8);
pmesh->Print(omesh);
ofstream osol(phi_name.str().c_str());
osol.precision(8);
phi.Save(osol);
ofstream osol3(psi_name.str().c_str());
osol3.precision(8);
psi.Save(osol3);
ofstream osol4(w_name.str().c_str());
osol4.precision(8);
w.Save(osol4);
}
//+++++Free the used memory.
delete ode_solver;
delete ode_solver2;
delete pmesh;
oper.DestroyHypre();
if (use_petsc) { MFEMFinalizePetsc(); }
MPI_Finalize();
return 0;
}
| 30.641379
| 87
| 0.609498
|
fanronghong
|
1f7a6452665d1c909389e6c7dee21c9904679c9c
| 595
|
cpp
|
C++
|
src/UnitTest/TUTTest.cpp
|
franjgonzalez/Quinoa
|
411eb8815e92618c563881b784e287e2dd916f89
|
[
"RSA-MD"
] | null | null | null |
src/UnitTest/TUTTest.cpp
|
franjgonzalez/Quinoa
|
411eb8815e92618c563881b784e287e2dd916f89
|
[
"RSA-MD"
] | null | null | null |
src/UnitTest/TUTTest.cpp
|
franjgonzalez/Quinoa
|
411eb8815e92618c563881b784e287e2dd916f89
|
[
"RSA-MD"
] | null | null | null |
// *****************************************************************************
/*!
\file src/UnitTest/TUTTest.cpp
\copyright 2012-2015 J. Bakosi,
2016-2018 Los Alamos National Security, LLC.,
2019 Triad National Security, LLC.
All rights reserved. See the LICENSE file for details.
\brief Template Unit Test unit test class definition
\details Template Unit Test unit test class definition.
*/
// *****************************************************************************
#include "TUTTest.hpp"
#include "NoWarning/tuttest.def.h"
| 37.1875
| 80
| 0.489076
|
franjgonzalez
|
1f7f12a6ffe15a419b2ba405037cef94db2ad0de
| 383
|
cpp
|
C++
|
0049 - Product of consecutive Fib numbers/solution.cpp
|
dimitri-dev/CodeWars
|
da428b2f9da4e56080aac6196575e101b1395c6d
|
[
"MIT"
] | null | null | null |
0049 - Product of consecutive Fib numbers/solution.cpp
|
dimitri-dev/CodeWars
|
da428b2f9da4e56080aac6196575e101b1395c6d
|
[
"MIT"
] | null | null | null |
0049 - Product of consecutive Fib numbers/solution.cpp
|
dimitri-dev/CodeWars
|
da428b2f9da4e56080aac6196575e101b1395c6d
|
[
"MIT"
] | null | null | null |
#include <vector>
typedef unsigned long long ull;
class ProdFib {
public:
static std::vector<ull> productFib(ull prod) {
ull t1 = 0, t2 = 1, nextTerm = t1 + t2;
while(t1*t2 <= prod) {
if (t1 * t2 == prod) return {t1, t2, true};
t1 = t2; t2 = nextTerm; nextTerm = t1 + t2;
}
if (t1 * t2 > prod) return {t1, t2, false};
}
};
| 22.529412
| 51
| 0.524804
|
dimitri-dev
|
1f8208304eb52691a62fd8f33e1ea34ad00b43a4
| 2,634
|
cpp
|
C++
|
src/posix/time.cpp
|
abdes/asap_filesystem
|
44b8ab19900db6ce58a8802817a5b42d6ab6a4b3
|
[
"BSD-3-Clause"
] | 3
|
2019-05-20T14:21:11.000Z
|
2019-05-21T19:09:13.000Z
|
src/posix/time.cpp
|
abdes/asap_filesystem
|
44b8ab19900db6ce58a8802817a5b42d6ab6a4b3
|
[
"BSD-3-Clause"
] | null | null | null |
src/posix/time.cpp
|
abdes/asap_filesystem
|
44b8ab19900db6ce58a8802817a5b42d6ab6a4b3
|
[
"BSD-3-Clause"
] | null | null | null |
// Copyright The Authors 2018.
// Distributed under the 3-Clause BSD License.
// (See accompanying file LICENSE or copy at
// https://opensource.org/licenses/BSD-3-Clause)
#include "../fs_portability.h"
#if defined(ASAP_POSIX)
// -----------------------------------------------------------------------------
// detail: file time utils
// -----------------------------------------------------------------------------
namespace asap {
namespace filesystem {
namespace detail {
namespace posix_port {
namespace {
// We know this may create an overflow and also that the tests may always be
// true. This is here for cases where the representation of
// std::chrono::duration is smaller than the TimeSpec representation.
HEDLEY_DIAGNOSTIC_PUSH
#if defined(HEDLEY_GCC_VERSION)
HEDLEY_PRAGMA(GCC diagnostic ignored "-Woverflow")
#endif // HEDLEY_GCC_VERSION
#if defined(__clang__)
HEDLEY_PRAGMA(clang diagnostic ignored "-Wtautological-type-limit-compare")
#endif // __clang__
auto FileTimeIsRepresentable(TimeSpec tm) -> bool {
using std::chrono::nanoseconds;
using std::chrono::seconds;
if (tm.tv_sec >= 0) {
return tm.tv_sec <= seconds::max().count();
}
if (tm.tv_sec == (seconds::min().count() - 1)) {
return tm.tv_nsec >= nanoseconds::min().count();
}
return tm.tv_sec >= seconds::min().count();
}
HEDLEY_DIAGNOSTIC_POP
} // namespace
auto FileTimeTypeFromPosixTimeSpec(TimeSpec tm) -> file_time_type {
using std::chrono::duration;
using std::chrono::duration_cast;
using rep = typename file_time_type::rep;
using fs_duration = typename file_time_type::duration;
using fs_seconds = duration<rep>;
using fs_nanoseconds = duration<rep, std::nano>;
if (tm.tv_sec >= 0 || tm.tv_nsec == 0) {
return file_time_type(
fs_seconds(tm.tv_sec) +
duration_cast<fs_duration>(fs_nanoseconds(tm.tv_nsec)));
} // tm.tv_sec < 0
auto adj_subsec =
duration_cast<fs_duration>(fs_seconds(1) - fs_nanoseconds(tm.tv_nsec));
auto Dur = fs_seconds(tm.tv_sec + 1) - adj_subsec;
return file_time_type(Dur);
}
auto ExtractLastWriteTime(const path &p, const StatT &st, std::error_code *ec)
-> file_time_type {
ErrorHandler<file_time_type> err("last_write_time", ec, &p);
auto ts = detail::posix_port::ExtractModificationTime(st);
if (!detail::posix_port::FileTimeIsRepresentable(ts)) {
return err.report(std::errc::value_too_large);
}
return detail::posix_port::FileTimeTypeFromPosixTimeSpec(ts);
}
} // namespace posix_port
} // namespace detail
} // namespace filesystem
} // namespace asap
#endif // ASAP_POSIX
| 32.518519
| 80
| 0.667046
|
abdes
|
1f875975a55ca02fc65efe05f5900c797901f749
| 3,355
|
cpp
|
C++
|
Engine/source/util/catmullRom.cpp
|
fr1tz/alux3d
|
249a3b51751ce3184d52879b481f83eabe89e7e3
|
[
"MIT"
] | 46
|
2015-01-05T17:34:43.000Z
|
2022-01-04T04:03:09.000Z
|
Engine/source/util/catmullRom.cpp
|
fr1tz/alux3d
|
249a3b51751ce3184d52879b481f83eabe89e7e3
|
[
"MIT"
] | 10
|
2015-01-20T23:14:46.000Z
|
2019-04-05T22:04:15.000Z
|
Engine/source/util/catmullRom.cpp
|
fr1tz/terminal-overload
|
85f0689a40022e5eb7e54dcb6ddfb5ddd82a0a60
|
[
"CC-BY-4.0"
] | 9
|
2015-08-08T18:46:06.000Z
|
2021-02-01T13:53:20.000Z
|
// Copyright information can be found in the file named COPYING
// located in the root directory of this distribution.
#include "platform/platform.h"
#include "util/catmullRom.h"
#include "math/mMathFn.h"
const F32 CatmullRomBase::smX[] =
{
0.0000000000f, 0.5384693101f, -0.5384693101f, 0.9061798459f, -0.9061798459f
};
const F32 CatmullRomBase::smC[] =
{
0.5688888889f, 0.4786286705f, 0.4786286705f, 0.2369268850f, 0.2369268850f
};
CatmullRomBase::CatmullRomBase()
: mTimes( NULL ),
mLengths( NULL ),
mTotalLength( 0.0f ),
mCount( 0 )
{
}
void CatmullRomBase::_initialize( U32 count, const F32 *times )
{
//AssertFatal( times, "CatmullRomBase::_initialize() - Got null position!" )
AssertFatal( count > 1, "CatmullRomBase::_initialize() - Must have more than 2 points!" )
// set up arrays
mTimes = new F32[count];
mCount = count;
// set up curve segment lengths
mLengths = new F32[count-1];
mTotalLength = 0.0f;
for ( U32 i = 0; i < count-1; ++i )
{
mLengths[i] = segmentArcLength(i, 0.0f, 1.0f);
mTotalLength += mLengths[i];
}
// copy the times if we have them.
F32 l = 0.0f;
for ( U32 i = 0; i < count; ++i )
{
if ( times )
mTimes[i] = times[i];
else
{
if ( mIsZero( mTotalLength ) )
mTimes[i] = 0.0f;
else
mTimes[i] = l / mTotalLength;
if ( i < count-1 )
l += mLengths[i];
}
}
}
void CatmullRomBase::clear()
{
delete [] mTimes;
mTimes = NULL;
delete [] mLengths;
mLengths = NULL;
mTotalLength = 0.0f;
mCount = 0;
}
F32 CatmullRomBase::arcLength( F32 t1, F32 t2 )
{
if ( t2 <= t1 )
return 0.0f;
if ( t1 < mTimes[0] )
t1 = mTimes[0];
if ( t2 > mTimes[mCount-1] )
t2 = mTimes[mCount-1];
// find segment and parameter
U32 seg1;
for ( seg1 = 0; seg1 < mCount-1; ++seg1 )
{
if ( t1 <= mTimes[seg1+1] )
{
break;
}
}
F32 u1 = (t1 - mTimes[seg1])/(mTimes[seg1+1] - mTimes[seg1]);
// find segment and parameter
U32 seg2;
for ( seg2 = 0; seg2 < mCount-1; ++seg2 )
{
if ( t2 <= mTimes[seg2+1] )
{
break;
}
}
F32 u2 = (t2 - mTimes[seg2])/(mTimes[seg2+1] - mTimes[seg2]);
F32 result;
// both parameters lie in one segment
if ( seg1 == seg2 )
{
result = segmentArcLength( seg1, u1, u2 );
}
// parameters cross segments
else
{
result = segmentArcLength( seg1, u1, 1.0f );
for ( U32 i = seg1+1; i < seg2; ++i )
result += mLengths[i];
result += segmentArcLength( seg2, 0.0f, u2 );
}
return result;
}
U32 CatmullRomBase::getPrevNode( F32 t )
{
AssertFatal( mCount >= 2, "CatmullRomBase::getPrevNode - Bad point count!" );
// handle boundary conditions
if ( t <= mTimes[0] )
return 0;
else if ( t >= mTimes[mCount-1] )
return mCount-1;
// find segment and parameter
U32 i; // segment #
for ( i = 0; i < mCount-1; ++i )
{
if ( t <= mTimes[i+1] )
break;
}
AssertFatal( i >= 0 && i < mCount, "CatmullRomBase::getPrevNode - Got bad output index!" );
return i;
}
F32 CatmullRomBase::getTime( U32 idx )
{
AssertFatal( idx >= 0 && idx < mCount, "CatmullRomBase::getTime - Got bad index!" );
return mTimes[idx];
}
| 21.645161
| 94
| 0.569001
|
fr1tz
|
1f8989f008bd2186682b99ccb5577861cd3c9cc3
| 1,637
|
hpp
|
C++
|
include/StateInGame.hpp
|
nqbinh47/Maze-Runner
|
f8bd2ad1c39154676f9b49d0285464396adbcf80
|
[
"MIT"
] | 4
|
2022-01-18T02:47:11.000Z
|
2022-01-19T13:04:59.000Z
|
include/StateInGame.hpp
|
phphuc62/Maze-Runner
|
f8bd2ad1c39154676f9b49d0285464396adbcf80
|
[
"MIT"
] | null | null | null |
include/StateInGame.hpp
|
phphuc62/Maze-Runner
|
f8bd2ad1c39154676f9b49d0285464396adbcf80
|
[
"MIT"
] | 1
|
2022-01-18T02:52:53.000Z
|
2022-01-18T02:52:53.000Z
|
#pragma once
#include "StateGame.hpp"
#define SCREEN_TITLE_WIDTH (SCREEN_WIDTH - 2 * SPACE)
#define SCREEN_TITLE_HEIGHT (OFFSET_MAZE_Y - 2 * SPACE)
#define OFFSET_TITLE_X (SPACE + SCREEN_TITLE_WIDTH / 2)
#define OFFSET_TITLE_Y (SPACE + SCREEN_TITLE_HEIGHT / 2)
#define NUMBER_OF_BOXES 3
#define NUMBER_OF_BUTTONS 3
#define SCREEN_INFO_HEIGHT (SCREEN_MAZE_Y / NUMBER_OF_BOXES)
#define SCREEN_INFO_WIDTH (SCREEN_WIDTH - SCREEN_MAZE_X - 2 * SPACE)
#define OFFSET_LEVEL_X (OFFSET_MAZE_X + SCREEN_MAZE_X + 5 + SCREEN_INFO_WIDTH / 2)
#define OFFSET_LEVEL_Y (OFFSET_MAZE_Y + SCREEN_INFO_HEIGHT / 2)
#define OFFSET_TIME_X (OFFSET_LEVEL_X - SCREEN_INFO_WIDTH / 4)
#define OFFSET_TIME_Y (OFFSET_LEVEL_Y + SCREEN_INFO_HEIGHT / 4 * 3)
#define OFFSET_TIME_INFO_X OFFSET_TIME_X
#define OFFSET_TIME_INFO_Y (OFFSET_TIME_Y + SCREEN_INFO_HEIGHT / 2)
#define OFFSET_COINS_X (OFFSET_LEVEL_X + SCREEN_INFO_WIDTH / 4)
#define OFFSET_COINS_Y OFFSET_TIME_Y
#define OFFSET_COINS_INFO_X OFFSET_COINS_X
#define OFFSET_COINS_INFO_Y (OFFSET_COINS_Y + SCREEN_INFO_HEIGHT / 2)
#define BUTTON_HEIGHT (SCREEN_INFO_HEIGHT / 2)
#define BUTTON_WIDTH (SCREEN_INFO_WIDTH / (NUMBER_OF_BUTTONS + 1))
#define BUTTON_SPACE (BUTTON_WIDTH / (NUMBER_OF_BUTTONS + 1))
#define OFFSET_HELP_X (OFFSET_LEVEL_X - SCREEN_INFO_WIDTH / 2 + BUTTON_SPACE + BUTTON_WIDTH / 2)
#define OFFSET_HELP_Y (OFFSET_TIME_INFO_Y + SCREEN_INFO_HEIGHT / 4 * 3)
#define OFFSET_RESTART_X (OFFSET_HELP_X + BUTTON_WIDTH + BUTTON_SPACE)
#define OFFSET_RESTART_Y OFFSET_HELP_Y
#define OFFSET_RETURN_MENU_X (OFFSET_RESTART_X + BUTTON_WIDTH + BUTTON_SPACE)
#define OFFSET_RETURN_MENU_Y OFFSET_HELP_Y
| 40.925
| 96
| 0.808186
|
nqbinh47
|
1f8b36183b039cad25ae480f4b2be6b17518b860
| 2,048
|
cpp
|
C++
|
BasiliskII/src/uae_cpu/fpu/rounding.cpp
|
jvernet/macemu
|
c616a0dae0f451fc15016765c896175fae3f46cf
|
[
"Intel",
"X11"
] | 940
|
2015-01-04T12:20:10.000Z
|
2022-03-29T12:35:27.000Z
|
BasiliskII/src/uae_cpu/fpu/rounding.cpp
|
Seanpm2001-virtual-machines/macemu
|
c616a0dae0f451fc15016765c896175fae3f46cf
|
[
"Intel",
"X11"
] | 163
|
2015-02-10T09:08:10.000Z
|
2022-03-13T05:48:10.000Z
|
BasiliskII/src/uae_cpu/fpu/rounding.cpp
|
Seanpm2001-virtual-machines/macemu
|
c616a0dae0f451fc15016765c896175fae3f46cf
|
[
"Intel",
"X11"
] | 188
|
2015-01-07T19:46:11.000Z
|
2022-03-26T19:06:00.000Z
|
/*
* fpu/rounding.cpp - system-dependant FPU rounding mode and precision
*
* Basilisk II (C) 1997-2008 Christian Bauer
*
* MC68881/68040 fpu emulation
*
* Original UAE FPU, copyright 1996 Herman ten Brugge
* Rewrite for x86, copyright 1999-2000 Lauri Pesonen
* New framework, copyright 2000 Gwenole Beauchesne
* Adapted for JIT compilation (c) Bernd Meyer, 2000
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#undef PRIVATE
#define PRIVATE /**/
#undef PUBLIC
#define PUBLIC /**/
#undef FFPU
#define FFPU /**/
#undef FPU
#define FPU fpu.
/* -------------------------------------------------------------------------- */
/* --- Native X86 Rounding Mode --- */
/* -------------------------------------------------------------------------- */
#ifdef FPU_USE_X86_ROUNDING_MODE
const uae_u32 FFPU x86_control_word_rm_mac2host[] = {
CW_RC_NEAR,
CW_RC_ZERO,
CW_RC_DOWN,
CW_RC_UP
};
#endif
/* -------------------------------------------------------------------------- */
/* --- Native X86 Rounding Precision --- */
/* -------------------------------------------------------------------------- */
#ifdef FPU_USE_X86_ROUNDING_PRECISION
const uae_u32 FFPU x86_control_word_rp_mac2host[] = {
CW_PC_EXTENDED,
CW_PC_SINGLE,
CW_PC_DOUBLE,
CW_PC_RESERVED
};
#endif
| 31.507692
| 80
| 0.587402
|
jvernet
|
1f8cda7fa9d89777f6f1368265cfe2be5fd45d95
| 27,457
|
cpp
|
C++
|
DryadVertex/VertexHost/system/channel/src/recorditem.cpp
|
TheWhiteEagle/Dryad
|
ad28579dd8303925befc6502633949850b7ca550
|
[
"Apache-2.0"
] | 242
|
2015-01-04T08:08:04.000Z
|
2022-03-31T02:00:14.000Z
|
DryadVertex/VertexHost/system/channel/src/recorditem.cpp
|
TheWhiteEagle/Dryad
|
ad28579dd8303925befc6502633949850b7ca550
|
[
"Apache-2.0"
] | 2
|
2015-04-30T07:44:42.000Z
|
2015-05-19T06:24:31.000Z
|
DryadVertex/VertexHost/system/channel/src/recorditem.cpp
|
TheWhiteEagle/Dryad
|
ad28579dd8303925befc6502633949850b7ca550
|
[
"Apache-2.0"
] | 50
|
2015-01-13T20:39:53.000Z
|
2022-01-09T20:42:34.000Z
|
/*
Copyright (c) Microsoft Corporation
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
THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF
TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions and
limitations under the License.
*/
#include "recorditem.h"
#pragma unmanaged
RecordArrayBase::RecordArrayBase()
{
m_recordArray = NULL;
m_recordArraySize = 0;
m_numberOfRecords = 0;
m_nextRecord = 0;
m_serializedAny = 0;
}
RecordArrayBase::~RecordArrayBase()
{
LogAssert(m_buffer == NULL);
LogAssert(m_recordArray == NULL);
}
void RecordArrayBase::FreeStorage()
{
m_buffer = NULL;
if (m_recordArraySize > 0)
{
FreeTypedArray(m_recordArray);
}
m_recordArray = NULL;
m_recordArraySize = 0;
m_numberOfRecords = 0;
m_nextRecord = 0;
}
void RecordArrayBase::PopRecord()
{
LogAssert(m_nextRecord > 0);
--m_nextRecord;
}
UInt32 RecordArrayBase::GetNumberOfRecords() const
{
return m_numberOfRecords;
}
UInt64 RecordArrayBase::GetNumberOfSubItems() const
{
return GetNumberOfRecords();
}
void RecordArrayBase::TruncateSubItems(UInt64 numberOfSubItems)
{
LogAssert(numberOfSubItems < (UInt64) m_numberOfRecords);
SetRecordIndex((UInt32) numberOfSubItems);
Truncate();
ResetRecordPointer();
}
UInt64 RecordArrayBase::GetItemSize() const
{
return (UInt64) GetRecordSize() * (UInt64) GetNumberOfRecords();
}
void* RecordArrayBase::GetRecordArrayUntyped()
{
return m_recordArray;
}
void RecordArrayBase::SetNumberOfRecords(UInt32 numberOfRecords)
{
if (m_recordArraySize < numberOfRecords)
{
if (m_recordArraySize > 0)
{
LogAssert(m_buffer == NULL);
FreeTypedArray(m_recordArray);
}
m_recordArraySize = numberOfRecords;
if (m_recordArraySize > 0)
{
m_recordArray = MakeTypedArray(m_recordArraySize);
}
else
{
m_recordArray = NULL;
}
}
else if (m_recordArraySize == 0)
{
LogAssert(m_buffer != NULL);
LogAssert(m_recordArray != NULL);
m_recordArray = NULL;
}
m_buffer = NULL;
m_numberOfRecords = numberOfRecords;
ResetRecordPointer();
}
void RecordArrayBase::ResetRecordPointer()
{
m_nextRecord = 0;
}
void* RecordArrayBase::GetRecordUntyped(UInt32 index)
{
LogAssert(index < m_numberOfRecords);
char* cPtr = (char *) m_recordArray;
return &(cPtr[GetRecordSize() * index]);
}
//
// Return pointer to next record in array
//
void* RecordArrayBase::NextRecordUntyped()
{
if (m_nextRecord == m_numberOfRecords)
{
//
// If no more records, return null
//
return NULL;
}
else
{
//
// If valid record index, set return value to correct
// offset from array start and increment "next record" index
//
LogAssert(m_nextRecord < m_numberOfRecords);
char* cPtr = (char *) m_recordArray;
void* r = &(cPtr[GetRecordSize() * m_nextRecord]);
++m_nextRecord;
return r;
}
}
//
// Return the next record index
//
UInt32 RecordArrayBase::GetRecordIndex() const
{
return m_nextRecord;
}
void RecordArrayBase::SetRecordIndex(UInt32 index)
{
LogAssert(index <= m_numberOfRecords);
m_nextRecord = index;
}
//
// Return whether there are any additional records available
//
bool RecordArrayBase::AtEnd()
{
return (m_nextRecord == m_numberOfRecords);
}
void RecordArrayBase::Truncate()
{
if (m_nextRecord*2 < m_recordArraySize)
{
void* newArray = TransferTruncatedArray(m_recordArray, m_nextRecord);
FreeTypedArray(m_recordArray);
m_recordArray = newArray;
m_recordArraySize = m_nextRecord;
}
m_numberOfRecords = m_nextRecord;
}
void RecordArrayBase::TransferRecord(void* dstRecord, void* srcRecord)
{
TransferRecord(NULL, dstRecord, NULL, srcRecord);
}
void* RecordArrayBase::TransferTruncatedArray(void* srcArrayUntyped,
UInt32 numberOfRecords)
{
if (numberOfRecords == 0)
{
return NULL;
}
void* dstArrayUntyped = MakeTypedArray(numberOfRecords);
LogAssert(dstArrayUntyped != NULL);
char* srcPtr = (char *) srcArrayUntyped;
char* dstPtr = (char *) dstArrayUntyped;
UInt32 i;
for (i=0; i<numberOfRecords;
++i, srcPtr += GetRecordSize(), dstPtr += GetRecordSize())
{
TransferRecord(this, dstPtr, this, srcPtr);
}
return dstArrayUntyped;
}
UInt32 RecordArrayBase::ReadArray(DrMemoryBuffer* buffer,
Size_t startOffset, UInt32 nRecords)
{
Size_t neededSize = nRecords * GetRecordSize();
Size_t availableSize = buffer->GetAvailableSize();
LogAssert(availableSize >= startOffset);
Size_t remainingSize = buffer->GetAvailableSize() - startOffset;
if (remainingSize < neededSize)
{
SetNumberOfRecords(0);
return 0;
}
else
{
SetNumberOfRecords(nRecords);
buffer->Read(startOffset, m_recordArray, neededSize);
return (UInt32) neededSize;
}
}
DrError RecordArrayBase::ReadFinalArray(DrMemoryBuffer* buffer)
{
LogAssert(buffer->GetAvailableSize() < GetRecordSize());
return DrError_EndOfStream;
}
UInt32 RecordArrayBase::AttachArray(DryadLockedMemoryBuffer* buffer,
Size_t startOffset)
{
Size_t remainingSize;
void* recordArray = (void *) buffer->GetReadAddress(startOffset,
&remainingSize);
LogAssert(remainingSize == buffer->GetAvailableSize() - startOffset);
UInt32 numberOfRecords = (UInt32) (remainingSize / GetRecordSize());
if (numberOfRecords == 0)
{
SetNumberOfRecords(0);
return 0;
}
else
{
FreeStorage();
m_buffer = buffer;
m_recordArray = recordArray;
m_numberOfRecords = numberOfRecords;
return (UInt32) (m_numberOfRecords * GetRecordSize());
}
}
DrError RecordArrayBase::DeSerialize(DrResettableMemoryReader* reader,
Size_t availableSize)
{
UInt32 numberOfRecords = (UInt32) (availableSize / GetRecordSize());
if (numberOfRecords < 1)
{
return DrError_EndOfStream;
}
if (GetNumberOfRecords() == 0)
{
SetNumberOfRecords(numberOfRecords);
}
if (numberOfRecords >= GetNumberOfRecords())
{
numberOfRecords = GetNumberOfRecords();
}
else
{
SetNumberOfRecords(numberOfRecords);
}
Size_t dataLength = (Size_t) (numberOfRecords * GetRecordSize());
DrError err = reader->ReadBytes((BYTE *) GetRecordArrayUntyped(),
dataLength);
LogAssert(err == DrError_OK);
return DrError_OK;
}
void RecordArrayBase::StartSerializing()
{
if (m_serializedAny == false)
{
ResetRecordPointer();
m_serializedAny = true;
}
}
DrError RecordArrayBase::Serialize(ChannelMemoryBufferWriter* writer)
{
StartSerializing();
void* nextRecord;
bool filledBuffer = writer->MarkRecordBoundary();
LogAssert(filledBuffer == false);
while (filledBuffer == false &&
(nextRecord = NextRecordUntyped()) != NULL)
{
writer->WriteBytes((BYTE *) nextRecord, GetRecordSize());
filledBuffer = writer->MarkRecordBoundary();
}
if (filledBuffer)
{
return DrError_IncompleteOperation;
}
else
{
return DrError_OK;
}
}
PackedRecordArrayParserBase::
PackedRecordArrayParserBase(DObjFactoryBase* factory)
{
m_factory = factory;
}
PackedRecordArrayParserBase::~PackedRecordArrayParserBase()
{
}
RChannelItem* PackedRecordArrayParserBase::
ParseNextItem(ChannelDataBufferList* bufferList,
Size_t startOffset,
Size_t* pOutLength)
{
LogAssert(bufferList->IsEmpty() == false);
RecordArrayBase *item =
(RecordArrayBase *) m_factory->AllocateObjectUntyped();
RChannelBufferData* headBuffer =
bufferList->CastOut(bufferList->GetHead());
if (bufferList->GetHead() != bufferList->GetTail())
{
RChannelBufferData* tailBuffer =
bufferList->CastOut(bufferList->GetTail());
Size_t tailBufferSize =
tailBuffer->GetData()->GetAvailableSize();
DrRef<RChannelReaderBuffer> combinedBuffer;
combinedBuffer.Attach(new RChannelReaderBuffer(bufferList,
startOffset,
tailBufferSize));
*pOutLength = item->ReadArray(combinedBuffer, 0, 1);
}
else
{
*pOutLength = item->AttachArray(headBuffer->GetData(), startOffset);
}
if (*pOutLength == 0)
{
m_factory->FreeObjectUntyped(item);
item = NULL;
}
return item;
}
RChannelItem* PackedRecordArrayParserBase::
ParsePartialItem(ChannelDataBufferList* bufferList,
Size_t startOffset,
RChannelBufferMarker*
markerBuffer)
{
if (bufferList->IsEmpty())
{
return NULL;
}
RChannelBufferData* tailBuffer =
bufferList->CastOut(bufferList->GetTail());
Size_t tailBufferSize =
tailBuffer->GetData()->GetAvailableSize();
DrRef<RChannelReaderBuffer> combinedBuffer;
combinedBuffer.Attach(new RChannelReaderBuffer(bufferList,
startOffset,
tailBufferSize));
RecordArrayBase *item =
(RecordArrayBase *) m_factory->AllocateObjectUntyped();
DrError err = item->ReadFinalArray(combinedBuffer);
if (err == DrError_OK)
{
return item;
}
m_factory->FreeObjectUntyped(item);
if (err == DrError_EndOfStream)
{
return NULL;
}
else
{
return RChannelMarkerItem::CreateErrorItem(RChannelItem_ParseError,
err);
}
}
PackedRecordArrayParser::PackedRecordArrayParser(DObjFactoryBase* factory) :
PackedRecordArrayParserBase(factory)
{
}
PackedRecordArrayParser::~PackedRecordArrayParser()
{
}
RecordArrayReaderBase::RecordArrayReaderBase()
{
}
RecordArrayReaderBase::RecordArrayReaderBase(SyncItemReaderBase* reader)
{
Initialize(reader);
}
RecordArrayReaderBase::~RecordArrayReaderBase()
{
delete [] m_currentRecord;
delete [] m_itemCache;
}
void RecordArrayReaderBase::Initialize(SyncItemReaderBase* reader)
{
m_reader = reader;
m_arrayItem = NULL;
m_cacheSize = 32;
m_currentRecord = new void* [m_cacheSize];
m_itemCache = new RChannelItemRef [m_cacheSize];
m_valid = 0;
m_cachedItemCount = 0;
}
void RecordArrayReaderBase::DiscardCachedItems()
{
UInt32 i;
for (i=0; i<m_cachedItemCount; ++i)
{
m_itemCache[i] = NULL;
}
m_cachedItemCount = 0;
}
bool RecordArrayReaderBase::AdvanceInternal(UInt32 slotNumber)
{
while (m_item == NULL)
{
LogAssert(m_arrayItem == NULL);
DrError status = m_reader->ReadItemSync(&m_item);
LogAssert(status == DrError_OK);
LogAssert(m_item != NULL);
RChannelItemType itemType = m_item->GetType();
if (itemType == RChannelItem_Data)
{
m_arrayItem = (RecordArrayBase *) (m_item.Ptr());
}
else if (RChannelItem::IsTerminationItem(itemType) == false)
{
/* this is a marker; skip it and fetch the next one */
m_item = NULL;
}
}
if (m_arrayItem != NULL)
{
m_currentRecord[slotNumber] = m_arrayItem->NextRecordUntyped();
LogAssert(m_currentRecord[slotNumber] != NULL);
if (m_arrayItem->AtEnd())
{
m_itemCache[m_cachedItemCount].TransferFrom(m_item);
LogAssert(m_item == NULL);
m_arrayItem = NULL;
++m_cachedItemCount;
}
return true;
}
else
{
return false;
}
}
void RecordArrayReaderBase::PushBack()
{
PushBack(true);
}
void RecordArrayReaderBase::PushBack(bool pushValid)
{
if (pushValid)
{
LogAssert(m_valid > 0);
}
if (m_arrayItem == NULL)
{
LogAssert(m_item == NULL);
LogAssert(m_cachedItemCount > 0);
--m_cachedItemCount;
m_item.TransferFrom(m_itemCache[m_cachedItemCount]);
m_arrayItem = (RecordArrayBase *) (m_item.Ptr());
}
if (m_arrayItem->GetRecordIndex() == 0)
{
DrLogA("Can't push back more than one record");
}
m_arrayItem->PopRecord();
if (pushValid)
{
--m_valid;
}
}
bool RecordArrayReaderBase::Advance()
{
DiscardCachedItems();
if (AdvanceInternal(0))
{
m_valid = 1;
return true;
}
else
{
m_valid = 0;
return false;
}
}
UInt32 RecordArrayReaderBase::AdvanceBlock(UInt32 validEntriesRequested)
{
DiscardCachedItems();
if (validEntriesRequested > m_cacheSize)
{
delete [] m_currentRecord;
delete [] m_itemCache;
m_cacheSize = validEntriesRequested;
m_currentRecord = new void* [m_cacheSize];
m_itemCache = new RChannelItemRef [m_cacheSize];
}
UInt32 i;
for (i=0; i<validEntriesRequested; ++i)
{
if (AdvanceInternal(i) == false)
{
break;
}
}
m_valid = i;
return i;
}
DrError RecordArrayReaderBase::GetStatus()
{
RChannelItem* item = GetTerminationItem();
if (item == NULL)
{
return DrError_OK;
}
else
{
return item->GetErrorFromItem();
}
}
RChannelItem* RecordArrayReaderBase::GetTerminationItem()
{
if (m_item == NULL ||
RChannelItem::IsTerminationItem(m_item->GetType()) == false)
{
return NULL;
}
else
{
return m_item;
}
}
UInt32 RecordArrayReaderBase::GetValidCount() const
{
return m_valid;
}
RecordArrayWriterBase::RecordArrayWriterBase()
{
m_currentRecord = NULL;
m_itemCache = NULL;
m_cachedItemCount = 0;
}
RecordArrayWriterBase::RecordArrayWriterBase(SyncItemWriterBase* writer,
DObjFactoryBase* factory)
{
m_currentRecord = NULL;
m_itemCache = NULL;
m_cachedItemCount = 0;
Initialize(writer, factory);
}
RecordArrayWriterBase::~RecordArrayWriterBase()
{
Destroy();
}
void RecordArrayWriterBase::Destroy()
{
Flush();
delete [] m_currentRecord;
delete [] m_itemCache;
}
void RecordArrayWriterBase::Initialize(SyncItemWriterBase* writer,
DObjFactoryBase* factory)
{
Destroy();
m_factory = factory;
m_writer = writer;
m_cacheSize = 32;
m_currentRecord = new void* [m_cacheSize];
m_itemCache = new DrRef<RecordArrayBase> [m_cacheSize];
m_valid = 0;
m_pushBackIndex = 0;
m_cachedItemCount = 0;
}
void RecordArrayWriterBase::SetWriter(SyncItemWriterBase* writer)
{
m_writer = writer;
}
DrError RecordArrayWriterBase::GetWriterStatus()
{
return m_writer->GetWriterStatus();
}
//
// Write out any cached items
//
void RecordArrayWriterBase::SendCachedItems()
{
UInt32 i;
for (i=0; i<m_cachedItemCount; ++i)
{
//
// ensure the record pointer is rewound in case we are sending
// this down a FIFO
//
m_itemCache[i]->ResetRecordPointer();
m_writer->WriteItemSync(m_itemCache[i]);
m_itemCache[i] = NULL;
}
m_cachedItemCount = 0;
}
//
// Move to next available object if one is available.
//
void RecordArrayWriterBase::AdvanceInternal(UInt32 slotNumber)
{
if (m_item == NULL)
{
//
// If no current record array, generate one
//
RecordArrayBase *item = (RecordArrayBase *)
m_factory->AllocateObjectUntyped();
m_item.Attach(item);
}
//
// Set current record to the next available record
//
m_currentRecord[slotNumber] = m_item->NextRecordUntyped();
LogAssert(m_currentRecord[slotNumber] != NULL);
//
// If there are no more records in this record array, transfer the
// record array into the item cache to remember that all items are cached.
//
if (m_item->AtEnd())
{
m_itemCache[m_cachedItemCount].TransferFrom(m_item);
LogAssert(m_item == NULL);
++m_cachedItemCount;
}
}
//
//
//
void RecordArrayWriterBase::MakeValid()
{
//
// Clear out any cached items to reset
//
SendCachedItems();
//
// Get the index of the next available record
//
if (m_item == NULL)
{
m_pushBackIndex = 0;
}
else
{
m_pushBackIndex = m_item->GetRecordIndex();
}
//
// Move to next available object if one is available and mark as valid
//
AdvanceInternal(0);
m_valid = 1;
}
void RecordArrayWriterBase::MakeValidBlock(UInt32 validEntriesRequested)
{
SendCachedItems();
if (m_item == NULL)
{
m_pushBackIndex = 0;
}
else
{
m_pushBackIndex = m_item->GetRecordIndex();
}
if (validEntriesRequested > m_cacheSize)
{
delete [] m_currentRecord;
delete [] m_itemCache;
m_cacheSize = validEntriesRequested;
m_currentRecord = new void* [m_cacheSize];
m_itemCache = new DrRef<RecordArrayBase> [m_cacheSize];
}
UInt32 i;
for (i=0; i<validEntriesRequested; ++i)
{
AdvanceInternal(i);
}
m_valid = validEntriesRequested;
}
UInt32 RecordArrayWriterBase::GetValidCount() const
{
return m_valid;
}
void RecordArrayWriterBase::PushBack()
{
LogAssert(m_valid > 0);
if (m_cachedItemCount > 0)
{
/* throw away back to the item we were using when we started */
m_item.TransferFrom(m_itemCache[0]);
UInt32 i;
for (i=1; i<m_cachedItemCount; ++i)
{
m_itemCache[i] = NULL;
}
m_cachedItemCount = 0;
}
LogAssert(m_item != NULL);
m_item->SetRecordIndex(m_pushBackIndex);
m_pushBackIndex = 0;
m_valid = 0;
}
void* RecordArrayWriterBase::ReadValidUntyped(UInt32 index)
{
LogAssert(index < m_valid);
return m_currentRecord[index];
}
void RecordArrayWriterBase::Flush()
{
if (m_item != NULL)
{
m_item->Truncate();
m_itemCache[m_cachedItemCount].TransferFrom(m_item);
LogAssert(m_item == NULL);
++m_cachedItemCount;
}
SendCachedItems();
m_valid = 0;
}
void RecordArrayWriterBase::Terminate()
{
Flush();
RChannelItemRef item;
item.Attach(RChannelMarkerItem::Create(RChannelItem_EndOfStream, false));
m_writer->WriteItemSync(item);
}
AlternativeRecordParserBase::
AlternativeRecordParserBase(DObjFactoryBase* factory)
{
m_factory = factory;
m_function = NULL;
}
AlternativeRecordParserBase::
AlternativeRecordParserBase(DObjFactoryBase* factory,
RecordDeSerializerFunction* function)
{
m_factory = factory;
m_function = function;
}
AlternativeRecordParserBase::~AlternativeRecordParserBase()
{
}
void AlternativeRecordParserBase::ResetParser()
{
m_pendingErrorItem = NULL;
}
DrError AlternativeRecordParserBase::
DeSerializeArray(RecordArrayBase* array,
DrResettableMemoryReader* reader,
Size_t availableSize)
{
if (array->GetNumberOfRecords() == 0)
{
array->SetNumberOfRecords(RChannelItem::s_defaultRecordBatchSize);
}
Size_t sizeUsed = 0;
Size_t remainingSize = availableSize;
DrError err = DrError_OK;
array->ResetRecordPointer();
void* nextRecord;
while (remainingSize > 0 &&
(nextRecord = array->NextRecordUntyped()) != NULL)
{
err = DeSerializeUntyped(nextRecord, reader, remainingSize, false);
if (err != DrError_OK)
{
array->PopRecord();
reader->ResetToBufferOffset(sizeUsed);
break;
}
sizeUsed = reader->GetBufferOffset();
LogAssert(sizeUsed <= availableSize);
remainingSize = availableSize - sizeUsed;
}
array->Truncate();
array->ResetRecordPointer();
if (err == DrError_EndOfStream && array->AtEnd() == false)
{
/* AtEnd() == false after Truncate+Reset means there's at
least one item */
err = DrError_OK;
}
return err;
}
RChannelItem* AlternativeRecordParserBase::
ParseNextItem(ChannelDataBufferList* bufferList,
Size_t startOffset,
Size_t* pOutLength)
{
if (m_pendingErrorItem != NULL)
{
return m_pendingErrorItem.Detach();
}
LogAssert(bufferList->IsEmpty() == false);
RChannelBufferData* tailBuffer =
bufferList->CastOut(bufferList->GetTail());
Size_t tailBufferSize =
tailBuffer->GetData()->GetAvailableSize();
DrRef<DrMemoryBuffer> buffer;
buffer.Attach(new RChannelReaderBuffer(bufferList,
startOffset,
tailBufferSize));
DrResettableMemoryReader reader(buffer);
RecordArrayBase* recordArray =
(RecordArrayBase *) m_factory->AllocateObjectUntyped();
DrError err = DeSerializeArray(recordArray, &reader,
buffer->GetAvailableSize());
if (err == DrError_OK)
{
*pOutLength = reader.GetBufferOffset();
return recordArray;
}
m_factory->FreeObjectUntyped(recordArray);
if (err == DrError_EndOfStream)
{
return NULL;
}
else
{
return RChannelMarkerItem::CreateErrorItem(RChannelItem_ParseError,
err);
}
}
RChannelItem* AlternativeRecordParserBase::
ParsePartialItem(ChannelDataBufferList* bufferList,
Size_t startOffset,
RChannelBufferMarker*
markerBuffer)
{
if (m_pendingErrorItem != NULL)
{
return m_pendingErrorItem.Detach();
}
if (bufferList->IsEmpty())
{
return NULL;
}
RChannelBufferData* tailBuffer =
bufferList->CastOut(bufferList->GetTail());
Size_t tailBufferSize =
tailBuffer->GetData()->GetAvailableSize();
DrRef<DrMemoryBuffer> buffer;
buffer.Attach(new RChannelReaderBuffer(bufferList,
startOffset,
tailBufferSize));
DrResettableMemoryReader reader(buffer);
RecordArrayBase* recordArray =
(RecordArrayBase *) m_factory->AllocateObjectUntyped();
recordArray->SetNumberOfRecords(1);
void* nextRecord = recordArray->NextRecordUntyped();
DrError err = DeSerializeUntyped(nextRecord, &reader,
buffer->GetAvailableSize(), true);
if (err == DrError_OK)
{
recordArray->ResetRecordPointer();
return recordArray;
}
m_factory->FreeObjectUntyped(recordArray);
if (err == DrError_EndOfStream)
{
return NULL;
}
else
{
return RChannelMarkerItem::CreateErrorItem(RChannelItem_ParseError,
err);
}
}
DrError AlternativeRecordParserBase::
DeSerializeUntyped(void* record,
DrMemoryBufferReader* reader,
Size_t availableSize, bool lastRecordInStream)
{
return (*m_function)(record, reader, availableSize, lastRecordInStream);
}
UntypedAlternativeRecordParser::
UntypedAlternativeRecordParser(DObjFactoryBase* factory,
RecordDeSerializerFunction* function) :
AlternativeRecordParserBase(factory, function)
{
}
StdAlternativeRecordParserFactory::
StdAlternativeRecordParserFactory(DObjFactoryBase* factory,
RecordDeSerializerFunction* function)
{
m_factory = factory;
m_function = function;
}
void StdAlternativeRecordParserFactory::
MakeParser(RChannelItemParserRef* pParser,
DVErrorReporter* errorReporter)
{
pParser->Attach(new UntypedAlternativeRecordParser(m_factory,
m_function));
}
AlternativeRecordMarshalerBase::AlternativeRecordMarshalerBase()
{
m_function = NULL;
}
AlternativeRecordMarshalerBase::
AlternativeRecordMarshalerBase(RecordSerializerFunction* function)
{
m_function = function;
}
AlternativeRecordMarshalerBase::~AlternativeRecordMarshalerBase()
{
}
void AlternativeRecordMarshalerBase::
SetFunction(RecordSerializerFunction* function)
{
m_function = function;
}
DrError AlternativeRecordMarshalerBase::
MarshalItem(ChannelMemoryBufferWriter* writer,
RChannelItem* item,
bool flush,
RChannelItemRef* pFailureItem)
{
DrError err = DrError_OK;
if (item->GetType() != RChannelItem_Data)
{
return err;
}
RecordArrayBase* arrayItem = (RecordArrayBase *) item;
arrayItem->StartSerializing();
Size_t currentPosition = 0;
void* nextRecord;
bool filledBuffer = writer->MarkRecordBoundary();
LogAssert(filledBuffer == false);
while (err == DrError_OK &&
filledBuffer == false &&
(nextRecord = arrayItem->NextRecordUntyped()) != NULL)
{
currentPosition = writer->GetBufferOffset();
err = SerializeUntyped(nextRecord, writer);
if (err == DrError_OK)
{
filledBuffer = writer->MarkRecordBoundary();
}
}
if (err != DrError_OK)
{
LogAssert(writer->GetStatus() == DrError_OK);
writer->SetBufferOffset(currentPosition);
pFailureItem->Attach(RChannelMarkerItem::
CreateErrorItem(RChannelItem_MarshalError,
err));
return DryadError_ChannelAbort;
}
if (filledBuffer)
{
return DrError_IncompleteOperation;
}
return DrError_OK;
}
DrError AlternativeRecordMarshalerBase::
SerializeUntyped(void* record,
DrMemoryBufferWriter* writer)
{
return (*m_function)(record, writer);
}
UntypedAlternativeRecordMarshaler::
UntypedAlternativeRecordMarshaler(RecordSerializerFunction* function) :
AlternativeRecordMarshalerBase(function)
{
}
StdAlternativeRecordMarshalerFactory::
StdAlternativeRecordMarshalerFactory(RecordSerializerFunction* function)
{
m_function = function;
}
void StdAlternativeRecordMarshalerFactory::
MakeMarshaler(RChannelItemMarshalerRef* pMarshaler,
DVErrorReporter* errorReporter)
{
pMarshaler->Attach(new UntypedAlternativeRecordMarshaler(m_function));
}
| 24.063979
| 100
| 0.62953
|
TheWhiteEagle
|
1f912a21fa0f0ff1efadb3bd28be31f267a9c009
| 1,802
|
cpp
|
C++
|
components/arduino/libraries/UC20/call.cpp
|
pornpol/enres_logger_idf
|
b3024594e94d70e9c83f7738261fb70696521188
|
[
"Apache-2.0"
] | null | null | null |
components/arduino/libraries/UC20/call.cpp
|
pornpol/enres_logger_idf
|
b3024594e94d70e9c83f7738261fb70696521188
|
[
"Apache-2.0"
] | null | null | null |
components/arduino/libraries/UC20/call.cpp
|
pornpol/enres_logger_idf
|
b3024594e94d70e9c83f7738261fb70696521188
|
[
"Apache-2.0"
] | null | null | null |
#include "call.h"
#include "TEE_UC20.h"
CALL:: CALL(){}
unsigned char CALL:: Call(String call_number) /* return 0 = Timeout
return 1 = OK
return 2 = NO CARRIER
return 3 = BUSY
*/
{
gsm.print(F("ATD"));
gsm.print(call_number);
gsm.println(F(";"));
while(!gsm.available())
{}
gsm.start_time_out();
while(1)
{
String req = gsm.readStringUntil('\n');
if(req.indexOf(F("OK")) != -1)
{
gsm.debug(F("OK"));
return(1);
}
if(req.indexOf(F("NO CARRIER")) != -1)
{
gsm.debug(F("NO CARRIER"));
return(2);
}
if(req.indexOf(F("BUSY")) != -1)
{
gsm.debug(F("BUSY"));
return(2);
}
if(gsm.time_out(10000))
{
gsm.debug(F("Error"));
return(0);
}
}
return(0);
}
bool CALL:: Answer()
{
gsm.println(F("ATA"));
return(gsm.wait_ok(3000));
}
bool CALL:: DisconnectExisting()
{
gsm.println(F("ATH"));
return(gsm.wait_ok(3000));
}
bool CALL:: HangUp()
{
gsm.println(F("AT+CHUP"));
return(gsm.wait_ok(3000));
}
String CALL:: CurrentCallsMe()
{
gsm.println(F("AT+CLCC"));
while(!gsm.available())
{}
gsm.start_time_out();
while(1)
{
String req = gsm.readStringUntil('\n');
if(req.indexOf(F("+CLCC")) != -1)
{
char index1 = req.indexOf(F("\""));
char index2 = req.indexOf(F("\""),index1+1);
return(req.substring(index1+1,index2));
//Serial.println("req");
return(req);
}
if(gsm.time_out(20000))
{
return(F("CurrentCallsMe Timeout"));
}
}
return(F(" "));
}
bool CALL::WaitRing()
{
while(gsm.available())
{
String req = gsm.readStringUntil('\n');
if(req.indexOf(F("RING")) != -1)
{
return(true);
}
}
return(false);
}
| 16.381818
| 70
| 0.523307
|
pornpol
|
1f9539cd13ceae2303e02e48b7735be4cf82c190
| 7,190
|
cpp
|
C++
|
src/atta/graphicsSystem/renderers/phongRenderer.cpp
|
Brenocq/Atta
|
e29e01067e06b97bc58165bca7351723174c6fc4
|
[
"MIT"
] | 1
|
2021-06-18T00:48:13.000Z
|
2021-06-18T00:48:13.000Z
|
src/atta/graphicsSystem/renderers/phongRenderer.cpp
|
Brenocq/Atta
|
e29e01067e06b97bc58165bca7351723174c6fc4
|
[
"MIT"
] | 6
|
2021-03-11T21:01:27.000Z
|
2021-09-06T19:41:46.000Z
|
src/atta/graphicsSystem/renderers/phongRenderer.cpp
|
Brenocq/Atta
|
e29e01067e06b97bc58165bca7351723174c6fc4
|
[
"MIT"
] | 1
|
2021-09-04T19:54:41.000Z
|
2021-09-04T19:54:41.000Z
|
//--------------------------------------------------
// Atta Graphics System
// phongRenderer.cpp
// Date: 2021-09-18
// By Breno Cunha Queiroz
//--------------------------------------------------
#include <atta/graphicsSystem/renderers/phongRenderer.h>
#include <atta/graphicsSystem/graphicsManager.h>
#include <atta/graphicsSystem/framebuffer.h>
#include <atta/graphicsSystem/renderPass.h>
#include <atta/resourceSystem/resourceManager.h>
#include <atta/resourceSystem/resources/mesh.h>
#include <atta/componentSystem/componentManager.h>
#include <atta/componentSystem/components/meshComponent.h>
#include <atta/componentSystem/components/transformComponent.h>
#include <atta/componentSystem/components/materialComponent.h>
#include <atta/componentSystem/components/pointLightComponent.h>
#include <atta/componentSystem/components/directionalLightComponent.h>
#include <atta/componentSystem/factory.h>
namespace atta
{
PhongRenderer::PhongRenderer():
Renderer("PhongRenderer")
{
//---------- Create geometry pipeline ----------//
// Framebuffer
Framebuffer::CreateInfo framebufferInfo {};
framebufferInfo.attachments.push_back({Image::Format::RGB});
framebufferInfo.attachments.push_back({Image::Format::DEPTH32F});
framebufferInfo.width = 500;
framebufferInfo.height = 500;
framebufferInfo.debugName = StringId("PhongRenderer Framebuffer");
std::shared_ptr<Framebuffer> framebuffer = GraphicsManager::create<Framebuffer>(framebufferInfo);
// Shader Group
ShaderGroup::CreateInfo shaderGroupInfo {};
shaderGroupInfo.shaderPaths = {"shaders/phongRenderer/shader.vert", "shaders/phongRenderer/shader.frag"};
shaderGroupInfo.debugName = StringId("PhongRenderer Shader Group");
std::shared_ptr<ShaderGroup> shaderGroup = GraphicsManager::create<ShaderGroup>(shaderGroupInfo);
// Render Pass
RenderPass::CreateInfo renderPassInfo {};
renderPassInfo.framebuffer = framebuffer;
renderPassInfo.debugName = StringId("PhongRenderer Render Pass");
std::shared_ptr<RenderPass> renderPass = GraphicsManager::create<RenderPass>(renderPassInfo);
Pipeline::CreateInfo pipelineInfo {};
// Vertex input layout
pipelineInfo.shaderGroup = shaderGroup;
pipelineInfo.layout = {
{ "inPosition", VertexBufferElement::Type::VEC3 },
{ "inNormal", VertexBufferElement::Type::VEC3 },
{ "inTexCoord", VertexBufferElement::Type::VEC2 }
};
pipelineInfo.renderPass = renderPass;
_geometryPipeline = GraphicsManager::create<Pipeline>(pipelineInfo);
}
PhongRenderer::~PhongRenderer()
{
}
void PhongRenderer::render(std::shared_ptr<Camera> camera)
{
std::vector<EntityId> entities = ComponentManager::getEntities();
_geometryPipeline->begin();
{
// Camera
std::shared_ptr<ShaderGroup> shader = _geometryPipeline->getShaderGroup();
shader->setMat4("projection", transpose(camera->getProj()));
shader->setMat4("view", transpose(camera->getView()));
shader->setVec3("viewPos", camera->getPosition());
//----- Lighting -----//
int numPointLights = 0;
for(auto entity : entities)
{
TransformComponent* transform = ComponentManager::getEntityComponent<TransformComponent>(entity);
PointLightComponent* pl = ComponentManager::getEntityComponent<PointLightComponent>(entity);
DirectionalLightComponent* dl = ComponentManager::getEntityComponent<DirectionalLightComponent>(entity);
if(transform && (pl || dl))
{
if(pl && numPointLights < 10)
{
int i = numPointLights++;
shader->setVec3(("pointLights["+std::to_string(i)+"].position").c_str(), transform->position);
shader->setVec3(("pointLights["+std::to_string(i)+"].intensity").c_str(), pl->intensity);
}
if(dl)
{
vec3 before = { 0.0f, -1.0f, 0.0f };
//vec3 direction;
//transform->orientation.transformVector(before, direction);
shader->setVec3("directionalLight.direction", before);
shader->setVec3("directionalLight.intensity", dl->intensity);
}
if(numPointLights++ == 10)
LOG_WARN("PhongRenderer", "Maximum number of point lights reached, 10 lights");
}
}
shader->setInt("numPointLights", numPointLights);
// Ambient
shader->setVec3("ambientColor", {0.2f, 0.2f, 0.2f});
shader->setFloat("ambientStrength", 1.0f);
// Diffuse
shader->setFloat("diffuseStrength", 1.0f);
// Specular
shader->setFloat("specularStrength", 1.0f);
for(auto entity : entities)
{
MeshComponent* mesh = ComponentManager::getEntityComponent<MeshComponent>(entity);
TransformComponent* transform = ComponentManager::getEntityComponent<TransformComponent>(entity);
MaterialComponent* material = ComponentManager::getEntityComponent<MaterialComponent>(entity);
if(mesh && transform)
{
mat4 model;
model.setPosOriScale(transform->position, transform->orientation, transform->scale);
model.transpose();
mat4 invModel = inverse(model);
shader->setMat4("model", model);
shader->setMat4("invModel", invModel);
if(material)
{
shader->setVec3("material.albedo", material->albedo);
shader->setFloat("material.metallic", material->metallic);
shader->setFloat("material.roughness", material->roughness);
shader->setFloat("material.ao", material->ao);
}
else
{
MaterialComponent material {};
shader->setVec3("material.albedo", material.albedo);
shader->setFloat("material.metallic", material.metallic);
shader->setFloat("material.roughness", material.roughness);
shader->setFloat("material.ao", material.ao);
}
GraphicsManager::getRendererAPI()->renderMesh(mesh->sid);
}
}
}
_geometryPipeline->end();
}
void PhongRenderer::resize(uint32_t width, uint32_t height)
{
if(width != _width || height != _height)
{
_geometryPipeline->getRenderPass()->getFramebuffer()->resize(width, height);
_width = width;
_height = height;
}
}
}
| 43.841463
| 120
| 0.581224
|
Brenocq
|
1f962f82b1838e00f1496520f9adc39e5113eb16
| 830
|
cpp
|
C++
|
AIC/AIC'20 - Level 1 Training/Week #9/P.cpp
|
MaGnsio/CP-Problems
|
a7f518a20ba470f554b6d54a414b84043bf209c5
|
[
"Unlicense"
] | 3
|
2020-11-01T06:31:30.000Z
|
2022-02-21T20:37:51.000Z
|
AIC/AIC'20 - Level 1 Training/Week #9/P.cpp
|
MaGnsio/CP-Problems
|
a7f518a20ba470f554b6d54a414b84043bf209c5
|
[
"Unlicense"
] | null | null | null |
AIC/AIC'20 - Level 1 Training/Week #9/P.cpp
|
MaGnsio/CP-Problems
|
a7f518a20ba470f554b6d54a414b84043bf209c5
|
[
"Unlicense"
] | 1
|
2021-05-05T18:56:31.000Z
|
2021-05-05T18:56:31.000Z
|
//https://codeforces.com/group/Rv2Qzg0DgK/contest/287283/problem/P
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
ll mod = 1e9 + 7;
int main ()
{
ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0);
int x = 2, i = 1;
string s;
vector<string> v;
while (cin >> s)
{
x = 2, i = 1;
v.push_back ("*");
for (auto& elem : s)
{
if (elem == '[') x = 1, i = 1;
else if (elem == ']') x = 2;
else if (x == 1)
{
v.back ().insert (v.back ().begin () + i, elem);
i++;
}
else v.back ().push_back (elem);
}
}
for (auto& elem : v) cout << elem.substr (1, elem.size () - 1) << "\n";
}
| 23.714286
| 75
| 0.459036
|
MaGnsio
|
1f9cd668d29757d4bfd08fd128d8589975358c4a
| 120
|
hpp
|
C++
|
lib/thing/include/ge/thing.hpp
|
snailbaron/ge
|
a3859d944c1d2534caaf2e9c52b90181e181aef3
|
[
"MIT"
] | null | null | null |
lib/thing/include/ge/thing.hpp
|
snailbaron/ge
|
a3859d944c1d2534caaf2e9c52b90181e181aef3
|
[
"MIT"
] | null | null | null |
lib/thing/include/ge/thing.hpp
|
snailbaron/ge
|
a3859d944c1d2534caaf2e9c52b90181e181aef3
|
[
"MIT"
] | null | null | null |
#pragma once
#include "ge/thing/entity.hpp"
#include "ge/thing/entity_manager.hpp"
#include "ge/thing/entity_pool.hpp"
| 20
| 38
| 0.766667
|
snailbaron
|
1f9e78bcc4ce09c6837b9ebcb0fc1bcc349ce947
| 939
|
hpp
|
C++
|
include/awl/backends/x11/window/original_class_hint.hpp
|
freundlich/libawl
|
0d51f388a6b662373058cb51a24ef25ed826fa0f
|
[
"BSL-1.0"
] | null | null | null |
include/awl/backends/x11/window/original_class_hint.hpp
|
freundlich/libawl
|
0d51f388a6b662373058cb51a24ef25ed826fa0f
|
[
"BSL-1.0"
] | null | null | null |
include/awl/backends/x11/window/original_class_hint.hpp
|
freundlich/libawl
|
0d51f388a6b662373058cb51a24ef25ed826fa0f
|
[
"BSL-1.0"
] | null | null | null |
#ifndef AWL_BACKENDS_X11_WINDOW_ORIGINAL_CLASS_HINT_HPP_INCLUDED
#define AWL_BACKENDS_X11_WINDOW_ORIGINAL_CLASS_HINT_HPP_INCLUDED
#include <awl/backends/x11/window/class_hint.hpp>
#include <awl/detail/symbol.hpp>
#include <fcppt/nonmovable.hpp>
#include <fcppt/unique_ptr_impl.hpp>
#include <fcppt/config/external_begin.hpp>
#include <X11/Xutil.h>
#include <fcppt/config/external_end.hpp>
namespace awl::backends::x11::window
{
class original_class_hint
{
FCPPT_NONMOVABLE(original_class_hint);
public:
AWL_DETAIL_SYMBOL
explicit original_class_hint(awl::backends::x11::window::class_hint &&);
AWL_DETAIL_SYMBOL
~original_class_hint();
[[nodiscard]] AWL_DETAIL_SYMBOL XClassHint *get() const;
[[nodiscard]] AWL_DETAIL_SYMBOL awl::backends::x11::window::class_hint const &hint() const;
private:
class impl;
fcppt::unique_ptr<impl> const impl_;
awl::backends::x11::window::class_hint const hint_;
};
}
#endif
| 22.902439
| 93
| 0.783813
|
freundlich
|
1fa22d5bc9102f5063e86fbaa6bc1a06f6f6bf15
| 5,239
|
cc
|
C++
|
src/_Meddly/src/storage/ct_styles.cc
|
asminer/smart
|
269747c4578b670e5c3973f93a1e6ec71d95be78
|
[
"Apache-2.0"
] | 6
|
2018-05-30T23:02:14.000Z
|
2022-01-19T07:30:46.000Z
|
src/_Meddly/src/storage/ct_styles.cc
|
asminer/smart
|
269747c4578b670e5c3973f93a1e6ec71d95be78
|
[
"Apache-2.0"
] | null | null | null |
src/_Meddly/src/storage/ct_styles.cc
|
asminer/smart
|
269747c4578b670e5c3973f93a1e6ec71d95be78
|
[
"Apache-2.0"
] | 2
|
2018-07-13T18:53:27.000Z
|
2021-04-12T17:54:02.000Z
|
/*
Meddly: Multi-terminal and Edge-valued Decision Diagram LibrarY.
Copyright (C) 2009, Iowa State University Research Foundation, Inc.
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ct_styles.h"
// #define DEBUG_SLOW
// #define DEBUG_CT_SEARCHES
// #define DEBUG_CT_SLOTS
// #define DEBUG_REHASH
// #define DEBUG_TABLE2LIST
// #define DEBUG_LIST2TABLE
// #define DEBUG_CTALLOC
// #define DEBUG_ISDEAD
// #define DEBUG_ISSTALE
// #define DEBUG_REMOVESTALES
// #define DEBUG_REMOVESTALES_DETAILS
// #define DEBUG_CT_SCAN
// #define DEBUG_CT
// #define DEBUG_VALIDATE_COUNTS
#define INTEGRATED_MEMMAN
#include "../hash_stream.h"
#include <climits>
#include "ct_typebased.h"
#include "ct_none.h"
// **********************************************************************
// * *
// * monolithic_chained_style methods *
// * *
// **********************************************************************
MEDDLY::monolithic_chained_style::monolithic_chained_style()
{
}
MEDDLY::compute_table*
MEDDLY::monolithic_chained_style::create(const ct_initializer::settings &s) const
{
switch (s.compression) {
case ct_initializer::None:
return new ct_none<true, true>(s, 0, 0);
case ct_initializer::TypeBased:
return new ct_typebased<true, true>(s, 0, 0);
default:
return 0;
}
}
bool MEDDLY::monolithic_chained_style::usesMonolithic() const
{
return true;
}
// **********************************************************************
// * *
// * monolithic_unchained_style methods *
// * *
// **********************************************************************
MEDDLY::monolithic_unchained_style::monolithic_unchained_style()
{
}
MEDDLY::compute_table*
MEDDLY::monolithic_unchained_style::create(const ct_initializer::settings &s) const
{
switch (s.compression) {
case ct_initializer::None:
return new ct_none<true, false>(s, 0, 0);
case ct_initializer::TypeBased:
return new ct_typebased<true, false>(s, 0, 0);
default:
return 0;
}
}
bool MEDDLY::monolithic_unchained_style::usesMonolithic() const
{
return true;
}
// **********************************************************************
// * *
// * operation_chained_style methods *
// * *
// **********************************************************************
MEDDLY::operation_chained_style::operation_chained_style()
{
}
MEDDLY::compute_table*
MEDDLY::operation_chained_style::create(const ct_initializer::settings &s, operation* op, unsigned slot) const
{
switch (s.compression) {
case ct_initializer::None:
return new ct_none<false, true>(s, 0, 0);
case ct_initializer::TypeBased:
return new ct_typebased<false, true>(s, 0, 0);
default:
return 0;
}
}
bool MEDDLY::operation_chained_style::usesMonolithic() const
{
return false;
}
// **********************************************************************
// * *
// * operation_unchained_style methods *
// * *
// **********************************************************************
MEDDLY::operation_unchained_style::operation_unchained_style()
{
}
MEDDLY::compute_table*
MEDDLY::operation_unchained_style::create(const ct_initializer::settings &s, operation* op, unsigned slot) const
{
switch (s.compression) {
case ct_initializer::None:
return new ct_none<false, false>(s, 0, 0);
case ct_initializer::TypeBased:
return new ct_typebased<false, false>(s, 0, 0);
default:
return 0;
}
}
bool MEDDLY::operation_unchained_style::usesMonolithic() const
{
return false;
}
| 31
| 113
| 0.493033
|
asminer
|
1fa7dcb5c61b14ca782a826f60f4a615aa8757f8
| 3,504
|
cpp
|
C++
|
SGCore/sgwin.cpp
|
mohemam/SGL
|
8d2b76bb199b8745b4c58fc39ad48e6b443da5e9
|
[
"MIT"
] | null | null | null |
SGCore/sgwin.cpp
|
mohemam/SGL
|
8d2b76bb199b8745b4c58fc39ad48e6b443da5e9
|
[
"MIT"
] | null | null | null |
SGCore/sgwin.cpp
|
mohemam/SGL
|
8d2b76bb199b8745b4c58fc39ad48e6b443da5e9
|
[
"MIT"
] | null | null | null |
#include "sgwin.h"
#include <iostream>
#include <Windows.h>
namespace sgl
{
void SetConsoleWindowSize(int width, int height)
{
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
if (h == INVALID_HANDLE_VALUE)
throw std::runtime_error("Unable to get stdout handle.");
// If either dimension is greater than the largest console window we can have,
// there is no point in attempting the change.
{
COORD largestSize = GetLargestConsoleWindowSize(h);
if (width > largestSize.X)
throw std::invalid_argument("The width is too large.");
if (height > largestSize.Y)
throw std::invalid_argument("The height is too large.");
}
CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
if (!GetConsoleScreenBufferInfo(h, &bufferInfo))
throw std::runtime_error("Unable to retrieve screen buffer info.");
SMALL_RECT& winInfo = bufferInfo.srWindow;
COORD windowSize = { winInfo.Right - winInfo.Left + 1, winInfo.Bottom - winInfo.Top + 1 };
if (windowSize.X > width || windowSize.Y > height)
{
// window size needs to be adjusted before the buffer size can be reduced.
SMALL_RECT info =
{
0,
0,
width < windowSize.X ? width - 1 : windowSize.X - 1,
height < windowSize.Y ? height - 1 : windowSize.Y - 1
};
if (!SetConsoleWindowInfo(h, TRUE, &info))
throw std::runtime_error("Unable to resize window before resizing buffer.");
}
COORD size = { width, height };
if (!SetConsoleScreenBufferSize(h, size))
throw std::runtime_error("Unable to resize screen buffer.");
SMALL_RECT info = { 0, 0, width - 1, height - 1 };
if (!SetConsoleWindowInfo(h, TRUE, &info))
throw std::runtime_error("Unable to resize window after resizing buffer.");
}
void ClearScreen(char fill)
{
COORD tl = { 0,0 };
CONSOLE_SCREEN_BUFFER_INFO s;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(console, &s);
DWORD written, cells = s.dwSize.X * s.dwSize.Y;
FillConsoleOutputCharacter(console, fill, cells, tl, &written);
FillConsoleOutputAttribute(console, s.wAttributes, cells, tl, &written);
SetConsoleCursorPosition(console, tl);
}
wchar_t* CreateScreenBuffer(int width, int height)
{
wchar_t* screen = new wchar_t[width * height];
HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
SetConsoleActiveScreenBuffer(hConsole);
DWORD dwBytesWritten = 0;
return screen;
}
void SetConsoleColor(unsigned int fg_color, unsigned int bg_color)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, fg_color | (bg_color * 16));
}
void CopyToClipboard(const std::string& s)
{
const size_t len = s.length() + 1;
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
memcpy(GlobalLock(hMem), s.c_str(), len);
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
SetClipboardData(CF_TEXT, hMem);
CloseClipboard();
}
void ShowLastSystemError()
{
LPSTR messageBuffer;
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
0, // source
GetLastError(),
0, // lang
(LPSTR)&messageBuffer,
0,
NULL);
std::cerr << messageBuffer << '\n';
LocalFree(messageBuffer);
}
void MoveWindow(unsigned int left, unsigned int top)
{
HWND console = GetConsoleWindow();
RECT r;
GetWindowRect(console, &r); //stores the console's current dimensions
MoveWindow(console, left, top, (r.right-r.left), (r.top - r.bottom), TRUE);
}
}
| 28.721311
| 116
| 0.704909
|
mohemam
|
1fabee3e53ef182cee547c25c1f48a2f9050197d
| 128
|
cpp
|
C++
|
math/Trig.cpp
|
nfoste82/engine
|
9b64077778bf3548a8d1a53bddcaabada7a2957e
|
[
"MIT"
] | 1
|
2017-02-17T07:15:49.000Z
|
2017-02-17T07:15:49.000Z
|
math/Trig.cpp
|
nfoste82/engine
|
9b64077778bf3548a8d1a53bddcaabada7a2957e
|
[
"MIT"
] | null | null | null |
math/Trig.cpp
|
nfoste82/engine
|
9b64077778bf3548a8d1a53bddcaabada7a2957e
|
[
"MIT"
] | null | null | null |
#include <math.h>
#include "Trig.hpp"
void Trig::SinCos(float x, float& sn, float& cs)
{
sn = sinf(x);
cs = cosf(x);
}
| 14.222222
| 48
| 0.578125
|
nfoste82
|
1fb729683d50a1300d855f1baf5a597308eca89a
| 122
|
hh
|
C++
|
dead_pixel/gfx/graphics_context.hh
|
ErrorOnUsername/dead-pixel
|
a13dba2a5be60c1b0d4112fc3557639d6d5af29a
|
[
"BSD-2-Clause"
] | null | null | null |
dead_pixel/gfx/graphics_context.hh
|
ErrorOnUsername/dead-pixel
|
a13dba2a5be60c1b0d4112fc3557639d6d5af29a
|
[
"BSD-2-Clause"
] | null | null | null |
dead_pixel/gfx/graphics_context.hh
|
ErrorOnUsername/dead-pixel
|
a13dba2a5be60c1b0d4112fc3557639d6d5af29a
|
[
"BSD-2-Clause"
] | null | null | null |
#pragma once
namespace DP::GraphicsContext {
void init(void* window_handle);
void swap_buffers(void* window_handle);
}
| 13.555556
| 39
| 0.770492
|
ErrorOnUsername
|
1fbbf6cf2d744c821120b32717568211da71711a
| 2,820
|
cpp
|
C++
|
src/renderer/base/fontinfo.cpp
|
RifasM/terminal
|
a5f31f77bc77068ba1eb3e3deec56c5a2e9e4513
|
[
"MIT"
] | 7
|
2021-02-18T01:15:39.000Z
|
2022-03-22T07:08:34.000Z
|
src/renderer/base/fontinfo.cpp
|
RifasM/terminal
|
a5f31f77bc77068ba1eb3e3deec56c5a2e9e4513
|
[
"MIT"
] | 116
|
2019-07-08T21:28:45.000Z
|
2021-07-28T21:12:21.000Z
|
src/renderer/base/fontinfo.cpp
|
RifasM/terminal
|
a5f31f77bc77068ba1eb3e3deec56c5a2e9e4513
|
[
"MIT"
] | 1
|
2019-11-25T00:13:17.000Z
|
2019-11-25T00:13:17.000Z
|
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include "..\inc\FontInfo.hpp"
bool operator==(const FontInfo& a, const FontInfo& b)
{
return (static_cast<FontInfoBase>(a) == static_cast<FontInfoBase>(b) &&
a._coordSize == b._coordSize &&
a._coordSizeUnscaled == b._coordSizeUnscaled);
}
FontInfo::FontInfo(_In_ PCWSTR const pwszFaceName,
const BYTE bFamily,
const LONG lWeight,
const COORD coordSize,
const UINT uiCodePage,
const bool fSetDefaultRasterFont /*= false*/) :
FontInfoBase(pwszFaceName, bFamily, lWeight, fSetDefaultRasterFont, uiCodePage),
_coordSize(coordSize),
_coordSizeUnscaled(coordSize)
{
ValidateFont();
}
FontInfo::FontInfo(const FontInfo& fiFont) :
FontInfoBase(fiFont),
_coordSize(fiFont.GetSize()),
_coordSizeUnscaled(fiFont.GetUnscaledSize())
{
}
COORD FontInfo::GetUnscaledSize() const
{
return _coordSizeUnscaled;
}
COORD FontInfo::GetSize() const
{
return _coordSize;
}
void FontInfo::SetFromEngine(_In_ PCWSTR const pwszFaceName,
const BYTE bFamily,
const LONG lWeight,
const bool fSetDefaultRasterFont,
const COORD coordSize,
const COORD coordSizeUnscaled)
{
FontInfoBase::SetFromEngine(pwszFaceName,
bFamily,
lWeight,
fSetDefaultRasterFont);
_coordSize = coordSize;
_coordSizeUnscaled = coordSizeUnscaled;
_ValidateCoordSize();
}
void FontInfo::ValidateFont()
{
_ValidateCoordSize();
}
void FontInfo::_ValidateCoordSize()
{
// a (0,0) font is okay for the default raster font, as we will eventually set the dimensions based on the font GDI
// passes back to us.
if (!IsDefaultRasterFontNoSize())
{
// Initialize X to 1 so we don't divide by 0
if (_coordSize.X == 0)
{
_coordSize.X = 1;
}
// If we have no font size, we want to use 8x12 by default
if (_coordSize.Y == 0)
{
_coordSize.X = 8;
_coordSize.Y = 12;
_coordSizeUnscaled = _coordSize;
}
}
}
#pragma warning(push)
#pragma warning(suppress : 4356)
Microsoft::Console::Render::IFontDefaultList* FontInfo::s_pFontDefaultList;
#pragma warning(pop)
void FontInfo::s_SetFontDefaultList(_In_ Microsoft::Console::Render::IFontDefaultList* const pFontDefaultList)
{
FontInfoBase::s_SetFontDefaultList(pFontDefaultList);
}
| 28.2
| 120
| 0.591844
|
RifasM
|
1fbde727811706eeb19098090723ce3acecdd2e1
| 2,827
|
cpp
|
C++
|
smolengine/src/ECS/Systems/AudioSystem.cpp
|
Floritte/Game-Engine-Samples
|
2b5dfc9a998963614e6d25fbbeaa05dbe1d214f9
|
[
"Apache-2.0"
] | 3
|
2021-05-18T00:01:06.000Z
|
2021-07-09T15:39:23.000Z
|
smolengine/src/ECS/Systems/AudioSystem.cpp
|
Floritte/Game-Engine-Samples
|
2b5dfc9a998963614e6d25fbbeaa05dbe1d214f9
|
[
"Apache-2.0"
] | null | null | null |
smolengine/src/ECS/Systems/AudioSystem.cpp
|
Floritte/Game-Engine-Samples
|
2b5dfc9a998963614e6d25fbbeaa05dbe1d214f9
|
[
"Apache-2.0"
] | null | null | null |
#include "stdafx.h"
#include "ECS/Systems/AudioSystem.h"
#include "ECS/Components/Include/Components.h"
#include "ECS/Components/Singletons/WorldAdminStateSComponent.h"
#include "ECS/Components/Singletons/AudioEngineSComponent.h"
#include "Audio/AudioSource.h"
#include <soloud.h>
#include <soloud_speech.h>
#include <soloud_wav.h>
#include <soloud_thread.h>
#include <soloud_bus.h>
#include <soloud_biquadresonantfilter.h>
#include <soloud_echofilter.h>
#include <soloud_dcremovalfilter.h>
#include <soloud_bassboostfilter.h>
#include <soloud_lofifilter.h>
#include <soloud_freeverbfilter.h>
#include <soloud_waveshaperfilter.h>
namespace SmolEngine
{
float* AudioSystem::GetFFT()
{
return m_State->Core->calcFFT();
}
float* AudioSystem::GetWave()
{
return m_State->Core->getWave();
}
void AudioSystem::SetGlobalVolume(float value)
{
m_State->Core->setGlobalVolume(value);
}
void AudioSystem::StopAll()
{
m_State->Core->stopAll();
}
void AudioSystem::RemoveHandle(uint32_t handle)
{
m_State->Handles.erase(std::remove_if(m_State->Handles.begin(), m_State->Handles.end(),
[&](const Ref<AudioHandle>& another) { return *another == handle; }), m_State->Handles.end());
}
void AudioSystem::OnBeginWorld()
{
entt::registry* registry = m_World->m_CurrentRegistry;
const auto& view = registry->view<AudioSourceComponent>();
for (auto entity : view)
{
AudioSourceComponent& component = view.get<AudioSourceComponent>(entity);
component.ClearFiltersEX();
component.CreateFiltersEX();
for (auto& info : component.Clips)
{
if (info.m_CreateInfo.bPlayOnAwake)
{
component.PlayClip(info.m_Clip, info.m_Handle);
}
}
}
}
void AudioSystem::OnEndWorld()
{
entt::registry* registry = m_World->m_CurrentRegistry;
const auto& view = registry->view<AudioSourceComponent>();
for (auto entity : view)
{
AudioSourceComponent& component = view.get<AudioSourceComponent>(entity);
component.StopAll();
}
}
void AudioSystem::OnUpdate(const glm::vec3 camPos)
{
m_State->Core->set3dListenerPosition(camPos.x, camPos.y, camPos.z);
{
entt::registry* registry = m_World->m_CurrentRegistry;
const auto& view = registry->view<AudioSourceComponent, TransformComponent>();
for (auto entity : view)
{
auto& [as, transform] = view.get<AudioSourceComponent, TransformComponent>(entity);
for (auto& clip_info : as.Clips)
{
AudioClipCreateInfo& create_info = clip_info.m_CreateInfo;
if (!create_info.bStatic && create_info.eType == ClipType::Sound_3D)
{
m_State->Core->set3dSourceParameters(*as.GroupHandle, transform.WorldPos.x, transform.WorldPos.y,
transform.WorldPos.z, transform.Rotation.x, transform.Rotation.y, transform.Rotation.z);
}
}
}
}
m_State->Core->update3dAudio();
}
}
| 26.92381
| 104
| 0.719844
|
Floritte
|
1fc7bc5ed907c5771ecf46d3bfaf2c743dfe094b
| 9,994
|
cpp
|
C++
|
src/map/StateMap.cpp
|
Streetwalrus/WalrusRPG
|
53d88ef36ca1b2c169b5755dd95ac2c5626b91f5
|
[
"MIT"
] | 12
|
2015-06-30T19:38:06.000Z
|
2017-11-27T20:26:32.000Z
|
src/map/StateMap.cpp
|
Pokespire/pokespire
|
53d88ef36ca1b2c169b5755dd95ac2c5626b91f5
|
[
"MIT"
] | 18
|
2015-06-26T01:44:48.000Z
|
2016-07-01T16:26:17.000Z
|
src/map/StateMap.cpp
|
Pokespire/pokespire
|
53d88ef36ca1b2c169b5755dd95ac2c5626b91f5
|
[
"MIT"
] | 1
|
2016-12-12T05:15:46.000Z
|
2016-12-12T05:15:46.000Z
|
#include "StateMap.h"
#include "DoorEntity.h"
#include "Graphics.h"
#include "Logger.h"
#include "TalkEntity.h"
#include "collision/Collision.h"
#include "input/Input.h"
#include "piaf/Archive.h"
#include "render/Text.h"
#include "render/TileRenderer.h"
#include <cmath>
using WalrusRPG::States::StateMap;
using namespace WalrusRPG;
using namespace WalrusRPG::Graphics;
using WalrusRPG::Utils::Rect;
using WalrusRPG::PIAF::Archive;
using WalrusRPG::PIAF::File;
using WalrusRPG::Graphics::Texture;
using namespace WalrusRPG::Input;
using WalrusRPG::Input::Key;
using WalrusRPG::Graphics::Font;
using WalrusRPG::Textbox;
using WalrusRPG::Entity;
using WalrusRPG::TileRenderer;
using WalrusRPG::TalkEntity;
using WalrusRPG::DoorEntity;
using WalrusRPG::MAP_OBJECT_GRID_TILE_WIDTH;
namespace
{
void print_debug_camera_data(const Camera &camera, const Font &fnt)
{
fnt.draw_format(240, 1, Black, "CAM : X : %d Y: %d", camera.get_x(),
camera.get_y());
fnt.draw_format(240, 0, "CAM : X : %d Y: %d", camera.get_x(), camera.get_y());
}
void print_debug_map_data(const Map &map, const Font &fnt)
{
fnt.draw_format(240, 9, Black, "MAP : W: %d, H:%d", map.get_width(),
map.get_height());
fnt.draw_format(240, 8, "MAP : W: %d, H:%d", map.get_width(), map.get_height());
}
}
// TODO : We definitely need a Resource Manager
StateMap::StateMap(int x, int y, Map &map)
: started(false), camera(x, y), map(map), data("data/wip_data.wrf"),
tex_haeccity((*data).get("t_haeccity")),
txt(tex_haeccity, (*data).get("f_haeccity")), box(txt),
p(*this, 32, 40, 10, 4,
new TileRenderer(map.tmap.get_texture(), TILE_DIMENSION, TILE_DIMENSION), 128)
{
map.add_entity(&p);
TileRenderer *tr =
new TileRenderer(map.tmap.get_texture(), TILE_DIMENSION, TILE_DIMENSION);
map.add_entity(new TalkEntity(*this, 128, 64, TILE_DIMENSION, TILE_DIMENSION, tr, 150,
"Hello, I'm a skeleton."));
map.add_entity(new TalkEntity(*this, 128, 96, TILE_DIMENSION, TILE_DIMENSION, tr, 134,
"Hello, I'm another skeleton."));
map.add_entity(new TalkEntity(
*this, 138, 104, TILE_DIMENSION, TILE_DIMENSION, tr, 134,
"Doot doot. Thanks \xFF\x02\xFF\x00\x00Mr. Skeltal\xFF\x02\xFF\xFF\xFF!"));
map.add_entity(new TalkEntity(
*this, 138, 104, TILE_DIMENSION, TILE_DIMENSION, tr, 134,
"Doot doot. Thanks \xFF\x02\xFF\x00\x00Mr. Skeltal\xFF\x02\xFF\xFF\xFF!"));
map.add_entity(
new DoorEntity(*this, 48, 240, TILE_DIMENSION, TILE_DIMENSION, tr, 4, 7));
map.add_entity(
new DoorEntity(*this, 352, 240, TILE_DIMENSION, TILE_DIMENSION, tr, 4, 7));
map.reset_entity_grid();
/*
map.add_entity(
new Entity(*this, 196, 112, TILE_DIMENSION, TILE_DIMENSION, tr,
134));
map.add_entity(
new Entity(*this, 196, 104, TILE_DIMENSION, TILE_DIMENSION, tr,
134));
*/
}
StateMap::~StateMap()
{
}
void StateMap::update()
{
camera.set_center_x(p.x + p.w / 2);
camera.set_center_y(p.y + p.h / 2);
unsigned t = (key_down(K_B) ? 16 : 1);
map.update();
if (started)
{
for (unsigned i = 0; i < t; i++)
box.update();
if (key_pressed(K_A) && box.state == Done)
{
started = false;
p.controllable = true;
}
}
else
{
if (key_pressed(K_A))
{
// Check direction.
Rect check_hitbox;
switch (p.direction)
{
// up
case 0:
check_hitbox = {(int) p.x, (int) p.y - 4, p.w, 4};
break;
// down
case 1:
check_hitbox = {(int) p.x, (int) p.y + (int) p.h, p.w, 4};
break;
// left
case 2:
check_hitbox = {(int) p.x - (int) p.w - 4, (int) p.y, 4, p.h};
break;
// down
case 3:
check_hitbox = {(int) p.x + (int) p.w, (int) p.y, 4, p.h};
break;
}
// Check
for (auto ptr = map.entities.begin(); ptr < map.entities.end(); ptr++)
{
Entity *e = *ptr;
if (e == &p)
continue;
if (WalrusRPG::AABBCheck(check_hitbox,
{(int) e->x, (int) e->y, e->w, e->h}))
{
e->interact_with(p, InteractionType::CHECK);
Logger::log("Interacted with %p", e);
map.remove_entity_from_grid(e);
map.add_entity_to_grid(e);
}
}
// if (!started && box.state != Done)
// started = true;
// else if (box.state == Done)
// {
// }
}
}
camera.update();
}
void StateMap::render()
{
map.render(camera);
print_debug_camera_data(camera, txt);
#if !IMGUI
print_debug_map_data(map, txt);
#endif
if (started)
box.render();
}
#if IMGUI
void StateMap::debug_layer(uint16_t *layer, ImU32 color, ImDrawList *list, ImVec2 offset)
{
for (signed i = 0; i < map.get_height(); i++)
{
for (signed j = 0; j < map.get_width(); j++)
{
float x = offset.x + 4 * j;
float y = offset.y + 4 * i;
uint16_t tile = layer[i * map.get_width() + j];
{
if (tile != 0)
{
list->AddRectFilled({x, y}, {x + 4, y + 4}, color);
}
}
}
}
}
void StateMap::debug()
{
if (!ImGui::Begin("Map state"))
return;
ImGui::BeginGroup();
ImGui::Text("Camera");
ImGui::Indent();
ImGui::Value("X", camera.get_x());
ImGui::SameLine();
ImGui::Value("Y", camera.get_y());
ImGui::EndGroup();
ImGui::Separator();
ImGui::Text("Map");
ImGui::Indent();
ImGui::Value("W", map.get_width());
ImGui::SameLine();
ImGui::Value("H", map.get_height());
ImGui::Value("Nb entities", (int) map.entities.size());
ImGui::Unindent();
ImGui::Text("Layers");
if (ImGui::Checkbox("Ground", &show_layer_ground))
;
ImGui::SameLine();
if (ImGui::Checkbox("Middle", &show_layer_middle))
;
ImGui::SameLine();
if (ImGui::Checkbox("Over", &show_layer_over))
;
if (ImGui::Checkbox("Entities", &show_entities))
;
if (show_entities)
{
ImGui::SameLine();
ImGui::Checkbox("Grid", &show_entity_grid);
}
if (ImGui::BeginChild("map_frame", {0, 0}, true))
{
if (ImGui::IsWindowHovered() && !ImGui::IsAnyItemActive() &&
ImGui::IsMouseDragging(1, 0.0f))
scrolling = {scrolling.x - ImGui::GetIO().MouseDelta.x,
scrolling.y - ImGui::GetIO().MouseDelta.y};
ImVec2 s = ImGui::GetCursorScreenPos();
s = {s.x - scrolling.x, s.y - scrolling.y};
ImDrawList *list = ImGui::GetWindowDrawList();
if (show_layer_ground && map.layer0 != nullptr)
StateMap::debug_layer(map.layer0, 0x88888888, list, s);
if (show_layer_middle && map.layer1 != nullptr)
StateMap::debug_layer(map.layer1, 0xFF0000FF, list, s);
if (show_entities)
{
for (auto ptr = map.entities.begin(); ptr != map.entities.end(); ptr++)
{
Entity *e = *ptr;
float x = s.x + e->x / TILE_DIMENSION * 4;
float x2 = s.x + (e->x + e->w) / TILE_DIMENSION * 4;
float y = s.y + e->y / TILE_DIMENSION * 4;
float y2 = s.y + (e->y + e->h) / TILE_DIMENSION * 4;
list->AddRectFilled({x, y}, {x2, y2}, 0xFFFFFFFF);
}
// Entity Grid
if (show_entity_grid)
{
for (int i = 0, max_i = map.get_height() / MAP_OBJECT_GRID_TILE_WIDTH + 1;
i < max_i; ++i)
{
for (int j = 0,
max_j = map.get_width() / MAP_OBJECT_GRID_TILE_WIDTH + 1;
j < max_j; ++j)
{
list->AddRect(
{std::floor(j * MAP_OBJECT_GRID_TILE_WIDTH * 4 + s.x),
std::floor(i * MAP_OBJECT_GRID_TILE_WIDTH * 4 + s.y)},
{std::floor((j + 1) * MAP_OBJECT_GRID_TILE_WIDTH * 4 + s.x),
std::floor((i + 1) * MAP_OBJECT_GRID_TILE_WIDTH * 4 + s.y)},
0x80FFFFFF);
}
}
}
}
if (show_layer_over && map.layer2 != nullptr)
StateMap::debug_layer(map.layer2, 0x800000FF, list, s);
float x = camera.get_x() / (float) TILE_DIMENSION;
float x2 = (camera.get_x() + 320) / (float) TILE_DIMENSION;
float y = camera.get_y() / (float) TILE_DIMENSION;
float y2 = (camera.get_y() + 240) / (float) TILE_DIMENSION;
list->AddRect({std::floor(x * 4 + s.x), std::floor(y * 4 + s.y)},
{std::floor(x2 * 4 + s.x), std::floor(y2 * 4 + s.y)}, 0xFFFFFF00);
}
ImGui::EndChild();
if (show_entity_grid)
{
ImGui::Text("Grid entity population");
for (int i = 0, max_i = map.get_height() / MAP_OBJECT_GRID_TILE_WIDTH + 1;
i < max_i; ++i)
{
for (int j = 0, max_j = map.get_width() / MAP_OBJECT_GRID_TILE_WIDTH + 1;
j < max_j; ++j)
{
ImGui::Text("%3d", map.entity_container[i][j].size());
ImGui::SameLine();
}
ImGui::Text("");
}
}
ImGui::End();
}
#endif
| 32.983498
| 90
| 0.510206
|
Streetwalrus
|
1fc89fece79685cbbc1f5e32122218216bc32778
| 7,498
|
cpp
|
C++
|
Opal Prospect/OpenGL/ArrayTexture.cpp
|
swbengs/OpalProspect
|
5f77dd07c1bb4197673589ac3f42546a4d0329b3
|
[
"MIT"
] | 2
|
2018-06-06T02:01:08.000Z
|
2020-07-25T18:10:32.000Z
|
Opal Prospect/OpenGL/ArrayTexture.cpp
|
swbengs/OpalProspect
|
5f77dd07c1bb4197673589ac3f42546a4d0329b3
|
[
"MIT"
] | 10
|
2018-07-27T01:56:45.000Z
|
2019-02-23T01:49:36.000Z
|
Opal Prospect/OpenGL/ArrayTexture.cpp
|
swbengs/OpalProspect
|
5f77dd07c1bb4197673589ac3f42546a4d0329b3
|
[
"MIT"
] | null | null | null |
//class header
#include "ArrayTexture.hpp"
//std lib includes
#include <iostream>
#include <sstream>
//other includes
#include "glew.h"
#include "OGLHelpers.hpp"
/*
MIT License
Copyright (c) 2018 Scott Bengs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
ArrayTexture::ArrayTexture()
{
id = 0;
texture_name = "";
}
void ArrayTexture::bind() const
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_ARRAY, getID());
}
void ArrayTexture::unbind() const
{
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
}
void ArrayTexture::loadImages(std::vector<std::string> file_paths)
{
int good_width = 0;
int good_height = 0;
std::stringstream bad_stream;
bad_stream << FilePath::getCWD() << "Textures" << FilePath::getOSSeperator() << "bad.png";
std::string fallback = bad_stream.str();
for (size_t i = 0; i < file_paths.size(); i++)
{
Image temp;
temp.setFilePath(file_paths[i]);
//temp.loadImage();
temp.loadImageFallback(temp.getPath(), fallback); //get the path we created and not the given file path
images.push_back(std::move(temp));
}
//std::cout << "second loop\n";
for (size_t i = 0; i < images.size(); i++)
{
if (images[i].getWidth() > 0)
{
good_width = images[i].getWidth();
good_height = images[i].getHeight();
break;
}
}
//std::cout << "good_width: " << good_width << "\n";
//std::cout << "good_height: " << good_height << "\n";
//do sanity check that all array textures are the same size. Any that deviate from the first non 0 one must match that
Image junk;
junk.setSolidColor(255, 0, 255, good_width, good_height);
//std::cout << "third loop\n";
for (size_t i = 0; i < images.size(); i++)
{
if (images[i].getWidth() != good_width || images[i].getHeight() != good_height)
{
//std::cout << "third loop if start\n";
junk.setFilePath(images[i].getFilename());
images[i] = junk;
//std::cout << "third loop if done\n";
}
//std::cout << "third loop running\n";
}
//std::cout << "third loop end\n";
}
void ArrayTexture::createTexture()
{
const int color_components = 4;
const int id_count = 1;
const int level = 0; //not using mipmaps so it's always 0
const int border = 0; //no border being used so set to 0
void* data = nullptr;
std::vector<unsigned char> complete_texture;
if (images.size() == 0)
{
std::cout << "No images have been loaded. Exiting\n";
return; //nothing to setup so just exit
}
if (id > 0)
{
destroy(); //make sure we clean up our current texture before we generate another
}
glGenTextures(id_count, &id); //create an id and bind it
bind();
OGLHelpers::getOpenGLError("pre teximage3d", true);
//void glTexImage3D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * data);
glTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_RGBA8, images[0].getWidth(), images[0].getHeight(), static_cast<int>(getImageCount()), border, GL_RGBA, GL_UNSIGNED_BYTE, data); //fill in the data on the graphics card
OGLHelpers::getOpenGLError("post teximage3d", true);
//GL_NEAREST, GL_LINEAR
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, GL_MIRRORED_REPEAT, GL_REPEAT, or GL_MIRROR_CLAMP_TO_EDGE
//glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
//glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT);
OGLHelpers::getOpenGLError("post texparam", true);
complete_texture.reserve(images[0].getSize() * getImageCount()); //holds the complete texture that is uploaded in one go. Only reserve them since we insert later
for (size_t i = 0; i < images.size(); i++)
{
const std::vector<unsigned char>& ref = images[i].getImageData();
complete_texture.insert(complete_texture.end(), ref.begin(), ref.end());
texture_numbers[images[i].getFilename()] = i;
}
uploadCompleteTexture(static_cast<int>(getImageCount()), complete_texture.data());
OGLHelpers::getOpenGLError("post array texture uploads", true);
unbind();
}
void ArrayTexture::destroy()
{
const int count = 1;
unbind();
if (id > 0)
{
glDeleteTextures(count, &id);
}
}
unsigned int ArrayTexture::getID() const
{
return id;
}
int ArrayTexture::getImageWidth() const
{
if (images.size() == 0) //don't cause exception if there are no loaded images
{
return 0;
}
else
{
return images[0].getWidth();
}
}
int ArrayTexture::getImageHeight() const
{
if (images.size() == 0)
{
return 0;
}
else
{
return images[0].getWidth();
}
}
size_t ArrayTexture::getImageCount() const
{
return images.size();
}
std::string ArrayTexture::getTextureName() const
{
return texture_name;
}
unsigned int ArrayTexture::getTextureNumberReference(std::string filename) const
{
auto it = texture_numbers.find(filename);
if (it == texture_numbers.end())
{
//std::cout << "name: " << filename << " was not found\n";
return 0;
}
else
{
return it->second + 1;
}
}
void ArrayTexture::setTextureName(std::string name)
{
texture_name = name;
}
/*
Sends the entire texture up in one go instead of individual layers
*/
void ArrayTexture::uploadCompleteTexture(int count, void* data) const
{
const int level = 0;
const int x_offset = 0;
const int y_offset = 0;
const int z_offset = 0; //start at the beginning
//z offset specifies what level you want to start on. 0 is base. You can upload it all from 0 or just do them idividually
//void glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels);
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level, x_offset, y_offset, z_offset, images[0].getWidth(), images[0].getHeight(), count, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
| 31.241667
| 216
| 0.674713
|
swbengs
|
1fc9874e28b560c0716ca47cf04fcab29e04ea94
| 3,486
|
cpp
|
C++
|
leetcode/2157/solution_4_1.cpp
|
mkmark/leetcode
|
638a9d37fb3223107d2852ce493d831996a7649e
|
[
"MIT"
] | null | null | null |
leetcode/2157/solution_4_1.cpp
|
mkmark/leetcode
|
638a9d37fb3223107d2852ce493d831996a7649e
|
[
"MIT"
] | null | null | null |
leetcode/2157/solution_4_1.cpp
|
mkmark/leetcode
|
638a9d37fb3223107d2852ce493d831996a7649e
|
[
"MIT"
] | null | null | null |
/*
author: mark@mkmark.net
time: O()
space: O()
Runtime: 1270 ms, faster than 64.18% of C++ online submissions for Groups of Strings.
Memory Usage: 68.5 MB, less than 69.73% of C++ online submissions for Groups of Strings.
*/
// profiled
#include <bits/stdc++.h>
using namespace std;
class disjoint_set {
public:
vector<int> parent;
vector<int> size;
vector<int> sum_val;
int set_cnt;
int max_sum_val;
disjoint_set(int max_size) {
parent.resize(max_size);
size.resize(max_size);
sum_val.resize(max_size);
for (int i=0; i<max_size; ++i) {
parent[i] = i;
size[i] = 1;
}
}
disjoint_set(int max_size, vector<int>& val): sum_val(val) {
parent.resize(max_size);
size.resize(max_size);
sum_val.resize(max_size);
for (int i=0; i<max_size; ++i) {
parent[i] = i;
size[i] = 1;
}
set_cnt = max_size;
max_sum_val = 1;
}
int get_set(int x) {
if (x == parent[x])
return x;
return parent[x] = get_set(parent[x]);
}
void union_set(int a, int b) {
a = get_set(a);
b = get_set(b);
if (a != b) {
if (size[a] > size[b])
swap(a, b);
parent[a] = b;
size[b] += size[a];
sum_val[b] += sum_val[a];
max_sum_val = max(max_sum_val, sum_val[b]);
--set_cnt;
}
}
};
class Solution {
public:
vector<int> groupStrings(vector<string>& words) {
bitset<26> words_b[20000];
unordered_map<int, int> words_b_count;
int n = words.size();
int cnt = 0;
for (int i=0; i<n; ++i){
auto word_b = to_b(words[i]);
auto mask = word_b.to_ulong();
if (words_b_count[mask]){
++words_b_count[mask];
} else {
words_b[cnt++] = word_b;
words_b_count[mask] = 1;
}
}
sort(words_b, words_b+cnt, [](bitset<26>& i, bitset<26>& j){return i.count() < j.count();});
int m = cnt;
if (m == 1){
vector<int> res = { 1, words_b_count[words_b[0].to_ulong()] };
return res;
}
vector<int> word_length(m);
vector<int> val(m);
for (int i=0; i<m; ++i){
val[i] = words_b_count[words_b[i].to_ulong()];
word_length[i] = words_b[i].count();
}
disjoint_set ds(m, val);
for (int i=0; i<m; ++i){
for (int j=i+1; j<m; ++j){
int diff_length = word_length[j] - word_length[i];
// rely on sorted vec
if (diff_length > 1){
break;
}
auto diff_cnt = (words_b[i] ^ words_b[j]).count();
if (
diff_cnt <= 1 ||
(diff_cnt == 2 && diff_length == 0)
){
ds.union_set(i, j);
}
}
}
vector<int> res = { ds.set_cnt, ds.max_sum_val };
return res;
}
inline bitset<26> to_b(string word){
bitset<26> b;
for (auto c : word) {
b |= (1<<(c-'a'));
}
return b;
}
};
const static auto initialize = [] {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
return nullptr;
}();
| 24.208333
| 100
| 0.468158
|
mkmark
|
1fca9e88a75f99b52e4f3db97003bff3fe704254
| 151,337
|
cpp
|
C++
|
cslbuild/generated-c/u37.cpp
|
arthurcnorman/general
|
5e8fef0cc7999fa8ab75d8fdf79ad5488047282b
|
[
"BSD-2-Clause"
] | null | null | null |
cslbuild/generated-c/u37.cpp
|
arthurcnorman/general
|
5e8fef0cc7999fa8ab75d8fdf79ad5488047282b
|
[
"BSD-2-Clause"
] | null | null | null |
cslbuild/generated-c/u37.cpp
|
arthurcnorman/general
|
5e8fef0cc7999fa8ab75d8fdf79ad5488047282b
|
[
"BSD-2-Clause"
] | null | null | null |
// $destdir/u37.c Machine generated C code
// $Id: 1fca9e88a75f99b52e4f3db97003bff3fe704254 $
#include "config.h"
#include "headers.h"
// Code for lessppair
static LispObject CC_lessppair(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_25, v_26, v_27, v_28;
#ifdef CHECK_STACK
if_check_stack;
#endif
// copy arguments values to proper place
v_26 = v_3;
v_27 = v_2;
// end of prologue
v_25 = v_27;
if (!car_legal(v_25)) v_28 = carerror(v_25); else
v_28 = car(v_25);
v_25 = v_26;
if (!car_legal(v_25)) v_25 = carerror(v_25); else
v_25 = car(v_25);
if (equal(v_28, v_25)) goto v_7;
else goto v_8;
v_7:
v_25 = v_27;
if (!car_legal(v_25)) v_25 = cdrerror(v_25); else
v_25 = cdr(v_25);
if (!car_legal(v_26)) v_26 = cdrerror(v_26); else
v_26 = cdr(v_26);
return Llessp_2(nil, v_25, v_26);
v_8:
v_25 = v_27;
if (!car_legal(v_25)) v_25 = carerror(v_25); else
v_25 = car(v_25);
if (!car_legal(v_26)) v_26 = carerror(v_26); else
v_26 = car(v_26);
return Llessp_2(nil, v_25, v_26);
v_25 = nil;
return onevalue(v_25);
}
// Code for lalr_print_first_information
static LispObject CC_lalr_print_first_information(LispObject env)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_52, v_53;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
env = reclaim(env, "stack", GC_STACK, 0);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// end of prologue
v_52 = basic_elt(env, 1); // "=== FIRST sets for each nonterminal ==="
v_52 = Lprinc(nil, v_52);
env = stack[-2];
v_52 = Lterpri(nil);
env = stack[-2];
v_52 = qvalue(basic_elt(env, 2)); // nonterminals
stack[-1] = v_52;
v_9:
v_52 = stack[-1];
if (v_52 == nil) goto v_13;
else goto v_14;
v_13:
goto v_8;
v_14:
v_52 = stack[-1];
if (!car_legal(v_52)) v_52 = carerror(v_52); else
v_52 = car(v_52);
stack[0] = v_52;
v_52 = stack[0];
{ LispObject fn = basic_elt(env, 6); // lalr_prin_symbol
v_52 = (*qfn1(fn))(fn, v_52);
}
env = stack[-2];
v_52 = basic_elt(env, 3); // ":"
v_52 = Lprinc(nil, v_52);
env = stack[-2];
v_52 = static_cast<LispObject>(320)+TAG_FIXNUM; // 20
v_52 = Lttab(nil, v_52);
env = stack[-2];
v_53 = stack[0];
v_52 = basic_elt(env, 4); // lalr_first
v_52 = get(v_53, v_52);
env = stack[-2];
stack[0] = v_52;
v_29:
v_52 = stack[0];
if (v_52 == nil) goto v_35;
else goto v_36;
v_35:
goto v_28;
v_36:
v_52 = stack[0];
if (!car_legal(v_52)) v_52 = carerror(v_52); else
v_52 = car(v_52);
{ LispObject fn = basic_elt(env, 6); // lalr_prin_symbol
v_52 = (*qfn1(fn))(fn, v_52);
}
env = stack[-2];
v_52 = basic_elt(env, 5); // " "
v_52 = Lprinc(nil, v_52);
env = stack[-2];
v_52 = stack[0];
if (!car_legal(v_52)) v_52 = cdrerror(v_52); else
v_52 = cdr(v_52);
stack[0] = v_52;
goto v_29;
v_28:
v_52 = Lterpri(nil);
env = stack[-2];
v_52 = stack[-1];
if (!car_legal(v_52)) v_52 = cdrerror(v_52); else
v_52 = cdr(v_52);
stack[-1] = v_52;
goto v_9;
v_8:
return Lterpri(nil);
}
// Code for smt_prin2x
static LispObject CC_smt_prin2x(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_7, v_8;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
stack_popper stack_popper_var(1);
// copy arguments values to proper place
v_7 = v_2;
// end of prologue
v_8 = v_7;
v_7 = qvalue(basic_elt(env, 1)); // outl!*
v_7 = cons(v_8, v_7);
env = stack[0];
setvalue(basic_elt(env, 1), v_7); // outl!*
return onevalue(v_7);
}
// Code for ofsf_simplequal
static LispObject CC_ofsf_simplequal(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_64, v_65, v_66;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil, nil, nil);
stack_popper stack_popper_var(5);
// copy arguments values to proper place
stack[-1] = v_3;
stack[-2] = v_2;
// end of prologue
v_64 = stack[-2];
{ LispObject fn = basic_elt(env, 8); // ofsf_posdefp
v_64 = (*qfn1(fn))(fn, v_64);
}
env = stack[-4];
stack[-3] = v_64;
v_65 = stack[-3];
v_64 = basic_elt(env, 1); // stsq
if (v_65 == v_64) goto v_14;
else goto v_15;
v_14:
v_64 = basic_elt(env, 2); // false
goto v_9;
v_15:
v_64 = stack[-2];
{ LispObject fn = basic_elt(env, 9); // sfto_sqfpartf
v_64 = (*qfn1(fn))(fn, v_64);
}
env = stack[-4];
stack[0] = v_64;
v_64 = stack[0];
{ LispObject fn = basic_elt(env, 8); // ofsf_posdefp
v_64 = (*qfn1(fn))(fn, v_64);
}
env = stack[-4];
v_66 = v_64;
v_65 = v_66;
v_64 = basic_elt(env, 1); // stsq
if (v_65 == v_64) goto v_25;
else goto v_26;
v_25:
v_64 = basic_elt(env, 2); // false
goto v_9;
v_26:
v_64 = qvalue(basic_elt(env, 3)); // !*rlsitsqspl
if (v_64 == nil) goto v_33;
v_64 = qvalue(basic_elt(env, 4)); // !*rlsiexpla
if (v_64 == nil) goto v_37;
else goto v_36;
v_37:
v_64 = qvalue(basic_elt(env, 5)); // !*rlsiexpl
if (v_64 == nil) goto v_39;
v_65 = stack[-1];
v_64 = basic_elt(env, 6); // and
if (v_65 == v_64) goto v_42;
else goto v_39;
v_42:
goto v_36;
v_39:
goto v_33;
v_36:
v_65 = v_66;
v_64 = basic_elt(env, 7); // tsq
if (v_65 == v_64) goto v_47;
else goto v_48;
v_47:
v_64 = stack[0];
{
LispObject fn = basic_elt(env, 10); // ofsf_tsqsplequal
return (*qfn1(fn))(fn, v_64);
}
v_48:
v_65 = stack[-3];
v_64 = basic_elt(env, 7); // tsq
if (v_65 == v_64) goto v_55;
else goto v_56;
v_55:
v_64 = stack[-2];
{
LispObject fn = basic_elt(env, 10); // ofsf_tsqsplequal
return (*qfn1(fn))(fn, v_64);
}
v_56:
goto v_31;
v_33:
v_31:
v_65 = stack[0];
v_64 = stack[-1];
{
LispObject fn = basic_elt(env, 11); // ofsf_facequal!*
return (*qfn2(fn))(fn, v_65, v_64);
}
v_9:
return onevalue(v_64);
}
// Code for pasf_exprng!-gand
static LispObject CC_pasf_exprngKgand(LispObject env, LispObject v_2,
LispObject v_3, LispObject v_4, LispObject _a4up_)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_86, v_87, v_88;
LispObject v_5;
if (_a4up_ == nil)
aerror1("not enough arguments provided", basic_elt(env, 0));
v_5 = car(_a4up_); _a4up_ = cdr(_a4up_);
if (_a4up_ != nil)
aerror1("too many arguments provided", basic_elt(env, 0));
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3,v_4,v_5);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_5,v_4,v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
real_push(nil);
stack_popper stack_popper_var(7);
// copy arguments values to proper place
stack[-1] = v_5;
stack[-2] = v_4;
stack[-3] = v_3;
stack[-4] = v_2;
// end of prologue
stack[0] = nil;
v_86 = lisp_true;
stack[-5] = v_86;
v_16:
v_86 = stack[-5];
if (v_86 == nil) goto v_19;
v_86 = stack[-3];
if (v_86 == nil) goto v_19;
goto v_20;
v_19:
goto v_15;
v_20:
v_86 = stack[-3];
if (!car_legal(v_86)) v_86 = carerror(v_86); else
v_86 = car(v_86);
v_87 = v_86;
v_86 = stack[-3];
if (!car_legal(v_86)) v_86 = cdrerror(v_86); else
v_86 = cdr(v_86);
stack[-3] = v_86;
v_86 = v_87;
{ LispObject fn = basic_elt(env, 4); // pasf_exprng
v_86 = (*qfn1(fn))(fn, v_86);
}
env = stack[-6];
v_88 = v_86;
v_87 = v_88;
v_86 = stack[-1];
if (v_87 == v_86) goto v_39;
else goto v_40;
v_39:
v_86 = nil;
stack[-5] = v_86;
goto v_38;
v_40:
v_87 = v_88;
v_86 = stack[-2];
if (equal(v_87, v_86)) goto v_45;
v_87 = v_88;
v_86 = stack[0];
v_86 = cons(v_87, v_86);
env = stack[-6];
stack[0] = v_86;
goto v_38;
v_45:
v_38:
goto v_16;
v_15:
v_86 = stack[-5];
if (v_86 == nil) goto v_53;
else goto v_54;
v_53:
v_86 = stack[-1];
goto v_12;
v_54:
v_86 = stack[0];
if (v_86 == nil) goto v_60;
v_86 = stack[0];
if (!car_legal(v_86)) v_86 = cdrerror(v_86); else
v_86 = cdr(v_86);
if (v_86 == nil) goto v_60;
v_87 = stack[-4];
v_86 = stack[0];
return cons(v_87, v_86);
v_60:
v_86 = stack[0];
if (v_86 == nil) goto v_69;
else goto v_70;
v_69:
v_87 = stack[-4];
v_86 = basic_elt(env, 1); // and
if (v_87 == v_86) goto v_74;
else goto v_75;
v_74:
v_86 = basic_elt(env, 2); // true
goto v_73;
v_75:
v_86 = basic_elt(env, 3); // false
goto v_73;
v_86 = nil;
v_73:
goto v_58;
v_70:
v_86 = stack[0];
if (!car_legal(v_86)) v_86 = carerror(v_86); else
v_86 = car(v_86);
goto v_58;
v_86 = nil;
v_58:
v_12:
return onevalue(v_86);
}
// Code for bvarom
static LispObject CC_bvarom(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_29, v_30;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
stack[0] = v_2;
// end of prologue
v_29 = stack[0];
if (!car_legal(v_29)) v_29 = carerror(v_29); else
v_29 = car(v_29);
v_29 = Lconsp(nil, v_29);
env = stack[-1];
if (v_29 == nil) goto v_9;
v_29 = stack[0];
if (!car_legal(v_29)) v_29 = carerror(v_29); else
v_29 = car(v_29);
if (!car_legal(v_29)) v_30 = carerror(v_29); else
v_30 = car(v_29);
v_29 = basic_elt(env, 1); // bvar
if (v_30 == v_29) goto v_15;
else goto v_16;
v_15:
v_29 = stack[0];
if (!car_legal(v_29)) v_29 = carerror(v_29); else
v_29 = car(v_29);
if (!car_legal(v_29)) v_29 = cdrerror(v_29); else
v_29 = cdr(v_29);
if (!car_legal(v_29)) v_29 = carerror(v_29); else
v_29 = car(v_29);
{ LispObject fn = basic_elt(env, 2); // objectom
v_29 = (*qfn1(fn))(fn, v_29);
}
env = stack[-1];
v_29 = stack[0];
if (!car_legal(v_29)) v_29 = cdrerror(v_29); else
v_29 = cdr(v_29);
{ LispObject fn = basic_elt(env, 0); // bvarom
v_29 = (*qfn1(fn))(fn, v_29);
}
goto v_14;
v_16:
v_14:
goto v_7;
v_9:
v_7:
v_29 = nil;
return onevalue(v_29);
}
// Code for s!-nextarg
static LispObject CC_sKnextarg(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_134, v_135, v_136;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// copy arguments values to proper place
stack[0] = v_2;
// end of prologue
v_134 = qvalue(basic_elt(env, 1)); // !*udebug
if (v_134 == nil) goto v_11;
v_134 = nil;
{ LispObject fn = basic_elt(env, 12); // uprint
v_134 = (*qfn1(fn))(fn, v_134);
}
env = stack[-2];
goto v_9;
v_11:
v_9:
v_134 = qvalue(basic_elt(env, 2)); // comb
if (v_134 == nil) goto v_17;
else goto v_18;
v_17:
v_134 = qvalue(basic_elt(env, 3)); // i
v_134 = add1(v_134);
env = stack[-2];
setvalue(basic_elt(env, 3), v_134); // i
v_134 = stack[0];
{ LispObject fn = basic_elt(env, 13); // initcomb
v_134 = (*qfn1(fn))(fn, v_134);
}
env = stack[-2];
setvalue(basic_elt(env, 2), v_134); // comb
goto v_16;
v_18:
v_16:
v_135 = stack[0];
v_134 = qvalue(basic_elt(env, 2)); // comb
{ LispObject fn = basic_elt(env, 14); // getcomb
v_134 = (*qfn2(fn))(fn, v_135, v_134);
}
env = stack[-2];
stack[-1] = v_134;
if (v_134 == nil) goto v_27;
v_135 = qvalue(basic_elt(env, 3)); // i
v_134 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
if (v_135 == v_134) goto v_37;
else goto v_38;
v_37:
v_135 = qvalue(basic_elt(env, 3)); // i
v_134 = qvalue(basic_elt(env, 4)); // upb
v_134 = static_cast<LispObject>(lesseq2(v_135, v_134));
v_134 = v_134 ? lisp_true : nil;
env = stack[-2];
goto v_36;
v_38:
v_134 = nil;
goto v_36;
v_134 = nil;
v_36:
if (v_134 == nil) goto v_34;
v_134 = stack[-1];
if (!car_legal(v_134)) v_134 = carerror(v_134); else
v_134 = car(v_134);
if (!car_legal(v_134)) v_135 = carerror(v_134); else
v_135 = car(v_134);
v_134 = stack[-1];
if (!car_legal(v_134)) v_134 = cdrerror(v_134); else
v_134 = cdr(v_134);
return cons(v_135, v_134);
v_34:
v_135 = qvalue(basic_elt(env, 3)); // i
v_134 = static_cast<LispObject>(0)+TAG_FIXNUM; // 0
if (v_135 == v_134) goto v_57;
else goto v_58;
v_57:
v_135 = qvalue(basic_elt(env, 3)); // i
v_134 = qvalue(basic_elt(env, 4)); // upb
v_134 = static_cast<LispObject>(lesseq2(v_135, v_134));
v_134 = v_134 ? lisp_true : nil;
env = stack[-2];
goto v_56;
v_58:
v_134 = nil;
goto v_56;
v_134 = nil;
v_56:
if (v_134 == nil) goto v_54;
v_135 = basic_elt(env, 5); // (null!-fn)
v_134 = stack[0];
return cons(v_135, v_134);
v_54:
v_134 = qvalue(basic_elt(env, 6)); // acontract
if (v_134 == nil) goto v_71;
v_135 = qvalue(basic_elt(env, 3)); // i
v_134 = qvalue(basic_elt(env, 4)); // upb
v_134 = static_cast<LispObject>(lesseq2(v_135, v_134));
v_134 = v_134 ? lisp_true : nil;
env = stack[-2];
if (v_134 == nil) goto v_71;
v_136 = qvalue(basic_elt(env, 7)); // op
v_134 = stack[-1];
if (!car_legal(v_134)) v_135 = carerror(v_134); else
v_135 = car(v_134);
v_134 = stack[-1];
if (!car_legal(v_134)) v_134 = cdrerror(v_134); else
v_134 = cdr(v_134);
v_134 = acons(v_136, v_135, v_134);
env = stack[-2];
{
LispObject fn = basic_elt(env, 15); // mval
return (*qfn1(fn))(fn, v_134);
}
v_71:
v_134 = qvalue(basic_elt(env, 8)); // mcontract
if (v_134 == nil) goto v_86;
v_135 = qvalue(basic_elt(env, 3)); // i
v_134 = qvalue(basic_elt(env, 4)); // upb
v_134 = static_cast<LispObject>(lesseq2(v_135, v_134));
v_134 = v_134 ? lisp_true : nil;
env = stack[-2];
if (v_134 == nil) goto v_86;
v_136 = basic_elt(env, 9); // null!-fn
v_134 = stack[-1];
if (!car_legal(v_134)) v_135 = carerror(v_134); else
v_135 = car(v_134);
v_134 = stack[-1];
if (!car_legal(v_134)) v_134 = cdrerror(v_134); else
v_134 = cdr(v_134);
return acons(v_136, v_135, v_134);
v_86:
v_134 = qvalue(basic_elt(env, 10)); // expand
if (v_134 == nil) goto v_100;
v_134 = nil;
setvalue(basic_elt(env, 10), v_134); // expand
v_135 = qvalue(basic_elt(env, 11)); // identity
v_134 = stack[0];
return cons(v_135, v_134);
v_100:
v_134 = nil;
goto v_32;
v_134 = nil;
v_32:
goto v_25;
v_27:
v_135 = qvalue(basic_elt(env, 3)); // i
v_134 = static_cast<LispObject>(0)+TAG_FIXNUM; // 0
if (v_135 == v_134) goto v_113;
else goto v_114;
v_113:
v_135 = qvalue(basic_elt(env, 3)); // i
v_134 = qvalue(basic_elt(env, 4)); // upb
v_134 = static_cast<LispObject>(lesseq2(v_135, v_134));
v_134 = v_134 ? lisp_true : nil;
env = stack[-2];
goto v_112;
v_114:
v_134 = nil;
goto v_112;
v_134 = nil;
v_112:
if (v_134 == nil) goto v_110;
v_135 = basic_elt(env, 5); // (null!-fn)
v_134 = stack[0];
return cons(v_135, v_134);
v_110:
v_134 = qvalue(basic_elt(env, 10)); // expand
if (v_134 == nil) goto v_127;
v_134 = nil;
setvalue(basic_elt(env, 10), v_134); // expand
v_135 = qvalue(basic_elt(env, 11)); // identity
v_134 = stack[0];
return cons(v_135, v_134);
v_127:
v_134 = nil;
v_25:
return onevalue(v_134);
}
// Code for wedgef
static LispObject CC_wedgef(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_150, v_151, v_152;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil, nil);
stack_popper stack_popper_var(4);
// copy arguments values to proper place
stack[-1] = v_2;
// end of prologue
v_150 = stack[-1];
{ LispObject fn = basic_elt(env, 6); // dim!<deg
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
if (v_150 == nil) goto v_7;
v_150 = nil;
goto v_5;
v_7:
v_150 = stack[-1];
if (!car_legal(v_150)) v_151 = carerror(v_150); else
v_151 = car(v_150);
v_150 = basic_elt(env, 1); // hodge
if (!consp(v_151)) goto v_12;
v_151 = car(v_151);
if (v_151 == v_150) goto v_11;
else goto v_12;
v_11:
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
{ LispObject fn = basic_elt(env, 7); // deg!*form
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
stack[-2] = v_150;
stack[0] = stack[-2];
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
{ LispObject fn = basic_elt(env, 8); // deg!*farg
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
if (equal(stack[0], v_150)) goto v_25;
else goto v_26;
v_25:
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_152 = carerror(v_150); else
v_152 = car(v_150);
v_151 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_150 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_150 = list2star(v_152, v_151, v_150);
env = stack[-3];
stack[0] = ncons(v_150);
env = stack[-3];
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (v_150 == nil) goto v_46;
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
{ LispObject fn = basic_elt(env, 9); // mkuniquewedge1
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
goto v_44;
v_46:
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_152 = carerror(v_150); else
v_152 = car(v_150);
v_151 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_150 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_150 = list2star(v_152, v_151, v_150);
env = stack[-3];
v_150 = ncons(v_150);
env = stack[-3];
goto v_44;
v_150 = nil;
v_44:
{ LispObject fn = basic_elt(env, 10); // hodgepf
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 11); // mkunarywedge
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 12); // wedgepf2
stack[-1] = (*qfn2(fn))(fn, stack[0], v_150);
}
env = stack[-3];
stack[0] = stack[-2];
v_150 = qvalue(basic_elt(env, 2)); // dimex!*
{ LispObject fn = basic_elt(env, 13); // negf
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 14); // addf
v_150 = (*qfn2(fn))(fn, stack[-2], v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 15); // multf
v_150 = (*qfn2(fn))(fn, stack[0], v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 16); // mksgnsq
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{
LispObject v_156 = stack[-1];
LispObject fn = basic_elt(env, 17); // multpfsq
return (*qfn2(fn))(fn, v_156, v_150);
}
v_26:
v_150 = stack[-1];
{
LispObject fn = basic_elt(env, 18); // mkwedge
return (*qfn1(fn))(fn, v_150);
}
v_150 = nil;
goto v_5;
v_12:
v_150 = stack[-1];
if (!car_legal(v_150)) v_151 = carerror(v_150); else
v_151 = car(v_150);
v_150 = basic_elt(env, 3); // d
if (!consp(v_151)) goto v_78;
v_151 = car(v_151);
if (v_151 == v_150) goto v_77;
else goto v_78;
v_77:
v_151 = basic_elt(env, 3); // d
v_150 = basic_elt(env, 4); // noxpnd
v_150 = Lflagp(nil, v_151, v_150);
env = stack[-3];
if (v_150 == nil) goto v_86;
v_150 = lisp_true;
goto v_84;
v_86:
v_151 = qvalue(basic_elt(env, 5)); // lftshft!*
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
{ LispObject fn = basic_elt(env, 19); // smemqlp
v_150 = (*qfn2(fn))(fn, v_151, v_150);
}
env = stack[-3];
goto v_84;
v_150 = nil;
v_84:
goto v_76;
v_78:
v_150 = nil;
goto v_76;
v_150 = nil;
v_76:
if (v_150 == nil) goto v_74;
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_151 = carerror(v_150); else
v_151 = car(v_150);
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
v_150 = cons(v_151, v_150);
env = stack[-3];
{ LispObject fn = basic_elt(env, 20); // dwedge
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 11); // mkunarywedge
stack[-2] = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_152 = carerror(v_150); else
v_152 = car(v_150);
v_151 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_150 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_150 = list2star(v_152, v_151, v_150);
env = stack[-3];
stack[0] = ncons(v_150);
env = stack[-3];
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (v_150 == nil) goto v_126;
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
{ LispObject fn = basic_elt(env, 20); // dwedge
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
goto v_124;
v_126:
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
{ LispObject fn = basic_elt(env, 21); // exdfk
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
goto v_124;
v_150 = nil;
v_124:
{ LispObject fn = basic_elt(env, 11); // mkunarywedge
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 12); // wedgepf2
stack[0] = (*qfn2(fn))(fn, stack[0], v_150);
}
env = stack[-3];
v_150 = stack[-1];
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
if (!car_legal(v_150)) v_150 = cdrerror(v_150); else
v_150 = cdr(v_150);
if (!car_legal(v_150)) v_150 = carerror(v_150); else
v_150 = car(v_150);
{ LispObject fn = basic_elt(env, 7); // deg!*form
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 16); // mksgnsq
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 22); // negsq
v_150 = (*qfn1(fn))(fn, v_150);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 17); // multpfsq
v_150 = (*qfn2(fn))(fn, stack[0], v_150);
}
env = stack[-3];
{
LispObject v_157 = stack[-2];
LispObject fn = basic_elt(env, 23); // addpf
return (*qfn2(fn))(fn, v_157, v_150);
}
v_74:
v_150 = stack[-1];
{
LispObject fn = basic_elt(env, 18); // mkwedge
return (*qfn1(fn))(fn, v_150);
}
v_150 = nil;
v_5:
return onevalue(v_150);
}
// Code for apply_e
static LispObject CC_apply_e(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_17, v_18;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
stack_popper stack_popper_var(1);
// copy arguments values to proper place
v_17 = v_2;
// end of prologue
v_18 = v_17;
v_17 = nil;
{ LispObject fn = basic_elt(env, 2); // apply
v_18 = (*qfn2(fn))(fn, v_18, v_17);
}
env = stack[0];
v_17 = v_18;
v_18 = integerp(v_18);
if (v_18 == nil) goto v_7;
goto v_5;
v_7:
v_17 = basic_elt(env, 1); // "randpoly expons function must return an integer"
{
LispObject fn = basic_elt(env, 3); // rederr
return (*qfn1(fn))(fn, v_17);
}
v_17 = nil;
v_5:
return onevalue(v_17);
}
// Code for diff_vertex
static LispObject CC_diff_vertex(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_40, v_41, v_42;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// copy arguments values to proper place
stack[0] = v_3;
stack[-1] = v_2;
// end of prologue
v_42 = nil;
v_8:
v_40 = stack[-1];
if (v_40 == nil) goto v_11;
else goto v_12;
v_11:
v_40 = v_42;
{
LispObject fn = basic_elt(env, 2); // nreverse
return (*qfn1(fn))(fn, v_40);
}
v_12:
v_40 = stack[-1];
if (!car_legal(v_40)) v_40 = carerror(v_40); else
v_40 = car(v_40);
if (!car_legal(v_40)) v_41 = carerror(v_40); else
v_41 = car(v_40);
v_40 = stack[0];
v_40 = Lassoc(nil, v_41, v_40);
if (v_40 == nil) goto v_17;
v_40 = stack[-1];
if (!car_legal(v_40)) v_40 = carerror(v_40); else
v_40 = car(v_40);
if (!car_legal(v_40)) v_41 = carerror(v_40); else
v_41 = car(v_40);
v_40 = qvalue(basic_elt(env, 1)); // !_0edge
if (!car_legal(v_40)) v_40 = carerror(v_40); else
v_40 = car(v_40);
if (v_41 == v_40) goto v_17;
v_40 = stack[-1];
if (!car_legal(v_40)) v_40 = cdrerror(v_40); else
v_40 = cdr(v_40);
stack[-1] = v_40;
goto v_8;
v_17:
v_40 = stack[-1];
if (!car_legal(v_40)) v_40 = carerror(v_40); else
v_40 = car(v_40);
v_41 = v_42;
v_40 = cons(v_40, v_41);
env = stack[-2];
v_42 = v_40;
v_40 = stack[-1];
if (!car_legal(v_40)) v_40 = cdrerror(v_40); else
v_40 = cdr(v_40);
stack[-1] = v_40;
goto v_8;
v_40 = nil;
return onevalue(v_40);
}
// Code for assert_kernelp
static LispObject CC_assert_kernelp(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_43, v_44;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
stack_popper stack_popper_var(1);
// copy arguments values to proper place
v_43 = v_2;
// end of prologue
v_44 = v_43;
if (symbolp(v_44)) goto v_9;
else goto v_10;
v_9:
v_43 = lisp_true;
goto v_6;
v_10:
v_44 = v_43;
v_44 = Lconsp(nil, v_44);
env = stack[0];
if (v_44 == nil) goto v_15;
else goto v_16;
v_15:
v_43 = nil;
goto v_6;
v_16:
v_44 = v_43;
if (!car_legal(v_44)) v_44 = carerror(v_44); else
v_44 = car(v_44);
if (!symbolp(v_44)) v_44 = nil;
else { v_44 = qfastgets(v_44);
if (v_44 != nil) { v_44 = elt(v_44, 38); // fkernfn
#ifdef RECORD_GET
if (v_44 != SPID_NOPROP)
record_get(elt(fastget_names, 38), 1);
else record_get(elt(fastget_names, 38), 0),
v_44 = nil; }
else record_get(elt(fastget_names, 38), 0); }
#else
if (v_44 == SPID_NOPROP) v_44 = nil; }}
#endif
if (v_44 == nil) goto v_23;
v_43 = lisp_true;
goto v_6;
v_23:
v_44 = v_43;
if (!car_legal(v_44)) v_44 = carerror(v_44); else
v_44 = car(v_44);
if (!consp(v_44)) goto v_30;
else goto v_31;
v_30:
v_44 = v_43;
if (!car_legal(v_44)) v_44 = carerror(v_44); else
v_44 = car(v_44);
if (!symbolp(v_44)) v_44 = nil;
else { v_44 = qfastgets(v_44);
if (v_44 != nil) { v_44 = elt(v_44, 24); // klist
#ifdef RECORD_GET
if (v_44 != SPID_NOPROP)
record_get(elt(fastget_names, 24), 1);
else record_get(elt(fastget_names, 24), 0),
v_44 = nil; }
else record_get(elt(fastget_names, 24), 0); }
#else
if (v_44 == SPID_NOPROP) v_44 = nil; }}
#endif
goto v_29;
v_31:
v_44 = qvalue(basic_elt(env, 1)); // exlist!*
goto v_29;
v_44 = nil;
v_29:
v_43 = Latsoc(nil, v_43, v_44);
v_6:
return onevalue(v_43);
}
// Code for evalgreaterp
static LispObject CC_evalgreaterp(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_67, v_68, v_69;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
v_68 = v_3;
v_67 = v_2;
// end of prologue
v_69 = basic_elt(env, 1); // difference
v_67 = list3(v_69, v_68, v_67);
env = stack[-1];
{ LispObject fn = basic_elt(env, 3); // simp!*
v_67 = (*qfn1(fn))(fn, v_67);
}
env = stack[-1];
stack[0] = v_67;
v_67 = stack[0];
if (!car_legal(v_67)) v_67 = cdrerror(v_67); else
v_67 = cdr(v_67);
if (!consp(v_67)) goto v_18;
v_67 = lisp_true;
goto v_16;
v_18:
v_67 = stack[0];
if (!car_legal(v_67)) v_67 = carerror(v_67); else
v_67 = car(v_67);
if (!consp(v_67)) goto v_26;
else goto v_27;
v_26:
v_67 = lisp_true;
goto v_25;
v_27:
v_67 = stack[0];
if (!car_legal(v_67)) v_67 = carerror(v_67); else
v_67 = car(v_67);
if (!car_legal(v_67)) v_67 = carerror(v_67); else
v_67 = car(v_67);
v_67 = (consp(v_67) ? nil : lisp_true);
goto v_25;
v_67 = nil;
v_25:
v_67 = (v_67 == nil ? lisp_true : nil);
goto v_16;
v_67 = nil;
v_16:
if (v_67 == nil) goto v_14;
v_67 = stack[0];
if (!car_legal(v_67)) v_67 = carerror(v_67); else
v_67 = car(v_67);
{ LispObject fn = basic_elt(env, 4); // minusf
v_67 = (*qfn1(fn))(fn, v_67);
}
env = stack[-1];
if (v_67 == nil) goto v_43;
v_67 = stack[0];
{ LispObject fn = basic_elt(env, 5); // negsq
v_67 = (*qfn1(fn))(fn, v_67);
}
env = stack[-1];
goto v_41;
v_43:
v_67 = stack[0];
goto v_41;
v_67 = nil;
v_41:
{ LispObject fn = basic_elt(env, 6); // mk!*sq
v_68 = (*qfn1(fn))(fn, v_67);
}
env = stack[-1];
v_67 = basic_elt(env, 2); // "number"
{
LispObject fn = basic_elt(env, 7); // typerr
return (*qfn2(fn))(fn, v_68, v_67);
}
v_14:
v_67 = stack[0];
if (!car_legal(v_67)) v_67 = carerror(v_67); else
v_67 = car(v_67);
if (v_67 == nil) goto v_57;
else goto v_58;
v_57:
v_67 = nil;
goto v_56;
v_58:
v_67 = stack[0];
if (!car_legal(v_67)) v_67 = carerror(v_67); else
v_67 = car(v_67);
{
LispObject fn = basic_elt(env, 8); // !:minusp
return (*qfn1(fn))(fn, v_67);
}
v_67 = nil;
v_56:
goto v_12;
v_67 = nil;
v_12:
return onevalue(v_67);
}
// Code for solvealgdepends
static LispObject CC_solvealgdepends(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_61, v_62;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// copy arguments values to proper place
stack[0] = v_3;
stack[-1] = v_2;
// end of prologue
v_8:
v_62 = stack[-1];
v_61 = stack[0];
if (equal(v_62, v_61)) goto v_11;
else goto v_12;
v_11:
v_61 = lisp_true;
goto v_7;
v_12:
v_61 = stack[-1];
if (!consp(v_61)) goto v_16;
else goto v_17;
v_16:
v_61 = nil;
goto v_7;
v_17:
v_62 = stack[-1];
v_61 = basic_elt(env, 1); // root_of
if (!consp(v_62)) goto v_21;
v_62 = car(v_62);
if (v_62 == v_61) goto v_20;
else goto v_21;
v_20:
v_62 = stack[0];
v_61 = stack[-1];
if (!car_legal(v_61)) v_61 = cdrerror(v_61); else
v_61 = cdr(v_61);
if (!car_legal(v_61)) v_61 = cdrerror(v_61); else
v_61 = cdr(v_61);
if (!car_legal(v_61)) v_61 = carerror(v_61); else
v_61 = car(v_61);
if (equal(v_62, v_61)) goto v_27;
else goto v_28;
v_27:
v_61 = nil;
goto v_7;
v_28:
v_61 = stack[-1];
if (!car_legal(v_61)) v_61 = cdrerror(v_61); else
v_61 = cdr(v_61);
if (!car_legal(v_61)) v_61 = carerror(v_61); else
v_61 = car(v_61);
stack[-1] = v_61;
goto v_8;
goto v_10;
v_21:
v_61 = stack[-1];
if (!car_legal(v_61)) v_62 = carerror(v_61); else
v_62 = car(v_61);
v_61 = stack[0];
{ LispObject fn = basic_elt(env, 0); // solvealgdepends
v_61 = (*qfn2(fn))(fn, v_62, v_61);
}
env = stack[-2];
v_62 = v_61;
if (v_61 == nil) goto v_45;
v_61 = v_62;
goto v_7;
v_45:
v_61 = stack[-1];
if (!car_legal(v_61)) v_62 = cdrerror(v_61); else
v_62 = cdr(v_61);
v_61 = stack[0];
{ LispObject fn = basic_elt(env, 0); // solvealgdepends
v_61 = (*qfn2(fn))(fn, v_62, v_61);
}
v_62 = v_61;
if (v_61 == nil) goto v_52;
v_61 = v_62;
goto v_7;
v_52:
v_61 = nil;
goto v_7;
goto v_10;
v_10:
v_61 = nil;
v_7:
return onevalue(v_61);
}
// Code for make!-image
static LispObject CC_makeKimage(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_60, v_61, v_62;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil, nil);
stack_popper stack_popper_var(4);
// copy arguments values to proper place
stack[0] = v_3;
stack[-1] = v_2;
// end of prologue
v_60 = stack[-1];
if (!consp(v_60)) goto v_11;
else goto v_12;
v_11:
v_60 = lisp_true;
goto v_10;
v_12:
v_60 = stack[-1];
if (!car_legal(v_60)) v_60 = carerror(v_60); else
v_60 = car(v_60);
v_60 = (consp(v_60) ? nil : lisp_true);
goto v_10;
v_60 = nil;
v_10:
if (v_60 == nil) goto v_8;
v_60 = stack[-1];
goto v_6;
v_8:
v_60 = stack[-1];
if (!car_legal(v_60)) v_60 = carerror(v_60); else
v_60 = car(v_60);
if (!car_legal(v_60)) v_60 = carerror(v_60); else
v_60 = car(v_60);
if (!car_legal(v_60)) v_61 = carerror(v_60); else
v_61 = car(v_60);
v_60 = qvalue(basic_elt(env, 1)); // m!-image!-variable
if (equal(v_61, v_60)) goto v_21;
else goto v_22;
v_21:
v_60 = stack[-1];
if (!car_legal(v_60)) v_60 = carerror(v_60); else
v_60 = car(v_60);
if (!car_legal(v_60)) v_61 = cdrerror(v_60); else
v_61 = cdr(v_60);
v_60 = stack[0];
{ LispObject fn = basic_elt(env, 2); // evaluate!-in!-order
v_60 = (*qfn2(fn))(fn, v_61, v_60);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 3); // !*n2f
stack[-2] = (*qfn1(fn))(fn, v_60);
}
env = stack[-3];
v_60 = stack[-1];
if (!car_legal(v_60)) v_61 = cdrerror(v_60); else
v_61 = cdr(v_60);
v_60 = stack[0];
{ LispObject fn = basic_elt(env, 0); // make!-image
v_60 = (*qfn2(fn))(fn, v_61, v_60);
}
v_61 = stack[-2];
v_62 = v_61;
if (v_62 == nil) goto v_42;
else goto v_43;
v_42:
goto v_41;
v_43:
v_62 = stack[-1];
if (!car_legal(v_62)) v_62 = carerror(v_62); else
v_62 = car(v_62);
if (!car_legal(v_62)) v_62 = carerror(v_62); else
v_62 = car(v_62);
return acons(v_62, v_61, v_60);
v_60 = nil;
v_41:
goto v_6;
v_22:
v_61 = stack[-1];
v_60 = stack[0];
{ LispObject fn = basic_elt(env, 2); // evaluate!-in!-order
v_60 = (*qfn2(fn))(fn, v_61, v_60);
}
env = stack[-3];
{
LispObject fn = basic_elt(env, 3); // !*n2f
return (*qfn1(fn))(fn, v_60);
}
v_60 = nil;
v_6:
return onevalue(v_60);
}
// Code for giplus!:
static LispObject CC_giplusT(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_20, v_21;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil, nil);
stack_popper stack_popper_var(4);
// copy arguments values to proper place
stack[0] = v_3;
stack[-1] = v_2;
// end of prologue
v_20 = stack[-1];
if (!car_legal(v_20)) v_20 = cdrerror(v_20); else
v_20 = cdr(v_20);
if (!car_legal(v_20)) v_21 = carerror(v_20); else
v_21 = car(v_20);
v_20 = stack[0];
if (!car_legal(v_20)) v_20 = cdrerror(v_20); else
v_20 = cdr(v_20);
if (!car_legal(v_20)) v_20 = carerror(v_20); else
v_20 = car(v_20);
stack[-2] = plus2(v_21, v_20);
env = stack[-3];
v_20 = stack[-1];
if (!car_legal(v_20)) v_20 = cdrerror(v_20); else
v_20 = cdr(v_20);
if (!car_legal(v_20)) v_21 = cdrerror(v_20); else
v_21 = cdr(v_20);
v_20 = stack[0];
if (!car_legal(v_20)) v_20 = cdrerror(v_20); else
v_20 = cdr(v_20);
if (!car_legal(v_20)) v_20 = cdrerror(v_20); else
v_20 = cdr(v_20);
v_20 = plus2(v_21, v_20);
env = stack[-3];
{
LispObject v_25 = stack[-2];
LispObject fn = basic_elt(env, 1); // mkgi
return (*qfn2(fn))(fn, v_25, v_20);
}
}
// Code for ext_mult
static LispObject CC_ext_mult(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_41, v_42, v_43;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
v_41 = v_3;
v_42 = v_2;
// end of prologue
if (!car_legal(v_42)) v_42 = cdrerror(v_42); else
v_42 = cdr(v_42);
if (!car_legal(v_41)) v_41 = cdrerror(v_41); else
v_41 = cdr(v_41);
{ LispObject fn = basic_elt(env, 2); // merge_lists
v_41 = (*qfn2(fn))(fn, v_42, v_41);
}
env = stack[-1];
stack[0] = v_41;
v_41 = stack[0];
if (v_41 == nil) goto v_13;
else goto v_14;
v_13:
v_42 = nil;
v_41 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
return cons(v_42, v_41);
v_14:
v_41 = stack[0];
if (!car_legal(v_41)) v_41 = cdrerror(v_41); else
v_41 = cdr(v_41);
if (v_41 == nil) goto v_19;
else goto v_20;
v_19:
v_42 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_41 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
return cons(v_42, v_41);
v_20:
v_42 = basic_elt(env, 1); // ext
v_41 = stack[0];
if (!car_legal(v_41)) v_41 = cdrerror(v_41); else
v_41 = cdr(v_41);
v_41 = cons(v_42, v_41);
env = stack[-1];
{ LispObject fn = basic_elt(env, 3); // !*a2k
v_42 = (*qfn1(fn))(fn, v_41);
}
env = stack[-1];
v_41 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
{ LispObject fn = basic_elt(env, 4); // to
v_42 = (*qfn2(fn))(fn, v_42, v_41);
}
env = stack[-1];
v_41 = stack[0];
if (!car_legal(v_41)) v_41 = carerror(v_41); else
v_41 = car(v_41);
v_43 = cons(v_42, v_41);
v_42 = nil;
v_41 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
return acons(v_43, v_42, v_41);
v_41 = nil;
return onevalue(v_41);
}
// Code for gcd!-with!-number
static LispObject CC_gcdKwithKnumber(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_70, v_71, v_72;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
stack[0] = v_3;
v_71 = v_2;
// end of prologue
v_7:
v_72 = v_71;
v_70 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
if (v_72 == v_70) goto v_14;
else goto v_15;
v_14:
v_70 = lisp_true;
goto v_13;
v_15:
v_70 = v_71;
if (!consp(v_70)) goto v_24;
v_70 = lisp_true;
goto v_22;
v_24:
v_70 = qvalue(basic_elt(env, 1)); // dmode!*
if (!symbolp(v_70)) v_70 = nil;
else { v_70 = qfastgets(v_70);
if (v_70 != nil) { v_70 = elt(v_70, 3); // field
#ifdef RECORD_GET
if (v_70 == SPID_NOPROP)
record_get(elt(fastget_names, 3), 0),
v_70 = nil;
else record_get(elt(fastget_names, 3), 1),
v_70 = lisp_true; }
else record_get(elt(fastget_names, 3), 0); }
#else
if (v_70 == SPID_NOPROP) v_70 = nil; else v_70 = lisp_true; }}
#endif
goto v_22;
v_70 = nil;
v_22:
goto v_13;
v_70 = nil;
v_13:
if (v_70 == nil) goto v_11;
v_70 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
goto v_6;
v_11:
v_70 = stack[0];
if (!consp(v_70)) goto v_36;
else goto v_37;
v_36:
v_70 = lisp_true;
goto v_35;
v_37:
v_70 = stack[0];
if (!car_legal(v_70)) v_70 = carerror(v_70); else
v_70 = car(v_70);
v_70 = (consp(v_70) ? nil : lisp_true);
goto v_35;
v_70 = nil;
v_35:
if (v_70 == nil) goto v_33;
v_70 = stack[0];
if (v_70 == nil) goto v_47;
else goto v_48;
v_47:
v_70 = v_71;
return Labsval(nil, v_70);
v_48:
v_70 = stack[0];
if (!consp(v_70)) goto v_53;
v_70 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
goto v_6;
v_53:
v_70 = stack[0];
{
LispObject fn = basic_elt(env, 2); // gcddd
return (*qfn2(fn))(fn, v_71, v_70);
}
goto v_9;
v_33:
v_70 = stack[0];
if (!car_legal(v_70)) v_70 = carerror(v_70); else
v_70 = car(v_70);
if (!car_legal(v_70)) v_70 = cdrerror(v_70); else
v_70 = cdr(v_70);
{ LispObject fn = basic_elt(env, 0); // gcd!-with!-number
v_70 = (*qfn2(fn))(fn, v_71, v_70);
}
env = stack[-1];
v_71 = v_70;
v_70 = stack[0];
if (!car_legal(v_70)) v_70 = cdrerror(v_70); else
v_70 = cdr(v_70);
stack[0] = v_70;
goto v_7;
v_9:
v_70 = nil;
v_6:
return onevalue(v_70);
}
// Code for aex_sgn
static LispObject CC_aex_sgn(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_113, v_114;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
stack_popper stack_popper_var(6);
// copy arguments values to proper place
stack[0] = v_2;
// end of prologue
goto v_15;
goto v_13;
v_15:
v_13:
v_113 = stack[0];
{ LispObject fn = basic_elt(env, 5); // aex_simpleratp
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
if (v_113 == nil) goto v_20;
v_113 = stack[0];
{ LispObject fn = basic_elt(env, 6); // aex_ex
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{
LispObject fn = basic_elt(env, 7); // rat_sgn
return (*qfn1(fn))(fn, v_113);
}
v_20:
v_113 = qvalue(basic_elt(env, 1)); // !*rlanuexsgnopt
if (v_113 == nil) goto v_29;
v_113 = stack[0];
{ LispObject fn = basic_elt(env, 8); // aex_containment
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
stack[-2] = v_113;
{ LispObject fn = basic_elt(env, 9); // rat_0
stack[-1] = (*qfn0(fn))(fn);
}
env = stack[-5];
v_113 = stack[-2];
{ LispObject fn = basic_elt(env, 10); // iv_lb
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 11); // rat_less
v_113 = (*qfn2(fn))(fn, stack[-1], v_113);
}
env = stack[-5];
if (v_113 == nil) goto v_36;
v_113 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
goto v_11;
v_36:
v_113 = stack[-2];
{ LispObject fn = basic_elt(env, 12); // iv_rb
stack[-1] = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 9); // rat_0
v_113 = (*qfn0(fn))(fn);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 11); // rat_less
v_113 = (*qfn2(fn))(fn, stack[-1], v_113);
}
env = stack[-5];
if (v_113 == nil) goto v_45;
v_113 = static_cast<LispObject>(-16)+TAG_FIXNUM; // -1
goto v_11;
v_45:
goto v_27;
v_29:
v_27:
v_113 = stack[0];
{ LispObject fn = basic_elt(env, 13); // aex_mvar
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
stack[-4] = v_113;
v_113 = stack[0];
{ LispObject fn = basic_elt(env, 14); // aex_ctx
v_114 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
v_113 = stack[-4];
{ LispObject fn = basic_elt(env, 15); // ctx_get
v_113 = (*qfn2(fn))(fn, v_114, v_113);
}
env = stack[-5];
stack[-3] = v_113;
v_114 = stack[0];
v_113 = stack[-4];
{ LispObject fn = basic_elt(env, 16); // aex_unbind
v_113 = (*qfn2(fn))(fn, v_114, v_113);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 17); // aex_reduce
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 18); // aex_mklcnt
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
stack[-1] = v_113;
v_113 = stack[-1];
{ LispObject fn = basic_elt(env, 5); // aex_simpleratp
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
if (v_113 == nil) goto v_65;
v_113 = stack[-1];
{ LispObject fn = basic_elt(env, 6); // aex_ex
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{
LispObject fn = basic_elt(env, 7); // rat_sgn
return (*qfn1(fn))(fn, v_113);
}
v_65:
v_113 = qvalue(basic_elt(env, 2)); // !*rlverbose
if (v_113 == nil) goto v_74;
v_113 = qvalue(basic_elt(env, 3)); // !*rlanuexverbose
if (v_113 == nil) goto v_74;
v_114 = stack[-1];
v_113 = stack[-4];
{ LispObject fn = basic_elt(env, 19); // aex_deg
v_114 = (*qfn2(fn))(fn, v_114, v_113);
}
env = stack[-5];
v_113 = static_cast<LispObject>(0)+TAG_FIXNUM; // 0
v_113 = static_cast<LispObject>(lesseq2(v_114, v_113));
v_113 = v_113 ? lisp_true : nil;
env = stack[-5];
if (v_113 == nil) goto v_82;
v_113 = basic_elt(env, 4); // "[aex_sgn:num!]"
v_113 = Lprinc(nil, v_113);
env = stack[-5];
goto v_80;
v_82:
v_80:
goto v_72;
v_74:
v_72:
v_113 = stack[-3];
{ LispObject fn = basic_elt(env, 20); // anu_dp
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
stack[0] = v_113;
v_114 = v_113;
v_113 = stack[-4];
{ LispObject fn = basic_elt(env, 21); // aex_diff
v_114 = (*qfn2(fn))(fn, v_114, v_113);
}
env = stack[-5];
v_113 = stack[-1];
{ LispObject fn = basic_elt(env, 22); // aex_mult
v_114 = (*qfn2(fn))(fn, v_114, v_113);
}
env = stack[-5];
v_113 = stack[-4];
{ LispObject fn = basic_elt(env, 23); // aex_sturmchain
v_113 = (*qfn3(fn))(fn, stack[0], v_114, v_113);
}
env = stack[-5];
stack[-2] = v_113;
stack[-1] = stack[-2];
stack[0] = stack[-4];
v_113 = stack[-3];
{ LispObject fn = basic_elt(env, 24); // anu_iv
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 10); // iv_lb
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 25); // aex_stchsgnch1
stack[0] = (*qfn3(fn))(fn, stack[-1], stack[0], v_113);
}
env = stack[-5];
stack[-1] = stack[-2];
stack[-2] = stack[-4];
v_113 = stack[-3];
{ LispObject fn = basic_elt(env, 24); // anu_iv
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 12); // iv_rb
v_113 = (*qfn1(fn))(fn, v_113);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 25); // aex_stchsgnch1
v_113 = (*qfn3(fn))(fn, stack[-1], stack[-2], v_113);
}
{
LispObject v_120 = stack[0];
return difference2(v_120, v_113);
}
v_11:
return onevalue(v_113);
}
// Code for containerom
static LispObject CC_containerom(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_97, v_98;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil, nil, nil);
stack_popper stack_popper_var(5);
// copy arguments values to proper place
stack[-2] = v_2;
// end of prologue
// Binding name
// FLUIDBIND: reloadenv=4 litvec-offset=1 saveloc=0
{ bind_fluid_stack bind_fluid_var(-4, 1, 0);
setvalue(basic_elt(env, 1), nil); // name
v_97 = stack[-2];
if (!car_legal(v_97)) v_97 = cdrerror(v_97); else
v_97 = cdr(v_97);
if (!car_legal(v_97)) v_97 = carerror(v_97); else
v_97 = car(v_97);
stack[-1] = v_97;
v_97 = stack[-2];
if (!car_legal(v_97)) v_97 = carerror(v_97); else
v_97 = car(v_97);
setvalue(basic_elt(env, 1), v_97); // name
v_97 = basic_elt(env, 2); // "<OMA>"
{ LispObject fn = basic_elt(env, 14); // printout
v_97 = (*qfn1(fn))(fn, v_97);
}
env = stack[-4];
v_97 = lisp_true;
{ LispObject fn = basic_elt(env, 15); // indent!*
v_97 = (*qfn1(fn))(fn, v_97);
}
env = stack[-4];
v_98 = qvalue(basic_elt(env, 1)); // name
v_97 = basic_elt(env, 3); // vectorml
if (v_98 == v_97) goto v_21;
else goto v_22;
v_21:
v_97 = basic_elt(env, 4); // vector
setvalue(basic_elt(env, 1), v_97); // name
goto v_20;
v_22:
v_20:
v_98 = qvalue(basic_elt(env, 1)); // name
v_97 = qvalue(basic_elt(env, 5)); // valid_om!*
v_97 = Lassoc(nil, v_98, v_97);
if (!car_legal(v_97)) v_97 = cdrerror(v_97); else
v_97 = cdr(v_97);
if (!car_legal(v_97)) v_97 = carerror(v_97); else
v_97 = car(v_97);
stack[-3] = v_97;
v_97 = stack[-2];
if (!car_legal(v_97)) v_98 = carerror(v_97); else
v_98 = car(v_97);
v_97 = basic_elt(env, 6); // set
if (v_98 == v_97) goto v_37;
else goto v_38;
v_37:
v_97 = stack[-1];
v_97 = Lconsp(nil, v_97);
env = stack[-4];
goto v_36;
v_38:
v_97 = nil;
goto v_36;
v_97 = nil;
v_36:
if (v_97 == nil) goto v_34;
v_97 = stack[-1];
if (!car_legal(v_97)) v_97 = carerror(v_97); else
v_97 = car(v_97);
if (!car_legal(v_97)) v_97 = cdrerror(v_97); else
v_97 = cdr(v_97);
if (!car_legal(v_97)) v_97 = carerror(v_97); else
v_97 = car(v_97);
v_98 = Lintern(nil, v_97);
env = stack[-4];
v_97 = basic_elt(env, 7); // multiset
if (v_98 == v_97) goto v_49;
else goto v_50;
v_49:
v_97 = basic_elt(env, 8); // multiset1
stack[-3] = v_97;
goto v_48;
v_50:
v_48:
goto v_32;
v_34:
v_32:
v_97 = stack[-2];
if (!car_legal(v_97)) v_98 = carerror(v_97); else
v_98 = car(v_97);
v_97 = basic_elt(env, 3); // vectorml
if (v_98 == v_97) goto v_61;
else goto v_62;
v_61:
v_97 = basic_elt(env, 9); // "vector"
setvalue(basic_elt(env, 1), v_97); // name
goto v_60;
v_62:
v_60:
v_97 = stack[-2];
if (!car_legal(v_97)) v_98 = carerror(v_97); else
v_98 = car(v_97);
v_97 = basic_elt(env, 3); // vectorml
if (v_98 == v_97) goto v_69;
else goto v_70;
v_69:
v_98 = basic_elt(env, 4); // vector
v_97 = stack[-2];
if (!car_legal(v_97)) v_97 = cdrerror(v_97); else
v_97 = cdr(v_97);
v_97 = cons(v_98, v_97);
env = stack[-4];
stack[-2] = v_97;
goto v_68;
v_70:
v_68:
v_97 = basic_elt(env, 10); // "<OMS cd="""
{ LispObject fn = basic_elt(env, 14); // printout
v_97 = (*qfn1(fn))(fn, v_97);
}
env = stack[-4];
v_97 = stack[-3];
v_97 = Lprinc(nil, v_97);
env = stack[-4];
v_97 = basic_elt(env, 11); // """ name="""
v_97 = Lprinc(nil, v_97);
env = stack[-4];
v_97 = qvalue(basic_elt(env, 1)); // name
v_97 = Lprinc(nil, v_97);
env = stack[-4];
v_97 = basic_elt(env, 12); // """/>"
v_97 = Lprinc(nil, v_97);
env = stack[-4];
v_97 = stack[-2];
if (!car_legal(v_97)) v_97 = cdrerror(v_97); else
v_97 = cdr(v_97);
if (!car_legal(v_97)) v_97 = cdrerror(v_97); else
v_97 = cdr(v_97);
{ LispObject fn = basic_elt(env, 16); // multiom
v_97 = (*qfn1(fn))(fn, v_97);
}
env = stack[-4];
v_97 = nil;
{ LispObject fn = basic_elt(env, 15); // indent!*
v_97 = (*qfn1(fn))(fn, v_97);
}
env = stack[-4];
v_97 = basic_elt(env, 13); // "</OMA>"
{ LispObject fn = basic_elt(env, 14); // printout
v_97 = (*qfn1(fn))(fn, v_97);
}
v_97 = nil;
;} // end of a binding scope
return onevalue(v_97);
}
// Code for mkexdf
static LispObject CC_mkexdf(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_22, v_23;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
v_22 = v_2;
// end of prologue
v_23 = basic_elt(env, 1); // d
v_22 = list2(v_23, v_22);
env = stack[-1];
stack[0] = v_22;
{ LispObject fn = basic_elt(env, 2); // opmtch
v_22 = (*qfn1(fn))(fn, v_22);
}
env = stack[-1];
v_23 = v_22;
if (v_22 == nil) goto v_11;
v_22 = v_23;
{
LispObject fn = basic_elt(env, 3); // partitop
return (*qfn1(fn))(fn, v_22);
}
v_11:
v_22 = stack[0];
{
LispObject fn = basic_elt(env, 4); // mkupf
return (*qfn1(fn))(fn, v_22);
}
v_22 = nil;
return onevalue(v_22);
}
// Code for z!-roads
static LispObject CC_zKroads(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_59, v_60, v_61;
#ifdef CHECK_STACK
if_check_stack;
#endif
// copy arguments values to proper place
v_60 = v_2;
// end of prologue
v_61 = static_cast<LispObject>(0)+TAG_FIXNUM; // 0
v_59 = v_60;
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (v_61 == v_59) goto v_6;
else goto v_7;
v_6:
v_59 = v_60;
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
goto v_5;
v_7:
v_61 = static_cast<LispObject>(0)+TAG_FIXNUM; // 0
v_59 = v_60;
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (v_61 == v_59) goto v_16;
else goto v_17;
v_16:
v_59 = v_60;
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
goto v_5;
v_17:
v_61 = static_cast<LispObject>(0)+TAG_FIXNUM; // 0
v_59 = v_60;
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (v_61 == v_59) goto v_28;
else goto v_29;
v_28:
v_59 = v_60;
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (!car_legal(v_59)) v_59 = cdrerror(v_59); else
v_59 = cdr(v_59);
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
goto v_5;
v_29:
v_59 = nil;
goto v_5;
v_59 = nil;
v_5:
v_61 = v_59;
v_59 = v_61;
if (v_59 == nil) goto v_48;
else goto v_49;
v_48:
v_59 = nil;
goto v_47;
v_49:
v_59 = v_61;
if (!car_legal(v_59)) v_59 = carerror(v_59); else
v_59 = car(v_59);
if (!car_legal(v_60)) v_60 = cdrerror(v_60); else
v_60 = cdr(v_60);
return cons(v_59, v_60);
v_59 = nil;
v_47:
return onevalue(v_59);
}
// Code for msolve!-psys1
static LispObject CC_msolveKpsys1(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_101, v_102;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
push(nil, nil);
stack_popper stack_popper_var(8);
// copy arguments values to proper place
stack[-5] = v_3;
stack[0] = v_2;
// end of prologue
v_101 = nil;
v_101 = ncons(v_101);
env = stack[-7];
v_102 = v_101;
v_101 = stack[0];
stack[-4] = v_101;
v_16:
v_101 = stack[-4];
if (v_101 == nil) goto v_20;
else goto v_21;
v_20:
goto v_15;
v_21:
v_101 = stack[-4];
if (!car_legal(v_101)) v_101 = carerror(v_101); else
v_101 = car(v_101);
stack[-3] = v_101;
v_101 = nil;
stack[-6] = v_101;
v_101 = v_102;
stack[-2] = v_101;
v_31:
v_101 = stack[-2];
if (v_101 == nil) goto v_35;
else goto v_36;
v_35:
goto v_30;
v_36:
v_101 = stack[-2];
if (!car_legal(v_101)) v_101 = carerror(v_101); else
v_101 = car(v_101);
stack[-1] = v_101;
v_102 = stack[-3];
v_101 = stack[-1];
{ LispObject fn = basic_elt(env, 1); // subf
v_101 = (*qfn2(fn))(fn, v_102, v_101);
}
env = stack[-7];
if (!car_legal(v_101)) v_101 = carerror(v_101); else
v_101 = car(v_101);
{ LispObject fn = basic_elt(env, 2); // moduntag
v_101 = (*qfn1(fn))(fn, v_101);
}
env = stack[-7];
{ LispObject fn = basic_elt(env, 3); // general!-reduce!-mod!-p
v_101 = (*qfn1(fn))(fn, v_101);
}
env = stack[-7];
v_102 = v_101;
v_101 = v_102;
if (v_101 == nil) goto v_50;
else goto v_51;
v_50:
v_102 = stack[-1];
v_101 = stack[-6];
v_101 = cons(v_102, v_101);
env = stack[-7];
stack[-6] = v_101;
goto v_49;
v_51:
v_101 = v_102;
if (!consp(v_101)) goto v_60;
else goto v_61;
v_60:
v_101 = lisp_true;
goto v_59;
v_61:
v_101 = v_102;
if (!car_legal(v_101)) v_101 = carerror(v_101); else
v_101 = car(v_101);
v_101 = (consp(v_101) ? nil : lisp_true);
goto v_59;
v_101 = nil;
v_59:
if (v_101 == nil) goto v_57;
goto v_49;
v_57:
v_101 = stack[-5];
{ LispObject fn = basic_elt(env, 4); // msolve!-poly
v_101 = (*qfn2(fn))(fn, v_102, v_101);
}
env = stack[-7];
stack[0] = v_101;
v_75:
v_101 = stack[0];
if (v_101 == nil) goto v_81;
else goto v_82;
v_81:
goto v_74;
v_82:
v_101 = stack[0];
if (!car_legal(v_101)) v_101 = carerror(v_101); else
v_101 = car(v_101);
v_102 = stack[-1];
v_102 = Lappend_2(nil, v_102, v_101);
env = stack[-7];
v_101 = stack[-6];
v_101 = cons(v_102, v_101);
env = stack[-7];
stack[-6] = v_101;
v_101 = stack[0];
if (!car_legal(v_101)) v_101 = cdrerror(v_101); else
v_101 = cdr(v_101);
stack[0] = v_101;
goto v_75;
v_74:
goto v_49;
v_49:
v_101 = stack[-2];
if (!car_legal(v_101)) v_101 = cdrerror(v_101); else
v_101 = cdr(v_101);
stack[-2] = v_101;
goto v_31;
v_30:
v_101 = stack[-6];
v_102 = v_101;
v_101 = stack[-4];
if (!car_legal(v_101)) v_101 = cdrerror(v_101); else
v_101 = cdr(v_101);
stack[-4] = v_101;
goto v_16;
v_15:
v_101 = v_102;
return onevalue(v_101);
}
// Code for ratlessp
static LispObject CC_ratlessp(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_11, v_12;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
stack_popper stack_popper_var(1);
// copy arguments values to proper place
v_11 = v_3;
v_12 = v_2;
// end of prologue
{ LispObject fn = basic_elt(env, 1); // ratdif
v_11 = (*qfn2(fn))(fn, v_12, v_11);
}
if (!car_legal(v_11)) v_12 = carerror(v_11); else
v_12 = car(v_11);
v_11 = static_cast<LispObject>(0)+TAG_FIXNUM; // 0
return Llessp_2(nil, v_12, v_11);
}
// Code for lastcar
static LispObject CC_lastcar(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_23, v_24;
#ifdef CHECK_STACK
if_check_stack;
#endif
// copy arguments values to proper place
v_23 = v_2;
// end of prologue
v_6:
v_24 = v_23;
if (v_24 == nil) goto v_9;
else goto v_10;
v_9:
v_23 = nil;
goto v_5;
v_10:
v_24 = v_23;
if (!car_legal(v_24)) v_24 = cdrerror(v_24); else
v_24 = cdr(v_24);
if (v_24 == nil) goto v_13;
else goto v_14;
v_13:
if (!car_legal(v_23)) v_23 = carerror(v_23); else
v_23 = car(v_23);
goto v_5;
v_14:
if (!car_legal(v_23)) v_23 = cdrerror(v_23); else
v_23 = cdr(v_23);
goto v_6;
v_23 = nil;
v_5:
return onevalue(v_23);
}
// Code for aex_divposcnt
static LispObject CC_aex_divposcnt(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_55, v_56;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil, nil, nil);
stack_popper stack_popper_var(5);
// copy arguments values to proper place
v_55 = v_3;
stack[-2] = v_2;
// end of prologue
v_55 = stack[-2];
{ LispObject fn = basic_elt(env, 1); // aex_ex
v_55 = (*qfn1(fn))(fn, v_55);
}
env = stack[-4];
if (!car_legal(v_55)) v_55 = carerror(v_55); else
v_55 = car(v_55);
stack[0] = v_55;
v_55 = stack[0];
{ LispObject fn = basic_elt(env, 2); // sfto_ucontentf
v_55 = (*qfn1(fn))(fn, v_55);
}
env = stack[-4];
stack[-1] = v_55;
v_56 = stack[0];
v_55 = stack[-1];
{ LispObject fn = basic_elt(env, 3); // quotfx
v_55 = (*qfn2(fn))(fn, v_56, v_55);
}
env = stack[-4];
stack[0] = v_55;
v_56 = stack[-1];
v_55 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[-3] = cons(v_56, v_55);
env = stack[-4];
v_55 = stack[-1];
{ LispObject fn = basic_elt(env, 4); // kernels
stack[-1] = (*qfn1(fn))(fn, v_55);
}
env = stack[-4];
v_55 = stack[-2];
{ LispObject fn = basic_elt(env, 5); // aex_ctx
v_55 = (*qfn1(fn))(fn, v_55);
}
env = stack[-4];
{ LispObject fn = basic_elt(env, 6); // ctx_filter
v_55 = (*qfn2(fn))(fn, stack[-1], v_55);
}
env = stack[-4];
{ LispObject fn = basic_elt(env, 7); // aex_mk
v_55 = (*qfn2(fn))(fn, stack[-3], v_55);
}
env = stack[-4];
{ LispObject fn = basic_elt(env, 8); // aex_sgn
v_55 = (*qfn1(fn))(fn, v_55);
}
env = stack[-4];
stack[-3] = v_55;
goto v_34;
goto v_32;
v_34:
v_32:
v_56 = stack[0];
v_55 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[-1] = cons(v_56, v_55);
env = stack[-4];
v_55 = stack[0];
{ LispObject fn = basic_elt(env, 4); // kernels
stack[0] = (*qfn1(fn))(fn, v_55);
}
env = stack[-4];
v_55 = stack[-2];
{ LispObject fn = basic_elt(env, 5); // aex_ctx
v_55 = (*qfn1(fn))(fn, v_55);
}
env = stack[-4];
{ LispObject fn = basic_elt(env, 6); // ctx_filter
v_55 = (*qfn2(fn))(fn, stack[0], v_55);
}
env = stack[-4];
{ LispObject fn = basic_elt(env, 7); // aex_mk
v_55 = (*qfn2(fn))(fn, stack[-1], v_55);
}
env = stack[-4];
stack[0] = v_55;
v_56 = stack[-3];
v_55 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_55 = Leqn_2(nil, v_56, v_55);
env = stack[-4];
if (v_55 == nil) goto v_48;
v_55 = stack[0];
goto v_11;
v_48:
v_55 = stack[0];
{
LispObject fn = basic_elt(env, 9); // aex_neg
return (*qfn1(fn))(fn, v_55);
}
v_11:
return onevalue(v_55);
}
// Code for settcollectnonmultiprolongations
static LispObject CC_settcollectnonmultiprolongations(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_80, v_81;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
real_push(nil);
stack_popper stack_popper_var(7);
// copy arguments values to proper place
stack[-4] = v_2;
// end of prologue
v_80 = qvalue(basic_elt(env, 1)); // fluidbibasissett
if (!car_legal(v_80)) v_80 = carerror(v_80); else
v_80 = car(v_80);
if (v_80 == nil) goto v_7;
v_80 = qvalue(basic_elt(env, 1)); // fluidbibasissett
if (!car_legal(v_80)) v_80 = carerror(v_80); else
v_80 = car(v_80);
stack[-5] = v_80;
v_81 = stack[-5];
v_80 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_80 = Lgetv(nil, v_81, v_80);
env = stack[-6];
if (!car_legal(v_80)) v_80 = carerror(v_80); else
v_80 = car(v_80);
{ LispObject fn = basic_elt(env, 3); // monomgetfirstmultivar
v_80 = (*qfn1(fn))(fn, v_80);
}
env = stack[-6];
v_80 = static_cast<LispObject>(static_cast<std::intptr_t>(v_80) - 0x10);
stack[-2] = v_80;
v_80 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[-1] = v_80;
v_28:
v_81 = stack[-2];
v_80 = stack[-1];
v_80 = difference2(v_81, v_80);
env = stack[-6];
v_80 = Lminusp(nil, v_80);
env = stack[-6];
if (v_80 == nil) goto v_33;
goto v_27;
v_33:
v_81 = stack[-5];
v_80 = stack[-1];
{ LispObject fn = basic_elt(env, 4); // tripleisprolongedby
v_80 = (*qfn2(fn))(fn, v_81, v_80);
}
env = stack[-6];
if (v_80 == nil) goto v_41;
else goto v_42;
v_41:
v_81 = stack[-5];
v_80 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[0] = Lgetv(nil, v_81, v_80);
env = stack[-6];
v_81 = qvalue(basic_elt(env, 2)); // fluidbibasissinglevariablemonomialss
v_80 = stack[-1];
v_80 = Lgetv(nil, v_81, v_80);
env = stack[-6];
{ LispObject fn = basic_elt(env, 5); // polynommultiplybymonom
v_80 = (*qfn2(fn))(fn, stack[0], v_80);
}
env = stack[-6];
stack[0] = v_80;
v_81 = stack[-5];
v_80 = stack[-1];
{ LispObject fn = basic_elt(env, 6); // triplesetprolongedby
v_80 = (*qfn2(fn))(fn, v_81, v_80);
}
env = stack[-6];
v_80 = stack[0];
if (!car_legal(v_80)) v_80 = carerror(v_80); else
v_80 = car(v_80);
if (v_80 == nil) goto v_59;
v_81 = stack[-5];
v_80 = static_cast<LispObject>(32)+TAG_FIXNUM; // 2
v_80 = Lgetv(nil, v_81, v_80);
env = stack[-6];
{ LispObject fn = basic_elt(env, 7); // createtriplewithancestor
v_80 = (*qfn2(fn))(fn, stack[0], v_80);
}
env = stack[-6];
stack[-3] = v_80;
stack[0] = stack[-3];
v_81 = stack[-5];
v_80 = static_cast<LispObject>(48)+TAG_FIXNUM; // 3
v_80 = Lgetv(nil, v_81, v_80);
env = stack[-6];
{ LispObject fn = basic_elt(env, 8); // triplesetprolongset
v_80 = (*qfn2(fn))(fn, stack[0], v_80);
}
env = stack[-6];
v_81 = stack[-4];
v_80 = stack[-3];
{ LispObject fn = basic_elt(env, 9); // sortedtriplelistinsert
v_80 = (*qfn2(fn))(fn, v_81, v_80);
}
env = stack[-6];
goto v_57;
v_59:
v_57:
goto v_40;
v_42:
v_40:
v_80 = stack[-1];
v_80 = add1(v_80);
env = stack[-6];
stack[-1] = v_80;
goto v_28;
v_27:
v_80 = nil;
goto v_5;
v_7:
v_80 = nil;
v_5:
return onevalue(v_80);
}
// Code for processpartitie1list1
static LispObject CC_processpartitie1list1(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_30, v_31, v_32;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
real_push(nil);
stack_popper stack_popper_var(7);
// copy arguments values to proper place
v_30 = v_3;
v_31 = v_2;
// end of prologue
v_8:
v_32 = v_31;
if (v_32 == nil) goto v_11;
else goto v_12;
v_11:
goto v_7;
v_12:
v_32 = v_31;
if (!car_legal(v_32)) v_32 = cdrerror(v_32); else
v_32 = cdr(v_32);
stack[-5] = v_32;
if (!car_legal(v_31)) stack[-4] = carerror(v_31); else
stack[-4] = car(v_31);
stack[-3] = static_cast<LispObject>(0)+TAG_FIXNUM; // 0
stack[-2] = nil;
stack[-1] = nil;
stack[0] = nil;
v_30 = ncons(v_30);
env = stack[-6];
v_30 = acons(stack[-1], stack[0], v_30);
env = stack[-6];
{ LispObject fn = basic_elt(env, 1); // processpartitie1
v_30 = (*qfn4up(fn))(fn, stack[-4], stack[-3], stack[-2], v_30);
}
env = stack[-6];
v_31 = stack[-5];
goto v_8;
v_30 = nil;
v_7:
return onevalue(v_30);
}
// Code for mk!+outer!+list
static LispObject CC_mkLouterLlist(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_10, v_11;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
stack[0] = v_2;
// end of prologue
v_10 = basic_elt(env, 1); // list
v_11 = ncons(v_10);
v_10 = stack[0];
return Lappend_2(nil, v_11, v_10);
return onevalue(v_10);
}
// Code for repr_ldeg
static LispObject CC_repr_ldeg(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_10;
#ifdef CHECK_STACK
if_check_stack;
#endif
// copy arguments values to proper place
v_10 = v_2;
// end of prologue
if (!car_legal(v_10)) v_10 = cdrerror(v_10); else
v_10 = cdr(v_10);
if (!car_legal(v_10)) v_10 = cdrerror(v_10); else
v_10 = cdr(v_10);
if (!car_legal(v_10)) v_10 = cdrerror(v_10); else
v_10 = cdr(v_10);
if (!car_legal(v_10)) v_10 = cdrerror(v_10); else
v_10 = cdr(v_10);
if (!car_legal(v_10)) v_10 = carerror(v_10); else
v_10 = car(v_10);
return onevalue(v_10);
}
// Code for dip_f2dip2
static LispObject CC_dip_f2dip2(LispObject env, LispObject v_2,
LispObject v_3, LispObject v_4, LispObject _a4up_)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_34, v_35, v_36, v_37, v_38, v_39;
LispObject v_5, v_6;
if (_a4up_ == nil)
aerror1("not enough arguments provided", basic_elt(env, 0));
v_5 = car(_a4up_); _a4up_ = cdr(_a4up_);
if (_a4up_ == nil)
aerror1("not enough arguments provided", basic_elt(env, 0));
v_6 = car(_a4up_); _a4up_ = cdr(_a4up_);
if (_a4up_ != nil)
aerror1("too many arguments provided", basic_elt(env, 0));
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3,v_4,v_5,v_6);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_6,v_5,v_4,v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
stack_popper stack_popper_var(6);
// copy arguments values to proper place
stack[-3] = v_6;
v_36 = v_5;
v_37 = v_4;
v_38 = v_3;
v_39 = v_2;
// end of prologue
v_35 = v_39;
v_34 = qvalue(basic_elt(env, 1)); // dip_vars!*
v_34 = Lmemq(nil, v_35, v_34);
if (v_34 == nil) goto v_11;
stack[-4] = v_37;
stack[-2] = v_36;
stack[-1] = v_39;
stack[0] = v_38;
v_34 = qvalue(basic_elt(env, 1)); // dip_vars!*
v_34 = ncons(v_34);
env = stack[-5];
{ LispObject fn = basic_elt(env, 2); // ev_insert
v_35 = (*qfn4up(fn))(fn, stack[-2], stack[-1], stack[0], v_34);
}
env = stack[-5];
v_34 = stack[-3];
{
LispObject v_45 = stack[-4];
LispObject fn = basic_elt(env, 3); // dip_f2dip1
return (*qfn3(fn))(fn, v_45, v_35, v_34);
}
v_11:
stack[-1] = v_37;
stack[0] = v_36;
stack[-2] = stack[-3];
v_34 = v_39;
v_35 = v_38;
{ LispObject fn = basic_elt(env, 4); // bc_pmon
v_34 = (*qfn2(fn))(fn, v_34, v_35);
}
env = stack[-5];
{ LispObject fn = basic_elt(env, 5); // bc_prod
v_34 = (*qfn2(fn))(fn, stack[-2], v_34);
}
env = stack[-5];
{
LispObject v_46 = stack[-1];
LispObject v_47 = stack[0];
LispObject fn = basic_elt(env, 3); // dip_f2dip1
return (*qfn3(fn))(fn, v_46, v_47, v_34);
}
v_34 = nil;
return onevalue(v_34);
}
// Code for setfuncsnaryrd
static LispObject CC_setfuncsnaryrd(LispObject env)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_45, v_46;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
env = reclaim(env, "stack", GC_STACK, 0);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// end of prologue
{ LispObject fn = basic_elt(env, 3); // mathml
v_45 = (*qfn0(fn))(fn);
}
env = stack[-1];
stack[0] = v_45;
v_45 = stack[0];
v_45 = Lconsp(nil, v_45);
env = stack[-1];
if (v_45 == nil) goto v_10;
v_45 = stack[0];
if (!car_legal(v_45)) v_45 = cdrerror(v_45); else
v_45 = cdr(v_45);
if (!car_legal(v_45)) v_45 = carerror(v_45); else
v_45 = car(v_45);
if (v_45 == nil) goto v_16;
v_45 = stack[0];
if (!car_legal(v_45)) v_45 = cdrerror(v_45); else
v_45 = cdr(v_45);
if (!car_legal(v_45)) v_45 = carerror(v_45); else
v_45 = car(v_45);
if (!car_legal(v_45)) v_45 = carerror(v_45); else
v_45 = car(v_45);
if (!car_legal(v_45)) v_45 = cdrerror(v_45); else
v_45 = cdr(v_45);
if (!car_legal(v_45)) v_45 = carerror(v_45); else
v_45 = car(v_45);
v_46 = Lintern(nil, v_45);
env = stack[-1];
v_45 = basic_elt(env, 1); // multiset
if (v_46 == v_45) goto v_22;
else goto v_23;
v_22:
v_45 = basic_elt(env, 1); // multiset
setvalue(basic_elt(env, 2), v_45); // mmlatts
goto v_21;
v_23:
v_21:
goto v_14;
v_16:
v_14:
goto v_8;
v_10:
v_8:
v_45 = stack[0];
if (v_45 == nil) goto v_36;
else goto v_37;
v_36:
v_45 = nil;
goto v_35;
v_37:
{ LispObject fn = basic_elt(env, 0); // setfuncsnaryrd
v_45 = (*qfn0(fn))(fn);
}
{
LispObject v_48 = stack[0];
return cons(v_48, v_45);
}
v_45 = nil;
v_35:
return onevalue(v_45);
}
// Code for sqprint
static LispObject CC_sqprint(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_115, v_116, v_117;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil, nil);
stack_popper stack_popper_var(4);
// copy arguments values to proper place
stack[-1] = v_2;
// end of prologue
// Binding !*prin!#
// FLUIDBIND: reloadenv=3 litvec-offset=1 saveloc=0
{ bind_fluid_stack bind_fluid_var(-3, 1, 0);
setvalue(basic_elt(env, 1), nil); // !*prin!#
v_115 = lisp_true;
setvalue(basic_elt(env, 1), v_115); // !*prin!#
v_115 = qvalue(basic_elt(env, 2)); // orig!*
stack[-2] = v_115;
v_115 = qvalue(basic_elt(env, 3)); // !*nat
if (v_115 == nil) goto v_15;
v_116 = qvalue(basic_elt(env, 4)); // posn!*
v_115 = static_cast<LispObject>(320)+TAG_FIXNUM; // 20
v_115 = static_cast<LispObject>(lessp2(v_116, v_115));
v_115 = v_115 ? lisp_true : nil;
env = stack[-3];
if (v_115 == nil) goto v_15;
v_115 = qvalue(basic_elt(env, 4)); // posn!*
setvalue(basic_elt(env, 2), v_115); // orig!*
goto v_13;
v_15:
v_13:
v_115 = qvalue(basic_elt(env, 5)); // !*pri
if (v_115 == nil) goto v_27;
else goto v_25;
v_27:
v_115 = qvalue(basic_elt(env, 6)); // wtl!*
if (v_115 == nil) goto v_29;
else goto v_25;
v_29:
goto v_26;
v_25:
v_115 = stack[-1];
{ LispObject fn = basic_elt(env, 8); // sqhorner!*
v_115 = (*qfn1(fn))(fn, v_115);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 9); // prepsq!*
v_115 = (*qfn1(fn))(fn, v_115);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 10); // prepreform
v_115 = (*qfn1(fn))(fn, v_115);
}
env = stack[-3];
{ LispObject fn = basic_elt(env, 11); // maprin
v_115 = (*qfn1(fn))(fn, v_115);
}
env = stack[-3];
goto v_24;
v_26:
v_115 = stack[-1];
if (!car_legal(v_115)) v_116 = cdrerror(v_115); else
v_116 = cdr(v_115);
v_115 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
if (v_116 == v_115) goto v_37;
v_115 = stack[-1];
if (!car_legal(v_115)) v_115 = carerror(v_115); else
v_115 = car(v_115);
if (!consp(v_115)) goto v_47;
else goto v_48;
v_47:
v_115 = lisp_true;
goto v_46;
v_48:
v_115 = stack[-1];
if (!car_legal(v_115)) v_115 = carerror(v_115); else
v_115 = car(v_115);
if (!car_legal(v_115)) v_115 = carerror(v_115); else
v_115 = car(v_115);
v_115 = (consp(v_115) ? nil : lisp_true);
goto v_46;
v_115 = nil;
v_46:
if (v_115 == nil) goto v_43;
else goto v_44;
v_43:
v_115 = stack[-1];
if (!car_legal(v_115)) v_115 = carerror(v_115); else
v_115 = car(v_115);
if (!car_legal(v_115)) v_115 = cdrerror(v_115); else
v_115 = cdr(v_115);
goto v_42;
v_44:
v_115 = nil;
goto v_42;
v_115 = nil;
v_42:
v_116 = stack[-1];
if (!car_legal(v_116)) v_117 = carerror(v_116); else
v_117 = car(v_116);
v_116 = v_115;
v_115 = nil;
{ LispObject fn = basic_elt(env, 12); // xprinf
v_115 = (*qfn3(fn))(fn, v_117, v_116, v_115);
}
env = stack[-3];
v_115 = basic_elt(env, 7); // " / "
{ LispObject fn = basic_elt(env, 13); // prin2!*
v_115 = (*qfn1(fn))(fn, v_115);
}
env = stack[-3];
v_115 = stack[-1];
if (!car_legal(v_115)) v_115 = cdrerror(v_115); else
v_115 = cdr(v_115);
if (!consp(v_115)) goto v_77;
else goto v_78;
v_77:
v_115 = lisp_true;
goto v_76;
v_78:
v_115 = stack[-1];
if (!car_legal(v_115)) v_115 = cdrerror(v_115); else
v_115 = cdr(v_115);
if (!car_legal(v_115)) v_115 = carerror(v_115); else
v_115 = car(v_115);
v_115 = (consp(v_115) ? nil : lisp_true);
goto v_76;
v_115 = nil;
v_76:
if (v_115 == nil) goto v_73;
else goto v_74;
v_73:
v_115 = stack[-1];
if (!car_legal(v_115)) v_115 = cdrerror(v_115); else
v_115 = cdr(v_115);
if (!car_legal(v_115)) v_115 = cdrerror(v_115); else
v_115 = cdr(v_115);
if (v_115 == nil) goto v_90;
else goto v_89;
v_90:
v_115 = stack[-1];
if (!car_legal(v_115)) v_115 = cdrerror(v_115); else
v_115 = cdr(v_115);
if (!car_legal(v_115)) v_115 = carerror(v_115); else
v_115 = car(v_115);
if (!car_legal(v_115)) v_116 = cdrerror(v_115); else
v_116 = cdr(v_115);
v_115 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_115 = Lneq_2(nil, v_116, v_115);
env = stack[-3];
v_89:
goto v_72;
v_74:
v_115 = nil;
goto v_72;
v_115 = nil;
v_72:
v_116 = stack[-1];
if (!car_legal(v_116)) v_117 = cdrerror(v_116); else
v_117 = cdr(v_116);
v_116 = v_115;
v_115 = nil;
{ LispObject fn = basic_elt(env, 12); // xprinf
v_115 = (*qfn3(fn))(fn, v_117, v_116, v_115);
}
env = stack[-3];
goto v_24;
v_37:
v_115 = stack[-1];
if (!car_legal(v_115)) v_115 = carerror(v_115); else
v_115 = car(v_115);
{ LispObject fn = basic_elt(env, 14); // xprinf2
v_115 = (*qfn1(fn))(fn, v_115);
}
env = stack[-3];
goto v_24;
v_24:
v_115 = stack[-2];
setvalue(basic_elt(env, 2), v_115); // orig!*
;} // end of a binding scope
return onevalue(v_115);
}
// Code for red_tailreddriver
static LispObject CC_red_tailreddriver(LispObject env,
LispObject v_2, LispObject v_3,
LispObject v_4)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_53;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3,v_4);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_4,v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
stack_popper stack_popper_var(6);
// copy arguments values to proper place
stack[-1] = v_4;
stack[-2] = v_3;
stack[-3] = v_2;
// end of prologue
v_53 = stack[-2];
{ LispObject fn = basic_elt(env, 1); // bas_dpoly
v_53 = (*qfn1(fn))(fn, v_53);
}
env = stack[-5];
if (v_53 == nil) goto v_12;
else goto v_13;
v_12:
v_53 = lisp_true;
goto v_11;
v_13:
v_53 = stack[-2];
{ LispObject fn = basic_elt(env, 1); // bas_dpoly
v_53 = (*qfn1(fn))(fn, v_53);
}
env = stack[-5];
if (!car_legal(v_53)) v_53 = cdrerror(v_53); else
v_53 = cdr(v_53);
if (v_53 == nil) goto v_21;
else goto v_22;
v_21:
v_53 = lisp_true;
goto v_20;
v_22:
v_53 = stack[-3];
v_53 = (v_53 == nil ? lisp_true : nil);
goto v_20;
v_53 = nil;
v_20:
goto v_11;
v_53 = nil;
v_11:
if (v_53 == nil) goto v_9;
v_53 = stack[-2];
goto v_7;
v_9:
v_38:
v_53 = stack[-2];
{ LispObject fn = basic_elt(env, 1); // bas_dpoly
v_53 = (*qfn1(fn))(fn, v_53);
}
env = stack[-5];
if (v_53 == nil) goto v_41;
else goto v_42;
v_41:
goto v_37;
v_42:
stack[-4] = stack[-1];
stack[0] = stack[-3];
v_53 = stack[-2];
{ LispObject fn = basic_elt(env, 2); // red!=hidelt
v_53 = (*qfn1(fn))(fn, v_53);
}
env = stack[-5];
v_53 = Lapply2(nil, stack[-4], stack[0], v_53);
env = stack[-5];
stack[-2] = v_53;
goto v_38;
v_37:
v_53 = stack[-2];
{
LispObject fn = basic_elt(env, 3); // red!=recover
return (*qfn1(fn))(fn, v_53);
}
goto v_7;
v_53 = nil;
v_7:
return onevalue(v_53);
}
// Code for getavalue
static LispObject CC_getavalue(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_18, v_19;
#ifdef CHECK_STACK
if_check_stack;
#endif
// copy arguments values to proper place
v_18 = v_2;
// end of prologue
if (!symbolp(v_18)) v_18 = nil;
else { v_18 = qfastgets(v_18);
if (v_18 != nil) { v_18 = elt(v_18, 4); // avalue
#ifdef RECORD_GET
if (v_18 != SPID_NOPROP)
record_get(elt(fastget_names, 4), 1);
else record_get(elt(fastget_names, 4), 0),
v_18 = nil; }
else record_get(elt(fastget_names, 4), 0); }
#else
if (v_18 == SPID_NOPROP) v_18 = nil; }}
#endif
v_19 = v_18;
v_18 = v_19;
if (v_18 == nil) goto v_10;
v_18 = v_19;
if (!car_legal(v_18)) v_18 = cdrerror(v_18); else
v_18 = cdr(v_18);
if (!car_legal(v_18)) v_18 = carerror(v_18); else
v_18 = car(v_18);
goto v_8;
v_10:
v_18 = nil;
goto v_8;
v_18 = nil;
v_8:
return onevalue(v_18);
}
// Code for reduce!-eival!-powers
static LispObject CC_reduceKeivalKpowers(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_46, v_47, v_48, v_49;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
v_48 = v_3;
v_49 = v_2;
// end of prologue
v_46 = v_48;
if (!consp(v_46)) goto v_15;
else goto v_16;
v_15:
v_46 = lisp_true;
goto v_14;
v_16:
v_46 = v_48;
if (!car_legal(v_46)) v_46 = carerror(v_46); else
v_46 = car(v_46);
v_46 = (consp(v_46) ? nil : lisp_true);
goto v_14;
v_46 = nil;
v_14:
if (v_46 == nil) goto v_12;
v_46 = lisp_true;
goto v_10;
v_12:
v_46 = v_48;
if (!car_legal(v_46)) v_46 = carerror(v_46); else
v_46 = car(v_46);
if (!car_legal(v_46)) v_46 = carerror(v_46); else
v_46 = car(v_46);
if (!car_legal(v_46)) v_47 = carerror(v_46); else
v_47 = car(v_46);
v_46 = v_49;
if (!car_legal(v_46)) v_46 = carerror(v_46); else
v_46 = car(v_46);
if (!car_legal(v_46)) v_46 = carerror(v_46); else
v_46 = car(v_46);
v_46 = (v_47 == v_46 ? lisp_true : nil);
v_46 = (v_46 == nil ? lisp_true : nil);
goto v_10;
v_46 = nil;
v_10:
if (v_46 == nil) goto v_8;
v_47 = v_48;
v_46 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
return cons(v_47, v_46);
v_8:
stack[0] = v_49;
v_47 = v_48;
v_46 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_46 = cons(v_47, v_46);
env = stack[-1];
{
LispObject v_51 = stack[0];
LispObject fn = basic_elt(env, 1); // reduce!-eival!-powers1
return (*qfn2(fn))(fn, v_51, v_46);
}
v_46 = nil;
return onevalue(v_46);
}
// Code for find!-null!-space
static LispObject CC_findKnullKspace(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_36, v_37, v_38;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
push(nil, nil);
stack_popper stack_popper_var(8);
// copy arguments values to proper place
stack[-4] = v_3;
stack[-5] = v_2;
// end of prologue
// Binding null!-space!-basis
// FLUIDBIND: reloadenv=7 litvec-offset=1 saveloc=6
{ bind_fluid_stack bind_fluid_var(-7, 1, -6);
setvalue(basic_elt(env, 1), nil); // null!-space!-basis
v_36 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[-3] = v_36;
v_12:
v_37 = stack[-4];
v_36 = stack[-3];
v_36 = static_cast<LispObject>(static_cast<std::uintptr_t>(v_37) - static_cast<std::uintptr_t>(v_36) + TAG_FIXNUM);
v_36 = (static_cast<std::intptr_t>(v_36) < 0 ? lisp_true : nil);
if (v_36 == nil) goto v_17;
goto v_11;
v_17:
stack[-2] = stack[-3];
stack[-1] = qvalue(basic_elt(env, 1)); // null!-space!-basis
stack[0] = stack[-5];
v_36 = stack[-4];
v_36 = ncons(v_36);
env = stack[-7];
{ LispObject fn = basic_elt(env, 2); // clear!-column
v_36 = (*qfn4up(fn))(fn, stack[-2], stack[-1], stack[0], v_36);
}
env = stack[-7];
setvalue(basic_elt(env, 1), v_36); // null!-space!-basis
v_36 = stack[-3];
v_36 = static_cast<LispObject>(static_cast<std::intptr_t>(v_36) + 0x10);
stack[-3] = v_36;
goto v_12;
v_11:
v_38 = qvalue(basic_elt(env, 1)); // null!-space!-basis
v_37 = stack[-5];
v_36 = stack[-4];
{ LispObject fn = basic_elt(env, 3); // tidy!-up!-null!-vectors
v_36 = (*qfn3(fn))(fn, v_38, v_37, v_36);
}
;} // end of a binding scope
return onevalue(v_36);
}
// Code for set_parser
static LispObject CC_set_parser(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_34, v_35;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
stack[0] = v_2;
// end of prologue
v_34 = stack[0];
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
{ LispObject fn = basic_elt(env, 8); // lex_restore_context
v_34 = (*qfn1(fn))(fn, v_34);
}
env = stack[-1];
v_34 = stack[0];
if (!car_legal(v_34)) v_34 = cdrerror(v_34); else
v_34 = cdr(v_34);
stack[0] = v_34;
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
setvalue(basic_elt(env, 1), v_34); // parser_action_table
v_34 = stack[0];
if (!car_legal(v_34)) v_34 = cdrerror(v_34); else
v_34 = cdr(v_34);
stack[0] = v_34;
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
v_35 = v_34;
v_34 = v_35;
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
setvalue(basic_elt(env, 2), v_34); // reduction_fn
v_34 = v_35;
if (!car_legal(v_34)) v_34 = cdrerror(v_34); else
v_34 = cdr(v_34);
v_35 = v_34;
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
setvalue(basic_elt(env, 3), v_34); // reduction_rhs_n
v_34 = v_35;
if (!car_legal(v_34)) v_34 = cdrerror(v_34); else
v_34 = cdr(v_34);
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
setvalue(basic_elt(env, 4), v_34); // reduction_lhs
v_34 = stack[0];
if (!car_legal(v_34)) v_34 = cdrerror(v_34); else
v_34 = cdr(v_34);
stack[0] = v_34;
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
setvalue(basic_elt(env, 5), v_34); // parser_goto_table
v_34 = stack[0];
if (!car_legal(v_34)) v_34 = cdrerror(v_34); else
v_34 = cdr(v_34);
stack[0] = v_34;
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
setvalue(basic_elt(env, 6), v_34); // nonterminal_codes
v_34 = stack[0];
if (!car_legal(v_34)) v_34 = cdrerror(v_34); else
v_34 = cdr(v_34);
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
setvalue(basic_elt(env, 7), v_34); // terminal_codes
v_34 = nil;
return onevalue(v_34);
}
// Code for sq_member
static LispObject CC_sq_member(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_16, v_17;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// copy arguments values to proper place
stack[0] = v_3;
stack[-1] = v_2;
// end of prologue
v_17 = stack[-1];
v_16 = stack[0];
if (!car_legal(v_16)) v_16 = carerror(v_16); else
v_16 = car(v_16);
{ LispObject fn = basic_elt(env, 1); // sf_member
v_16 = (*qfn2(fn))(fn, v_17, v_16);
}
env = stack[-2];
if (v_16 == nil) goto v_7;
else goto v_6;
v_7:
v_17 = stack[-1];
v_16 = stack[0];
if (!car_legal(v_16)) v_16 = cdrerror(v_16); else
v_16 = cdr(v_16);
{
LispObject fn = basic_elt(env, 1); // sf_member
return (*qfn2(fn))(fn, v_17, v_16);
}
v_6:
return onevalue(v_16);
}
// Code for orddf
static LispObject CC_orddf(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_51, v_52;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// copy arguments values to proper place
stack[0] = v_3;
stack[-1] = v_2;
// end of prologue
v_7:
v_51 = stack[-1];
if (v_51 == nil) goto v_10;
else goto v_11;
v_10:
v_51 = stack[0];
if (v_51 == nil) goto v_15;
else goto v_16;
v_15:
v_51 = basic_elt(env, 1); // "Orddf = case"
{
LispObject fn = basic_elt(env, 4); // interr
return (*qfn1(fn))(fn, v_51);
}
v_16:
v_51 = basic_elt(env, 2); // "Orddf v longer than u"
{
LispObject fn = basic_elt(env, 4); // interr
return (*qfn1(fn))(fn, v_51);
}
goto v_9;
v_11:
v_51 = stack[0];
if (v_51 == nil) goto v_24;
else goto v_25;
v_24:
v_51 = basic_elt(env, 3); // "Orddf u longer than v"
{
LispObject fn = basic_elt(env, 4); // interr
return (*qfn1(fn))(fn, v_51);
}
v_25:
v_51 = stack[-1];
if (!car_legal(v_51)) v_52 = carerror(v_51); else
v_52 = car(v_51);
v_51 = stack[0];
if (!car_legal(v_51)) v_51 = carerror(v_51); else
v_51 = car(v_51);
{ LispObject fn = basic_elt(env, 5); // exptcompare
v_51 = (*qfn2(fn))(fn, v_52, v_51);
}
env = stack[-2];
if (v_51 == nil) goto v_30;
v_51 = lisp_true;
goto v_6;
v_30:
v_51 = stack[0];
if (!car_legal(v_51)) v_52 = carerror(v_51); else
v_52 = car(v_51);
v_51 = stack[-1];
if (!car_legal(v_51)) v_51 = carerror(v_51); else
v_51 = car(v_51);
{ LispObject fn = basic_elt(env, 5); // exptcompare
v_51 = (*qfn2(fn))(fn, v_52, v_51);
}
env = stack[-2];
if (v_51 == nil) goto v_38;
v_51 = nil;
goto v_6;
v_38:
v_51 = stack[-1];
if (!car_legal(v_51)) v_51 = cdrerror(v_51); else
v_51 = cdr(v_51);
stack[-1] = v_51;
v_51 = stack[0];
if (!car_legal(v_51)) v_51 = cdrerror(v_51); else
v_51 = cdr(v_51);
stack[0] = v_51;
goto v_7;
v_9:
v_51 = nil;
v_6:
return onevalue(v_51);
}
// Code for cl_susiupdknowl
static LispObject CC_cl_susiupdknowl(LispObject env, LispObject v_2,
LispObject v_3, LispObject v_4, LispObject _a4up_)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_47, v_48, v_49;
LispObject v_5;
if (_a4up_ == nil)
aerror1("not enough arguments provided", basic_elt(env, 0));
v_5 = car(_a4up_); _a4up_ = cdr(_a4up_);
if (_a4up_ != nil)
aerror1("too many arguments provided", basic_elt(env, 0));
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3,v_4,v_5);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_5,v_4,v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
push(nil, nil);
stack_popper stack_popper_var(8);
// copy arguments values to proper place
stack[-3] = v_5;
v_48 = v_4;
stack[-4] = v_3;
stack[-5] = v_2;
// end of prologue
stack[-6] = nil;
v_12:
v_47 = stack[-4];
if (v_47 == nil) goto v_15;
else goto v_16;
v_15:
goto v_11;
v_16:
v_47 = stack[-4];
if (!car_legal(v_47)) v_47 = carerror(v_47); else
v_47 = car(v_47);
stack[-6] = v_47;
v_47 = stack[-4];
if (!car_legal(v_47)) v_47 = cdrerror(v_47); else
v_47 = cdr(v_47);
stack[-4] = v_47;
stack[-2] = stack[-5];
stack[-1] = stack[-6];
stack[0] = v_48;
v_47 = stack[-3];
v_47 = ncons(v_47);
env = stack[-7];
{ LispObject fn = basic_elt(env, 3); // cl_susiupdknowl1
v_47 = (*qfn4up(fn))(fn, stack[-2], stack[-1], stack[0], v_47);
}
env = stack[-7];
v_48 = v_47;
v_49 = v_48;
v_47 = basic_elt(env, 1); // false
if (v_49 == v_47) goto v_31;
else goto v_32;
v_31:
v_47 = nil;
stack[-4] = v_47;
v_47 = basic_elt(env, 2); // break
stack[-6] = v_47;
goto v_30;
v_32:
v_30:
goto v_12;
v_11:
v_49 = stack[-6];
v_47 = basic_elt(env, 2); // break
if (v_49 == v_47) goto v_39;
else goto v_40;
v_39:
v_47 = basic_elt(env, 1); // false
goto v_9;
v_40:
v_47 = v_48;
goto v_9;
v_47 = nil;
v_9:
return onevalue(v_47);
}
// Code for gftimes
static LispObject CC_gftimes(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_19, v_20, v_21;
#ifdef CHECK_STACK
if_check_stack;
#endif
// copy arguments values to proper place
v_20 = v_3;
v_21 = v_2;
// end of prologue
v_19 = v_21;
if (!car_legal(v_19)) v_19 = carerror(v_19); else
v_19 = car(v_19);
if (!consp(v_19)) goto v_7;
else goto v_8;
v_7:
v_19 = v_21;
{
LispObject fn = basic_elt(env, 1); // gfftimes
return (*qfn2(fn))(fn, v_19, v_20);
}
v_8:
v_19 = v_21;
{
LispObject fn = basic_elt(env, 2); // gbftimes
return (*qfn2(fn))(fn, v_19, v_20);
}
v_19 = nil;
return onevalue(v_19);
}
// Code for calc_den_tar
static LispObject CC_calc_den_tar(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_25, v_26;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
stack_popper stack_popper_var(1);
// copy arguments values to proper place
v_25 = v_3;
v_26 = v_2;
// end of prologue
{ LispObject fn = basic_elt(env, 1); // denlist
v_25 = (*qfn2(fn))(fn, v_26, v_25);
}
env = stack[0];
v_26 = v_25;
v_25 = v_26;
if (v_25 == nil) goto v_11;
else goto v_12;
v_11:
v_25 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
goto v_10;
v_12:
v_25 = v_26;
if (!car_legal(v_25)) v_25 = cdrerror(v_25); else
v_25 = cdr(v_25);
if (v_25 == nil) goto v_15;
else goto v_16;
v_15:
v_25 = v_26;
if (!car_legal(v_25)) v_25 = carerror(v_25); else
v_25 = car(v_25);
goto v_10;
v_16:
v_25 = v_26;
{
LispObject fn = basic_elt(env, 2); // constimes
return (*qfn1(fn))(fn, v_25);
}
v_25 = nil;
v_10:
return onevalue(v_25);
}
// Code for no!-side!-effectp
static LispObject CC_noKsideKeffectp(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_48, v_49;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
stack[0] = v_2;
// end of prologue
v_48 = stack[0];
if (!consp(v_48)) goto v_6;
else goto v_7;
v_6:
v_48 = stack[0];
v_48 = (is_number(v_48) ? lisp_true : nil);
if (v_48 == nil) goto v_11;
else goto v_10;
v_11:
v_48 = stack[0];
if (symbolp(v_48)) goto v_17;
v_48 = nil;
goto v_15;
v_17:
v_48 = stack[0];
v_48 = Lsymbol_specialp(nil, v_48);
env = stack[-1];
if (v_48 == nil) goto v_24;
else goto v_23;
v_24:
v_48 = stack[0];
v_48 = Lsymbol_globalp(nil, v_48);
v_23:
v_48 = (v_48 == nil ? lisp_true : nil);
goto v_15;
v_48 = nil;
v_15:
v_10:
goto v_5;
v_7:
v_48 = stack[0];
if (!car_legal(v_48)) v_49 = carerror(v_48); else
v_49 = car(v_48);
v_48 = basic_elt(env, 1); // quote
if (v_49 == v_48) goto v_30;
else goto v_31;
v_30:
v_48 = lisp_true;
goto v_5;
v_31:
v_48 = stack[0];
if (!car_legal(v_48)) v_49 = carerror(v_48); else
v_49 = car(v_48);
v_48 = basic_elt(env, 2); // nosideeffects
v_48 = Lflagp(nil, v_49, v_48);
env = stack[-1];
if (v_48 == nil) goto v_37;
v_48 = stack[0];
if (!car_legal(v_48)) v_48 = cdrerror(v_48); else
v_48 = cdr(v_48);
{
LispObject fn = basic_elt(env, 3); // no!-side!-effect!-listp
return (*qfn1(fn))(fn, v_48);
}
v_37:
v_48 = nil;
goto v_5;
v_48 = nil;
v_5:
return onevalue(v_48);
}
// Code for atom_compare
static LispObject CC_atom_compare(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_32, v_33, v_34;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
stack_popper stack_popper_var(1);
// copy arguments values to proper place
v_33 = v_3;
v_34 = v_2;
// end of prologue
v_32 = v_34;
if (is_number(v_32)) goto v_7;
else goto v_8;
v_7:
v_32 = v_33;
if (is_number(v_32)) goto v_13;
v_32 = nil;
goto v_11;
v_13:
v_32 = v_34;
v_32 = static_cast<LispObject>(lessp2(v_32, v_33));
v_32 = v_32 ? lisp_true : nil;
v_32 = (v_32 == nil ? lisp_true : nil);
goto v_11;
v_32 = nil;
v_11:
goto v_6;
v_8:
v_32 = v_33;
if (symbolp(v_32)) goto v_22;
else goto v_23;
v_22:
v_32 = v_34;
return Lorderp(nil, v_32, v_33);
v_23:
v_32 = v_33;
v_32 = (is_number(v_32) ? lisp_true : nil);
goto v_6;
v_32 = nil;
v_6:
return onevalue(v_32);
}
// Code for lalr_expand_grammar
static LispObject CC_lalr_expand_grammar(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_34, v_35;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// copy arguments values to proper place
v_34 = v_2;
// end of prologue
// Binding pending_rules!*
// FLUIDBIND: reloadenv=2 litvec-offset=1 saveloc=1
{ bind_fluid_stack bind_fluid_var(-2, 1, -1);
setvalue(basic_elt(env, 1), nil); // pending_rules!*
{ LispObject fn = basic_elt(env, 2); // lalr_check_grammar
v_34 = (*qfn1(fn))(fn, v_34);
}
env = stack[-2];
setvalue(basic_elt(env, 1), v_34); // pending_rules!*
v_34 = nil;
stack[0] = v_34;
v_16:
v_34 = qvalue(basic_elt(env, 1)); // pending_rules!*
if (v_34 == nil) goto v_19;
else goto v_20;
v_19:
goto v_15;
v_20:
v_34 = qvalue(basic_elt(env, 1)); // pending_rules!*
if (!car_legal(v_34)) v_34 = carerror(v_34); else
v_34 = car(v_34);
v_35 = v_34;
v_34 = qvalue(basic_elt(env, 1)); // pending_rules!*
if (!car_legal(v_34)) v_34 = cdrerror(v_34); else
v_34 = cdr(v_34);
setvalue(basic_elt(env, 1), v_34); // pending_rules!*
v_34 = v_35;
{ LispObject fn = basic_elt(env, 3); // expand_rule
v_35 = (*qfn1(fn))(fn, v_34);
}
env = stack[-2];
v_34 = stack[0];
v_34 = cons(v_35, v_34);
env = stack[-2];
stack[0] = v_34;
goto v_16;
v_15:
v_34 = stack[0];
v_34 = Lreverse(nil, v_34);
;} // end of a binding scope
return onevalue(v_34);
}
// Code for aex_stchsgnch1
static LispObject CC_aex_stchsgnch1(LispObject env,
LispObject v_2, LispObject v_3,
LispObject v_4)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_50, v_51, v_52;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3,v_4);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_4,v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
real_push(nil);
stack_popper stack_popper_var(7);
// copy arguments values to proper place
stack[-3] = v_4;
stack[-4] = v_3;
v_50 = v_2;
// end of prologue
stack[-5] = v_50;
v_50 = stack[-5];
if (v_50 == nil) goto v_16;
else goto v_17;
v_16:
v_50 = nil;
goto v_11;
v_17:
v_50 = stack[-5];
if (!car_legal(v_50)) v_50 = carerror(v_50); else
v_50 = car(v_50);
v_52 = v_50;
v_51 = stack[-4];
v_50 = stack[-3];
{ LispObject fn = basic_elt(env, 1); // aex_subrat1
v_50 = (*qfn3(fn))(fn, v_52, v_51, v_50);
}
env = stack[-6];
{ LispObject fn = basic_elt(env, 2); // aex_sgn
v_50 = (*qfn1(fn))(fn, v_50);
}
env = stack[-6];
v_50 = ncons(v_50);
env = stack[-6];
stack[-1] = v_50;
stack[-2] = v_50;
v_12:
v_50 = stack[-5];
if (!car_legal(v_50)) v_50 = cdrerror(v_50); else
v_50 = cdr(v_50);
stack[-5] = v_50;
v_50 = stack[-5];
if (v_50 == nil) goto v_33;
else goto v_34;
v_33:
v_50 = stack[-2];
goto v_11;
v_34:
stack[0] = stack[-1];
v_50 = stack[-5];
if (!car_legal(v_50)) v_50 = carerror(v_50); else
v_50 = car(v_50);
v_52 = v_50;
v_51 = stack[-4];
v_50 = stack[-3];
{ LispObject fn = basic_elt(env, 1); // aex_subrat1
v_50 = (*qfn3(fn))(fn, v_52, v_51, v_50);
}
env = stack[-6];
{ LispObject fn = basic_elt(env, 2); // aex_sgn
v_50 = (*qfn1(fn))(fn, v_50);
}
env = stack[-6];
v_50 = ncons(v_50);
env = stack[-6];
if (!car_legal(stack[0])) rplacd_fails(stack[0]);
setcdr(stack[0], v_50);
v_50 = stack[-1];
if (!car_legal(v_50)) v_50 = cdrerror(v_50); else
v_50 = cdr(v_50);
stack[-1] = v_50;
goto v_12;
v_11:
{
LispObject fn = basic_elt(env, 3); // lto_sgnchg
return (*qfn1(fn))(fn, v_50);
}
}
// Code for janettreenodebuild
static LispObject CC_janettreenodebuild(LispObject env,
LispObject v_2, LispObject v_3,
LispObject v_4)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_61, v_62;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3,v_4);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_4,v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
push(nil, nil, nil, nil);
stack_popper stack_popper_var(10);
// copy arguments values to proper place
stack[-5] = v_4;
stack[-6] = v_3;
stack[-7] = v_2;
// end of prologue
v_62 = stack[-5];
v_61 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_61 = Lgetv(nil, v_62, v_61);
env = stack[-9];
if (!car_legal(v_61)) v_61 = carerror(v_61); else
v_61 = car(v_61);
stack[-3] = v_61;
v_62 = stack[-3];
v_61 = stack[-6];
{ LispObject fn = basic_elt(env, 1); // monomgetvariabledegree
stack[-1] = (*qfn2(fn))(fn, v_62, v_61);
}
env = stack[-9];
stack[0] = nil;
v_61 = nil;
v_61 = ncons(v_61);
env = stack[-9];
v_61 = acons(stack[-1], stack[0], v_61);
env = stack[-9];
stack[-8] = v_61;
v_61 = stack[-8];
stack[-4] = v_61;
v_25:
stack[0] = stack[-7];
v_62 = stack[-3];
v_61 = stack[-6];
{ LispObject fn = basic_elt(env, 1); // monomgetvariabledegree
v_61 = (*qfn2(fn))(fn, v_62, v_61);
}
env = stack[-9];
if ((static_cast<std::intptr_t>(stack[0]) > static_cast<std::intptr_t>(v_61))) goto v_29;
goto v_24;
v_29:
stack[0] = stack[-7];
v_62 = stack[-3];
v_61 = stack[-6];
{ LispObject fn = basic_elt(env, 1); // monomgetvariabledegree
v_61 = (*qfn2(fn))(fn, v_62, v_61);
}
env = stack[-9];
v_61 = static_cast<LispObject>(static_cast<std::uintptr_t>(stack[0]) - static_cast<std::uintptr_t>(v_61) + TAG_FIXNUM);
stack[-7] = v_61;
v_61 = stack[-6];
v_61 = static_cast<LispObject>(static_cast<std::intptr_t>(v_61) + 0x10);
stack[-6] = v_61;
v_61 = stack[-4];
if (!car_legal(v_61)) stack[-2] = cdrerror(v_61); else
stack[-2] = cdr(v_61);
v_62 = stack[-3];
v_61 = stack[-6];
{ LispObject fn = basic_elt(env, 1); // monomgetvariabledegree
stack[-1] = (*qfn2(fn))(fn, v_62, v_61);
}
env = stack[-9];
stack[0] = nil;
v_61 = nil;
v_61 = ncons(v_61);
env = stack[-9];
v_61 = acons(stack[-1], stack[0], v_61);
env = stack[-9];
{ LispObject fn = basic_elt(env, 2); // setcdr
v_61 = (*qfn2(fn))(fn, stack[-2], v_61);
}
env = stack[-9];
v_61 = stack[-4];
if (!car_legal(v_61)) v_61 = cdrerror(v_61); else
v_61 = cdr(v_61);
if (!car_legal(v_61)) v_61 = cdrerror(v_61); else
v_61 = cdr(v_61);
stack[-4] = v_61;
goto v_25;
v_24:
v_61 = stack[-4];
if (!car_legal(v_61)) v_62 = carerror(v_61); else
v_62 = car(v_61);
v_61 = stack[-5];
{ LispObject fn = basic_elt(env, 2); // setcdr
v_61 = (*qfn2(fn))(fn, v_62, v_61);
}
v_61 = stack[-8];
return onevalue(v_61);
}
// Code for even_action_term
static LispObject CC_even_action_term(LispObject env, LispObject v_2,
LispObject v_3, LispObject v_4, LispObject _a4up_)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_33, v_34;
LispObject v_5;
if (_a4up_ == nil)
aerror1("not enough arguments provided", basic_elt(env, 0));
v_5 = car(_a4up_); _a4up_ = cdr(_a4up_);
if (_a4up_ != nil)
aerror1("too many arguments provided", basic_elt(env, 0));
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3,v_4,v_5);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_5,v_4,v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
push(nil, nil);
stack_popper stack_popper_var(8);
// copy arguments values to proper place
stack[-2] = v_5;
stack[-3] = v_4;
stack[-4] = v_3;
stack[-5] = v_2;
// end of prologue
stack[-6] = stack[-5];
v_33 = stack[-4];
if (!car_legal(v_33)) stack[-1] = carerror(v_33); else
stack[-1] = car(v_33);
stack[0] = stack[-3];
v_34 = stack[-2];
v_33 = stack[-4];
if (!car_legal(v_33)) v_33 = cdrerror(v_33); else
v_33 = cdr(v_33);
{ LispObject fn = basic_elt(env, 1); // multf
v_34 = (*qfn2(fn))(fn, v_34, v_33);
}
env = stack[-7];
v_33 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_33 = cons(v_34, v_33);
env = stack[-7];
v_33 = ncons(v_33);
env = stack[-7];
{ LispObject fn = basic_elt(env, 2); // even_action_pow
stack[-1] = (*qfn4up(fn))(fn, stack[-6], stack[-1], stack[0], v_33);
}
env = stack[-7];
v_33 = stack[-4];
if (!car_legal(v_33)) stack[0] = cdrerror(v_33); else
stack[0] = cdr(v_33);
v_33 = stack[-4];
if (!car_legal(v_33)) v_34 = carerror(v_33); else
v_34 = car(v_33);
v_33 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
v_33 = cons(v_34, v_33);
env = stack[-7];
v_33 = ncons(v_33);
env = stack[-7];
{ LispObject fn = basic_elt(env, 1); // multf
v_33 = (*qfn2(fn))(fn, stack[-2], v_33);
}
env = stack[-7];
v_33 = ncons(v_33);
env = stack[-7];
{ LispObject fn = basic_elt(env, 3); // even_action_sf
v_33 = (*qfn4up(fn))(fn, stack[-5], stack[0], stack[-3], v_33);
}
env = stack[-7];
{
LispObject v_42 = stack[-1];
LispObject fn = basic_elt(env, 4); // addsq
return (*qfn2(fn))(fn, v_42, v_33);
}
}
// Code for testord
static LispObject CC_testord(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_28, v_29;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// copy arguments values to proper place
stack[0] = v_3;
stack[-1] = v_2;
// end of prologue
v_7:
v_28 = stack[-1];
if (v_28 == nil) goto v_10;
else goto v_11;
v_10:
v_28 = lisp_true;
goto v_6;
v_11:
v_28 = stack[-1];
if (!car_legal(v_28)) v_29 = carerror(v_28); else
v_29 = car(v_28);
v_28 = stack[0];
if (!car_legal(v_28)) v_28 = carerror(v_28); else
v_28 = car(v_28);
v_28 = static_cast<LispObject>(lesseq2(v_29, v_28));
v_28 = v_28 ? lisp_true : nil;
env = stack[-2];
if (v_28 == nil) goto v_15;
v_28 = stack[-1];
if (!car_legal(v_28)) v_28 = cdrerror(v_28); else
v_28 = cdr(v_28);
stack[-1] = v_28;
v_28 = stack[0];
if (!car_legal(v_28)) v_28 = cdrerror(v_28); else
v_28 = cdr(v_28);
stack[0] = v_28;
goto v_7;
v_15:
v_28 = nil;
goto v_6;
v_28 = nil;
v_6:
return onevalue(v_28);
}
// Code for my!+nullsq!+p
static LispObject CC_myLnullsqLp(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_13;
#ifdef CHECK_STACK
if_check_stack;
#endif
// copy arguments values to proper place
v_13 = v_2;
// end of prologue
if (!car_legal(v_13)) v_13 = carerror(v_13); else
v_13 = car(v_13);
if (v_13 == nil) goto v_8;
else goto v_9;
v_8:
v_13 = lisp_true;
goto v_5;
v_9:
v_13 = nil;
v_5:
return onevalue(v_13);
}
// Code for pasf_varlat
static LispObject CC_pasf_varlat(LispObject env,
LispObject v_2)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_88, v_89;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil, nil, nil);
stack_popper stack_popper_var(5);
// copy arguments values to proper place
stack[0] = v_2;
// end of prologue
v_88 = stack[0];
if (!car_legal(v_88)) v_88 = cdrerror(v_88); else
v_88 = cdr(v_88);
if (!car_legal(v_88)) v_88 = carerror(v_88); else
v_88 = car(v_88);
{ LispObject fn = basic_elt(env, 3); // kernels
stack[-1] = (*qfn1(fn))(fn, v_88);
}
env = stack[-4];
v_88 = stack[0];
v_88 = Lconsp(nil, v_88);
env = stack[-4];
if (v_88 == nil) goto v_15;
v_88 = stack[0];
if (!car_legal(v_88)) v_88 = carerror(v_88); else
v_88 = car(v_88);
v_88 = Lconsp(nil, v_88);
env = stack[-4];
if (v_88 == nil) goto v_15;
v_88 = stack[0];
if (!car_legal(v_88)) v_88 = carerror(v_88); else
v_88 = car(v_88);
if (!car_legal(v_88)) v_89 = carerror(v_88); else
v_89 = car(v_88);
v_88 = basic_elt(env, 1); // (cong ncong)
v_88 = Lmemq(nil, v_89, v_88);
if (v_88 == nil) goto v_15;
v_88 = stack[0];
if (!car_legal(v_88)) v_88 = carerror(v_88); else
v_88 = car(v_88);
if (!car_legal(v_88)) v_88 = cdrerror(v_88); else
v_88 = cdr(v_88);
{ LispObject fn = basic_elt(env, 3); // kernels
v_88 = (*qfn1(fn))(fn, v_88);
}
env = stack[-4];
goto v_13;
v_15:
v_88 = nil;
goto v_13;
v_88 = nil;
v_13:
v_88 = Lappend_2(nil, stack[-1], v_88);
env = stack[-4];
v_89 = v_88;
v_88 = qvalue(basic_elt(env, 2)); // !*rlbrkcxk
if (v_88 == nil) goto v_40;
v_88 = v_89;
stack[-3] = v_88;
v_47:
v_88 = stack[-3];
if (v_88 == nil) goto v_52;
else goto v_53;
v_52:
v_88 = nil;
goto v_46;
v_53:
v_88 = stack[-3];
if (!car_legal(v_88)) v_88 = carerror(v_88); else
v_88 = car(v_88);
{ LispObject fn = basic_elt(env, 4); // lto_lpvarl
v_88 = (*qfn1(fn))(fn, v_88);
}
env = stack[-4];
stack[-2] = v_88;
v_88 = stack[-2];
{ LispObject fn = basic_elt(env, 5); // lastpair
v_88 = (*qfn1(fn))(fn, v_88);
}
env = stack[-4];
stack[-1] = v_88;
v_88 = stack[-3];
if (!car_legal(v_88)) v_88 = cdrerror(v_88); else
v_88 = cdr(v_88);
stack[-3] = v_88;
v_88 = stack[-1];
if (!consp(v_88)) goto v_67;
else goto v_68;
v_67:
goto v_47;
v_68:
v_48:
v_88 = stack[-3];
if (v_88 == nil) goto v_72;
else goto v_73;
v_72:
v_88 = stack[-2];
goto v_46;
v_73:
stack[0] = stack[-1];
v_88 = stack[-3];
if (!car_legal(v_88)) v_88 = carerror(v_88); else
v_88 = car(v_88);
{ LispObject fn = basic_elt(env, 4); // lto_lpvarl
v_88 = (*qfn1(fn))(fn, v_88);
}
env = stack[-4];
if (!car_legal(stack[0])) rplacd_fails(stack[0]);
setcdr(stack[0], v_88);
v_88 = stack[-1];
{ LispObject fn = basic_elt(env, 5); // lastpair
v_88 = (*qfn1(fn))(fn, v_88);
}
env = stack[-4];
stack[-1] = v_88;
v_88 = stack[-3];
if (!car_legal(v_88)) v_88 = cdrerror(v_88); else
v_88 = cdr(v_88);
stack[-3] = v_88;
goto v_48;
v_46:
v_89 = v_88;
goto v_38;
v_40:
v_38:
v_88 = v_89;
return onevalue(v_88);
}
// Code for rl_surep
static LispObject CC_rl_surep(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_10, v_11;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// copy arguments values to proper place
v_10 = v_3;
v_11 = v_2;
// end of prologue
stack[0] = qvalue(basic_elt(env, 1)); // rl_surep!*
v_10 = list2(v_11, v_10);
env = stack[-1];
{
LispObject v_13 = stack[0];
LispObject fn = basic_elt(env, 2); // apply
return (*qfn2(fn))(fn, v_13, v_10);
}
}
// Code for minusrd
static LispObject CC_minusrd(LispObject env)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_24, v_25, v_26;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
env = reclaim(env, "stack", GC_STACK, 0);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil);
stack_popper stack_popper_var(2);
// end of prologue
{ LispObject fn = basic_elt(env, 1); // mathml
v_24 = (*qfn0(fn))(fn);
}
env = stack[-1];
stack[0] = v_24;
{ LispObject fn = basic_elt(env, 1); // mathml
v_24 = (*qfn0(fn))(fn);
}
env = stack[-1];
v_25 = v_24;
if (v_25 == nil) goto v_11;
else goto v_12;
v_11:
v_24 = stack[0];
v_24 = ncons(v_24);
stack[0] = v_24;
goto v_10;
v_12:
v_26 = stack[0];
v_25 = v_24;
v_24 = nil;
v_24 = list2star(v_26, v_25, v_24);
env = stack[-1];
stack[0] = v_24;
{ LispObject fn = basic_elt(env, 2); // lex
v_24 = (*qfn0(fn))(fn);
}
goto v_10;
v_10:
v_24 = stack[0];
return onevalue(v_24);
}
// Code for assoc2
static LispObject CC_assoc2(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_26, v_27, v_28, v_29;
#ifdef CHECK_STACK
if_check_stack;
#endif
// copy arguments values to proper place
v_27 = v_3;
v_28 = v_2;
// end of prologue
v_7:
v_26 = v_27;
if (v_26 == nil) goto v_10;
else goto v_11;
v_10:
v_26 = nil;
goto v_6;
v_11:
v_29 = v_28;
v_26 = v_27;
if (!car_legal(v_26)) v_26 = carerror(v_26); else
v_26 = car(v_26);
if (!car_legal(v_26)) v_26 = cdrerror(v_26); else
v_26 = cdr(v_26);
if (equal(v_29, v_26)) goto v_14;
else goto v_15;
v_14:
v_26 = v_27;
if (!car_legal(v_26)) v_26 = carerror(v_26); else
v_26 = car(v_26);
goto v_6;
v_15:
v_26 = v_27;
if (!car_legal(v_26)) v_26 = cdrerror(v_26); else
v_26 = cdr(v_26);
v_27 = v_26;
goto v_7;
v_26 = nil;
v_6:
return onevalue(v_26);
}
// Code for rewrite
static LispObject CC_rewrite(LispObject env, LispObject v_2,
LispObject v_3, LispObject v_4, LispObject _a4up_)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_190, v_191, v_192;
LispObject v_5;
if (_a4up_ == nil)
aerror1("not enough arguments provided", basic_elt(env, 0));
v_5 = car(_a4up_); _a4up_ = cdr(_a4up_);
if (_a4up_ != nil)
aerror1("too many arguments provided", basic_elt(env, 0));
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3,v_4,v_5);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_5,v_4,v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
real_push(nil, nil, nil, nil, nil);
real_push(nil, nil, nil, nil, nil);
push(nil, nil, nil, nil);
stack_popper stack_popper_var(15);
// copy arguments values to proper place
stack[-9] = v_5;
stack[-10] = v_4;
stack[-11] = v_3;
stack[-12] = v_2;
// end of prologue
v_190 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[-13] = v_190;
v_190 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[-2] = v_190;
v_190 = stack[-12];
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
if (!car_legal(v_190)) v_190 = carerror(v_190); else
v_190 = car(v_190);
v_191 = v_190;
if (!car_legal(v_191)) v_191 = cdrerror(v_191); else
v_191 = cdr(v_191);
if (!car_legal(v_191)) v_191 = carerror(v_191); else
v_191 = car(v_191);
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
if (!car_legal(v_190)) v_190 = carerror(v_190); else
v_190 = car(v_190);
if (equal(v_191, v_190)) goto v_30;
else goto v_31;
v_30:
v_190 = stack[-11];
v_190 = add1(v_190);
env = stack[-14];
stack[-1] = v_190;
goto v_29;
v_31:
v_190 = stack[-11];
stack[-1] = v_190;
goto v_29;
v_29:
v_190 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[0] = v_190;
v_47:
v_191 = stack[-1];
v_190 = stack[0];
v_190 = difference2(v_191, v_190);
env = stack[-14];
v_190 = Lminusp(nil, v_190);
env = stack[-14];
if (v_190 == nil) goto v_52;
goto v_46;
v_52:
v_191 = stack[-12];
v_190 = stack[0];
{ LispObject fn = basic_elt(env, 1); // findrow
v_190 = (*qfn2(fn))(fn, v_191, v_190);
}
env = stack[-14];
v_191 = v_190;
v_190 = v_191;
if (v_190 == nil) goto v_64;
v_190 = v_191;
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
stack[-7] = v_190;
v_190 = stack[0];
stack[-3] = v_190;
v_191 = stack[-13];
v_190 = stack[-10];
if (equal(v_191, v_190)) goto v_71;
else goto v_72;
v_71:
v_190 = stack[-13];
v_190 = add1(v_190);
env = stack[-14];
stack[-13] = v_190;
goto v_70;
v_72:
v_70:
v_191 = stack[-3];
v_190 = stack[-13];
if (equal(v_191, v_190)) goto v_79;
else goto v_80;
v_79:
v_190 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[-4] = v_190;
v_190 = static_cast<LispObject>(16)+TAG_FIXNUM; // 1
stack[-8] = v_190;
v_190 = nil;
stack[-5] = v_190;
v_88:
v_190 = stack[-7];
if (v_190 == nil) goto v_91;
stack[-3] = stack[-4];
v_190 = stack[-11];
v_190 = add1(v_190);
env = stack[-14];
if (equal(stack[-3], v_190)) goto v_91;
goto v_92;
v_91:
goto v_87;
v_92:
v_190 = stack[-7];
if (!car_legal(v_190)) v_190 = carerror(v_190); else
v_190 = car(v_190);
v_191 = v_190;
v_190 = v_191;
if (!car_legal(v_190)) v_190 = carerror(v_190); else
v_190 = car(v_190);
stack[-6] = v_190;
v_190 = v_191;
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
stack[-3] = v_190;
v_191 = stack[-4];
v_190 = stack[-9];
if (equal(v_191, v_190)) goto v_108;
else goto v_109;
v_108:
v_190 = stack[-8];
v_190 = add1(v_190);
env = stack[-14];
stack[-8] = v_190;
goto v_107;
v_109:
v_107:
v_191 = stack[-6];
v_190 = stack[-8];
if (equal(v_191, v_190)) goto v_116;
else goto v_117;
v_116:
v_192 = stack[-4];
v_191 = stack[-3];
v_190 = stack[-5];
v_190 = acons(v_192, v_191, v_190);
env = stack[-14];
stack[-5] = v_190;
v_190 = stack[-4];
v_190 = add1(v_190);
env = stack[-14];
stack[-4] = v_190;
v_190 = stack[-7];
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
stack[-7] = v_190;
v_190 = stack[-8];
v_190 = add1(v_190);
env = stack[-14];
stack[-8] = v_190;
goto v_115;
v_117:
v_190 = stack[-8];
v_190 = add1(v_190);
env = stack[-14];
stack[-8] = v_190;
v_190 = stack[-4];
v_190 = add1(v_190);
env = stack[-14];
stack[-4] = v_190;
goto v_115;
v_115:
goto v_88;
v_87:
v_191 = stack[-12];
v_190 = stack[-2];
stack[-4] = list2(v_191, v_190);
env = stack[-14];
v_190 = nil;
stack[-3] = ncons(v_190);
env = stack[-14];
v_190 = stack[-5];
v_190 = Lreverse(nil, v_190);
env = stack[-14];
stack[-5] = cons(stack[-3], v_190);
env = stack[-14];
stack[-3] = stack[-12];
v_190 = nil;
v_190 = ncons(v_190);
env = stack[-14];
{ LispObject fn = basic_elt(env, 2); // letmtr3
v_190 = (*qfn4up(fn))(fn, stack[-4], stack[-5], stack[-3], v_190);
}
env = stack[-14];
v_190 = stack[-2];
v_190 = add1(v_190);
env = stack[-14];
stack[-2] = v_190;
v_190 = stack[-13];
v_190 = add1(v_190);
env = stack[-14];
stack[-13] = v_190;
goto v_78;
v_80:
v_190 = stack[-13];
v_190 = add1(v_190);
env = stack[-14];
stack[-13] = v_190;
v_190 = stack[-2];
v_190 = add1(v_190);
env = stack[-14];
stack[-2] = v_190;
goto v_78;
v_78:
goto v_62;
v_64:
v_190 = stack[-13];
v_190 = add1(v_190);
env = stack[-14];
stack[-13] = v_190;
goto v_62;
v_62:
v_190 = stack[0];
v_190 = add1(v_190);
env = stack[-14];
stack[0] = v_190;
goto v_47;
v_46:
v_190 = stack[-11];
v_191 = add1(v_190);
env = stack[-14];
v_190 = stack[-12];
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
if (!car_legal(v_190)) v_190 = carerror(v_190); else
v_190 = car(v_190);
if (!car_legal(v_190)) v_190 = cdrerror(v_190); else
v_190 = cdr(v_190);
if (!car_legal(v_190)) v_190 = carerror(v_190); else
v_190 = car(v_190);
if (equal(v_191, v_190)) goto v_170;
else goto v_171;
v_170:
stack[0] = stack[-12];
v_190 = stack[-11];
v_190 = add1(v_190);
env = stack[-14];
stack[-2] = list2(stack[0], v_190);
env = stack[-14];
stack[-1] = nil;
stack[0] = stack[-12];
v_190 = nil;
v_190 = ncons(v_190);
env = stack[-14];
{ LispObject fn = basic_elt(env, 2); // letmtr3
v_190 = (*qfn4up(fn))(fn, stack[-2], stack[-1], stack[0], v_190);
}
goto v_169;
v_171:
v_169:
v_190 = stack[-12];
return onevalue(v_190);
}
// Code for ndepends
static LispObject CC_ndepends(LispObject env,
LispObject v_2, LispObject v_3)
{
env = qenv(env);
#if 0 // Start of trace output
#endif // End of trace output
LispObject v_142, v_143, v_144;
#ifdef CHECK_STACK
if_check_stack;
#endif
#ifdef CONSERVATIVE
poll();
#else // CONSERVATIVE
if (++reclaim_trigger_count == reclaim_trigger_target ||
stack >= stackLimit)
{
push(v_2,v_3);
env = reclaim(env, "stack", GC_STACK, 0);
pop(v_3,v_2);
}
#endif // CONSERVATIVE
real_push(env);
// space for vars preserved across procedure calls
push(nil, nil);
stack_popper stack_popper_var(3);
// copy arguments values to proper place
stack[0] = v_3;
stack[-1] = v_2;
// end of prologue
v_142 = stack[-1];
if (v_142 == nil) goto v_11;
else goto v_12;
v_11:
v_142 = lisp_true;
goto v_10;
v_12:
v_142 = stack[-1];
v_142 = (is_number(v_142) ? lisp_true : nil);
if (v_142 == nil) goto v_19;
else goto v_18;
v_19:
v_142 = stack[0];
v_142 = (is_number(v_142) ? lisp_true : nil);
v_18:
goto v_10;
v_142 = nil;
v_10:
if (v_142 == nil) goto v_8;
v_142 = nil;
goto v_6;
v_8:
v_143 = stack[-1];
v_142 = stack[0];
if (equal(v_143, v_142)) goto v_25;
else goto v_26;
v_25:
v_142 = stack[-1];
goto v_6;
v_26:
v_142 = stack[-1];
if (!consp(v_142)) goto v_34;
else goto v_35;
v_34:
v_143 = stack[-1];
v_142 = qvalue(basic_elt(env, 1)); // frlis!*
v_142 = Lmemq(nil, v_143, v_142);
goto v_33;
v_35:
v_142 = nil;
goto v_33;
v_142 = nil;
v_33:
if (v_142 == nil) goto v_31;
v_142 = lisp_true;
goto v_6;
v_31:
v_143 = stack[-1];
v_142 = qvalue(basic_elt(env, 2)); // depl!*
v_142 = Lassoc(nil, v_143, v_142);
v_143 = v_142;
v_142 = v_143;
if (v_142 == nil) goto v_52;
else goto v_53;
v_52:
v_142 = nil;
goto v_51;
v_53:
v_142 = v_143;
if (!car_legal(v_142)) v_143 = cdrerror(v_142); else
v_143 = cdr(v_142);
v_142 = stack[0];
{ LispObject fn = basic_elt(env, 4); // lndepends
v_142 = (*qfn2(fn))(fn, v_143, v_142);
}
env = stack[-2];
goto v_51;
v_142 = nil;
v_51:
if (v_142 == nil) goto v_45;
v_142 = lisp_true;
goto v_6;
v_45:
v_142 = stack[-1];
if (!consp(v_142)) goto v_68;
v_142 = stack[-1];
if (!car_legal(v_142)) v_142 = carerror(v_142); else
v_142 = car(v_142);
if (symbolp(v_142)) goto v_73;
v_142 = nil;
goto v_71;
v_73:
v_142 = stack[-1];
if (!car_legal(v_142)) v_142 = carerror(v_142); else
v_142 = car(v_142);
if (!symbolp(v_142)) v_142 = nil;
else { v_142 = qfastgets(v_142);
if (v_142 != nil) { v_142 = elt(v_142, 8); // dname
#ifdef RECORD_GET
if (v_142 != SPID_NOPROP)
record_get(elt(fastget_names, 8), 1);
else record_get(elt(fastget_names, 8), 0),
v_142 = nil; }
else record_get(elt(fastget_names, 8), 0); }
#else
if (v_142 == SPID_NOPROP) v_142 = nil; }}
#endif
goto v_71;
v_142 = nil;
v_71:
goto v_66;
v_68:
v_142 = nil;
goto v_66;
v_142 = nil;
v_66:
if (v_142 == nil) goto v_64;
v_142 = stack[-1];
if (!car_legal(v_142)) v_143 = carerror(v_142); else
v_143 = car(v_142);
v_142 = basic_elt(env, 3); // domain!-depends!-fn
v_142 = get(v_143, v_142);
v_143 = v_142;
v_142 = v_143;
if (v_142 == nil) goto v_93;
v_144 = v_143;
v_143 = stack[-1];
v_142 = stack[0];
return Lapply2(nil, v_144, v_143, v_142);
v_93:
v_142 = nil;
goto v_91;
v_142 = nil;
v_91:
goto v_6;
v_64:
v_142 = stack[-1];
{ LispObject fn = basic_elt(env, 5); // atomf
v_142 = (*qfn1(fn))(fn, v_142);
}
env = stack[-2];
if (v_142 == nil) goto v_106;
else goto v_107;
v_106:
v_142 = stack[-1];
if (!car_legal(v_142)) v_143 = cdrerror(v_142); else
v_143 = cdr(v_142);
v_142 = stack[0];
{ LispObject fn = basic_elt(env, 4); // lndepends
v_142 = (*qfn2(fn))(fn, v_143, v_142);
}
env = stack[-2];
if (v_142 == nil) goto v_112;
else goto v_111;
v_112:
v_142 = stack[-1];
if (!car_legal(v_142)) v_143 = carerror(v_142); else
v_143 = car(v_142);
v_142 = stack[0];
{ LispObject fn = basic_elt(env, 0); // ndepends
v_142 = (*qfn2(fn))(fn, v_143, v_142);
}
env = stack[-2];
v_111:
goto v_105;
v_107:
v_142 = nil;
goto v_105;
v_142 = nil;
v_105:
if (v_142 == nil) goto v_103;
v_142 = lisp_true;
goto v_6;
v_103:
v_142 = stack[0];
{ LispObject fn = basic_elt(env, 5); // atomf
v_142 = (*qfn1(fn))(fn, v_142);
}
if (v_142 == nil) goto v_127;
else goto v_125;
v_127:
v_142 = stack[0];
if (!car_legal(v_142)) v_142 = carerror(v_142); else
v_142 = car(v_142);
if (symbolp(v_142)) goto v_131;
else goto v_130;
v_131:
v_142 = stack[0];
if (!car_legal(v_142)) v_142 = carerror(v_142); else
v_142 = car(v_142);
if (!symbolp(v_142)) v_142 = nil;
else { v_142 = qfastgets(v_142);
if (v_142 != nil) { v_142 = elt(v_142, 8); // dname
#ifdef RECORD_GET
if (v_142 != SPID_NOPROP)
record_get(elt(fastget_names, 8), 1);
else record_get(elt(fastget_names, 8), 0),
v_142 = nil; }
else record_get(elt(fastget_names, 8), 0); }
#else
if (v_142 == SPID_NOPROP) v_142 = nil; }}
#endif
if (v_142 == nil) goto v_130;
goto v_125;
v_130:
goto v_126;
v_125:
v_142 = nil;
goto v_6;
v_126:
v_142 = nil;
goto v_6;
v_142 = nil;
v_6:
return onevalue(v_142);
}
setup_type const u37_setup[] =
{
{"lessppair", G0W2, G1W2, CC_lessppair,G3W2, G4W2},
{"lalr_print_first_information",CC_lalr_print_first_information,G1W0,G2W0,G3W0,G4W0},
{"smt_prin2x", G0W1, CC_smt_prin2x,G2W1, G3W1, G4W1},
{"ofsf_simplequal", G0W2, G1W2, CC_ofsf_simplequal,G3W2,G4W2},
{"pasf_exprng-gand", G0W4up, G1W4up, G2W4up, G3W4up, CC_pasf_exprngKgand},
{"bvarom", G0W1, CC_bvarom,G2W1, G3W1, G4W1},
{"s-nextarg", G0W1, CC_sKnextarg,G2W1, G3W1, G4W1},
{"wedgef", G0W1, CC_wedgef,G2W1, G3W1, G4W1},
{"apply_e", G0W1, CC_apply_e,G2W1, G3W1, G4W1},
{"diff_vertex", G0W2, G1W2, CC_diff_vertex,G3W2,G4W2},
{"assert_kernelp", G0W1, CC_assert_kernelp,G2W1,G3W1, G4W1},
{"evalgreaterp", G0W2, G1W2, CC_evalgreaterp,G3W2,G4W2},
{"solvealgdepends", G0W2, G1W2, CC_solvealgdepends,G3W2,G4W2},
{"make-image", G0W2, G1W2, CC_makeKimage,G3W2, G4W2},
{"giplus:", G0W2, G1W2, CC_giplusT,G3W2, G4W2},
{"ext_mult", G0W2, G1W2, CC_ext_mult,G3W2, G4W2},
{"gcd-with-number", G0W2, G1W2, CC_gcdKwithKnumber,G3W2,G4W2},
{"aex_sgn", G0W1, CC_aex_sgn,G2W1, G3W1, G4W1},
{"containerom", G0W1, CC_containerom,G2W1,G3W1, G4W1},
{"mkexdf", G0W1, CC_mkexdf,G2W1, G3W1, G4W1},
{"z-roads", G0W1, CC_zKroads,G2W1, G3W1, G4W1},
{"msolve-psys1", G0W2, G1W2, CC_msolveKpsys1,G3W2,G4W2},
{"ratlessp", G0W2, G1W2, CC_ratlessp,G3W2, G4W2},
{"lastcar", G0W1, CC_lastcar,G2W1, G3W1, G4W1},
{"aex_divposcnt", G0W2, G1W2, CC_aex_divposcnt,G3W2,G4W2},
{"settcollectnonmultiprolongations",G0W1,CC_settcollectnonmultiprolongations,G2W1,G3W1,G4W1},
{"processpartitie1list1", G0W2, G1W2, CC_processpartitie1list1,G3W2,G4W2},
{"mk+outer+list", G0W1, CC_mkLouterLlist,G2W1,G3W1, G4W1},
{"repr_ldeg", G0W1, CC_repr_ldeg,G2W1, G3W1, G4W1},
{"dip_f2dip2", G0W4up, G1W4up, G2W4up, G3W4up, CC_dip_f2dip2},
{"setfuncsnaryrd", CC_setfuncsnaryrd,G1W0,G2W0, G3W0, G4W0},
{"sqprint", G0W1, CC_sqprint,G2W1, G3W1, G4W1},
{"red_tailreddriver", G0W3, G1W3, G2W3, CC_red_tailreddriver,G4W3},
{"getavalue", G0W1, CC_getavalue,G2W1, G3W1, G4W1},
{"reduce-eival-powers", G0W2, G1W2, CC_reduceKeivalKpowers,G3W2,G4W2},
{"find-null-space", G0W2, G1W2, CC_findKnullKspace,G3W2,G4W2},
{"set_parser", G0W1, CC_set_parser,G2W1, G3W1, G4W1},
{"sq_member", G0W2, G1W2, CC_sq_member,G3W2, G4W2},
{"orddf", G0W2, G1W2, CC_orddf, G3W2, G4W2},
{"cl_susiupdknowl", G0W4up, G1W4up, G2W4up, G3W4up, CC_cl_susiupdknowl},
{"gftimes", G0W2, G1W2, CC_gftimes,G3W2, G4W2},
{"calc_den_tar", G0W2, G1W2, CC_calc_den_tar,G3W2,G4W2},
{"no-side-effectp", G0W1, CC_noKsideKeffectp,G2W1,G3W1, G4W1},
{"atom_compare", G0W2, G1W2, CC_atom_compare,G3W2,G4W2},
{"lalr_expand_grammar", G0W1, CC_lalr_expand_grammar,G2W1,G3W1,G4W1},
{"aex_stchsgnch1", G0W3, G1W3, G2W3, CC_aex_stchsgnch1,G4W3},
{"janettreenodebuild", G0W3, G1W3, G2W3, CC_janettreenodebuild,G4W3},
{"even_action_term", G0W4up, G1W4up, G2W4up, G3W4up, CC_even_action_term},
{"testord", G0W2, G1W2, CC_testord,G3W2, G4W2},
{"my+nullsq+p", G0W1, CC_myLnullsqLp,G2W1,G3W1, G4W1},
{"pasf_varlat", G0W1, CC_pasf_varlat,G2W1,G3W1, G4W1},
{"rl_surep", G0W2, G1W2, CC_rl_surep,G3W2, G4W2},
{"minusrd", CC_minusrd,G1W0, G2W0, G3W0, G4W0},
{"assoc2", G0W2, G1W2, CC_assoc2,G3W2, G4W2},
{"rewrite", G0W4up, G1W4up, G2W4up, G3W4up, CC_rewrite},
{"ndepends", G0W2, G1W2, CC_ndepends,G3W2, G4W2},
{nullptr,
reinterpret_cast<no_args *>(
reinterpret_cast<uintptr_t>("u37")),
reinterpret_cast<one_arg *>(
reinterpret_cast<uintptr_t>("151279 6388377 1372549")),
nullptr, nullptr, nullptr}
};
// end of generated code
| 26.065622
| 123
| 0.576819
|
arthurcnorman
|
1fcc7e469e970f97ae9d90ed18bb7ae530a941e9
| 5,453
|
cpp
|
C++
|
src/Cube/CubePlayer.cpp
|
austinkinross/rubiks-cube-solver
|
dac8c375502a2c002e3797a549d04b4e31e9e9c2
|
[
"MIT"
] | 25
|
2015-09-02T10:25:51.000Z
|
2022-02-26T03:50:51.000Z
|
src/Cube/CubePlayer.cpp
|
austinkinross/rubiks-cube-solver
|
dac8c375502a2c002e3797a549d04b4e31e9e9c2
|
[
"MIT"
] | 1
|
2018-02-13T12:59:04.000Z
|
2018-02-13T12:59:04.000Z
|
src/Cube/CubePlayer.cpp
|
austinkinross/rubiks-cube-solver
|
dac8c375502a2c002e3797a549d04b4e31e9e9c2
|
[
"MIT"
] | 11
|
2017-05-06T09:40:21.000Z
|
2021-04-21T04:09:15.000Z
|
#include "pch.h"
#include "CubePlayer.h"
CubePlayer::CubePlayer(CubePlayerDesc* desc)
{
mCube = new Cube();
mDesc = *desc;
Reset();
bPaused = false;
if (mDesc.populateColors)
{
mPlaybackState = PLAYBACK_STATE_POPULATING_COLORS;
mFoldingAngle = 3.141592653f / 2;
// Set all the faces to be nearly black
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
mCube->frontFaceStickers[i][j]->SetColor(StickerColor::CUBE_BLACK);
mCube->backFaceStickers[i][j]->SetColor(StickerColor::CUBE_BLACK);
mCube->topFaceStickers[i][j]->SetColor(StickerColor::CUBE_BLACK);
mCube->bottomFaceStickers[i][j]->SetColor(StickerColor::CUBE_BLACK);
mCube->leftFaceStickers[i][j]->SetColor(StickerColor::CUBE_BLACK);
mCube->rightFaceStickers[i][j]->SetColor(StickerColor::CUBE_BLACK);
}
}
}
else if (mDesc.unfoldCubeAtStart)
{
mPlaybackState = PLAYBACK_STATE_FOLDING;
mFoldingAngle = 3.141592653f / 2;
}
else
{
mPlaybackState = PLAYBACK_STATE_SOLVING;
mFoldingAngle = 0.0f;
}
mCube->SetFoldAngle(mFoldingAngle);
}
CubePlayer::~CubePlayer()
{
delete mCube;
}
void CubePlayer::Reset()
{
uiCurrentCommandPos = 0;
fCurrentCommandProportion = 0.0f;
}
void CubePlayer::UseCommandList(CubeCommandList *pCommandList)
{
mCubeCommandList = pCommandList;
Reset();
}
void CubePlayer::Pause()
{
bPaused = true;
}
void CubePlayer::Play()
{
bPaused = false;
}
unsigned int tempCount = 0;
//-------------------------------------------------------------------------------------------------------------------------------------------------------
// NOT NEEDED
//-------------------------------------------------------------------------------------------------------------------------------------------------------
void CubePlayer::Update(float timeTotal, float timeDelta)
{
// XMStoreFloat4x4(&pPlaybackCube->worldMatrix, XMMatrixTranspose(XMMatrixMultiply(XMMatrixRotationY(timeTotal * XM_PIDIV4), XMMatrixRotationX((float) sin(0/3) * XM_PIDIV4))));
if (!bPaused)
{
if (mPlaybackState == PLAYBACK_STATE_FOLDING)
{
mFoldingAngle -= timeDelta / mDesc.speeds.foldingSpeed;
if (mFoldingAngle < 0.0f)
{
mFoldingAngle = 0.0f;
mPlaybackState = PLAYBACK_STATE_SOLVING;
}
mCube->SetFoldAngle(mFoldingAngle);
}
else if (mPlaybackState == PLAYBACK_STATE_SOLVING)
{
if (uiCurrentCommandPos < mCubeCommandList->GetLength())
{
CubeCommand currentCommand = mCubeCommandList->GetCommandAt(uiCurrentCommandPos);
fCurrentCommandProportion += timeDelta / mDesc.speeds.solvingSpeed;
if (fCurrentCommandProportion >= 1.0f)
{
mCube->ApplyCommand(currentCommand);
fCurrentCommandProportion = 0.0f;
uiCurrentCommandPos += 1;
if (uiCurrentCommandPos < mCubeCommandList->GetLength())
{
CubeCommand nextCommand = mCubeCommandList->GetCommandAt(uiCurrentCommandPos);
while (nextCommand == CubeRotateY && uiCurrentCommandPos < mCubeCommandList->GetLength())
{
mCube->ApplyCommand(nextCommand);
uiCurrentCommandPos += 1;
if (uiCurrentCommandPos < mCubeCommandList->GetLength())
{
nextCommand = mCubeCommandList->GetCommandAt(uiCurrentCommandPos);
}
}
}
// Maybe call Update again with a reduced time delta?
}
// Now that we've performed the actual twist (if it was needed), we should update the slices' angles
float fRotationAngle = (-fCurrentCommandProportion*fCurrentCommandProportion*fCurrentCommandProportion + 2 * fCurrentCommandProportion*fCurrentCommandProportion) * (float)(3.141592f / 2);
if (IsPrimeCubeCommand(currentCommand))
{
fRotationAngle *= -1;
}
switch (currentCommand)
{
case CubeCommandLeft:
case CubeCommandLeftPrime:
mCube->pLeftSlice->SetAngle(fRotationAngle);
break;
case CubeCommandRight:
case CubeCommandRightPrime:
mCube->pRightSlice->SetAngle(fRotationAngle);
break;
case CubeCommandTop:
case CubeCommandTopPrime:
mCube->pTopSlice->SetAngle(fRotationAngle);
break;
case CubeCommandBottom:
case CubeCommandBottomPrime:
mCube->pBottomSlice->SetAngle(fRotationAngle);
break;
case CubeCommandFront:
case CubeCommandFrontPrime:
mCube->pFrontSlice->SetAngle(fRotationAngle);
break;
case CubeCommandBack:
case CubeCommandBackPrime:
mCube->pBackSlice->SetAngle(fRotationAngle);
break;
}
}
}
}
}
| 33.048485
| 203
| 0.537502
|
austinkinross
|
1fcdd8cfaef7342c56d5f667712a70cc23694a8a
| 3,749
|
cc
|
C++
|
agenda.cc
|
Ralusama19/AgendaPRO2
|
fcbf56a4ef28d06b85845671c847725deb4e8ed0
|
[
"MIT"
] | 1
|
2016-01-16T10:17:20.000Z
|
2016-01-16T10:17:20.000Z
|
agenda.cc
|
Ralusama19/Agenda
|
fcbf56a4ef28d06b85845671c847725deb4e8ed0
|
[
"MIT"
] | null | null | null |
agenda.cc
|
Ralusama19/Agenda
|
fcbf56a4ef28d06b85845671c847725deb4e8ed0
|
[
"MIT"
] | null | null | null |
/** @file agenda.cc
@brief Codi de la classe Agenda
*/
#include "agenda.hh"
void Agenda::escriu(string expressio, map<Rellotge,Activitat>::iterator& principi,
map<Rellotge,Activitat>::iterator& final, bool passat){
//Buidem el menu abans de cada consulta
menu.clear();
int i = 1;
for(map<Rellotge,Activitat>::iterator it = principi; it != final; ++it){
if((expressio == "") or (it->second.compleix_expressio(expressio))){
//Si no es una consulta sobre el passat, actualitzem el menu amb els iteradors de les activitats escrites
if (not passat) menu.push_back(it);
cout << i << " " ;
it->second.escriu_titol();
cout << " " << it->first.consultar_data() << " " << it->first.consultar_horaminut();
it->second.escriu_etiquetes();
cout << endl;
++i;
}
}
}
// Constructora
Agenda::Agenda(){}
//Destructora
Agenda::~Agenda(){}
// Consultores
bool Agenda::i_valida(int i) const{
//Ens assegurem que la i es refereixi a una posicio del menu i que la tasca a la que es refereix existeixi
return (0 <= i and i < menu.size() and menu[i] != agenda.end());
}
void Agenda::consultar_rellotge_intern(Rellotge& rel) const{
rel = rellotge_intern;
}
void Agenda::consultar_rellotge_iessim(Rellotge & rel, int i) const{
rel = menu[i]->first;
}
void Agenda::consultar_activitat_iessima(Activitat & act, int i) const{
act = menu[i]->second;
}
//Modificadores
void Agenda::modifica_rellotge_intern(Rellotge& rel) {
//assignem rel al rellotge intern
rellotge_intern = rel;
int i = 0;
//actualitzem el menu perque no es puguin modificar tasques que formen part del passat
while (i < menu.size() and menu[i] != agenda.end()
and menu[i]->first < rellotge_intern){
menu[i] = agenda.end();
++i;
}
}
void Agenda::modifica_activitat_iessima(Activitat& act, int i) {
menu[i]->second = act;
}
bool Agenda::afegir_activitat(const Rellotge& rel,const Activitat& act){
pair<map<Rellotge, Activitat>::iterator, bool> result;
//ens assegurem de no crear una tasca ala mateixa data i hora que unaltre
result = agenda.insert(make_pair(rel, act));
return result.second;
}
bool Agenda::esborra_etiqueta(int i,string etiq){
return menu[i]->second.esborrar_etiqueta(etiq);
}
void Agenda::esborra_etiquetes(int i){
menu[i]->second.esborrar_totes_etiquetes();
}
bool Agenda::esborra_activitat(int i){
int num_borrats = agenda.erase(menu[i]->first);
if (num_borrats > 0) menu[i] = agenda.end();
return (num_borrats > 0);
}
// Escriptura
void Agenda::escriu_rellotge(){
rellotge_intern.escriu_rellotge();
}
void Agenda::escriu_passat(){
menu.clear();
map<Rellotge,Activitat>::iterator principi = agenda.begin();
map<Rellotge,Activitat>::iterator final = agenda.lower_bound(rellotge_intern);
escriu("", principi, final, true);
}
void Agenda::escriu_per_condicio(const bool& data, string primera_data, string segona_data,
const string& s, bool h){
map<Rellotge,Activitat>::iterator principi, final;
if(data){
Rellotge rel1("00:00", primera_data), rel2("23:59", segona_data);
if (h){
rel1 = rellotge_intern;
}
principi = agenda.lower_bound(rel1);
final = agenda.upper_bound(rel2);
}
else {
principi = agenda.lower_bound(rellotge_intern);
final = agenda.end();
}
escriu(s,principi,final, false);
}
void Agenda::escriu_futur(){
map<Rellotge,Activitat>::iterator principi = agenda.lower_bound(rellotge_intern);
map<Rellotge,Activitat>::iterator final = agenda.end();
escriu("", principi, final, false);
}
| 28.618321
| 117
| 0.656175
|
Ralusama19
|
1fd019f5eae961b527c7274325f4a3aa76ad6f4b
| 476
|
hpp
|
C++
|
libs/media/impl/include/sge/media/impl/log_name.hpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | 2
|
2016-01-27T13:18:14.000Z
|
2018-05-11T01:11:32.000Z
|
libs/media/impl/include/sge/media/impl/log_name.hpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | null | null | null |
libs/media/impl/include/sge/media/impl/log_name.hpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | 3
|
2018-05-11T01:11:34.000Z
|
2021-04-24T19:47:45.000Z
|
// Copyright Carl Philipp Reh 2006 - 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef SGE_MEDIA_IMPL_LOG_NAME_HPP_INCLUDED
#define SGE_MEDIA_IMPL_LOG_NAME_HPP_INCLUDED
#include <sge/media/detail/symbol.hpp>
#include <fcppt/log/name.hpp>
namespace sge::media::impl
{
SGE_MEDIA_DETAIL_SYMBOL
fcppt::log::name log_name();
}
#endif
| 22.666667
| 61
| 0.743697
|
cpreh
|
1fd2c78f8f8cb0adda77f14cbe70d968e5983560
| 7,815
|
hpp
|
C++
|
Code/Libs/Math/Bits.hpp
|
NotKyon/Tenshi
|
9bd298c6ef4e6ae446a866c2918e15b4ab22f9e7
|
[
"Zlib"
] | null | null | null |
Code/Libs/Math/Bits.hpp
|
NotKyon/Tenshi
|
9bd298c6ef4e6ae446a866c2918e15b4ab22f9e7
|
[
"Zlib"
] | 8
|
2016-11-17T00:39:03.000Z
|
2016-11-29T14:46:27.000Z
|
Code/Libs/Math/Bits.hpp
|
NotKyon/Tenshi
|
9bd298c6ef4e6ae446a866c2918e15b4ab22f9e7
|
[
"Zlib"
] | null | null | null |
#pragma once
#include "../Platform/Platform.hpp"
#include "../Core/TypeTraits.hpp"
namespace Ax { namespace Math {
/// Unsigned bit-shift right
template< typename tInt >
inline tInt BitShiftRightU( tInt x, tInt y )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
typedef typename TMakeUnsigned< tInt >::type tUnsigned;
return
static_cast< tInt >(
static_cast< tUnsigned >( x ) >> y
);
}
/// Signed bit-shift right
template< typename tInt >
inline tInt BitShiftRightS( tInt x, tInt y )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
typedef typename TMakeSigned< tInt >::type tSigned;
return
static_cast< tInt >(
static_cast< tSigned >( x ) >> y
);
}
/// Put a zero bit between each of the lower bits of the given value
template< typename tInt >
inline tInt BitExpand( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
tInt r = 0;
for( uintcpu i = 0; i < ( sizeof( x )*8 )/2; ++i )
{
r |= ( x & ( 1 << i ) ) << i;
}
return r;
}
/// Take each other bit of a value and merge into one value
template< typename tInt >
inline tInt BitMerge( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
tInt r = 0;
for( uintcpu i = 0; i < ( sizeof( x )*8 )/2; ++i )
{
r |= ( x & ( 1 << ( i*2 ) ) ) >> i;
}
return r;
}
/// Specialization of BitExpand() for uint32
inline uint32 BitExpand( uint32 x )
{
// http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/
x &= 0xFFFF;
x = ( x ^ ( x << 8 ) ) & 0x00FF00FF;
x = ( x ^ ( x << 4 ) ) & 0x0F0F0F0F;
x = ( x ^ ( x << 2 ) ) & 0x33333333;
x = ( x ^ ( x << 1 ) ) & 0x55555555;
return x;
}
/// Specialization of BitMerge() for uint32
inline uint32 BitMerge( uint32 x )
{
// http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/
x &= 0x55555555;
x = ( x ^ ( x >> 1 ) ) & 0x33333333;
x = ( x ^ ( x >> 2 ) ) & 0x0F0F0F0F;
x = ( x ^ ( x >> 4 ) ) & 0x00FF00FF;
x = ( x ^ ( x >> 8 ) ) & 0x0000FFFF;
return x;
}
/// Turn off the right-most set bit (e.g., 01011000 -> 01010000)
template< typename tInt >
inline tInt BitRemoveLowestSet( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return x & ( x - 1 );
}
/// Determine whether a number is a power of two
template< typename tInt >
inline bool BitIsPowerOfTwo( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return BitRemoveLowestSet( x ) == 0;
}
/// Isolate the right-most set bit (e.g., 01011000 -> 00001000)
template< typename tInt >
inline tInt BitIsolateLowestSet( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return x & ( -x );
}
/// Isolate the right-most clear bit (e.g., 10100111 -> 00001000)
template< typename tInt >
inline tInt BitIsolateLowestClear( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return -x & ( x + 1 );
}
/// Create a mask of the trailing clear bits (e.g., 01011000 -> 00000111)
template< typename tInt >
inline tInt BitIdentifyLowestClears( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return -x & ( x - 1 );
}
/// Create a mask that identifies the least significant set bit and the
/// trailing clear bits (e.g., 01011000 -> 00001111)
template< typename tInt >
inline tInt BitIdentifyLowestSetAndClears( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return x ^ ( x - 1 );
}
/// Propagate the lowest set bit to the lower clear bits
template< typename tInt >
inline tInt BitPropagateLowestSet( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return x | ( x - 1 );
}
/// Find the absolute value of an integer
template< typename tInt >
inline tInt BitAbs( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
const tInt y = BitShiftRightS( x, ( tInt )( sizeof( x )*8 - 1 ) );
return ( x ^ y ) - y;
}
/// Find the sign of an integer
template< typename tInt >
inline tInt BitSign( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
static const tInt s = sizeof( tInt )*8 - 1;
return BitShiftRightS( x, s ) | BitShiftRightU( -x, s );
}
/// Transfer the sign of src into dst
template< typename tInt >
inline tInt BitCopySign( tInt dst, tInt src )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
const tInt t = BitShiftRightS( src, ( tInt )( sizeof( tInt )*8 - 1 ) );
return ( BitAbs( dst ) + t ) ^ t;
}
/// Rotate a field of bits left
template< typename tInt >
inline tInt BitRotateLeft( tInt x, tInt y )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return ( x << y ) | BitShiftRightU( x, sizeof( x )*8 - y );
}
/// Rotate a field of bits right
template< typename tInt >
inline tInt BitRotateRight( tInt x, tInt y )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
return BitShiftRightU( x, y ) | ( x << ( sizeof( x )*8 - y ) );
}
/// Count the number of set bits
template< typename tInt >
inline tInt BitCount( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
tInt r = x;
for( int i = 0; i < sizeof( x )*8; ++i )
{
r -= x >> ( 1 << i );
}
return r;
}
/// Specialization of BitCount() for 32-bit integers
inline uint32 BitCount( uint32 x )
{
x = x - ( ( x >> 1 ) & 0x55555555 );
x = ( x & 0x33333333 ) + ( ( x >> 2 ) & 0x33333333 );
x = ( x + ( x >> 4 ) ) & 0x0F0F0F0F;
x = x + ( x >> 8 );
x = x + ( x >> 16 );
return x & 0x0000003F;
}
/// Compute the parity of an integer (true for odd, false for even)
template< typename tInt >
inline tInt BitParity( tInt x )
{
static_assert( TIsInt< tInt >::value, "Integer type required" );
x = x ^ ( x >> 1 );
x = x ^ ( x >> 2 );
x = x ^ ( x >> 4 );
if( sizeof( x ) > 1 )
{
x = x ^ ( x >> 8 );
if( sizeof( x ) > 2 )
{
x = x ^ ( x >> 16 );
if( sizeof( x ) > 4 )
{
x = x ^ ( x >> 32 );
int i = 8;
while( sizeof( x ) > i )
{
x = x ^ ( x >> ( i*8 ) );
i = i*2;
}
}
}
}
return x;
}
/// Treat the bits of a signed-integer as a float encoding.
inline float IntBitsToFloat( int32 x )
{
union
{
float f;
int32 i;
} v;
v.i = x;
return v.f;
}
inline double IntBitsToFloat( int64 x )
{
union
{
double f;
int64 i;
} v;
v.i = x;
return v.f;
}
/// Treat the bits of an unsigned-integer as a float encoding.
inline float UintBitsToFloat( uint32 x )
{
union
{
float f;
uint32 i;
} v;
v.i = x;
return v.f;
}
inline double UintBitsToFloat( uint64 x )
{
union
{
double f;
uint64 i;
} v;
v.i = x;
return v.f;
}
/// Retrieve the encoding of a float's bits as a signed-integer.
inline int32 FloatToIntBits( float x )
{
union
{
float f;
int32 i;
} v;
v.f = x;
return v.i;
}
inline int64 FloatToIntBits( double x )
{
union
{
double f;
int64 i;
} v;
v.f = x;
return v.i;
}
/// Retrieve the encoding of a float's bits as an unsigned-integer.
inline uint32 FloatToUintBits( float x )
{
union
{
float f;
uint32 i;
} v;
v.f = x;
return v.i;
}
inline uint64 FloatToUintBits( double x )
{
union
{
double f;
uint64 i;
} v;
v.f = x;
return v.i;
}
/// Check whether a floating-point value is a NAN.
inline bool IsNAN( float x )
{
const uint32 xi = FloatToUintBits( x );
return ( xi & 0x7F800000 ) == 0x7F800000 && ( xi & 0x7FFFFF ) != 0;
}
/// Check whether a floating-point value is infinity.
inline bool IsInf( float x )
{
return ( FloatToUintBits( x ) & 0x7FFFFFFF ) == 0x7F800000;
}
}}
| 22.456897
| 74
| 0.595777
|
NotKyon
|
1fdadc0b7096a0bea6af82390e209a511cde7b36
| 299
|
cpp
|
C++
|
Library/Library.prj/TBButton.cpp
|
rrvt/RWracesDB
|
4f01fed973df7dfb7ec516b2969b20fc6744d7fe
|
[
"MIT"
] | null | null | null |
Library/Library.prj/TBButton.cpp
|
rrvt/RWracesDB
|
4f01fed973df7dfb7ec516b2969b20fc6744d7fe
|
[
"MIT"
] | 1
|
2020-05-01T00:37:31.000Z
|
2020-05-01T00:37:31.000Z
|
Library/Library.prj/TBButton.cpp
|
rrvt/RWracesDB
|
4f01fed973df7dfb7ec516b2969b20fc6744d7fe
|
[
"MIT"
] | 1
|
2020-02-25T09:11:37.000Z
|
2020-02-25T09:11:37.000Z
|
// Toolbar Button (i.e. MFC Tool Bar Button)
#include "stdafx.h"
#include "TBButton.h"
TBButton::TBButton(uint id) : CMFCToolBarButton(id, -1) { }
void TBButton::install(TCchar* caption)
{m_nStyle = TBBS_BUTTON | TBBS_AUTOSIZE; m_strText = caption; m_bText = true; m_bImage = false;}
| 21.357143
| 104
| 0.692308
|
rrvt
|
1fde1f386c04c4a1f8a36b5e634b98ea9cd96fbe
| 2,788
|
hh
|
C++
|
LiteCore/RevTrees/RevID.hh
|
cedseat/couchbase-lite-core
|
451cdfcf527073c595c7cc389f1bd70694e215fb
|
[
"Apache-2.0"
] | 1
|
2019-04-17T07:41:04.000Z
|
2019-04-17T07:41:04.000Z
|
LiteCore/RevTrees/RevID.hh
|
cedseat/couchbase-lite-core
|
451cdfcf527073c595c7cc389f1bd70694e215fb
|
[
"Apache-2.0"
] | 1
|
2020-03-17T11:11:30.000Z
|
2020-03-17T11:11:30.000Z
|
LiteCore/RevTrees/RevID.hh
|
cedseat/couchbase-lite-core
|
451cdfcf527073c595c7cc389f1bd70694e215fb
|
[
"Apache-2.0"
] | null | null | null |
//
// RevID.hh
//
// Copyright (c) 2014 Couchbase, Inc All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#pragma once
#include "Base.hh"
namespace litecore {
enum revidType {
kDigestType,
kClockType
};
/** A compressed revision ID.
Since this is based on slice, it doesn't own the memory it points to.
The data format is the generation as a varint, followed by the digest as raw binary. */
class revid : public slice {
public:
revid() :slice() {}
revid(const void* b, size_t s) :slice(b,s) {}
explicit revid(slice s) :slice(s) {}
alloc_slice expanded() const;
size_t expandedSize() const;
bool expandInto(slice &dst) const;
bool isClock() const {return (*this)[0] == 0;}
unsigned generation() const;
slice digest() const;
uint64_t getGenAndDigest(slice &digest) const;
bool operator< (const revid&) const;
bool operator> (const revid &r) const {return r < *this;}
explicit operator std::string() const;
private:
slice skipFlag() const;
void _expandInto(slice &dst) const;
};
/** A self-contained revid that includes its own data buffer. */
class revidBuffer : public revid {
public:
revidBuffer() :revid(&_buffer, 0) {}
revidBuffer(revid rev) :revid(&_buffer, rev.size)
{memcpy(&_buffer, rev.buf, rev.size);}
explicit revidBuffer(slice s, bool allowClock =false)
:revid(&_buffer, 0)
{parse(s, allowClock);}
revidBuffer(unsigned generation, slice digest, revidType);
revidBuffer(const revidBuffer&);
revidBuffer& operator= (const revidBuffer&);
revidBuffer& operator= (const revid&);
/** Parses a regular (uncompressed) revID and compresses it.
Throws BadRevisionID if the revID isn't in the proper format.*/
void parse(slice, bool allowClock =false);
void parseNew(slice s);
bool tryParse(slice ascii, bool allowClock =false);
private:
uint8_t _buffer[42];
};
}
| 32.8
| 95
| 0.607245
|
cedseat
|
1fe04dedb05770bc65276832e1c58bef77e13ee6
| 21,489
|
cpp
|
C++
|
source/Lib/TLibEncoder/SEIEncoder.cpp
|
henryhuang329/h266
|
ff05b4a10abe3e992a11e5481fa86bc671574a3b
|
[
"BSD-3-Clause"
] | 9
|
2019-10-30T06:29:33.000Z
|
2021-11-19T08:34:08.000Z
|
source/Lib/TLibEncoder/SEIEncoder.cpp
|
hexiaoyi95/DL-HM-16.6-JEM-7.0-dev
|
80206bf91a2be1c62589bee0af4ca4251d0a7e09
|
[
"BSD-3-Clause"
] | null | null | null |
source/Lib/TLibEncoder/SEIEncoder.cpp
|
hexiaoyi95/DL-HM-16.6-JEM-7.0-dev
|
80206bf91a2be1c62589bee0af4ca4251d0a7e09
|
[
"BSD-3-Clause"
] | 2
|
2019-03-29T15:14:34.000Z
|
2019-04-27T10:46:40.000Z
|
/* The copyright in this software is being made available under the BSD
* License, included below. This software may be subject to other third party
* and contributor rights, including patent rights, and no such rights are
* granted under this license.
*
* Copyright (c) 2010-2015, ITU/ISO/IEC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "TLibCommon/CommonDef.h"
#include "TLibCommon/SEI.h"
#include "TEncGOP.h"
#include "TEncTop.h"
//! \ingroup TLibEncoder
//! \{
Void SEIEncoder::initSEIActiveParameterSets (SEIActiveParameterSets *seiActiveParameterSets, const TComVPS *vps, const TComSPS *sps)
{
assert (m_isInitialized);
assert (seiActiveParameterSets!=NULL);
assert (vps!=NULL);
assert (sps!=NULL);
seiActiveParameterSets->activeVPSId = vps->getVPSId();
seiActiveParameterSets->m_selfContainedCvsFlag = false;
seiActiveParameterSets->m_noParameterSetUpdateFlag = false;
seiActiveParameterSets->numSpsIdsMinus1 = 0;
seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId();
}
Void SEIEncoder::initSEIFramePacking(SEIFramePacking *seiFramePacking, Int currPicNum)
{
assert (m_isInitialized);
assert (seiFramePacking!=NULL);
seiFramePacking->m_arrangementId = m_pcCfg->getFramePackingArrangementSEIId();
seiFramePacking->m_arrangementCancelFlag = 0;
seiFramePacking->m_arrangementType = m_pcCfg->getFramePackingArrangementSEIType();
assert((seiFramePacking->m_arrangementType > 2) && (seiFramePacking->m_arrangementType < 6) );
seiFramePacking->m_quincunxSamplingFlag = m_pcCfg->getFramePackingArrangementSEIQuincunx();
seiFramePacking->m_contentInterpretationType = m_pcCfg->getFramePackingArrangementSEIInterpretation();
seiFramePacking->m_spatialFlippingFlag = 0;
seiFramePacking->m_frame0FlippedFlag = 0;
seiFramePacking->m_fieldViewsFlag = (seiFramePacking->m_arrangementType == 2);
seiFramePacking->m_currentFrameIsFrame0Flag = ((seiFramePacking->m_arrangementType == 5) && (currPicNum&1) );
seiFramePacking->m_frame0SelfContainedFlag = 0;
seiFramePacking->m_frame1SelfContainedFlag = 0;
seiFramePacking->m_frame0GridPositionX = 0;
seiFramePacking->m_frame0GridPositionY = 0;
seiFramePacking->m_frame1GridPositionX = 0;
seiFramePacking->m_frame1GridPositionY = 0;
seiFramePacking->m_arrangementReservedByte = 0;
seiFramePacking->m_arrangementPersistenceFlag = true;
seiFramePacking->m_upsampledAspectRatio = 0;
}
Void SEIEncoder::initSEISegmentedRectFramePacking(SEISegmentedRectFramePacking *seiSegmentedRectFramePacking)
{
assert (m_isInitialized);
assert (seiSegmentedRectFramePacking!=NULL);
seiSegmentedRectFramePacking->m_arrangementCancelFlag = m_pcCfg->getSegmentedRectFramePackingArrangementSEICancel();
seiSegmentedRectFramePacking->m_contentInterpretationType = m_pcCfg->getSegmentedRectFramePackingArrangementSEIType();
seiSegmentedRectFramePacking->m_arrangementPersistenceFlag = m_pcCfg->getSegmentedRectFramePackingArrangementSEIPersistence();
}
Void SEIEncoder::initSEIDisplayOrientation(SEIDisplayOrientation* seiDisplayOrientation)
{
assert (m_isInitialized);
assert (seiDisplayOrientation!=NULL);
seiDisplayOrientation->cancelFlag = false;
seiDisplayOrientation->horFlip = false;
seiDisplayOrientation->verFlip = false;
seiDisplayOrientation->anticlockwiseRotation = m_pcCfg->getDisplayOrientationSEIAngle();
}
Void SEIEncoder::initSEIToneMappingInfo(SEIToneMappingInfo *seiToneMappingInfo)
{
assert (m_isInitialized);
assert (seiToneMappingInfo!=NULL);
seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();
seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();
seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag();
seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth();
assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);
seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();
assert(seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17);
seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();
assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);
switch( seiToneMappingInfo->m_modelId)
{
case 0:
{
seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue();
seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue();
break;
}
case 1:
{
seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint();
seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth();
break;
}
case 2:
{
UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth);
seiToneMappingInfo->m_startOfCodedInterval.resize(num);
Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva();
if(ptmp)
{
for(Int i=0; i<num;i++)
{
seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i];
}
}
break;
}
case 3:
{
seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots();
seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots);
seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots);
Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue();
Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue();
if(ptmpcoded&&ptmptarget)
{
for(Int i=0; i<(seiToneMappingInfo->m_numPivots);i++)
{
seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i];
seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i];
}
}
break;
}
case 4:
{
seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc();
seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
seiToneMappingInfo->m_exposureIndexIdc = m_pcCfg->getTMISEIExposurIndexIdc();
seiToneMappingInfo->m_exposureIndexValue = m_pcCfg->getTMISEIExposurIndexValue();
assert( seiToneMappingInfo->m_exposureIndexValue !=0 );
seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc();
seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite();
seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel();
assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );
seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue();
seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue();
assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );
seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue();
assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );
break;
}
default:
{
assert(!"Undefined SEIToneMapModelId");
break;
}
}
}
Void SEIEncoder::initSEISOPDescription(SEISOPDescription *sopDescriptionSEI, TComSlice *slice, Int picInGOP, Int lastIdr, Int currGOPSize)
{
assert (m_isInitialized);
assert (sopDescriptionSEI != NULL);
assert (slice != NULL);
Int sopCurrPOC = slice->getPOC();
sopDescriptionSEI->m_sopSeqParameterSetId = slice->getSPS()->getSPSId();
Int i = 0;
Int prevEntryId = picInGOP;
for (Int j = picInGOP; j < currGOPSize; j++)
{
Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;
if ((sopCurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())
{
sopCurrPOC += deltaPOC;
sopDescriptionSEI->m_sopDescVclNaluType[i] = m_pcEncGOP->getNalUnitType(sopCurrPOC, lastIdr, slice->getPic()->isField());
sopDescriptionSEI->m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
sopDescriptionSEI->m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(sopCurrPOC, j);
sopDescriptionSEI->m_sopDescPocDelta[i] = deltaPOC;
prevEntryId = j;
i++;
}
}
sopDescriptionSEI->m_numPicsInSopMinus1 = i - 1;
}
Void SEIEncoder::initSEIBufferingPeriod(SEIBufferingPeriod *bufferingPeriodSEI, TComSlice *slice)
{
assert (m_isInitialized);
assert (bufferingPeriodSEI != NULL);
assert (slice != NULL);
UInt uiInitialCpbRemovalDelay = (90000/2); // 0.5 sec
bufferingPeriodSEI->m_initialCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay;
bufferingPeriodSEI->m_initialCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay;
bufferingPeriodSEI->m_initialCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay;
bufferingPeriodSEI->m_initialCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay;
Double dTmp = (Double)slice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)slice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale();
UInt uiTmp = (UInt)( dTmp * 90000.0 );
uiInitialCpbRemovalDelay -= uiTmp;
uiInitialCpbRemovalDelay -= uiTmp / ( slice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 );
bufferingPeriodSEI->m_initialAltCpbRemovalDelay [0][0] = uiInitialCpbRemovalDelay;
bufferingPeriodSEI->m_initialAltCpbRemovalDelayOffset[0][0] = uiInitialCpbRemovalDelay;
bufferingPeriodSEI->m_initialAltCpbRemovalDelay [0][1] = uiInitialCpbRemovalDelay;
bufferingPeriodSEI->m_initialAltCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay;
bufferingPeriodSEI->m_rapCpbParamsPresentFlag = 0;
//for the concatenation, it can be set to one during splicing.
bufferingPeriodSEI->m_concatenationFlag = 0;
//since the temporal layer HRD is not ready, we assumed it is fixed
bufferingPeriodSEI->m_auCpbRemovalDelayDelta = 1;
bufferingPeriodSEI->m_cpbDelayOffset = 0;
bufferingPeriodSEI->m_dpbDelayOffset = 0;
}
//! initialize scalable nesting SEI message.
//! Note: The SEI message structures input into this function will become part of the scalable nesting SEI and will be
//! automatically freed, when the nesting SEI is disposed.
Void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, SEIMessages &nestedSEIs)
{
assert (m_isInitialized);
assert (scalableNestingSEI != NULL);
scalableNestingSEI->m_bitStreamSubsetFlag = 1; // If the nested SEI messages are picture buffering SEI messages, picture timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1
scalableNestingSEI->m_nestingOpFlag = 0;
scalableNestingSEI->m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1
scalableNestingSEI->m_allLayersFlag = 0;
scalableNestingSEI->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1
scalableNestingSEI->m_nestingNumLayersMinus1 = 1 - 1; //nesting_num_layers_minus1
scalableNestingSEI->m_nestingLayerId[0] = 0;
scalableNestingSEI->m_nestedSEIs.clear();
for (SEIMessages::iterator it=nestedSEIs.begin(); it!=nestedSEIs.end(); it++)
{
scalableNestingSEI->m_nestedSEIs.push_back((*it));
}
}
Void SEIEncoder::initSEIRecoveryPoint(SEIRecoveryPoint *recoveryPointSEI, TComSlice *slice)
{
assert (m_isInitialized);
assert (recoveryPointSEI != NULL);
assert (slice != NULL);
recoveryPointSEI->m_recoveryPocCnt = 0;
recoveryPointSEI->m_exactMatchingFlag = ( slice->getPOC() == 0 ) ? (true) : (false);
recoveryPointSEI->m_brokenLinkFlag = false;
}
//! calculate hashes for entire reconstructed picture
Void SEIEncoder::initDecodedPictureHashSEI(SEIDecodedPictureHash *decodedPictureHashSEI, TComPic *pcPic, std::string &rHashString, const BitDepths &bitDepths)
{
assert (m_isInitialized);
assert (decodedPictureHashSEI!=NULL);
assert (pcPic!=NULL);
if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 1)
{
decodedPictureHashSEI->method = SEIDecodedPictureHash::MD5;
UInt numChar=calcMD5(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
}
else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 2)
{
decodedPictureHashSEI->method = SEIDecodedPictureHash::CRC;
UInt numChar=calcCRC(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
}
else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 3)
{
decodedPictureHashSEI->method = SEIDecodedPictureHash::CHECKSUM;
UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
}
}
Void SEIEncoder::initTemporalLevel0IndexSEI(SEITemporalLevel0Index *temporalLevel0IndexSEI, TComSlice *slice)
{
assert (m_isInitialized);
assert (temporalLevel0IndexSEI!=NULL);
assert (slice!=NULL);
if (slice->getRapPicFlag())
{
m_tl0Idx = 0;
m_rapIdx = (m_rapIdx + 1) & 0xFF;
}
else
{
m_tl0Idx = (m_tl0Idx + (slice->getTLayer() ? 0 : 1)) & 0xFF;
}
temporalLevel0IndexSEI->tl0Idx = m_tl0Idx;
temporalLevel0IndexSEI->rapIdx = m_rapIdx;
}
Void SEIEncoder::initSEITempMotionConstrainedTileSets (SEITempMotionConstrainedTileSets *sei, const TComPPS *pps)
{
assert (m_isInitialized);
assert (sei!=NULL);
assert (pps!=NULL);
if(pps->getTilesEnabledFlag())
{
sei->m_mc_all_tiles_exact_sample_value_match_flag = false;
sei->m_each_tile_one_tile_set_flag = false;
sei->m_limited_tile_set_display_flag = false;
sei->setNumberOfTileSets((pps->getNumTileColumnsMinus1() + 1) * (pps->getNumTileRowsMinus1() + 1));
for(Int i=0; i < sei->getNumberOfTileSets(); i++)
{
sei->tileSetData(i).m_mcts_id = i; //depends the application;
sei->tileSetData(i).setNumberOfTileRects(1);
for(Int j=0; j<sei->tileSetData(i).getNumberOfTileRects(); j++)
{
sei->tileSetData(i).topLeftTileIndex(j) = i+j;
sei->tileSetData(i).bottomRightTileIndex(j) = i+j;
}
sei->tileSetData(i).m_exact_sample_value_match_flag = false;
sei->tileSetData(i).m_mcts_tier_level_idc_present_flag = false;
}
}
else
{
assert(!"Tile is not enabled");
}
}
Void SEIEncoder::initSEIKneeFunctionInfo(SEIKneeFunctionInfo *seiKneeFunctionInfo)
{
assert (m_isInitialized);
assert (seiKneeFunctionInfo!=NULL);
seiKneeFunctionInfo->m_kneeId = m_pcCfg->getKneeSEIId();
seiKneeFunctionInfo->m_kneeCancelFlag = m_pcCfg->getKneeSEICancelFlag();
if ( !seiKneeFunctionInfo->m_kneeCancelFlag )
{
seiKneeFunctionInfo->m_kneePersistenceFlag = m_pcCfg->getKneeSEIPersistenceFlag();
seiKneeFunctionInfo->m_kneeInputDrange = m_pcCfg->getKneeSEIInputDrange();
seiKneeFunctionInfo->m_kneeInputDispLuminance = m_pcCfg->getKneeSEIInputDispLuminance();
seiKneeFunctionInfo->m_kneeOutputDrange = m_pcCfg->getKneeSEIOutputDrange();
seiKneeFunctionInfo->m_kneeOutputDispLuminance = m_pcCfg->getKneeSEIOutputDispLuminance();
seiKneeFunctionInfo->m_kneeNumKneePointsMinus1 = m_pcCfg->getKneeSEINumKneePointsMinus1();
Int* piInputKneePoint = m_pcCfg->getKneeSEIInputKneePoint();
Int* piOutputKneePoint = m_pcCfg->getKneeSEIOutputKneePoint();
if(piInputKneePoint&&piOutputKneePoint)
{
seiKneeFunctionInfo->m_kneeInputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
seiKneeFunctionInfo->m_kneeOutputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
for(Int i=0; i<=seiKneeFunctionInfo->m_kneeNumKneePointsMinus1; i++)
{
seiKneeFunctionInfo->m_kneeInputKneePoint[i] = piInputKneePoint[i];
seiKneeFunctionInfo->m_kneeOutputKneePoint[i] = piOutputKneePoint[i];
}
}
}
}
Void SEIEncoder::initSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint *seiChromaSamplingFilterHint, Int iHorFilterIndex, Int iVerFilterIndex)
{
assert (m_isInitialized);
assert (seiChromaSamplingFilterHint!=NULL);
seiChromaSamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex;
seiChromaSamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex;
seiChromaSamplingFilterHint->m_verFilteringProcessFlag = 1;
seiChromaSamplingFilterHint->m_targetFormatIdc = 3;
seiChromaSamplingFilterHint->m_perfectReconstructionFlag = false;
if(seiChromaSamplingFilterHint->m_verChromaFilterIdc == 1)
{
seiChromaSamplingFilterHint->m_numVerticalFilters = 1;
seiChromaSamplingFilterHint->m_verTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int));
seiChromaSamplingFilterHint->m_verFilterCoeff = (Int**)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int*));
for(Int i = 0; i < seiChromaSamplingFilterHint->m_numVerticalFilters; i ++)
{
seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] = 0;
seiChromaSamplingFilterHint->m_verFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] * sizeof(Int));
for(Int j = 0; j < seiChromaSamplingFilterHint->m_verTapLengthMinus1[i]; j ++)
{
seiChromaSamplingFilterHint->m_verFilterCoeff[i][j] = 0;
}
}
}
else
{
seiChromaSamplingFilterHint->m_numVerticalFilters = 0;
seiChromaSamplingFilterHint->m_verTapLengthMinus1 = NULL;
seiChromaSamplingFilterHint->m_verFilterCoeff = NULL;
}
if(seiChromaSamplingFilterHint->m_horChromaFilterIdc == 1)
{
seiChromaSamplingFilterHint->m_numHorizontalFilters = 1;
seiChromaSamplingFilterHint->m_horTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int));
seiChromaSamplingFilterHint->m_horFilterCoeff = (Int**)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int*));
for(Int i = 0; i < seiChromaSamplingFilterHint->m_numHorizontalFilters; i ++)
{
seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] = 0;
seiChromaSamplingFilterHint->m_horFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] * sizeof(Int));
for(Int j = 0; j < seiChromaSamplingFilterHint->m_horTapLengthMinus1[i]; j ++)
{
seiChromaSamplingFilterHint->m_horFilterCoeff[i][j] = 0;
}
}
}
else
{
seiChromaSamplingFilterHint->m_numHorizontalFilters = 0;
seiChromaSamplingFilterHint->m_horTapLengthMinus1 = NULL;
seiChromaSamplingFilterHint->m_horFilterCoeff = NULL;
}
}
Void SEIEncoder::initSEITimeCode(SEITimeCode *seiTimeCode)
{
assert (m_isInitialized);
assert (seiTimeCode!=NULL);
// Set data as per command line options
seiTimeCode->numClockTs = m_pcCfg->getNumberOfTimesets();
for(Int i = 0; i < seiTimeCode->numClockTs; i++)
{
seiTimeCode->timeSetArray[i] = m_pcCfg->getTimeSet(i);
}
}
//! \}
| 46.014989
| 236
| 0.742799
|
henryhuang329
|
1fe2bb489e8d44f5d70bbf26d34f9a9dfb270ddb
| 17,794
|
hpp
|
C++
|
include/System/TermInfoDriver.hpp
|
darknight1050/BeatSaber-Quest-Codegen
|
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
|
[
"Unlicense"
] | null | null | null |
include/System/TermInfoDriver.hpp
|
darknight1050/BeatSaber-Quest-Codegen
|
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
|
[
"Unlicense"
] | null | null | null |
include/System/TermInfoDriver.hpp
|
darknight1050/BeatSaber-Quest-Codegen
|
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
|
[
"Unlicense"
] | null | null | null |
// Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "extern/beatsaber-hook/shared/utils/typedefs.h"
// Including type: System.IConsoleDriver
#include "System/IConsoleDriver.hpp"
// Including type: System.ConsoleColor
#include "System/ConsoleColor.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp"
#include "extern/beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp"
#include "extern/beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Begin forward declares
// Forward declaring namespace: System
namespace System {
// Forward declaring type: TermInfoReader
class TermInfoReader;
// Forward declaring type: ByteMatcher
class ByteMatcher;
// Forward declaring type: ConsoleKeyInfo
struct ConsoleKeyInfo;
// Forward declaring type: TermInfoStrings
struct TermInfoStrings;
}
// Forward declaring namespace: System::IO
namespace System::IO {
// Forward declaring type: StreamReader
class StreamReader;
// Forward declaring type: CStreamWriter
class CStreamWriter;
}
// Forward declaring namespace: System::Collections
namespace System::Collections {
// Forward declaring type: Hashtable
class Hashtable;
}
// Completed forward declares
// Type namespace: System
namespace System {
// Size: 0x11C
#pragma pack(push, 1)
// Autogenerated type: System.TermInfoDriver
class TermInfoDriver : public ::Il2CppObject/*, public System::IConsoleDriver*/ {
public:
// private System.TermInfoReader reader
// Size: 0x8
// Offset: 0x10
System::TermInfoReader* reader;
// Field size check
static_assert(sizeof(System::TermInfoReader*) == 0x8);
// private System.Int32 cursorLeft
// Size: 0x4
// Offset: 0x18
int cursorLeft;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Int32 cursorTop
// Size: 0x4
// Offset: 0x1C
int cursorTop;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.String title
// Size: 0x8
// Offset: 0x20
::Il2CppString* title;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String titleFormat
// Size: 0x8
// Offset: 0x28
::Il2CppString* titleFormat;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.Boolean cursorVisible
// Size: 0x1
// Offset: 0x30
bool cursorVisible;
// Field size check
static_assert(sizeof(bool) == 0x1);
// Padding between fields: cursorVisible and: csrVisible
char __padding5[0x7] = {};
// private System.String csrVisible
// Size: 0x8
// Offset: 0x38
::Il2CppString* csrVisible;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String csrInvisible
// Size: 0x8
// Offset: 0x40
::Il2CppString* csrInvisible;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String clear
// Size: 0x8
// Offset: 0x48
::Il2CppString* clear;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String bell
// Size: 0x8
// Offset: 0x50
::Il2CppString* bell;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String term
// Size: 0x8
// Offset: 0x58
::Il2CppString* term;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.IO.StreamReader stdin
// Size: 0x8
// Offset: 0x60
System::IO::StreamReader* stdin;
// Field size check
static_assert(sizeof(System::IO::StreamReader*) == 0x8);
// private System.IO.CStreamWriter stdout
// Size: 0x8
// Offset: 0x68
System::IO::CStreamWriter* stdout;
// Field size check
static_assert(sizeof(System::IO::CStreamWriter*) == 0x8);
// private System.Int32 windowWidth
// Size: 0x4
// Offset: 0x70
int windowWidth;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Int32 windowHeight
// Size: 0x4
// Offset: 0x74
int windowHeight;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Int32 bufferHeight
// Size: 0x4
// Offset: 0x78
int bufferHeight;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Int32 bufferWidth
// Size: 0x4
// Offset: 0x7C
int bufferWidth;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Char[] buffer
// Size: 0x8
// Offset: 0x80
::Array<::Il2CppChar>* buffer;
// Field size check
static_assert(sizeof(::Array<::Il2CppChar>*) == 0x8);
// private System.Int32 readpos
// Size: 0x4
// Offset: 0x88
int readpos;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Int32 writepos
// Size: 0x4
// Offset: 0x8C
int writepos;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.String keypadXmit
// Size: 0x8
// Offset: 0x90
::Il2CppString* keypadXmit;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String keypadLocal
// Size: 0x8
// Offset: 0x98
::Il2CppString* keypadLocal;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.Boolean inited
// Size: 0x1
// Offset: 0xA0
bool inited;
// Field size check
static_assert(sizeof(bool) == 0x1);
// Padding between fields: inited and: initLock
char __padding22[0x7] = {};
// private System.Object initLock
// Size: 0x8
// Offset: 0xA8
::Il2CppObject* initLock;
// Field size check
static_assert(sizeof(::Il2CppObject*) == 0x8);
// private System.Boolean initKeys
// Size: 0x1
// Offset: 0xB0
bool initKeys;
// Field size check
static_assert(sizeof(bool) == 0x1);
// Padding between fields: initKeys and: origPair
char __padding24[0x7] = {};
// private System.String origPair
// Size: 0x8
// Offset: 0xB8
::Il2CppString* origPair;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String origColors
// Size: 0x8
// Offset: 0xC0
::Il2CppString* origColors;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String cursorAddress
// Size: 0x8
// Offset: 0xC8
::Il2CppString* cursorAddress;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.ConsoleColor fgcolor
// Size: 0x4
// Offset: 0xD0
System::ConsoleColor fgcolor;
// Field size check
static_assert(sizeof(System::ConsoleColor) == 0x4);
// Padding between fields: fgcolor and: setfgcolor
char __padding28[0x4] = {};
// private System.String setfgcolor
// Size: 0x8
// Offset: 0xD8
::Il2CppString* setfgcolor;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.String setbgcolor
// Size: 0x8
// Offset: 0xE0
::Il2CppString* setbgcolor;
// Field size check
static_assert(sizeof(::Il2CppString*) == 0x8);
// private System.Int32 maxColors
// Size: 0x4
// Offset: 0xE8
int maxColors;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Boolean noGetPosition
// Size: 0x1
// Offset: 0xEC
bool noGetPosition;
// Field size check
static_assert(sizeof(bool) == 0x1);
// Padding between fields: noGetPosition and: keymap
char __padding32[0x3] = {};
// private System.Collections.Hashtable keymap
// Size: 0x8
// Offset: 0xF0
System::Collections::Hashtable* keymap;
// Field size check
static_assert(sizeof(System::Collections::Hashtable*) == 0x8);
// private System.ByteMatcher rootmap
// Size: 0x8
// Offset: 0xF8
System::ByteMatcher* rootmap;
// Field size check
static_assert(sizeof(System::ByteMatcher*) == 0x8);
// private System.Int32 rl_startx
// Size: 0x4
// Offset: 0x100
int rl_startx;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Int32 rl_starty
// Size: 0x4
// Offset: 0x104
int rl_starty;
// Field size check
static_assert(sizeof(int) == 0x4);
// private System.Byte[] control_characters
// Size: 0x8
// Offset: 0x108
::Array<uint8_t>* control_characters;
// Field size check
static_assert(sizeof(::Array<uint8_t>*) == 0x8);
// private System.Char[] echobuf
// Size: 0x8
// Offset: 0x110
::Array<::Il2CppChar>* echobuf;
// Field size check
static_assert(sizeof(::Array<::Il2CppChar>*) == 0x8);
// private System.Int32 echon
// Size: 0x4
// Offset: 0x118
int echon;
// Field size check
static_assert(sizeof(int) == 0x4);
// Creating value type constructor for type: TermInfoDriver
TermInfoDriver(System::TermInfoReader* reader_ = {}, int cursorLeft_ = {}, int cursorTop_ = {}, ::Il2CppString* title_ = {}, ::Il2CppString* titleFormat_ = {}, bool cursorVisible_ = {}, ::Il2CppString* csrVisible_ = {}, ::Il2CppString* csrInvisible_ = {}, ::Il2CppString* clear_ = {}, ::Il2CppString* bell_ = {}, ::Il2CppString* term_ = {}, System::IO::StreamReader* stdin_ = {}, System::IO::CStreamWriter* stdout_ = {}, int windowWidth_ = {}, int windowHeight_ = {}, int bufferHeight_ = {}, int bufferWidth_ = {}, ::Array<::Il2CppChar>* buffer_ = {}, int readpos_ = {}, int writepos_ = {}, ::Il2CppString* keypadXmit_ = {}, ::Il2CppString* keypadLocal_ = {}, bool inited_ = {}, ::Il2CppObject* initLock_ = {}, bool initKeys_ = {}, ::Il2CppString* origPair_ = {}, ::Il2CppString* origColors_ = {}, ::Il2CppString* cursorAddress_ = {}, System::ConsoleColor fgcolor_ = {}, ::Il2CppString* setfgcolor_ = {}, ::Il2CppString* setbgcolor_ = {}, int maxColors_ = {}, bool noGetPosition_ = {}, System::Collections::Hashtable* keymap_ = {}, System::ByteMatcher* rootmap_ = {}, int rl_startx_ = {}, int rl_starty_ = {}, ::Array<uint8_t>* control_characters_ = {}, ::Array<::Il2CppChar>* echobuf_ = {}, int echon_ = {}) noexcept : reader{reader_}, cursorLeft{cursorLeft_}, cursorTop{cursorTop_}, title{title_}, titleFormat{titleFormat_}, cursorVisible{cursorVisible_}, csrVisible{csrVisible_}, csrInvisible{csrInvisible_}, clear{clear_}, bell{bell_}, term{term_}, stdin{stdin_}, stdout{stdout_}, windowWidth{windowWidth_}, windowHeight{windowHeight_}, bufferHeight{bufferHeight_}, bufferWidth{bufferWidth_}, buffer{buffer_}, readpos{readpos_}, writepos{writepos_}, keypadXmit{keypadXmit_}, keypadLocal{keypadLocal_}, inited{inited_}, initLock{initLock_}, initKeys{initKeys_}, origPair{origPair_}, origColors{origColors_}, cursorAddress{cursorAddress_}, fgcolor{fgcolor_}, setfgcolor{setfgcolor_}, setbgcolor{setbgcolor_}, maxColors{maxColors_}, noGetPosition{noGetPosition_}, keymap{keymap_}, rootmap{rootmap_}, rl_startx{rl_startx_}, rl_starty{rl_starty_}, control_characters{control_characters_}, echobuf{echobuf_}, echon{echon_} {}
// Creating interface conversion operator: operator System::IConsoleDriver
operator System::IConsoleDriver() noexcept {
return *reinterpret_cast<System::IConsoleDriver*>(this);
}
// Get static field: static private System.Int32* native_terminal_size
static int* _get_native_terminal_size();
// Set static field: static private System.Int32* native_terminal_size
static void _set_native_terminal_size(int* value);
// Get static field: static private System.Int32 terminal_size
static int _get_terminal_size();
// Set static field: static private System.Int32 terminal_size
static void _set_terminal_size(int value);
// Get static field: static private readonly System.String[] locations
static ::Array<::Il2CppString*>* _get_locations();
// Set static field: static private readonly System.String[] locations
static void _set_locations(::Array<::Il2CppString*>* value);
// Get static field: static private readonly System.Int32[] _consoleColorToAnsiCode
static ::Array<int>* _get__consoleColorToAnsiCode();
// Set static field: static private readonly System.Int32[] _consoleColorToAnsiCode
static void _set__consoleColorToAnsiCode(::Array<int>* value);
// static private System.String TryTermInfoDir(System.String dir, System.String term)
// Offset: 0x1B3E710
static ::Il2CppString* TryTermInfoDir(::Il2CppString* dir, ::Il2CppString* term);
// static private System.String SearchTerminfo(System.String term)
// Offset: 0x1B3E854
static ::Il2CppString* SearchTerminfo(::Il2CppString* term);
// private System.Void WriteConsole(System.String str)
// Offset: 0x1B3E9D0
void WriteConsole(::Il2CppString* str);
// public System.Void .ctor(System.String term)
// Offset: 0x1B3E9F4
template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary>
static TermInfoDriver* New_ctor(::Il2CppString* term) {
static auto ___internal__logger = ::Logger::get().WithContext("System::TermInfoDriver::.ctor");
return THROW_UNLESS((::il2cpp_utils::New<TermInfoDriver*, creationType>(term)));
}
// public System.Boolean get_Initialized()
// Offset: 0x1B3F038
bool get_Initialized();
// public System.Void Init()
// Offset: 0x1B3F040
void Init();
// private System.Void IncrementX()
// Offset: 0x1B3FA80
void IncrementX();
// public System.Void WriteSpecialKey(System.ConsoleKeyInfo key)
// Offset: 0x1B3FB60
void WriteSpecialKey(System::ConsoleKeyInfo key);
// public System.Void WriteSpecialKey(System.Char c)
// Offset: 0x1B3FE38
void WriteSpecialKey(::Il2CppChar c);
// public System.Boolean IsSpecialKey(System.ConsoleKeyInfo key)
// Offset: 0x1B3FFF0
bool IsSpecialKey(System::ConsoleKeyInfo key);
// public System.Boolean IsSpecialKey(System.Char c)
// Offset: 0x1B40078
bool IsSpecialKey(::Il2CppChar c);
// private System.Void GetCursorPosition()
// Offset: 0x1B3F7D0
void GetCursorPosition();
// private System.Void CheckWindowDimensions()
// Offset: 0x1B401BC
void CheckWindowDimensions();
// public System.Int32 get_WindowHeight()
// Offset: 0x1B3FB28
int get_WindowHeight();
// public System.Int32 get_WindowWidth()
// Offset: 0x1B3FAF0
int get_WindowWidth();
// private System.Void AddToBuffer(System.Int32 b)
// Offset: 0x1B400AC
void AddToBuffer(int b);
// private System.Void AdjustBuffer()
// Offset: 0x1B4031C
void AdjustBuffer();
// private System.ConsoleKeyInfo CreateKeyInfoFromInt(System.Int32 n, System.Boolean alt)
// Offset: 0x1B3FE6C
System::ConsoleKeyInfo CreateKeyInfoFromInt(int n, bool alt);
// private System.Object GetKeyFromBuffer(System.Boolean cooked)
// Offset: 0x1B40330
::Il2CppObject* GetKeyFromBuffer(bool cooked);
// private System.ConsoleKeyInfo ReadKeyInternal(out System.Boolean fresh)
// Offset: 0x1B4061C
System::ConsoleKeyInfo ReadKeyInternal(bool& fresh);
// private System.Boolean InputPending()
// Offset: 0x1B40954
bool InputPending();
// private System.Void QueueEcho(System.Char c)
// Offset: 0x1B40984
void QueueEcho(::Il2CppChar c);
// private System.Void Echo(System.ConsoleKeyInfo key)
// Offset: 0x1B40A7C
void Echo(System::ConsoleKeyInfo key);
// private System.Void EchoFlush()
// Offset: 0x1B40AE0
void EchoFlush();
// public System.Int32 Read(in System.Char[] dest, System.Int32 index, System.Int32 count)
// Offset: 0x1B40B20
int Read(::Array<::Il2CppChar>*& dest, int index, int count);
// public System.ConsoleKeyInfo ReadKey(System.Boolean intercept)
// Offset: 0x1B40E44
System::ConsoleKeyInfo ReadKey(bool intercept);
// public System.String ReadLine()
// Offset: 0x1B40EAC
::Il2CppString* ReadLine();
// public System.String ReadToEnd()
// Offset: 0x1B4109C
::Il2CppString* ReadToEnd();
// private System.String ReadUntilConditionInternal(System.Boolean haltOnNewLine)
// Offset: 0x1B40EB4
::Il2CppString* ReadUntilConditionInternal(bool haltOnNewLine);
// public System.Void SetCursorPosition(System.Int32 left, System.Int32 top)
// Offset: 0x1B3FC88
void SetCursorPosition(int left, int top);
// private System.Void CreateKeyMap()
// Offset: 0x1B410A4
void CreateKeyMap();
// private System.Void InitKeys()
// Offset: 0x1B407F0
void InitKeys();
// private System.Void AddStringMapping(System.TermInfoStrings s)
// Offset: 0x1B42F2C
void AddStringMapping(System::TermInfoStrings s);
// static private System.Void .cctor()
// Offset: 0x1B43018
static void _cctor();
}; // System.TermInfoDriver
#pragma pack(pop)
static check_size<sizeof(TermInfoDriver), 280 + sizeof(int)> __System_TermInfoDriverSizeCheck;
static_assert(sizeof(TermInfoDriver) == 0x11C);
}
DEFINE_IL2CPP_ARG_TYPE(System::TermInfoDriver*, "System", "TermInfoDriver");
| 41.189815
| 2,128
| 0.664943
|
darknight1050
|
1fe62d70db20f26857b21e63f7bd5509d9cfa45e
| 1,854
|
cpp
|
C++
|
src/Text.cpp
|
Alissa0101/CI628
|
f3401e9ea6a90d59572c4f079d27461148aab075
|
[
"MIT"
] | null | null | null |
src/Text.cpp
|
Alissa0101/CI628
|
f3401e9ea6a90d59572c4f079d27461148aab075
|
[
"MIT"
] | null | null | null |
src/Text.cpp
|
Alissa0101/CI628
|
f3401e9ea6a90d59572c4f079d27461148aab075
|
[
"MIT"
] | null | null | null |
#include "Text.h"
void Text::init(int xInit, int yInit, int fontSizeInit, bool boundRightInit, SDL_Color colorInit){
color = colorInit;
x = xInit;
y = yInit;
fontSize = fontSizeInit;
boundRight = boundRightInit;
font = TTF_OpenFont("Assets/pong.ttf", fontSize);
}
void Text::setText(std::string newText){
if (text.compare(newText)) {
color.a = 0;
}
text = newText;
}
void Text::setFontSize(int _fontSize) {
TTF_CloseFont(font);
font = TTF_OpenFont("Assets/pong.ttf", _fontSize);
fontSize = _fontSize;
}
/// <summary>
/// Render text
/// https://stackoverflow.com/questions/36198732/draw-text-to-screen
/// </summary>
/// <param name="renderer"></param>
/// <param name="text"></param>
/// <param name="fontSize"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="boundRight"></param>
void Text::render(SDL_Renderer* renderer){
if(text == ""){text = " "; }
//not great. Find a way to store this somewhere
SDL_Surface* textSurface = TTF_RenderText_Blended(font, text.c_str(), color);
SDL_Texture* textTexture = SDL_CreateTextureFromSurface(renderer, textSurface);
SDL_Rect dest = { x, y, textSurface->w, textSurface->h };
if (centerAlign) {
dest.x = dest.x - textSurface->w / 2;
}
if (boundRight) {
dest = { 800 - static_cast<int>(x) - textSurface->w, static_cast<int>(y), textSurface->w, textSurface->h };
}
SDL_RenderCopy(renderer, textTexture, NULL, &dest);
SDL_FreeSurface(textSurface);
SDL_DestroyTexture(textTexture);
//TTF_CloseFont(font);
//TTF_Quit();
if (color.a < 255) {
if (color.a + 10 > 255) {
color.a = 255;
}
else {
color.a += 10;
}
}
}
void Text::end(){
TTF_CloseFont(font);
TTF_Quit();
}
| 25.39726
| 116
| 0.612729
|
Alissa0101
|
1fe766bf3be4e0571c3110346d7aaef3306c4513
| 979
|
cpp
|
C++
|
27_remove/remove.cpp
|
neojou/leetcode_cplusplus
|
760232172c1e753ee13c376038c8e7b41f6cded7
|
[
"MIT"
] | null | null | null |
27_remove/remove.cpp
|
neojou/leetcode_cplusplus
|
760232172c1e753ee13c376038c8e7b41f6cded7
|
[
"MIT"
] | null | null | null |
27_remove/remove.cpp
|
neojou/leetcode_cplusplus
|
760232172c1e753ee13c376038c8e7b41f6cded7
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <thread>
#include <mutex>
#include <condition_variable>
using namespace std;
template <typename T>
void print_vector(vector<T> const &v)
{
cout << "[";
for (auto it = v.begin(); it != v.end(); it++) {
if (it != v.begin())
cout << ", ";
cout << *it;
}
cout << "]";
}
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int size = nums.size();
int count = 0;
for (int i = 0; i < size; i++) {
if (nums[i] == val)
continue;
nums[count++] = nums[i];
}
return count;
}
};
int main() {
Solution s;
vector<int> nums = {0, 1, 2, 2, 3, 0, 4, 2};
int val = 2;
int k = s.removeElement(nums, val);
vector<int> ret(nums.begin(), nums.begin() + k);
print_vector(ret);
cout << endl;
return 0;
}
| 18.471698
| 52
| 0.52094
|
neojou
|
1fea83f0b0aee856dcf4f75f6cfbd3c63c033ec7
| 3,309
|
cpp
|
C++
|
src/chapter_06_algorithms_and_data_structures/problem_051_transforming_a_list_of_phone_numbers.cpp
|
rturrado/TheModernCppChallenge
|
648284fb417b6aaa43c21ea2b12a5a21c8cb9269
|
[
"MIT"
] | null | null | null |
src/chapter_06_algorithms_and_data_structures/problem_051_transforming_a_list_of_phone_numbers.cpp
|
rturrado/TheModernCppChallenge
|
648284fb417b6aaa43c21ea2b12a5a21c8cb9269
|
[
"MIT"
] | null | null | null |
src/chapter_06_algorithms_and_data_structures/problem_051_transforming_a_list_of_phone_numbers.cpp
|
rturrado/TheModernCppChallenge
|
648284fb417b6aaa43c21ea2b12a5a21c8cb9269
|
[
"MIT"
] | null | null | null |
#include "chapter_06_algorithms_and_data_structures/problem_051_transforming_a_list_of_phone_numbers.h"
#include "chapter_06_algorithms_and_data_structures/phone_numbers.h"
#include "rtc/print.h"
#include <algorithm> // erase_if, transform
#include <fmt/ostream.h>
#include <fmt/ranges.h>
#include <functional> // reference_wrapper
#include <iostream> // cout
#include <regex> // regex_match, regex_replace, smatch
#include <sstream> // ostringstream
using phone_numbers = tmcppc::phone_numbers;
using country_code = tmcppc::country_code;
void format_phone_numbers(phone_numbers& ph_nos, const country_code& cc) {
std::transform(begin(ph_nos), end(ph_nos), begin(ph_nos), [&cc](auto& ph_no) {
// Remove whitespaces
std::regex space_pattern{ R"([[:space:]])" };
ph_no = std::regex_replace(ph_no, space_pattern, "");
// Match a phone number. It can be of the form:
// - +, country code, 10-digit number
// - country code, 10-digit number
// - 0, and then a 10-digit number
// - 10 digit number
// Country codes and 10-digit numbers shouldn't start with 0
std::regex ph_no_pattern{R"((?:0?|([1-9][0-9]*)|\+([1-9][0-9]*))([1-9][0-9]{9}))"};
std::smatch matches{};
std::ostringstream oss{};
if (std::regex_match(ph_no, matches, ph_no_pattern) and
((not matches[1].matched and not matches[2].matched) or
(matches[1].matched and stoi(matches[1]) == static_cast<int>(cc)) or
(matches[2].matched and stoi(matches[2]) == static_cast<int>(cc)))) {
oss << "+" << static_cast<int>(cc) << matches[3]; // outputs +, country code, 10-digit number
}
// Returns whether a formatted phone number or an empty string
return oss.str();
});
// Removes empty strings from the list of phone numbers
std::erase_if(ph_nos, [](auto& ph_no) { return ph_no.empty(); });
}
void problem_51_main(std::ostream& os) {
phone_numbers good_cases{
"07555 111111",
"07555222222",
"+44 7555 333333",
"44 7555 444444",
"7555 555555"
};
phone_numbers bad_cases{
"+1 2345 666666", // correct format, but wrong country code
"34 987 7777777", // same as above
"0 12345678", // doesn't contain a 10-digit number
"+02 1234567890" // country code starts with 0
};
for (auto& ph_nos : std::vector<std::reference_wrapper<phone_numbers>>{ good_cases, bad_cases }) {
fmt::print(os, "List of phone numbers:\n\t{}\n", ph_nos.get());
format_phone_numbers(ph_nos.get(), country_code::UK);
fmt::print(os, "List of UK phone numbers after formatting:\n\t{}\n\n", ph_nos.get());
}
}
// Transforming a list of phone numbers
//
// Write a function that, given a list of phone numbers, transforms them so they all start with a specified country code,
// preceded by the + sign.
// Any whitespaces from a phone number should be removed.
// The following is a list of input and output examples:
//
// 07555 123456 => +447555123456
// 07555123456 => +447555123456
// +44 7555 123456 => +447555123456
// 44 7555 123456 => +447555123456
// 7555 123456 => +447555123456
void problem_51_main() {
problem_51_main(std::cout);
}
| 37.602273
| 121
| 0.64249
|
rturrado
|
1ffd58b46b8d05e4695749e984a01dd8c8b2e5be
| 1,707
|
cc
|
C++
|
coset.cc
|
MadPidgeon/Graph-Isomorphism
|
30fb35a6faad8bda0663d49aff2fca1f2f69c56d
|
[
"MIT"
] | null | null | null |
coset.cc
|
MadPidgeon/Graph-Isomorphism
|
30fb35a6faad8bda0663d49aff2fca1f2f69c56d
|
[
"MIT"
] | null | null | null |
coset.cc
|
MadPidgeon/Graph-Isomorphism
|
30fb35a6faad8bda0663d49aff2fca1f2f69c56d
|
[
"MIT"
] | null | null | null |
#include <stdexcept>
#include <iostream>
#include "coset.h"
#include "group.h"
#include "permutation.h"
#include "ext.h"
Group Coset::supergroup() const {
return _G;
}
Group Coset::subgroup() const {
return _H;
}
bool Coset::isRightCoset() const {
return _right;
}
const Permutation& Coset::representative() const {
return _sigma;
}
bool Coset::operator==( const Coset& other ) const {
if( subgroup()->hasSubgroup(other.subgroup()) && other.subgroup()->hasSubgroup( subgroup() ) && isRightCoset() == other.isRightCoset() )
return subgroup()->contains( representative().inverse() * other.representative() );
throw std::range_error( "Cosets are incomparable" );
}
Coset::Coset( Group G, Group H, Permutation sigma, bool right ) : _sigma( std::move( sigma ) ) {
_G = std::move( G );
_H = std::move( H );
if( _H == nullptr or !_G->hasSubgroup( _H ) )
throw std::range_error( "Can't construct coset since argument is not a subgroup" );
_right = right;
}
std::ostream& operator<<( std::ostream& os, const Coset& c ) {
if( c.isRightCoset() )
return os << c.subgroup()->generators() << c.representative();
else
return os << c.representative() << c.subgroup()->generators();
}
bool Iso::isEmpty() const {
return isSecond();
}
const Coset& Iso::coset() const {
return getFirst();
}
Coset operator*( const Permutation& sigma, const Coset& tauH ) {
// std::cout << tauH << std::endl;
assert( not tauH.isRightCoset() );
Permutation sigmatau = sigma * tauH.representative();
return Coset( tauH.supergroup(), tauH.subgroup(), sigmatau, false );
}
Iso operator*( const Permutation& sigma, const Iso& tauH ) {
if( tauH.isEmpty() )
return tauH;
else
return sigma * tauH.coset();
}
| 25.477612
| 137
| 0.674282
|
MadPidgeon
|
1fffb3f0211b6425028dd3500cab786e788a2019
| 7,950
|
cpp
|
C++
|
src/calibrationfilter.cpp
|
elvisdukaj/calibration_filter
|
2c2c0e9023994977d3d5550f3673e60baadf16eb
|
[
"BSD-2-Clause"
] | null | null | null |
src/calibrationfilter.cpp
|
elvisdukaj/calibration_filter
|
2c2c0e9023994977d3d5550f3673e60baadf16eb
|
[
"BSD-2-Clause"
] | null | null | null |
src/calibrationfilter.cpp
|
elvisdukaj/calibration_filter
|
2c2c0e9023994977d3d5550f3673e60baadf16eb
|
[
"BSD-2-Clause"
] | null | null | null |
// Copyright (c) 2017 Elvis Dukaj
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#include "calibrationfilter.h"
#include <opencv2/core/types_c.h>
#include <opencv2/core.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/imgproc.hpp>
#include <QDebug>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <fstream>
using namespace std;
// Print camera parameters to the output file
static void saveCameraParams(const cv::Mat& cameraMatrix, const cv::Mat& distCoeffs, double totalAvgErr )
{
cv::FileStorage fs( "cameraCalibration.xml", cv::FileStorage::WRITE );
fs << "CameraMatrix" << cameraMatrix;
fs << "DistortionCoefficients" << distCoeffs;
fs << "AvgReprojection_Error" << totalAvgErr;
}
QVideoFilterRunnable* CalibrationFilter::createFilterRunnable()
{
return new CalibrationFilterRunnable(this);
}
CalibrationFilterRunnable::CalibrationFilterRunnable(CalibrationFilter* filter)
: m_filter{filter}
{
}
QVideoFrame CalibrationFilterRunnable::run(QVideoFrame* frame, const QVideoSurfaceFormat&, QVideoFilterRunnable::RunFlags)
{
if (!isFrameValid(frame))
{
qDebug() << "Frame is NOT valid";
return QVideoFrame{};
}
if (!frame->map(QAbstractVideoBuffer::ReadWrite))
{
qDebug() << "Unable to map the videoframe in memory" << endl;
return *frame;
}
try
{
if (m_filter->hasToShowNegative())
showNegative(frame);
else if (!m_filter->isCalibrated())
acquireFrame(frame);
else if(m_filter->isCalibrated() && m_filter->showUnsistorted())
showUndistorted(frame);
else
showFlipped(frame);
}
catch(const std::exception& exc)
{
qDebug() << exc.what();
}
frame->unmap();
return *frame;
}
void CalibrationFilterRunnable::showFlipped(QVideoFrame* frame)
{
cv::Mat frameMat;
convertToCvMat(frame, frameMat);
cv::flip(frameMat, frameMat, 1);
}
void CalibrationFilterRunnable::showNegative(QVideoFrame* frame)
{
cv::Mat frameMat;
convertToCvMat(frame, frameMat);
cv::flip(frameMat, frameMat, 1);
m_lastFrameWithChessBoard.copyTo(
frameMat(cv::Rect{
20, 20,
m_lastFrameWithChessBoard.cols,
m_lastFrameWithChessBoard.rows
}
)
);
}
void CalibrationFilterRunnable::showUndistorted(QVideoFrame* frame)
{
cv::Mat frameMat;
convertToCvMat(frame, frameMat);
cv::flip(frameMat, frameMat, 1);
m_calibrator.remap(frameMat, frameMat );
}
void CalibrationFilterRunnable::acquireFrame(QVideoFrame* frame)
{
cv::Mat frameMat, grayscale;
videoFrameInGrayScaleAndColor(frame, grayscale, frameMat);
auto corners = m_calibrator.findChessboard(grayscale);
if (!corners.empty())
{
cv::drawChessboardCorners(
frameMat,
m_calibrator.boardSize(),
corners,
true
);
emit m_filter->chessBoardFound();
cv::bitwise_not(frameMat, m_lastFrameWithChessBoard);
cv::resize(m_lastFrameWithChessBoard, m_lastFrameWithChessBoard,
cv::Size{0, 0}, 0.25, 0.25
);
m_filter->addGoodFrame();
if (m_filter->goodFrames() == m_filter->maxFrames())
{
auto error = m_calibrator.calibrate(frameMat.size());
saveCameraParams(m_calibrator.cameraMatrix(), m_calibrator.distortion(), error);
qDebug() << "calibration done! Error: " << error;
m_filter->setCalibrated();
emit m_filter->calibrationFinished();
}
}
}
void CalibrationFilterRunnable::convertToCvMat(QVideoFrame *frame, cv::Mat& frameMat)
{
auto width = frame->width();
auto height = frame->height();
auto data = frame->bits();
switch (frame->pixelFormat()) {
case QVideoFrame::Format_RGB32:
frameMat = cv::Mat{height, width, CV_8UC4, data};
return;
case QVideoFrame::Format_RGB24:
frameMat = cv::Mat{height, width, CV_8UC3, data};
return;
case QVideoFrame::Format_YUV420P:
frameMat = cv::Mat{height, width, CV_8UC1, data};
return;
default:
throw std::runtime_error{"Unknown video frame type"};
}
}
vector<cv::Point2f> CameraCalibrator::findChessboard(const cv::Mat& grayscale)
{
vector<cv::Point2f> imageCorners;
if (cv::findChessboardCorners(grayscale, m_boardSize, imageCorners, cv::CALIB_CB_FAST_CHECK))
{
cv::cornerSubPix(
grayscale, imageCorners, m_boardSize,
cv::Size(-1, -1),
cv::TermCriteria{
CV_TERMCRIT_EPS + CV_TERMCRIT_ITER,
300, 0.01}
);
if (imageCorners.size() == m_boardSize.area())
addPoints(imageCorners);
else
imageCorners.clear();
}
return imageCorners;
}
void CameraCalibrator::addPoints(const std::vector<cv::Point2f> &imageCorners)
{
vector<cv::Point3f> objectCorners;
for (auto y = 0; y < m_boardSize.height; ++y)
for (auto x = 0; x < m_boardSize.width; ++x)
objectCorners.push_back(cv::Point3f(y, x, 0.0f));
m_worldObjectPoints.push_back(objectCorners);
m_imagePoints.push_back(imageCorners);
}
using namespace cv;
double CameraCalibrator::calibrate(cv::Size& imageSize)
{
qDebug() << "Calibrating...";
m_mustInitUndistort = true;
// start calibration
auto res = cv::calibrateCamera(
m_worldObjectPoints,
m_imagePoints,
imageSize,
m_cameraMatrix,
m_distCoeffs,
m_rotationVecs,
m_translationtVecs
);
cout << "Camera matrix: " << m_cameraMatrix << '\n'
<< "Camera distortion: " << m_distCoeffs << '\n'
<< endl;
return res;
}
void CameraCalibrator::CameraCalibrator::remap(const cv::Mat& image, cv::Mat& outImage)
{
if (m_mustInitUndistort)
{
cv::initUndistortRectifyMap(
m_cameraMatrix, // computed camera matrix
m_distCoeffs, // computed distortion matrix
cv::Mat(), // optional rectification (none)
cv::Mat(), // camera matrix to generate undistorted
image.size(), // size of undistorted
CV_32FC1, // type of output map
m_mapX, m_mapY // the x and y mapping functions
);
m_mustInitUndistort = false;
}
// Apply mapping functions
cv::remap(image, outImage, m_mapX, m_mapY, cv::INTER_LINEAR);
}
| 30.113636
| 122
| 0.619623
|
elvisdukaj
|
95019acff0b42b3b77a730c4be4450b8d3b45c09
| 4,117
|
cpp
|
C++
|
bindings/python/src/LibraryPhysicsPy/Environment/Objects/Celestial.cpp
|
cowlicks/library-physics
|
dd314011132430fcf074a9a1633b24471745cf92
|
[
"Apache-2.0"
] | null | null | null |
bindings/python/src/LibraryPhysicsPy/Environment/Objects/Celestial.cpp
|
cowlicks/library-physics
|
dd314011132430fcf074a9a1633b24471745cf92
|
[
"Apache-2.0"
] | null | null | null |
bindings/python/src/LibraryPhysicsPy/Environment/Objects/Celestial.cpp
|
cowlicks/library-physics
|
dd314011132430fcf074a9a1633b24471745cf92
|
[
"Apache-2.0"
] | null | null | null |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @project Library ▸ Physics
/// @file LibraryPhysicsPy/Environment/Objects/Celestial.cpp
/// @author Lucas Brémond <lucas@loftorbital.com>
/// @license Apache License 2.0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Library/Physics/Environment/Objects/Celestial.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline void LibraryPhysicsPy_Environment_Objects_Celestial ( )
{
using namespace boost::python ;
using library::core::types::Shared ;
using library::core::types::Real ;
using library::core::types::String ;
using library::physics::time::Instant ;
using library::physics::units::Length ;
using library::physics::units::Derived ;
using library::physics::env::Ephemeris ;
using library::physics::env::Object ;
using library::physics::env::obj::Celestial ;
using GravitationalModel = library::physics::environment::gravitational::Model ;
using MagneticModel = library::physics::environment::magnetic::Model ;
scope in_Celestial = class_<Celestial, bases<Object>>("Celestial", init<const String&, const Celestial::Type&, const Derived& , const Length&, const Real&, const Real&, const Shared<Ephemeris>&, const Shared<GravitationalModel>&, const Shared<MagneticModel>&, const Instant&>())
.def(init<const String&, const Celestial::Type&, const Derived& , const Length&, const Real&, const Real&, const Shared<Ephemeris>&, const Shared<GravitationalModel>&, const Shared<MagneticModel>&, const Instant&, const Object::Geometry&>())
// .def(self == self)
// .def(self != self)
.def(self_ns::str(self_ns::self))
.def(self_ns::repr(self_ns::self))
.def("isDefined", &Celestial::isDefined)
.def("accessEphemeris", &Celestial::accessEphemeris)
.def("accessGravitationalModel", &Celestial::accessGravitationalModel)
.def("accessMagneticModel", &Celestial::accessMagneticModel)
.def("getType", &Celestial::getType)
.def("getGravitationalParameter", &Celestial::getGravitationalParameter)
.def("getEquatorialRadius", &Celestial::getEquatorialRadius)
.def("getFlattening", &Celestial::getFlattening)
.def("getJ2", &Celestial::getJ2)
// .def("accessFrame", &Celestial::accessFrame)
.def("getPositionIn", &Celestial::getPositionIn)
.def("getTransformTo", &Celestial::getTransformTo)
.def("getAxesIn", &Celestial::getAxesIn)
.def("getGravitationalFieldAt", &Celestial::getGravitationalFieldAt)
.def("getMagneticFieldAt", &Celestial::getMagneticFieldAt)
.def("getFrameAt", &Celestial::getFrameAt)
.def("Undefined", &Celestial::Undefined).staticmethod("Undefined")
.def("StringFromFrameType", &Celestial::StringFromFrameType).staticmethod("StringFromFrameType")
;
enum_<Celestial::Type>("Type")
.value("Undefined", Celestial::Type::Undefined)
.value("Sun", Celestial::Type::Sun)
.value("Mercury", Celestial::Type::Mercury)
.value("Venus", Celestial::Type::Venus)
.value("Earth", Celestial::Type::Earth)
.value("Moon", Celestial::Type::Moon)
.value("Mars", Celestial::Type::Mars)
;
enum_<Celestial::FrameType>("FrameType")
.value("Undefined", Celestial::FrameType::Undefined)
.value("NED", Celestial::FrameType::NED)
;
register_ptr_to_python<Shared<const Celestial>>() ;
implicitly_convertible<Shared<Celestial>, Shared<const Celestial>>() ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| 44.268817
| 282
| 0.564732
|
cowlicks
|
9506265b265d32b0372b9e77ce96ec2d9806cdc4
| 10,239
|
cc
|
C++
|
src/table_file_iterator.cc
|
tobecontinued/Jungle
|
d06eb7915de4b1489b4cd0ead5b7281e8a8b82c4
|
[
"Apache-2.0"
] | 157
|
2019-12-27T18:12:19.000Z
|
2022-03-27T13:34:52.000Z
|
src/table_file_iterator.cc
|
tobecontinued/Jungle
|
d06eb7915de4b1489b4cd0ead5b7281e8a8b82c4
|
[
"Apache-2.0"
] | 11
|
2020-01-02T18:30:33.000Z
|
2021-09-28T03:10:09.000Z
|
src/table_file_iterator.cc
|
tobecontinued/Jungle
|
d06eb7915de4b1489b4cd0ead5b7281e8a8b82c4
|
[
"Apache-2.0"
] | 32
|
2019-12-28T18:17:27.000Z
|
2021-12-24T02:05:10.000Z
|
/************************************************************************
Copyright 2017-2019 eBay 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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**************************************************************************/
#include "table_file.h"
#include "table_mgr.h"
namespace jungle {
// === iterator ===============================================================
TableFile::Iterator::Iterator()
: tFile(nullptr)
, tFileSnap(nullptr)
, fdbSnap(nullptr)
, fdbItr(nullptr)
, minSeq(NOT_INITIALIZED)
, maxSeq(NOT_INITIALIZED)
{}
TableFile::Iterator::~Iterator() {
close();
}
Status TableFile::Iterator::init(DB* snap_handle,
TableFile* t_file,
const SizedBuf& start_key,
const SizedBuf& end_key)
{
tFile = t_file;
fdb_status fs;
Status s;
// Get last snap marker.
fdb_kvs_handle* fdb_snap = nullptr;
if (snap_handle) {
// Snapshot.
mGuard l(t_file->snapHandlesLock);
auto entry = t_file->snapHandles.find(snap_handle);
if (entry == t_file->snapHandles.end()) return Status::SNAPSHOT_NOT_FOUND;
fdb_kvs_handle* snap_src = entry->second;
fdb_seqnum_t snap_seqnum = 0;
fs = fdb_get_kvs_seqnum(snap_src, &snap_seqnum);
if (fs != FDB_RESULT_SUCCESS) return Status::INVALID_SNAPSHOT;
fs = fdb_snapshot_open( snap_src,
&fdbSnap,
snap_seqnum );
if (fs != FDB_RESULT_SUCCESS) return Status::FDB_OPEN_KVS_FAIL;
fdb_snap = fdbSnap;
} else {
// Normal, use latest snapshot.
tFile->leaseSnapshot(tFileSnap);
fs = fdb_snapshot_open( tFileSnap->fdbSnap,
&fdbSnap,
tFileSnap->fdbSeqnum );
if (fs != FDB_RESULT_SUCCESS) return Status::FDB_OPEN_KVS_FAIL;
fdb_snap = fdbSnap;
}
// if (valid_number(chk) && snap_seqnum > chk) snap_seqnum = chk;
fs = fdb_iterator_init(fdb_snap, &fdbItr,
start_key.data, start_key.size,
end_key.data, end_key.size,
FDB_ITR_NO_DELETES);
if (fs != FDB_RESULT_SUCCESS) return Status::FDB_OPEN_KVS_FAIL;
type = BY_KEY;
return Status();
}
Status TableFile::Iterator::initSN(DB* snap_handle,
TableFile* t_file,
const uint64_t min_seq,
const uint64_t max_seq)
{
tFile = t_file;
fdb_status fs;
Status s;
// Get last snap marker.
fdb_seqnum_t snap_seqnum = 0;
fdb_kvs_handle* fdb_snap = nullptr;
if (snap_handle) {
// Snapshot.
mGuard l(t_file->snapHandlesLock);
auto entry = t_file->snapHandles.find(snap_handle);
if (entry == t_file->snapHandles.end()) return Status::SNAPSHOT_NOT_FOUND;
fdb_kvs_handle* snap_src = entry->second;
fs = fdb_get_kvs_seqnum(snap_src, &snap_seqnum);
if (fs != FDB_RESULT_SUCCESS) return Status::INVALID_SNAPSHOT;
fs = fdb_snapshot_open( snap_src,
&fdbSnap,
snap_seqnum );
if (fs != FDB_RESULT_SUCCESS) return Status::FDB_OPEN_KVS_FAIL;
fdb_snap = fdbSnap;
} else {
// Normal, use latest snapshot.
tFile->leaseSnapshot(tFileSnap);
fs = fdb_snapshot_open( tFileSnap->fdbSnap,
&fdbSnap,
tFileSnap->fdbSeqnum );
if (fs != FDB_RESULT_SUCCESS) return Status::FDB_OPEN_KVS_FAIL;
fdb_snap = fdbSnap;
}
// if (valid_number(chk) && snap_seqnum > chk) snap_seqnum = chk;
if (valid_number(min_seq)) {
minSeq = min_seq;
} else {
minSeq = 0;
}
if (valid_number(max_seq)) {
// If `snap_seqnum` is zero and `max_seq` is given,
// we should honor `max_seq`.
if (snap_seqnum) {
maxSeq = std::min(snap_seqnum, max_seq);
} else {
maxSeq = max_seq;
}
} else {
maxSeq = 0;
}
fs = fdb_iterator_sequence_init(fdb_snap, &fdbItr,
minSeq, maxSeq,
FDB_ITR_NO_DELETES);
if (fs != FDB_RESULT_SUCCESS) return Status::FDB_OPEN_KVS_FAIL;
type = BY_SEQ;
return Status();
}
Status TableFile::Iterator::get(Record& rec_out) {
if (!tFile || !fdbItr) return Status::NOT_INITIALIZED;
fdb_status fs;
fdb_doc tmp_doc;
memset(&tmp_doc, 0x0, sizeof(tmp_doc));
fdb_doc *doc = &tmp_doc;
fs = fdb_iterator_get(fdbItr, &doc);
if (fs != FDB_RESULT_SUCCESS) {
return Status::ERROR;
}
rec_out.kv.key.set(doc->keylen, doc->key);
rec_out.kv.key.setNeedToFree();
rec_out.kv.value.set(doc->bodylen, doc->body);
rec_out.kv.value.setNeedToFree();
// Decode meta.
SizedBuf user_meta_out;
SizedBuf raw_meta(doc->metalen, doc->meta);;
SizedBuf::Holder h_raw_meta(raw_meta); // auto free raw meta.
raw_meta.setNeedToFree();
InternalMeta i_meta;
TableFile::rawMetaToUserMeta(raw_meta, i_meta, user_meta_out);
user_meta_out.moveTo( rec_out.meta );
// Decompress if needed.
DB* parent_db = tFile->tableMgr->getParentDb();
const DBConfig* db_config = tFile->tableMgr->getDbConfig();
try {
Status s;
TC( tFile->decompressValue(parent_db, db_config, rec_out, i_meta) );
rec_out.seqNum = doc->seqnum;
rec_out.type = (i_meta.isTombstone || doc->deleted)
? Record::DELETION
: Record::INSERTION;
return Status();
} catch (Status s) {
rec_out.kv.free();
rec_out.meta.free();
return s;
}
}
Status TableFile::Iterator::getMeta(Record& rec_out,
size_t& valuelen_out,
uint64_t& offset_out)
{
if (!tFile || !fdbItr) return Status::NOT_INITIALIZED;
fdb_status fs;
fdb_doc tmp_doc;
memset(&tmp_doc, 0x0, sizeof(tmp_doc));
fdb_doc *doc = &tmp_doc;
fs = fdb_iterator_get_metaonly(fdbItr, &doc);
if (fs != FDB_RESULT_SUCCESS) {
return Status::ERROR;
}
rec_out.kv.key.set(doc->keylen, doc->key);
rec_out.kv.key.setNeedToFree();
valuelen_out = doc->bodylen;
offset_out = doc->offset;
// Decode meta.
SizedBuf user_meta_out;
SizedBuf raw_meta(doc->metalen, doc->meta);;
SizedBuf::Holder h_raw_meta(raw_meta); // auto free raw meta.
raw_meta.setNeedToFree();
InternalMeta i_meta;
TableFile::rawMetaToUserMeta(raw_meta, i_meta, user_meta_out);
user_meta_out.moveTo( rec_out.meta );
rec_out.seqNum = doc->seqnum;
rec_out.type = (i_meta.isTombstone || doc->deleted)
? Record::DELETION
: Record::INSERTION;
return Status();
}
Status TableFile::Iterator::prev() {
if (!tFile || !fdbItr) return Status::NOT_INITIALIZED;
fdb_status fs;
fs = fdb_iterator_prev(fdbItr);
if (fs != FDB_RESULT_SUCCESS) {
fs = fdb_iterator_next(fdbItr);
assert(fs == FDB_RESULT_SUCCESS);
return Status::OUT_OF_RANGE;
}
return Status();
}
Status TableFile::Iterator::next() {
if (!tFile || !fdbItr) return Status::NOT_INITIALIZED;
fdb_status fs;
fs = fdb_iterator_next(fdbItr);
if (fs != FDB_RESULT_SUCCESS) {
fs = fdb_iterator_prev(fdbItr);
assert(fs == FDB_RESULT_SUCCESS);
return Status::OUT_OF_RANGE;
}
return Status();
}
Status TableFile::Iterator::seek(const SizedBuf& key, SeekOption opt) {
if (key.empty()) return gotoBegin();
if (!tFile || !fdbItr) return Status::NOT_INITIALIZED;
fdb_status fs;
fdb_iterator_seek_opt_t fdb_seek_opt =
(opt == GREATER)
? FDB_ITR_SEEK_HIGHER
: FDB_ITR_SEEK_LOWER;
fs = fdb_iterator_seek(fdbItr, key.data, key.size, fdb_seek_opt);
if (fs != FDB_RESULT_SUCCESS) {
if (opt == GREATER) {
fs = fdb_iterator_seek_to_max(fdbItr);
} else {
fs = fdb_iterator_seek_to_min(fdbItr);
}
if (fs != FDB_RESULT_SUCCESS) return Status::OUT_OF_RANGE;
}
return Status();
}
Status TableFile::Iterator::seekSN(const uint64_t seqnum, SeekOption opt) {
if (!tFile || !fdbItr) return Status::NOT_INITIALIZED;
fdb_status fs;
fdb_iterator_seek_opt_t fdb_seek_opt =
(opt == GREATER)
? FDB_ITR_SEEK_HIGHER
: FDB_ITR_SEEK_LOWER;
fs = fdb_iterator_seek_byseq(fdbItr, seqnum, fdb_seek_opt);
if (fs != FDB_RESULT_SUCCESS) {
if (opt == GREATER) {
fs = fdb_iterator_seek_to_max(fdbItr);
} else {
fs = fdb_iterator_seek_to_min(fdbItr);
}
assert(fs == FDB_RESULT_SUCCESS);
}
return Status();
}
Status TableFile::Iterator::gotoBegin() {
if (!tFile || !fdbItr) return Status::NOT_INITIALIZED;
fdb_status fs;
fs = fdb_iterator_seek_to_min(fdbItr);
(void)fs;
return Status();
}
Status TableFile::Iterator::gotoEnd() {
if (!tFile || !fdbItr) return Status::NOT_INITIALIZED;
fdb_status fs;
fs = fdb_iterator_seek_to_max(fdbItr);
(void)fs;
return Status();
}
Status TableFile::Iterator::close() {
if (fdbItr) {
fdb_iterator_close(fdbItr);
fdbItr = nullptr;
}
if (fdbSnap) {
fdb_kvs_close(fdbSnap);
fdbSnap = nullptr;
}
if (tFileSnap) {
tFile->returnSnapshot(tFileSnap);
tFileSnap = nullptr;
}
return Status();
}
}; // namespace jungle
| 28.600559
| 82
| 0.589608
|
tobecontinued
|
9507904b1fb189149a19d72c8f53d83af78b66a9
| 547
|
hpp
|
C++
|
src/canvas.hpp
|
kalsipp/SDL-turbo-enigma
|
f5883e5b766ea701a5343bc36d21d078eeba0e79
|
[
"MIT"
] | null | null | null |
src/canvas.hpp
|
kalsipp/SDL-turbo-enigma
|
f5883e5b766ea701a5343bc36d21d078eeba0e79
|
[
"MIT"
] | null | null | null |
src/canvas.hpp
|
kalsipp/SDL-turbo-enigma
|
f5883e5b766ea701a5343bc36d21d078eeba0e79
|
[
"MIT"
] | null | null | null |
#pragma once
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_mixer.h>
#include "logger.hpp"
#include "texture.hpp"
class Texture;
class Canvas{
public:
Canvas();
~Canvas();
void addTexture(Texture * );
void paint();
void clear();
SDL_Surface * getSurface();
SDL_Renderer * getRenderer();
private:
bool init();
Logger * m_log = NULL;
SDL_Window * m_window = NULL;
SDL_Surface * m_surface = NULL;
SDL_Renderer * m_renderer = NULL;
int m_screen_width = 1000;
int m_screen_height = 1000;
};
| 21.038462
| 34
| 0.709324
|
kalsipp
|
950ab831ac04f4f87452086c91d9aa28a35b4d4a
| 341
|
cpp
|
C++
|
Sandbox/test.cpp
|
pr0me7heu2/CSCI_121
|
001cdb29b94b94b29417a494e4d0fca4af38c138
|
[
"Apache-2.0"
] | 2
|
2020-09-15T04:03:40.000Z
|
2020-10-14T01:37:32.000Z
|
Sandbox/test.cpp
|
pr0me7heu2/CSCI_121
|
001cdb29b94b94b29417a494e4d0fca4af38c138
|
[
"Apache-2.0"
] | null | null | null |
Sandbox/test.cpp
|
pr0me7heu2/CSCI_121
|
001cdb29b94b94b29417a494e4d0fca4af38c138
|
[
"Apache-2.0"
] | null | null | null |
//
// Created by bryan on 2/10/19.
//
#include <iostream>
#include <cassert>
int main()
{
using namespace std;
int n1, n2;
cout << "how many" << endl;
cin >> n1 >> n2;
//assert(n1 > 0);
cout <<"n1 is not bigger than zero." << endl;
cout << "here they are." << endl;
cout << n1 << n2;
return 0;
}
| 12.62963
| 49
| 0.513196
|
pr0me7heu2
|
950f5165090f49a1c8c9e98b5fc7957bac9ab7b0
| 749
|
hpp
|
C++
|
Feather/src/Feather.hpp
|
pedrolmcastro/feather
|
e4581fb119706505dfcb25b5d982b47ee21e0746
|
[
"Apache-2.0"
] | null | null | null |
Feather/src/Feather.hpp
|
pedrolmcastro/feather
|
e4581fb119706505dfcb25b5d982b47ee21e0746
|
[
"Apache-2.0"
] | null | null | null |
Feather/src/Feather.hpp
|
pedrolmcastro/feather
|
e4581fb119706505dfcb25b5d982b47ee21e0746
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
#include "Precompiled.hpp"
#include "Core/Time.hpp"
#include "Core/Event.hpp"
#include "Core/Layer.hpp"
#include "Core/Application.hpp"
#include "Debug/Log.hpp"
#include "Debug/Assert.hpp"
#include "Input/Key.hpp"
#include "Input/Input.hpp"
#include "Input/Mouse.hpp"
#include "Math/Bool.hpp"
#include "Math/Matrix.hpp"
#include "Math/Vector.hpp"
#include "Math/Quaternion.hpp"
// TODO: Review Render Exposition
#include "Render/Index.hpp"
#include "Render/Vertex.hpp"
#include "Render/Shader.hpp"
#include "Render/Window.hpp"
#include "Render/Command.hpp"
#include "Render/Texture.hpp"
#include "Scene/Scene.hpp"
#include "Scene/Entity.hpp"
#include "Scene/Viewer.hpp"
#include "Scene/Component.hpp"
#include "Core/Entry.hpp"
| 20.243243
| 33
| 0.740988
|
pedrolmcastro
|
95118a49614bed4fafb6a6e67d39fc851ec2076e
| 2,230
|
cpp
|
C++
|
201804/dec201804_1.cpp
|
jibsen/aocpp2018
|
fdaa1adfd12963ef8f530bbe3f8542843486e1c9
|
[
"MIT"
] | 2
|
2020-04-26T17:31:29.000Z
|
2020-10-03T00:54:15.000Z
|
201804/dec201804_1.cpp
|
jibsen/aocpp2018
|
fdaa1adfd12963ef8f530bbe3f8542843486e1c9
|
[
"MIT"
] | null | null | null |
201804/dec201804_1.cpp
|
jibsen/aocpp2018
|
fdaa1adfd12963ef8f530bbe3f8542843486e1c9
|
[
"MIT"
] | null | null | null |
//
// Advent of Code 2018, day 4, part one
//
#include <algorithm>
#include <array>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using Event = std::pair<long long, std::string>;
using SleepSchedule = std::vector<std::pair<int, int>>;
bool get_timestamp(long long &ts)
{
int year, month, day, hour, minute;
if (scanf("[%d-%d-%d %d:%d] ", &year, &month, &day, &hour, &minute) == 5) {
ts = year * 100000000LL
+ month * 1000000LL
+ day * 10000LL
+ hour * 100LL
+ minute;
return true;
}
return false;
}
std::vector<Event> read_events()
{
std::vector<Event> events;
std::string line;
long long ts = 0;
while (get_timestamp(ts) && std::getline(std::cin, line)) {
events.emplace_back(ts, line);
}
return events;
}
std::map<int, SleepSchedule> get_guard_sleep_schedules(const std::vector<Event> &events)
{
std::map<int, SleepSchedule> schedules;
int guard = -1;
std::vector<int> minutes;
for (const auto &[ts, line] : events) {
if (auto p = line.find('#'); p != std::string::npos) {
guard = std::stoi(line.substr(p + 1));
continue;
}
minutes.push_back(ts % 100);
if (minutes.size() == 2) {
schedules[guard].push_back({minutes[0], minutes[1]});
minutes.clear();
}
}
return schedules;
}
int minute_most_asleep(const SleepSchedule &schedule)
{
std::array<int, 60> sleep_freq = {};
for (const auto &period : schedule) {
for (int i = period.first; i < period.second; ++i) {
sleep_freq[i]++;
}
}
return std::distance(sleep_freq.begin(), std::max_element(sleep_freq.begin(), sleep_freq.end()));
}
int main()
{
auto events = read_events();
std::sort(events.begin(), events.end());
auto schedules = get_guard_sleep_schedules(events);
int max_time = std::numeric_limits<int>::min();
int max_guard = -1;
for (const auto &[guard, schedule] : schedules) {
int time = std::accumulate(schedule.begin(), schedule.end(), 0,
[](int acc, const auto &period) {
return acc + (period.second - period.first);
});
if (time > max_time) {
max_time = time;
max_guard = guard;
}
}
std::cout << max_guard * minute_most_asleep(schedules[max_guard]) << '\n';
return 0;
}
| 20.09009
| 98
| 0.638565
|
jibsen
|
951782d3d7d71d56e25e75b5d02271395d29c296
| 812
|
cc
|
C++
|
LeetCode/Hard/waterTrap.cc
|
ChakreshSinghUC/CPPCodes
|
d82a3f467303566afbfcc927b660b0f7bf7c0432
|
[
"MIT"
] | null | null | null |
LeetCode/Hard/waterTrap.cc
|
ChakreshSinghUC/CPPCodes
|
d82a3f467303566afbfcc927b660b0f7bf7c0432
|
[
"MIT"
] | null | null | null |
LeetCode/Hard/waterTrap.cc
|
ChakreshSinghUC/CPPCodes
|
d82a3f467303566afbfcc927b660b0f7bf7c0432
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
using namespace std;
class Solution
{
public:
int trap(vector<int> &height)
{
int left = 0, right = height.size() - 1;
int ans = 0;
int left_max = 0, right_max = 0;
while (left < right)
{
if (height[left] < height[right])
{
height[left] >= left_max ? (left_max = height[left]) : ans += (left_max - height[left]);
++left;
}
else
{
height[right] >= right_max ? (right_max = height[right]) : ans += (right_max - height[right]);
--right;
}
}
};
int main()
{
Solution o;
vector<int> h = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1};
cout << o.trap(h);
}
| 26.193548
| 110
| 0.439655
|
ChakreshSinghUC
|
951908950b6eb51f9420cfd4e39482a835803e3a
| 3,169
|
cc
|
C++
|
whale/src/dbi/x86_64/instruction_rewriter_x86_64.cc
|
QiYueColdRain/whale
|
ab62303c8146d7a79f89c7b26a6625cbcf65b0f9
|
[
"Apache-2.0"
] | 1,333
|
2019-01-27T03:46:51.000Z
|
2022-03-31T05:28:23.000Z
|
whale/src/dbi/x86_64/instruction_rewriter_x86_64.cc
|
QiYueColdRain/whale
|
ab62303c8146d7a79f89c7b26a6625cbcf65b0f9
|
[
"Apache-2.0"
] | 59
|
2019-02-01T09:57:25.000Z
|
2022-03-09T09:40:33.000Z
|
whale/src/dbi/x86_64/instruction_rewriter_x86_64.cc
|
QiYueColdRain/whale
|
ab62303c8146d7a79f89c7b26a6625cbcf65b0f9
|
[
"Apache-2.0"
] | 309
|
2019-01-29T11:41:14.000Z
|
2022-03-31T06:10:38.000Z
|
#include "dbi/x86/instruction_rewriter_x86.h"
#include "instruction_rewriter_x86_64.h"
#include "dbi/x86/distorm/distorm.h"
#include "dbi/x86/distorm/mnemonics.h"
#define __ masm_->
namespace whale {
namespace x86_64 {
constexpr static const unsigned kRIP_index = 74;
void X86_64InstructionRewriter::Rewrite() {
u1 *instructions = code_->GetInstructions<u1>();
int pos = 0;
size_t count = code_->GetCount<u1>();
u8 pc = cfg_pc_;
while (pos < code_->GetCount<u1>()) {
u1 *current = instructions + pos;
_DInst insn = Decode(current, count - pos, 1);
pc += insn.size;
switch (insn.opcode) {
case I_MOV:
Rewrite_Mov(current, pc, insn);
break;
case I_CALL:
Rewrite_Call(current, pc, insn);
break;
case I_JMP:
Rewrite_Jmp(current, pc, insn);
break;
case I_JECXZ:
case I_JRCXZ:
Rewrite_JRCXZ(current, pc, insn);
break;
default:
EmitCode(current, insn.size);
break;
}
pos += insn.size;
}
}
void X86_64InstructionRewriter::Rewrite_Mov(u1 *current, u8 pc, _DInst insn) {
_Operand op0 = insn.ops[0];
_Operand op1 = insn.ops[1];
if (op0.type == O_REG && op1.type == O_SMEM && op1.index == kRIP_index) {
// mov rd, nword ptr [rip + disp]
int rd = insn.ops[0].index % 16;
__ movq(rd, Immediate(pc + insn.disp));
__ movl(rd, Address(rd, 0));
} else if (op0.type == O_SMEM && op1.type == O_IMM && op1.index == kRIP_index) {
// mov nword ptr [rip + disp], imm
__ pushq(RAX);
__ movq(RAX, Immediate(pc + insn.disp));
if (op1.size <= 32) {
__ movl(Address(RAX, 0), Immediate(insn.imm.dword));
} else {
__ movq(Address(RAX, 0), Immediate(insn.imm.qword));
}
__ popq(RAX);
} else {
EmitCode(current, insn.size);
}
}
void X86_64InstructionRewriter::Rewrite_Call(u1 *current, u8 pc, _DInst insn) {
_Operand op = insn.ops[0];
if (op.type == O_PC) {
__ movq(R11, Immediate(pc + insn.imm.qword));
__ call(R11);
} else {
EmitCode(current, insn.size);
}
}
void X86_64InstructionRewriter::Rewrite_Jmp(u1 *current, u8 pc, _DInst insn) {
_Operand op = insn.ops[0];
if (op.type == O_PC) {
__ movq(R11, Immediate(pc + insn.imm.qword));
__ jmp(R11);
} else {
EmitCode(current, insn.size);
}
}
void X86_64InstructionRewriter::Rewrite_JRCXZ(u1 *current, u8 pc, _DInst insn) {
bool rewritten = false;
u8 pcrel_address = pc + insn.imm.qword;
if (pcrel_address >= tail_pc_) {
NearLabel true_label, false_label;
__ jrcxz(&true_label);
__ jmp(&false_label);
__ Bind(&true_label);
__ movq(R11, Immediate(pcrel_address));
__ jmp(R11);
__ Bind(&false_label);
rewritten = true;
}
if (!rewritten) {
EmitCode(current, insn.size);
}
}
} // namespace x86
} // namespace whale
| 28.294643
| 84
| 0.561691
|
QiYueColdRain
|
951a7b5a163b16a75c84f4de27a1baff6d6ef171
| 3,697
|
cpp
|
C++
|
src/Subsystems/Mechanisms.cpp
|
3197Software/2018Season
|
5454ea97234ee5bf63b434302744c40785262356
|
[
"MIT"
] | 3
|
2018-04-06T14:28:50.000Z
|
2018-04-06T14:33:27.000Z
|
src/Subsystems/Mechanisms.cpp
|
3197Software/2018Season
|
5454ea97234ee5bf63b434302744c40785262356
|
[
"MIT"
] | null | null | null |
src/Subsystems/Mechanisms.cpp
|
3197Software/2018Season
|
5454ea97234ee5bf63b434302744c40785262356
|
[
"MIT"
] | 1
|
2019-01-20T07:57:38.000Z
|
2019-01-20T07:57:38.000Z
|
#include "Mechanisms.h"
#include "../Commands/AuxiliaryMotors.h"
#include "../RobotMap.h"
#include <math.h>
#include "WPILib.h"
#include "ctre/Phoenix.h"
#define MAXRPM 534
#define LARGE_AMOUNT_OF_CURRENT 50
#define PEAK_CLAW_CURRENT 5
Mechanisms::Mechanisms() :
Subsystem("AuxiliaryMotors") {
winchA = new WPI_TalonSRX(5);
winchB = new WPI_TalonSRX(6);
claw = new WPI_TalonSRX(7);
elevatorWinch = new WPI_TalonSRX(8);
elevatorClawA = new WPI_TalonSRX(9);
elevatorClawB = new WPI_TalonSRX(10);
elevatorClawB->Follow(*elevatorClawA);
elevatorClawB->SetInverted(true);
winchB->Follow(*winchA);
}
void Mechanisms::InitDefaultCommand() {
SetDefaultCommand(new AuxiliaryMotors());
maxObservedClawCurrent = 0;
}
void Mechanisms::Winch(float speed) {
winchA->Set(speed);
SmartDashboard::PutNumber("Winch Current", winchA->GetOutputCurrent());
}
void Mechanisms::Claw(float speed) {
claw->Set(speed);
SmartDashboard::PutNumber("Claw Current", claw->GetOutputCurrent());
}
void Mechanisms::ElevatorWinch(float speed) {
elevatorWinch->Set(speed);
// SmartDashboard::PutNumber("Elevator Winch Encoder",
// elevatorWinch->GetSensorCollection().GetQuadraturePosition());
SmartDashboard::PutNumber("Winch Current",
elevatorWinch->GetOutputCurrent());
}
void Mechanisms::ElevatorClaw(float speed) {
elevatorClawA->Set(speed);
float currentA = elevatorClawA->GetOutputCurrent();
float currentB = elevatorClawB->GetOutputCurrent();
if (currentA > maxObservedClawCurrent)
maxObservedClawCurrent = currentA;
if(currentB > maxObservedClawCurrent)
maxObservedClawCurrent =currentB;
SmartDashboard::PutNumber("Max ElevatorClaw Current", maxObservedClawCurrent);
SmartDashboard::PutNumber("ElevatorClawA Current", currentA);
SmartDashboard::PutNumber("ElevatorClawB Current", currentB);
}
bool Mechanisms::ClawRetractLim() {
bool trip = 0 != claw->GetSensorCollection().IsFwdLimitSwitchClosed();
// SmartDashboard::PutBoolean("Claw Forward Limit (retract)", trip);
return trip;
}
bool Mechanisms::ClawGrabLim() {
bool trip = 0 != claw->GetSensorCollection().IsRevLimitSwitchClosed();
// SmartDashboard::PutBoolean("Claw Reverse Limit (grab)", trip);
return trip;
}
bool Mechanisms::ElevatorClawBotLim() {
bool trip = 0
!= elevatorClawA->GetSensorCollection().IsRevLimitSwitchClosed();
// SmartDashboard::PutBoolean("Elevator Claw Forward Limit (bot)", trip);
return trip;
}
bool Mechanisms::ElevatorClawTopLim() {
bool trip = 0
!= elevatorClawA->GetSensorCollection().IsFwdLimitSwitchClosed();
// SmartDashboard::PutBoolean("Elevator Claw Reverse Limit (top)", trip);
return trip;
}
bool Mechanisms::ElevatorWinchForwardLimit() {
bool trip = 0
!= elevatorWinch->GetSensorCollection().IsFwdLimitSwitchClosed();
// SmartDashboard::PutBoolean("Elevator Winch Forward Limit (bot)", trip);
return trip;
}
bool Mechanisms::ElevatorWinchReverseLimit() {
bool trip = 0
!= elevatorWinch->GetSensorCollection().IsRevLimitSwitchClosed();
// SmartDashboard::PutBoolean("Elevator Winch Reverse Limit (top)", trip);
return trip;
}
void Mechanisms::UpdateCurrent() {
float clawCurrent = claw->GetOutputCurrent();
SmartDashboard::PutNumber("Claw Current", clawCurrent);
float winchCurrentA = winchA->GetOutputCurrent();
SmartDashboard::PutNumber("Winch A Current", winchCurrentA);
float winchCurrentB = winchB->GetOutputCurrent();
SmartDashboard::PutNumber("Winch B Current", winchCurrentB);
float eleClawCurrent = elevatorClawA->GetOutputCurrent();
SmartDashboard::PutNumber("Ele Claw Current", eleClawCurrent);
float eleWinchCurrent = elevatorWinch->GetOutputCurrent();
SmartDashboard::PutNumber("Ele Winch Current", eleWinchCurrent);
}
| 29.34127
| 79
| 0.760887
|
3197Software
|
951d9f59a64e608eb91f1ff4f913522fd8eed1db
| 1,701
|
hpp
|
C++
|
src/Data/GradedNote.hpp
|
Subject38/jujube
|
664b995cc65fa6045433b4837d765c62fe6490b4
|
[
"MIT"
] | 19
|
2020-02-28T20:34:12.000Z
|
2022-01-28T20:18:25.000Z
|
src/Data/GradedNote.hpp
|
Subject38/jujube
|
664b995cc65fa6045433b4837d765c62fe6490b4
|
[
"MIT"
] | 7
|
2019-10-22T09:43:16.000Z
|
2022-03-12T00:15:13.000Z
|
src/Data/GradedNote.hpp
|
Subject38/jujube
|
664b995cc65fa6045433b4837d765c62fe6490b4
|
[
"MIT"
] | 5
|
2019-10-22T08:14:57.000Z
|
2021-03-13T06:32:04.000Z
|
#pragma once
#include <optional>
#include <SFML/System/Time.hpp>
#include "../Resources/Marker.hpp"
#include "Note.hpp"
namespace Data {
enum class Judgement {
Perfect,
Great,
Good,
Poor,
Miss,
};
bool judgement_breaks_combo(Judgement j);
Resources::MarkerAnimation judgement_to_animation(Judgement j);
Judgement delta_to_judgement(const sf::Time& delta);
Judgement release_to_judgement(const sf::Time& duration_held, const sf::Time& note_duration, const int tail_length);
struct TimedJudgement {
TimedJudgement() : delta(sf::Time::Zero), judgement(Judgement::Miss) {};
TimedJudgement(const sf::Time& d, const Judgement& j) : delta(d), judgement(j) {};
explicit TimedJudgement(const sf::Time& t) : delta(t), judgement(delta_to_judgement(t)) {};
explicit TimedJudgement(
const sf::Time& duration_held,
const sf::Time& t,
const sf::Time& duration,
const int tail_length
) :
delta(t),
judgement(release_to_judgement(duration_held, duration, tail_length))
{};
sf::Time delta = sf::Time::Zero;
Judgement judgement = Judgement::Miss;
};
struct GradedNote : Data::Note {
GradedNote() = default;
GradedNote(const Data::Note& n) : Note::Note(n) {};
GradedNote(const Data::Note& n, const sf::Time& t) : Note::Note(n), tap_judgement(t) {};
GradedNote(const Data::Note& n, const TimedJudgement& t) : Note::Note(n), tap_judgement(t) {};
std::optional<TimedJudgement> tap_judgement = {};
std::optional<TimedJudgement> long_release = {};
};
}
| 32.711538
| 120
| 0.623163
|
Subject38
|
9525abcbf47687d65ffc49ab5cfe3f1b1fc363cd
| 8,377
|
cpp
|
C++
|
Tests/Source/UnitTests/ElementDocument.cpp
|
aquawicket/RmlUi
|
d56f17e49ca2ee88aadeb304228cd1eae14e3f51
|
[
"MIT"
] | null | null | null |
Tests/Source/UnitTests/ElementDocument.cpp
|
aquawicket/RmlUi
|
d56f17e49ca2ee88aadeb304228cd1eae14e3f51
|
[
"MIT"
] | null | null | null |
Tests/Source/UnitTests/ElementDocument.cpp
|
aquawicket/RmlUi
|
d56f17e49ca2ee88aadeb304228cd1eae14e3f51
|
[
"MIT"
] | null | null | null |
/*
* This source file is part of RmlUi, the HTML/CSS Interface Middleware
*
* For the latest information, see http://github.com/mikke89/RmlUi
*
* Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
* Copyright (c) 2019 The RmlUi Team, and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include "../Common/Mocks.h"
#include "../Common/TestsShell.h"
#include <RmlUi/Core/Context.h>
#include <RmlUi/Core/Element.h>
#include <RmlUi/Core/ElementDocument.h>
#include <RmlUi/Core/Factory.h>
#include <doctest.h>
#include <algorithm>
using namespace Rml;
static const String document_focus_rml = R"(
<rml>
<head>
<link type="text/rcss" href="/assets/rml.rcss"/>
<link type="text/rcss" href="/assets/invader.rcss"/>
<style>
button {
display: inline-block;
tab-index: auto;
}
:focus {
image-color: #af0;
}
:disabled {
image-color: #666;
}
.hide {
visibility: hidden;
}
.nodisplay {
display: none;
}
</style>
</head>
<body id="body" onload="something">
<input type="checkbox" id="p1"/> P1
<label><input type="checkbox" id="p2"/> P2</label>
<p>
<input type="checkbox" id="p3"/><label for="p3"> P3</label>
</p>
<p class="nodisplay">
<input type="checkbox" id="p4"/><label for="p4"> P4</label>
</p>
<input type="checkbox" id="p5"/> P5
<p>
<input type="checkbox" id="p6" disabled/><label for="p6"> P6</label>
</p>
<div>
<label><input type="checkbox" id="p7"/> P7</label>
<label class="hide"><input type="checkbox" id="p8"/> P8</label>
<label><button id="p9"> P9</button></label>
<label><input type="checkbox" id="p10"/> P10</label>
</div>
<div id="container">
<p> Deeply nested
<span>
<input type="checkbox" id="p11"/> P11
</span>
<input type="checkbox" id="p12"/> P12
</p>
<input type="checkbox" id="p13"/> P13
</div>
</body>
</rml>
)";
static const String focus_forward = "p1 p2 p3 p5 p7 p9 p10 p11 p12 p13";
TEST_SUITE_BEGIN("ElementDocument");
TEST_CASE("Focus")
{
Context* context = TestsShell::GetContext();
REQUIRE(context);
ElementDocument* document = context->LoadDocumentFromMemory(document_focus_rml);
REQUIRE(document);
document->Show();
context->Update();
context->Render();
TestsShell::RenderLoop();
SUBCASE("Tab order")
{
StringList ids;
StringUtilities::ExpandString(ids, focus_forward, ' ');
REQUIRE(!ids.empty());
document->Focus();
SUBCASE("Forward")
{
for(const String& id : ids)
{
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == id);
}
// Wrap around
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == ids[0]);
}
SUBCASE("Reverse")
{
std::reverse(ids.begin(), ids.end());
for (const String& id : ids)
{
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == id);
}
// Wrap around (reverse)
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == ids[0]);
}
}
SUBCASE("Tab to document")
{
Element* element = document->GetElementById("p13");
REQUIRE(element);
element->Focus();
document->SetProperty("tab-index", "auto");
document->UpdateDocument();
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "body");
}
SUBCASE("Tab from container element")
{
Element* container = document->GetElementById("container");
REQUIRE(container);
container->Focus();
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "p11");
container->Focus();
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == "p10");
}
SUBCASE("Single element")
{
document->SetProperty("tab-index", "none");
document->SetInnerRML(R"(<input type="checkbox" id="p1"/> P1)");
document->UpdateDocument();
document->Focus();
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "p1");
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "p1");
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == "p1");
document->SetProperty("tab-index", "auto");
document->UpdateDocument();
document->Focus();
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "p1");
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "body");
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == "p1");
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == "body");
}
SUBCASE("Single, non-tabable element")
{
document->SetProperty("tab-index", "none");
document->SetInnerRML(R"(<div id="child"/>)");
document->UpdateDocument();
Element* child = document->GetChild(0);
document->Focus();
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "body");
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == "body");
child->Focus();
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "child");
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == "child");
document->SetProperty("tab-index", "auto");
document->UpdateDocument();
document->Focus();
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "body");
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == "body");
child->Focus();
context->ProcessKeyDown(Input::KI_TAB, 0);
CHECK(context->GetFocusElement()->GetId() == "body");
child->Focus();
context->ProcessKeyDown(Input::KI_TAB, Input::KM_SHIFT);
CHECK(context->GetFocusElement()->GetId() == "body");
}
document->Close();
TestsShell::ShutdownShell();
}
TEST_CASE("Load")
{
namespace tl = trompeloeil;
constexpr auto BODY_TAG = "body";
Context* context = TestsShell::GetContext();
REQUIRE(context);
MockEventListener mockEventListener;
MockEventListenerInstancer mockEventListenerInstancer;
tl::sequence sequence;
REQUIRE_CALL(mockEventListenerInstancer, InstanceEventListener("something", tl::_))
.WITH(_2->GetTagName() == BODY_TAG)
.IN_SEQUENCE(sequence)
.LR_RETURN(&mockEventListener);
ALLOW_CALL(mockEventListener, OnAttach(tl::_));
ALLOW_CALL(mockEventListener, OnDetach(tl::_));
REQUIRE_CALL(mockEventListener, ProcessEvent(tl::_))
.WITH(_1.GetId() == EventId::Load && _1.GetTargetElement()->GetTagName() == BODY_TAG)
.IN_SEQUENCE(sequence);
Factory::RegisterEventListenerInstancer(&mockEventListenerInstancer);
ElementDocument* document = context->LoadDocumentFromMemory(document_focus_rml);
REQUIRE(document);
document->Close();
TestsShell::ShutdownShell();
}
TEST_CASE("ReloadStyleSheet")
{
Context* context = TestsShell::GetContext();
ElementDocument* document = context->LoadDocument("basic/demo/data/demo.rml");
// There should be no warnings when reloading style sheets.
document->ReloadStyleSheet();
document->Close();
TestsShell::ShutdownShell();
}
TEST_SUITE_END();
| 28.886207
| 87
| 0.694282
|
aquawicket
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.