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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ccc2130cec5daa2604d7251f6d2550b5d5aa8c8a
| 1,261
|
cpp
|
C++
|
src/sort/heapsort.cpp
|
mattlisle/algorithms-cpp
|
bb9fb7e04ac0b05249c0c59537a270774db94ce0
|
[
"MIT"
] | null | null | null |
src/sort/heapsort.cpp
|
mattlisle/algorithms-cpp
|
bb9fb7e04ac0b05249c0c59537a270774db94ce0
|
[
"MIT"
] | null | null | null |
src/sort/heapsort.cpp
|
mattlisle/algorithms-cpp
|
bb9fb7e04ac0b05249c0c59537a270774db94ce0
|
[
"MIT"
] | null | null | null |
#include "sort.hpp"
#include <vector>
using namespace std;
namespace sort {
namespace {
auto parent_idx(size_t idx) -> size_t { return (idx - 1) / 2; }
auto left_idx(size_t idx) -> size_t { return 2 * idx + 1; }
auto right_idx(size_t idx) -> size_t { return 2 * idx + 2; }
void emplace_heap_elem(vector<int>* source, size_t heap_size, size_t idx) {
auto left = left_idx(idx);
auto right = right_idx(idx);
auto largest = idx;
if (left <= heap_size && source->at(left) > source->at(largest)) {
largest = left;
}
if (right <= heap_size && source->at(right) > source->at(largest)) {
largest = right;
}
if (largest != idx) {
swap((*source)[idx], (*source)[largest]);
emplace_heap_elem(source, heap_size, largest);
}
}
void build_max_heap(vector<int>* source, size_t heap_size) {
for (auto i = heap_size / 2; i-- > 0;) {
emplace_heap_elem(source, heap_size, i);
}
}
} // namespace
void heap_sort(vector<int>* source) {
if (source->size() > 1) {
auto heap_size = source->size() - 1;
build_max_heap(source, heap_size);
for (auto i = source->size() - 1; i > 0; --i) {
swap((*source)[0], (*source)[i]);
--heap_size;
emplace_heap_elem(source, heap_size, 0);
}
}
}
} // namespace sort
| 25.22
| 75
| 0.620143
|
mattlisle
|
ccc2976f60a15def188ef4940dee3ed644efa4f3
| 3,915
|
cpp
|
C++
|
src/KeyJoy_Node.cpp
|
dgitz/icarus_rover_rc
|
2ec789d7757715d71fc6ec4ce90e15fdc8053f3e
|
[
"MIT"
] | null | null | null |
src/KeyJoy_Node.cpp
|
dgitz/icarus_rover_rc
|
2ec789d7757715d71fc6ec4ce90e15fdc8053f3e
|
[
"MIT"
] | null | null | null |
src/KeyJoy_Node.cpp
|
dgitz/icarus_rover_rc
|
2ec789d7757715d71fc6ec4ce90e15fdc8053f3e
|
[
"MIT"
] | null | null | null |
/* Author: David Gitz
Date: 7-March-2016
Purpose: Converts ros keyboard topic to joystick topic.
Usage: See Launch_UserControl.launch
*/
//Includes all the headers necessary to use the most common public pieces of the ROS system.
#include <ros/ros.h>
//Include some useful constants for image encoding. Refer to: http://www.ros.org/doc/api/sensor_msgs/html/namespacesensor__msgs_1_1image__encodings.html for more info.
#include <sensor_msgs/image_encodings.h>
#include <sensor_msgs/Joy.h>
#include <sensor_msgs/NavSatFix.h>
#include <sensor_msgs/NavSatStatus.h>
#include <geometry_msgs/Pose2D.h>
#include <sensor_msgs/LaserScan.h>
#include <std_msgs/Int32.h>
#include <tf/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>
#include <nav_msgs/Path.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
#include <dirent.h>
//#include <gps_common/conversions.h>
#include "keyboard/Key.h"
#include <sensor_msgs/Joy.h>
#define KEY_A 97
#define KEY_D 100
#define KEY_UP 273
#define KEY_DOWN 274
#define KEY_LEFT 276
#define KEY_RIGHT 275
#define KEY_SPACE 32
#define JOY_STEER_AXIS 0
#define JOY_THROTTLE_AXIS 3
#define JOY_DISARM_BUTTON 14
#define JOY_ARM_BUTTON 12
float Steer_Value = 0.0;
float Throttle_Value = 0.0;
int Armed_State = 0;
int armed_state_changed = 0;
int axis_changed = 0;
#include <sys/time.h>
sensor_msgs::Joy joy_command;
ros::Publisher Pub_Joy;
void KeyDown_Callback(const keyboard::Key::ConstPtr& msg)
{
if(msg->code == KEY_A)
{
Armed_State = 1;
armed_state_changed = 1;
}
else if((msg->code == KEY_D) || (msg->code == KEY_SPACE))
{
Armed_State = 0;
Steer_Value = 0.0;
Throttle_Value = 0.0;
armed_state_changed = 1;
axis_changed = 1;
}
else if(msg->code == KEY_UP)
{
float temp = Throttle_Value;
temp += 0.05;
if(temp < 1.0) { Throttle_Value = temp; }
else { Throttle_Value = 1.0; }
axis_changed = 1;
}
else if(msg->code == KEY_DOWN)
{
float temp = Throttle_Value;
temp -= 0.05;
if(temp > -1.0) { Throttle_Value = temp; }
else { Throttle_Value = -1.0; }
axis_changed = 1;
}
else if(msg->code == KEY_LEFT)
{
float temp = Steer_Value;
temp -= 0.05;
if(temp > -1.0) { Steer_Value = temp; }
else { Steer_Value = -1.0; }
axis_changed = 1;
}
else if(msg->code == KEY_RIGHT)
{
float temp = Steer_Value;
temp += 0.05;
if(temp < 1.0) { Steer_Value = temp; }
else{ Steer_Value = 1.0; }
axis_changed = 1;
}
if(armed_state_changed == 1)
{
if(Armed_State == 0)
{
joy_command.buttons[JOY_DISARM_BUTTON] = 1;
joy_command.buttons[JOY_ARM_BUTTON] = 0;
}
else
{
joy_command.buttons[JOY_DISARM_BUTTON] = 0;
joy_command.buttons[JOY_ARM_BUTTON] = 1;
}
armed_state_changed = 0;
}
if(axis_changed == 1)
{
joy_command.axes[JOY_STEER_AXIS] = Steer_Value*-1;;
joy_command.axes[JOY_THROTTLE_AXIS] = Throttle_Value;
axis_changed = 0;
}
Pub_Joy.publish(joy_command);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "KeyJoy_Node");
ros::NodeHandle nh("/");
joy_command.buttons.resize(20);
joy_command.axes.resize(8);
ros::Subscriber Sub_KeyboardDown = nh.subscribe<keyboard::Key>("/keyboard/keydown",1000,KeyDown_Callback);
Pub_Joy = nh.advertise<sensor_msgs::Joy>("joy",1000);
ros::Rate loop_rate(50);
while( ros::ok())
{
ros::spinOnce();
loop_rate.sleep();
}
}
| 25.756579
| 167
| 0.605109
|
dgitz
|
ccc3477508aed318dfc850a1f6c6b5433861a48d
| 1,572
|
hpp
|
C++
|
Strategy/Duck/RubberDuck.hpp
|
dambatbul/DesignPatterns
|
9aae245f7f5d1fb3e1ab2528c53ae2abc095437f
|
[
"BSD-3-Clause"
] | null | null | null |
Strategy/Duck/RubberDuck.hpp
|
dambatbul/DesignPatterns
|
9aae245f7f5d1fb3e1ab2528c53ae2abc095437f
|
[
"BSD-3-Clause"
] | null | null | null |
Strategy/Duck/RubberDuck.hpp
|
dambatbul/DesignPatterns
|
9aae245f7f5d1fb3e1ab2528c53ae2abc095437f
|
[
"BSD-3-Clause"
] | null | null | null |
/*
* =====================================================================================
*
* Filename: RubberDuck.hpp
*
* Description: head first ch1 example - Duck model(Strategy Pattern)
*
* Version: 0.1
* Created: 2015년 10월 14일 22시 39분 54초
* Revision: none
* Compiler: g++
*
* =====================================================================================
*/
#ifndef _HEAD_FIRST_DESIGN_PATTERNS_STRATEGY_RUBBER_DUCK_HPP_
#define _HEAD_FIRST_DESIGN_PATTERNS_STRATEGY_RUBBER_DUCK_HPP_
#include <iostream>
#include <Duck.hpp>
#include <FlyNoWay.hpp>
#include <Squeak.hpp>
namespace HeadFirstDesignPatterns {
namespace Strategy {
/*
* =====================================================================================
* Class: RubberDuck
* Description:
* =====================================================================================
*/
class RubberDuck : public Duck
{
public:
/* ==================== LIFECYCLE ======================================= */
RubberDuck () /* constructor */
{
flyBehavior = new FlyNoWay();
quackBehavior = new Squeak();
}
/* ==================== MUTATORS ======================================= */
virtual void display() {
std::cout << "I;m a rubber duck" << std::endl;
}
}; /* ----- end of class RubberDuck ----- */
} /* ----- end of namespace Strategy ----- */
} /* ----- end of namespace HeadFirstDesignPatterns ----- */
#endif
| 28.071429
| 90
| 0.400763
|
dambatbul
|
cccb1b5a373f039c0c771116dbdb605a6ef8bd46
| 1,180
|
cpp
|
C++
|
Source/Storm-Packager/include/CleanTask.cpp
|
SunlayGGX/Storm
|
83a34c14cc7d936347b6b8193a64cd13ccbf00a8
|
[
"MIT"
] | 3
|
2021-11-27T04:56:12.000Z
|
2022-02-14T04:02:10.000Z
|
Source/Storm-Packager/include/CleanTask.cpp
|
SunlayGGX/Storm
|
83a34c14cc7d936347b6b8193a64cd13ccbf00a8
|
[
"MIT"
] | null | null | null |
Source/Storm-Packager/include/CleanTask.cpp
|
SunlayGGX/Storm
|
83a34c14cc7d936347b6b8193a64cd13ccbf00a8
|
[
"MIT"
] | null | null | null |
#include "CleanTask.h"
#include "ConfigManager.h"
#include "PackagerHelper.h"
std::string_view StormPackager::CleanTask::getName() const
{
return "Cleaner";
}
std::string StormPackager::CleanTask::prepare()
{
std::string result;
const StormPackager::ConfigManager &configMgr = StormPackager::ConfigManager::instance();
const std::string &destination = configMgr.getDestinationPackageFolderPath();
const std::string &tempPath = configMgr.getTmpPath();
if (!StormPackager::PackagerHelper::erase(destination))
{
result += "Destination folder " + destination + " deletion failed!";
}
if (!StormPackager::PackagerHelper::createDirectory(destination))
{
result += "Error happened when creating " + destination + " folder!";
}
if (!StormPackager::PackagerHelper::erase(tempPath))
{
result += "Temporary folder " + tempPath + " deletion failed!";
}
if (!StormPackager::PackagerHelper::createDirectory(tempPath))
{
result += "Error happened when creating " + tempPath + " folder!";
}
return result;
}
std::string StormPackager::CleanTask::execute()
{
return std::string{};
}
std::string StormPackager::CleanTask::cleanUp()
{
return std::string{};
}
| 22.692308
| 90
| 0.720339
|
SunlayGGX
|
ccd0e33bd8a9a63de6eeae6f23b7cb7f78f13fc3
| 4,399
|
cpp
|
C++
|
ares/ms/vdp/background.cpp
|
CasualPokePlayer/ares
|
58690cd5fc7bb6566c22935c5b80504a158cca29
|
[
"BSD-3-Clause"
] | 153
|
2020-07-25T17:55:29.000Z
|
2021-10-01T23:45:01.000Z
|
ares/ms/vdp/background.cpp
|
CasualPokePlayer/ares
|
58690cd5fc7bb6566c22935c5b80504a158cca29
|
[
"BSD-3-Clause"
] | 245
|
2021-10-08T09:14:46.000Z
|
2022-03-31T08:53:13.000Z
|
ares/ms/vdp/background.cpp
|
CasualPokePlayer/ares
|
58690cd5fc7bb6566c22935c5b80504a158cca29
|
[
"BSD-3-Clause"
] | 44
|
2020-07-25T08:51:55.000Z
|
2021-09-25T16:09:01.000Z
|
auto VDP::Background::setup(n9 voffset) -> void {
if(!self.displayEnable()) return;
latch.nameTableAddress = io.nameTableAddress;
latch.hscroll = io.hscroll;
latch.vscroll = io.vscroll;
}
auto VDP::Background::run(n8 hoffset, n9 voffset) -> void {
output = {};
if(!self.displayEnable()) return;
switch(self.videoMode()) {
case 0b0000: return graphics1(hoffset, voffset);
case 0b0001: return;
case 0b0010: return graphics2(hoffset, voffset);
case 0b0011: return;
case 0b0100: return;
case 0b0101: return;
case 0b0110: return;
case 0b0111: return;
case 0b1000: return graphics3(hoffset, voffset, 192);
case 0b1001: return;
case 0b1010: return graphics3(hoffset, voffset, 192);
case 0b1011: return graphics3(hoffset, voffset, 224);
case 0b1100: return graphics3(hoffset, voffset, 192);
case 0b1101: return;
case 0b1110: return graphics3(hoffset, voffset, 240);
case 0b1111: return graphics3(hoffset, voffset, 192);
}
}
auto VDP::Background::graphics1(n8 hoffset, n9 voffset) -> void {
n14 nameTableAddress;
nameTableAddress.bit( 0, 4) = hoffset.bit(3,7);
nameTableAddress.bit( 5, 9) = voffset.bit(3,7);
nameTableAddress.bit(10,13) = latch.nameTableAddress;
n8 pattern = self.vram[nameTableAddress];
n14 patternAddress;
patternAddress.bit( 0, 2) = voffset.bit(0,2);
patternAddress.bit( 3,10) = pattern;
patternAddress.bit(11,13) = io.patternTableAddress;
n14 colorAddress; //d5 = 0
colorAddress.bit(0, 4) = pattern.bit(3,7);
colorAddress.bit(6,13) = io.colorTableAddress;
n8 color = self.vram[colorAddress];
n3 index = hoffset ^ 7;
if(!self.vram[patternAddress].bit(index)) {
output.color = color.bit(0,3);
} else {
output.color = color.bit(4,7);
}
}
auto VDP::Background::graphics2(n8 hoffset, n9 voffset) -> void {
n14 nameTableAddress;
nameTableAddress.bit( 0, 4) = hoffset.bit(3,7);
nameTableAddress.bit( 5, 9) = voffset.bit(3,7);
nameTableAddress.bit(10,13) = latch.nameTableAddress;
n8 pattern = self.vram[nameTableAddress];
n14 patternAddress;
patternAddress.bit(0, 2) = voffset.bit(0,2);
patternAddress.bit(3,10) = pattern;
if(voffset >= 64 && voffset <= 127) patternAddress.bit(11) = io.patternTableAddress.bit(0);
if(voffset >= 128 && voffset <= 191) patternAddress.bit(12) = io.patternTableAddress.bit(1);
n14 colorAddress = patternAddress;
patternAddress.bit(13) = io.patternTableAddress.bit(2);
colorAddress.bit(13) = io.colorTableAddress.bit(7);
n8 colorMask = io.colorTableAddress.bit(0,6) << 1 | 1;
n8 color = self.vram[colorAddress];
n3 index = hoffset ^ 7;
if(!self.vram[patternAddress].bit(index)) {
output.color = color.bit(0,3);
} else {
output.color = color.bit(4,7);
}
}
auto VDP::Background::graphics3(n8 hoffset, n9 voffset, u32 vlines) -> void {
if(hoffset < latch.hscroll.bit(0,2)) return;
if(!io.hscrollLock || voffset >= 16) hoffset -= latch.hscroll;
if(!io.vscrollLock || hoffset <= 191) voffset += latch.vscroll;
n14 nameTableAddress;
if(vlines == 192) {
voffset %= 224;
nameTableAddress = latch.nameTableAddress >> 1 << 11;
nameTableAddress += voffset >> 3 << 6;
nameTableAddress += hoffset >> 3 << 1;
if(self.revision->value() == 1) {
//SMS1 quirk: bit 0 of name table base address acts as a mask
nameTableAddress.bit(10) &= latch.nameTableAddress.bit(0);
}
} else {
voffset %= 256;
nameTableAddress = latch.nameTableAddress >> 2 << 12 | 0x0700;
nameTableAddress += voffset >> 3 << 6;
nameTableAddress += hoffset >> 3 << 1;
}
n16 pattern;
pattern.byte(0) = self.vram[nameTableAddress | 0];
pattern.byte(1) = self.vram[nameTableAddress | 1];
if(pattern.bit( 9)) hoffset ^= 7; //hflip
if(pattern.bit(10)) voffset ^= 7; //vflip
output.palette = pattern.bit(11);
output.priority = pattern.bit(12);
n14 patternAddress;
patternAddress.bit(2, 4) = voffset.bit(0,2);
patternAddress.bit(5,13) = pattern.bit(0,8);
n3 index = hoffset ^ 7;
output.color.bit(0) = self.vram[patternAddress | 0].bit(index);
output.color.bit(1) = self.vram[patternAddress | 1].bit(index);
output.color.bit(2) = self.vram[patternAddress | 2].bit(index);
output.color.bit(3) = self.vram[patternAddress | 3].bit(index);
if(output.color == 0) output.priority = 0;
}
auto VDP::Background::power() -> void {
io = {};
latch = {};
output = {};
}
| 33.325758
| 94
| 0.675381
|
CasualPokePlayer
|
ccd26c1dce1fcd871b16279991edb5f5920f7549
| 5,094
|
cpp
|
C++
|
USB Application2/Dll_USB_2/dllmain.cpp
|
abaelen/Arduino-Isochronous-USB
|
ff65cfcac11d617d310a70fdae59cd406724ed83
|
[
"MIT"
] | 1
|
2021-03-16T01:52:58.000Z
|
2021-03-16T01:52:58.000Z
|
USB Application2/Dll_USB_2/dllmain.cpp
|
abaelen/Arduino-Isochronous-USB
|
ff65cfcac11d617d310a70fdae59cd406724ed83
|
[
"MIT"
] | null | null | null |
USB Application2/Dll_USB_2/dllmain.cpp
|
abaelen/Arduino-Isochronous-USB
|
ff65cfcac11d617d310a70fdae59cd406724ed83
|
[
"MIT"
] | 2
|
2021-04-30T21:58:45.000Z
|
2021-11-28T01:50:14.000Z
|
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include "USB.h"
#include <vector>
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
_USB_Device USB_Device;
//To use the Class create a _USB_Device USB_Device member. Then call the USB_Device.Initialize(1023,1,1) eg. 1023 in 1 packet & 1 microframe (as only FS) or USB_Device.Initialize(2046,2,1), ...
//Below exposes all the public members and methods for external use. Call these from for example C# using
/* [DllImport(@"C:\Users\Gebruiker\Documents\OneDrive\Elec Projects\Github\YetAnother-USB-Oscilloscope\YetAnotherUSBOscilloscope\x64\Debug\Dll_USB_2.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern void USB2_Device_Initialize(UInt32 Buffersize, UInt32 PacketSize, UInt32 MicroFrameSize);
[DllImport(@"C:\Users\Gebruiker\Documents\OneDrive\Elec Projects\Github\YetAnother-USB-Oscilloscope\YetAnotherUSBOscilloscope\x64\Debug\Dll_USB_2.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern void USB2_Device_Start(UInt32 TaktTime, int[] pRequestToStop = null, ulong FrameNumber = 0);*/
//Keep data out of the dll export functions, as it increases speed of execution
//To get values, pass by value
//To send values, pass a pointer and set the value of the memory space of the pointer
extern "C" {
__declspec(dllexport) void USB2_Device_Initialize(uint32_t BufferSize, uint32_t PacketSize, uint32_t MicroFrameSize)
{
USB_Device.Initialize(BufferSize, PacketSize, MicroFrameSize);
}
__declspec(dllexport) void USB2_Device_Start(uint32_t TaktTime, PBOOL RequestToStop, ULONG FrameNumber = 0)
{
USB_Device.Start(TaktTime,RequestToStop, FrameNumber);
}
__declspec(dllexport) void USB2_Device_Stop()
{
USB_Device.Stop();
}
__declspec(dllexport) void USB2_Device_Copy(uint8_t* DestinationBuffer)
{
USB_Device.Copy(DestinationBuffer);
}
__declspec(dllexport) uint8_t USB2_Device_Swap()
{
return (uint8_t)USB_Device.Swap();
}
__declspec(dllexport) uint8_t USB2_Device_ZeroBackBuffer()
{
return (uint8_t)USB_Device.ZeroBackBuffer();
}
__declspec(dllexport) uint8_t USB2_Device_Status_Started()
{
return (uint8_t)USB_Device.Status.Started;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Stopped()
{
return (uint8_t)USB_Device.Status.Stopped;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Initialized()
{
return (uint8_t)USB_Device.Status.Initialized;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Errored()
{
return (uint8_t)USB_Device.Status.Errored;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_DeviceFound()
{
return (uint8_t)USB_Device.Status.Action.DeviceFound;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_GetDescriptor()
{
return (uint8_t)USB_Device.Status.Action.GetDescriptor;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_GetInterface()
{
return (uint8_t)USB_Device.Status.Action.GetInterface;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_IsocPipe()
{
return (uint8_t)USB_Device.Status.Action.GetIsochPipe;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_GetInterval()
{
return (uint8_t)USB_Device.Status.Action.GetInterval;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_SetTransferChars()
{
return (uint8_t)USB_Device.Status.Action.SetTransferChars;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_SetOverlappedStructure()
{
return (uint8_t)USB_Device.Status.Action.SetOverlappedStructure;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_SetOverlappedEvents()
{
return (uint8_t)USB_Device.Status.Action.SetOverlappedEvents;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_SetIsochPackets()
{
return (uint8_t)USB_Device.Status.Action.SetIsochPackets;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_RegisterIsochBuffer()
{
return (uint8_t)USB_Device.Status.Action.RegisterIsochBuffer;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_ResetPipe()
{
return (uint8_t)USB_Device.Status.Action.ResetPipe;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_EndAtFrame()
{
return (uint8_t)USB_Device.Status.Action.EndAtFrame;
}
__declspec(dllexport) uint8_t USB2_Device_Status_Action_ReadIsochPipe()
{
return (uint8_t)USB_Device.Status.Action.ReadIsochPipe;
}
}
| 38.590909
| 231
| 0.727719
|
abaelen
|
ccd4779032edc95413732dc11098337387991fdc
| 3,600
|
cc
|
C++
|
net/socket/tcp_socket.cc
|
kay1ess/allin-server
|
3be3a53ebd092ad645df4ba8b86f1f548585c6cc
|
[
"Apache-2.0"
] | null | null | null |
net/socket/tcp_socket.cc
|
kay1ess/allin-server
|
3be3a53ebd092ad645df4ba8b86f1f548585c6cc
|
[
"Apache-2.0"
] | null | null | null |
net/socket/tcp_socket.cc
|
kay1ess/allin-server
|
3be3a53ebd092ad645df4ba8b86f1f548585c6cc
|
[
"Apache-2.0"
] | null | null | null |
/*
* @Author: likai
* @Date: 2022-01-14 19:19:46
* @Last Modified by: likai
* @Last Modified time: 2022-01-25 15:57:34
* @Description: ""
*/
#include "socket/tcp_socket.h"
#include <unistd.h>
#include <fcntl.h>
namespace net {
TCPSocket::TCPSocket() {
type_ = TCP_SOCKET;
fd_ = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
if (fd_ == -1) {
LERROR << "TcpSocket create failed";
} else {
blocking_ = false;
opened_ = true;
}
LTRACE << "TcpSocket create fd=" << fd_;
}
TCPSocket::TCPSocket(int fd, bool blocking) : BaseSocket(fd, blocking) {
}
TCPSocket::~TCPSocket() {
Close();
LTRACE << "~TcpSocket destroyed fd=" << fd_;
}
void TCPSocket::Close() {
if (IsOpen()) {
close(fd_);
opened_ = false;
}
}
int TCPSocket::Bind(const IPAddr::ptr addr) {
if (!IsOpen()) {
LERROR << "tcp socket opened_=" << opened_;
return -1;
}
// Genernal bind addr for server
int ret = bind(fd_, addr->SockAddr(), addr->SockAddrLen());
localaddr_ = addr;
LTRACE << "bound addr=" << addr->ToString();
return ret;
}
int TCPSocket::Listen() {
if (!IsOpen()) {
return -1;
}
return listen(fd_, SOMAXCONN);
}
int TCPSocket::Connect(const IPAddr::ptr addr, int64_t timeout) {
if (!IsOpen()) {
return -1;
}
remoteaddr_ = addr;
// Get local addr for client
// if (localaddr_ == nullptr) {
// struct sockaddr_in sa;
// socklen_t len = sizeof sa;
// getsockname(fd_, reinterpret_cast<struct sockaddr*>(&sa), &len);
// localaddr_ = std::make_shared<IPAddr>(&sa);
// LTRACE << "local addr=" << localaddr_->ToString();
// }
int ret = connect(fd_, addr->SockAddr(), addr->SockAddrLen());
return ret;
}
BaseSocket::ptr TCPSocket::Accept() {
if (!IsOpen()) {
return nullptr;
}
struct sockaddr_in sa;
socklen_t len = sizeof sa;
int fd = accept4(
fd_, reinterpret_cast<struct sockaddr*>(&sa), &len,
SOCK_NONBLOCK | SOCK_CLOEXEC);
if (fd == -1) {
LERROR << "accept failed";
return nullptr;
}
auto client_sock = std::make_shared<TCPSocket>(fd, false);
LTRACE << "accept a client fd=" << client_sock->Fd();
remoteaddr_ = std::make_shared<IPAddr>(&sa);
client_sock->Init();
return client_sock;
}
ssize_t TCPSocket::Send(const void* buf, size_t len) {
return send(fd_, buf, len, 0);
}
ssize_t TCPSocket::Recv(void* buf, size_t len) {
return recv(fd_, buf, len, 0);
}
void TCPSocket::ReuseAddr(bool on) {
if (!IsOpen()) {
return;
}
int val = on ? 1 : 0;
int ret = setsockopt(fd_, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val);
ret |= setsockopt(fd_, SOL_SOCKET, SO_REUSEPORT, &val, sizeof val);
if (ret == 0) {
LTRACE << "set tcp reuseaddr success";
} else {
LERROR << "set tcp reuseaddr failed";
}
}
void TCPSocket::SetNotBlocking() {
if (!IsOpen()) {
return;
}
if (blocking_) {
int flags = fcntl(fd_, F_GETFL, 0);
if (flags == -1) {
LERROR << "fcntl error";
} else {
flags |= O_NONBLOCK;
if (fcntl(fd_, F_SETFL, flags) == -1) {
LERROR << "fcntl error";
} else {
blocking_ = false;
}
}
}
}
int TCPSocket::GetSocketError() {
int optval = -1;
socklen_t optlen = sizeof(optval);
getsockopt(fd_, SOL_SOCKET, SO_ERROR, &optval, &optlen);
return optval;
}
}; // namespace net
| 24.657534
| 75
| 0.566944
|
kay1ess
|
ccdbae880f3c2592fe22aa9769333914427d250e
| 636
|
hpp
|
C++
|
pomdog/experimental/magicavoxel/vox_model_exporter.hpp
|
mogemimi/pomdog
|
6dc6244d018f70d42e61c6118535cf94a9ee0618
|
[
"MIT"
] | 163
|
2015-03-16T08:42:32.000Z
|
2022-01-11T21:40:22.000Z
|
pomdog/experimental/magicavoxel/vox_model_exporter.hpp
|
mogemimi/pomdog
|
6dc6244d018f70d42e61c6118535cf94a9ee0618
|
[
"MIT"
] | 17
|
2015-04-12T20:57:50.000Z
|
2020-10-10T10:51:45.000Z
|
pomdog/experimental/magicavoxel/vox_model_exporter.hpp
|
mogemimi/pomdog
|
6dc6244d018f70d42e61c6118535cf94a9ee0618
|
[
"MIT"
] | 21
|
2015-04-12T20:45:11.000Z
|
2022-01-14T20:50:16.000Z
|
// Copyright mogemimi. Distributed under the MIT license.
#pragma once
#include "pomdog/basic/conditional_compilation.hpp"
#include "pomdog/basic/export.hpp"
#include "pomdog/utility/errors.hpp"
POMDOG_SUPPRESS_WARNINGS_GENERATED_BY_STD_HEADERS_BEGIN
#include <string>
POMDOG_SUPPRESS_WARNINGS_GENERATED_BY_STD_HEADERS_END
namespace pomdog::magicavoxel {
class VoxModel;
} // namespace pomdog::magicavoxel
namespace pomdog::magicavoxel::VoxModelExporter {
[[nodiscard]] POMDOG_EXPORT std::unique_ptr<Error>
Export(const VoxModel& model, const std::string& filePath) noexcept;
} // namespace pomdog::magicavoxel::VoxModelExporter
| 27.652174
| 68
| 0.81761
|
mogemimi
|
ef993fcecaa64d83f55f475c3694534e128caf8a
| 3,559
|
hpp
|
C++
|
src/IRHandler.hpp
|
luis-rr/OpenCat
|
ac5e32abf4861c069be38ad5a9e5c629d4db753f
|
[
"MIT"
] | null | null | null |
src/IRHandler.hpp
|
luis-rr/OpenCat
|
ac5e32abf4861c069be38ad5a9e5c629d4db753f
|
[
"MIT"
] | null | null | null |
src/IRHandler.hpp
|
luis-rr/OpenCat
|
ac5e32abf4861c069be38ad5a9e5c629d4db753f
|
[
"MIT"
] | null | null | null |
#include <IRremote.h>
// abbreviation //gait/posture/function names
#define K00 "d" // rest and shutdown all servos
#define K01 "F" // forward
#define K02 "g" // turn off gyro feedback to boost speed
#define K10 "L" // left
#define K11 "balance" // neutral stand up posture
#define K12 "R" // right
#define K20 "p" // pause motion and shut off all servos
#define K21 "B" // backward
#define K22 "c" // calibration mode with IMU turned off
#define K30 "vt" // stepping
#define K31 "cr" // crawl
#define K32 "wk" // walk
#define K40 "tr" // trot
#ifdef NYBBLE
#define K41 "lu" // look up
#define K42 "buttUp" // butt up
#else // BITTLE
#define K41 "rn" // run
#define K42 "ck" // check around
#endif
#define K50 "hi" // greeting
#define K51 "pu" // push up
#define K52 "pee" // standng with three legs
#define K60 "str" // stretch
#define K61 "sit" // sit
#define K62 "zero" // zero position
#define CMD_LEN 10
class IRHandler {
public:
decode_results results;
char token;
char lastToken;
char *lastCmd = new char[CMD_LEN];
char *newCmd = new char[CMD_LEN];
byte newCmdIdx = 0;
void setLastCmd(const char *const contents) { strcpy(lastCmd, contents); }
bool isLastCmd(const char *const contents) const {
return strcmp(lastCmd, "c");
}
void setNewCmd(const char *const contents) { strcpy(newCmd, contents); }
bool isNewCmd(const char *const contents) const {
return strcmp(newCmd, "c");
}
void resetNewCmd() {
newCmd[0] = '\0';
newCmdIdx = 0;
}
String translateIR() {
// takes action based on IR code received
// describing Remote IR codes.
switch (results.value) {
// IR signal key on IR remote //key mapping
case 0xFFA25D: /*PTLF(" CH-"); */
return (F(K00));
case 0xFF629D: /*PTLF(" CH"); */
return (F(K01));
case 0xFFE21D: /*PTLF(" CH+"); */
return (F(K02));
case 0xFF22DD: /*PTLF(" |<<"); */
return (F(K10));
case 0xFF02FD: /*PTLF(" >>|"); */
return (F(K11));
case 0xFFC23D: /*PTLF(" >||"); */
return (F(K12));
case 0xFFE01F: /*PTLF(" -"); */
return (F(K20));
case 0xFFA857: /*PTLF(" +"); */
return (F(K21));
case 0xFF906F: /*PTLF(" EQ"); */
return (F(K22));
case 0xFF6897: /*PTLF(" 0"); */
return (F(K30));
case 0xFF9867: /*PTLF(" 100+"); */
return (F(K31));
case 0xFFB04F: /*PTLF(" 200+"); */
return (F(K32));
case 0xFF30CF: /*PTLF(" 1"); */
return (F(K40));
case 0xFF18E7: /*PTLF(" 2"); */
return (F(K41));
case 0xFF7A85: /*PTLF(" 3"); */
return (F(K42));
case 0xFF10EF: /*PTLF(" 4"); */
return (F(K50));
case 0xFF38C7: /*PTLF(" 5"); */
return (F(K51));
case 0xFF5AA5: /*PTLF(" 6"); */
return (F(K52));
case 0xFF42BD: /*PTLF(" 7"); */
return (F(K60));
case 0xFF4AB5: /*PTLF(" 8"); */
return (F(K61));
case 0xFF52AD: /*PTLF(" 9"); */
return (F(K62));
case 0xFFFFFFFF:
return (""); // Serial.println(" REPEAT");
default: {
// Serial.println(results.value, HEX);
}
}
return (""); // Serial.println("null");
// delay(100); // Do not get immediate repeat //no need because the main
// loop is slow
// The control could be organized in another way, such as:
// forward/backward to change the gaits corresponding to different speeds.
// left/right key for turning left and right
// number keys for different postures or behaviors
}
};
| 25.978102
| 78
| 0.571509
|
luis-rr
|
ef99db031cfff3e49ac99826cfbde0e4d11243d9
| 483
|
cpp
|
C++
|
test/util/frame_checking_example.cpp
|
wavelab/wave_geometry
|
aabcad44a490fc6393b35e63db9ad8908cf46dec
|
[
"MIT"
] | 112
|
2018-05-07T00:57:57.000Z
|
2022-03-30T12:14:07.000Z
|
test/util/frame_checking_example.cpp
|
wavelab/wave_geometry
|
aabcad44a490fc6393b35e63db9ad8908cf46dec
|
[
"MIT"
] | 9
|
2018-08-02T20:10:49.000Z
|
2022-02-16T17:45:29.000Z
|
test/util/frame_checking_example.cpp
|
wavelab/wave_geometry
|
aabcad44a490fc6393b35e63db9ad8908cf46dec
|
[
"MIT"
] | 13
|
2018-05-27T01:08:24.000Z
|
2022-03-22T13:46:31.000Z
|
#include "wave/geometry/geometry.hpp"
int main() {
struct BodyFrame;
struct CameraFrame;
struct WorldFrame;
wave::RotationMFd<WorldFrame, BodyFrame> r1;
wave::RotationMFd<CameraFrame, BodyFrame> r2;
// Let's get the rotation between World and Camera (maybe)
// wave::RotationMFd<WorldFrame, CameraFrame> result = r1 * r2; // fails
wave::RotationMFd<WorldFrame, CameraFrame> result = r1 * inverse(r2); // ok
static_cast<void>(result);
}
| 30.1875
| 83
| 0.681159
|
wavelab
|
efa144079eb7309cc41f1844b461f7e819986f32
| 1,707
|
hpp
|
C++
|
software/source/tasks/task_leds.hpp
|
salkinium/calirona
|
a25ec42240358d0a2da9c1706d54783703fac343
|
[
"BSD-2-Clause"
] | null | null | null |
software/source/tasks/task_leds.hpp
|
salkinium/calirona
|
a25ec42240358d0a2da9c1706d54783703fac343
|
[
"BSD-2-Clause"
] | null | null | null |
software/source/tasks/task_leds.hpp
|
salkinium/calirona
|
a25ec42240358d0a2da9c1706d54783703fac343
|
[
"BSD-2-Clause"
] | null | null | null |
// coding: utf-8
#ifndef TASK_LEDS_HPP
#define TASK_LEDS_HPP
#include <xpcc/processing/periodic_timer.hpp>
#include "hardware.hpp"
namespace task
{
class Leds
{
public:
Leds()
: isBusy(false), isHeadphoneError(false), isMechanicalError(false)
{
}
void inline
initialize()
{
LED_Busy1::setOutput(xpcc::Gpio::Low);
LED_Busy2::setOutput(xpcc::Gpio::Low);
LED_Headphone::setOutput(xpcc::Gpio::Low);
LED_MechError::setOutput(xpcc::Gpio::Low);
}
void
update()
{
if (isBusy && timerBusy.isExpired())
{
LED_Busy1::toggle();
LED_Busy2::toggle();
}
if (isHeadphoneError && timerHeadphone.isExpired())
{
LED_Headphone::toggle();
}
if (isMechanicalError && timerMechanicalError.isExpired())
{
LED_MechError::toggle();
}
}
void inline
setBusy()
{
if (isBusy) return;
LED_Busy1::set();
LED_Busy2::reset();
isBusy = true;
timerBusy.restart(400);
}
void inline
resetBusy()
{
LED_Busy1::reset();
LED_Busy2::reset();
isBusy = false;
}
void inline
setHeadphoneError()
{
if (isHeadphoneError) return;
isHeadphoneError = true;
timerHeadphone.restart(300);
}
void inline
resetHeadphoneError()
{
LED_Headphone::set();
isHeadphoneError = false;
}
void inline
setMechanicalError()
{
if (isMechanicalError) return;
isMechanicalError = true;
timerMechanicalError.restart(300);
}
void inline
resetMechanicalError()
{
LED_MechError::reset();
isMechanicalError = false;
}
private:
xpcc::PeriodicTimer<> timerBusy;
xpcc::PeriodicTimer<> timerHeadphone;
xpcc::PeriodicTimer<> timerMechanicalError;
bool isBusy;
bool isHeadphoneError;
bool isMechanicalError;
};
} // namespace task
#endif // TASK_LEDS_HPP
| 15.518182
| 67
| 0.696544
|
salkinium
|
efa181fe69c9a2b48e89707dfa79fbc55d52237b
| 211
|
cpp
|
C++
|
Compiler/compilererror.cpp
|
beldmitr/i4004
|
f090bc91acbf88be119d72a80301cdcf57a8c159
|
[
"MIT"
] | 7
|
2017-04-07T01:17:26.000Z
|
2021-11-02T06:08:45.000Z
|
Compiler/compilererror.cpp
|
beldmitr/i4004
|
f090bc91acbf88be119d72a80301cdcf57a8c159
|
[
"MIT"
] | null | null | null |
Compiler/compilererror.cpp
|
beldmitr/i4004
|
f090bc91acbf88be119d72a80301cdcf57a8c159
|
[
"MIT"
] | 1
|
2018-12-13T10:47:08.000Z
|
2018-12-13T10:47:08.000Z
|
#include "compilererror.h"
CompilerError::CompilerError(unsigned int row, const std::string& message)
{
const_cast<unsigned int&>(this->row) = row;
const_cast<std::string&>(this->message) = message;
}
| 23.444444
| 74
| 0.7109
|
beldmitr
|
efa25af89065151261ee752098953192f4a31a02
| 985
|
cpp
|
C++
|
source/rectangle.cpp
|
antoniakk/programmiersprachen-aufgabenblatt-2
|
adcd0d5e00e40b5d857df4209492610f3ea226b3
|
[
"MIT"
] | null | null | null |
source/rectangle.cpp
|
antoniakk/programmiersprachen-aufgabenblatt-2
|
adcd0d5e00e40b5d857df4209492610f3ea226b3
|
[
"MIT"
] | null | null | null |
source/rectangle.cpp
|
antoniakk/programmiersprachen-aufgabenblatt-2
|
adcd0d5e00e40b5d857df4209492610f3ea226b3
|
[
"MIT"
] | null | null | null |
#include "rectangle.hpp"
Rectangle::Rectangle() : min_{0.0, 0.0}, max_{100.0, 100.0}, color_{} {};
Rectangle::Rectangle(Vec2 const& min, Vec2 const& max, Color const& color) : min_{min}, max_{max}, color_{color} {};
float Rectangle::circumfrence() const {
return 2*((abs(max_.y - min_.y)+abs((max_.x) - (min_.x))));
};
void Rectangle::draw(Window const& window, float thickness) const {
window.draw_line(min_.x, min_.y, max_.x, min_.y, color_.r, color_.b, color_.g, thickness);
window.draw_line(min_.x, min_.y, min_.x, max_.y, color_.r, color_.b, color_.g, thickness);
window.draw_line(min_.x, max_.y, max_.x, max_.y, color_.r, color_.b, color_.g, thickness);
window.draw_line(max_.x, max_.y, max_.x, min_.y, color_.r, color_.b, color_.g, thickness);
}
bool Rectangle::is_inside(Vec2 const& point) const {
if ((point.x <= min_.x || point.x >= max_.x) || (point.y <= min_.y || point.y >= max_.y)) {
return false;
}
return true;
}
| 39.4
| 117
| 0.639594
|
antoniakk
|
efa51bde50cd099ba65ed62e1294083f103fd503
| 3,742
|
hpp
|
C++
|
Coin.hpp
|
jancarlsson/kapital
|
90f232e85b0f7b259eb56adf16f47c519be47ed8
|
[
"MIT"
] | 4
|
2015-07-07T19:20:29.000Z
|
2017-12-02T12:56:47.000Z
|
Coin.hpp
|
jancarlsson/kapital
|
90f232e85b0f7b259eb56adf16f47c519be47ed8
|
[
"MIT"
] | null | null | null |
Coin.hpp
|
jancarlsson/kapital
|
90f232e85b0f7b259eb56adf16f47c519be47ed8
|
[
"MIT"
] | 4
|
2017-07-18T23:08:52.000Z
|
2019-07-23T20:30:35.000Z
|
#ifndef _KAPITAL_COIN_HPP_
#define _KAPITAL_COIN_HPP_
#include <cstdint>
#include <istream>
#include <ostream>
#include <vector>
#include <snarkfront.hpp>
#include <kapital/AddressKey.hpp>
#include <kapital/HashFunctions.hpp>
namespace kapital {
////////////////////////////////////////////////////////////////////////////////
// coin commitment in Merkle tree
// (cryptographic aspect)
//
template <typename FIELD> // CryptoPP::ECP or CryptoPP::EC2N
class Coin
{
public:
// saved coin before demarshalling from disk
// received coin before demarshalling decrypted stream from pour
Coin()
: m_valid(false)
{}
// freshly minted coin
// newly poured coin before encryption
Coin(const PublicAddr<FIELD>& addr)
: m_addr(addr),
m_rho(random_array(m_rho)),
m_r(random_array(m_r)),
m_valid(addr.valid())
{}
Coin(const AddrPair<FIELD>& addr)
: Coin{addr.publicAddr()}
{}
// public address of coin
const PublicAddr<FIELD>& addr() const { return m_addr; }
void addr(const PublicAddr<FIELD>& a) { m_valid = (m_addr = a).valid(); }
bool valid() const { return m_valid; }
// random parameters
const HashDigest& rho() const { return m_rho; }
const HashTrapdoor& r() const { return m_r; }
// coin value for commitment
const std::vector<std::uint32_t>& value() const { return m_value; }
void value(const std::uint32_t a) { m_value.push_back(a); }
HashDigest commitment_k() const {
return coin_commitment_k(
r(),
m_addr.destHash(), // public address
rho());
}
HashDigest commitment_cm(const HashDigest& k) const {
return coin_commitment_cm(
value(),
k);
}
HashDigest commitment_cm() const {
return commitment_cm(
commitment_k());
}
HashDigest serial_number(const SecretAddr<FIELD>& addr) const {
return coin_serial_number(
addr.destHash(), // secret address
rho());
}
HashDigest serial_number(const AddrPair<FIELD>& addr) const {
return serial_number(addr.secretAddr());
}
void marshal_out(std::ostream& os, const bool includeAddr = true) const {
snarkfront::writeStream(os, value());
snarkfront::writeStream(os, rho());
snarkfront::writeStream(os, r());
if (includeAddr) addr().marshal_out(os);
}
bool marshal_in(std::istream& is, const bool includeAddr = true) {
return m_valid =
snarkfront::readStream(is, m_value) &&
snarkfront::readStream(is, m_rho) &&
snarkfront::readStream(is, m_r) &&
(includeAddr ? m_addr.marshal_in(is) : true);
}
// newly poured refund coin before encryption
Coin refund() const {
return Coin<FIELD>(
m_addr,
m_rho, // same serial number
random_array(r()), // different commitment
m_valid);
}
private:
Coin(const PublicAddr<FIELD>& a,
const HashDigest& b,
const HashTrapdoor& c,
const bool d)
: m_addr(a),
m_rho(b),
m_r(c),
m_valid(d)
{}
// address and commitment randomness
PublicAddr<FIELD> m_addr;
HashDigest m_rho;
HashTrapdoor m_r;
bool m_valid;
// coin value for commitment
std::vector<std::uint32_t> m_value;
};
template <typename FIELD>
std::ostream& operator<< (std::ostream& os, const Coin<FIELD>& a) {
a.marshal_out(os);
return os;
}
template <typename FIELD>
std::istream& operator>> (std::istream& is, Coin<FIELD>& a) {
a.marshal_in(is);
return is;
}
} // namespace kapital
#endif
| 25.806897
| 80
| 0.596472
|
jancarlsson
|
efb46c2b7b1ed6153c79cd0a08925d1d9c9e30b0
| 3,342
|
cpp
|
C++
|
directfire_github/trunk/gameui/battle.net/sys/spellintropage.cpp
|
zhwsh00/DirectFire-android
|
10c757e1be0b25dee951f9ba3a0e1f6d5c04a938
|
[
"MIT"
] | 1
|
2015-08-12T04:05:33.000Z
|
2015-08-12T04:05:33.000Z
|
directfire_github/trunk/gameui/battle.net/sys/spellintropage.cpp
|
zhwsh00/DirectFire-android
|
10c757e1be0b25dee951f9ba3a0e1f6d5c04a938
|
[
"MIT"
] | null | null | null |
directfire_github/trunk/gameui/battle.net/sys/spellintropage.cpp
|
zhwsh00/DirectFire-android
|
10c757e1be0b25dee951f9ba3a0e1f6d5c04a938
|
[
"MIT"
] | null | null | null |
#include "spellintropage.h"
#include "gamecore/resource/resourcemgr.h"
SpellIntroPage::SpellIntroPage()
{
m_scroll = 0;
}
SpellIntroPage::~SpellIntroPage()
{
}
void SpellIntroPage::moveInItem()
{
BasSysPage::moveInItem();
}
void SpellIntroPage::moveOutItem()
{
BasSysPage::moveOutItem();
}
void SpellIntroPage::layoutCompleted()
{
BasSysPage::layoutCompleted();
if(m_scroll == 0)
initItem();
}
void SpellIntroPage::initItem()
{
ResourceMgr *mgr = ResourceMgr::getInstance();
LangDef *lang = mgr->getLangDef();
m_scroll = new VerScrollWidget();
this->addChild(m_scroll);
m_scroll->setFill("parent");
const std::vector<std::string> &props = mgr->propsNames();
int introstart = StringEnum::StormIntro;
float width = m_anchorWidth * 0.9;
std::string animName,first;
for(unsigned int i = 0;i < props.size();i++){
const std::string &prop = props[i];
animName = prop + "exec";
first = animName;
mgr->getFrameSpriteFirstFrame(first);
if(first.empty())
continue;
BasAnimSprite *anim = new BasAnimSprite(animName,first);
anim->setAnimFinishCB(this,callfuncND_selector(SpellIntroPage::onSpellFinished));
m_animMap.insert(std::make_pair(prop,anim));
std::string logoName = prop + ".png";
CCSprite *spellLogo = CCSprite::createWithSpriteFrameName(logoName.data());
CCSize animSize = spellLogo->getContentSize();
spellLogo->addChild(anim);
anim->setAnchorPoint(ccp(0.5,0.5));
anim->setPosition(ccp(animSize.width/2,animSize.height/2));
anim->setVisible(false);
const std::string introContent = lang->getStringById(introstart + i);
CCLabelBMFont *introSprite = CCLabelBMFont::create(introContent.data(),"fonts/font20.fnt",width*0.6,kCCTextAlignmentLeft);
CCSize fontSize = introSprite->getContentSize();
CCSize size = CCSizeMake(width,MAX(animSize.height,fontSize.height));
FSizeNullDelegate *dele = new FSizeNullDelegate(size);
FSizeCCNodeDelegate *animDele = new FSizeCCNodeDelegate(spellLogo);
animDele->setCanTouch(true);
animDele->setClickCB(this,callfuncND_selector(SpellIntroPage::onSpellClicked));
animDele->setName(prop);
dele->addChild(animDele);
animDele->setVertical("parent",0.5);
animDele->setHorizontal("parent",0.2);
FSizeCCNodeDelegate *fontDele = new FSizeCCNodeDelegate(introSprite);
dele->addChild(fontDele);
fontDele->setVertical("parent",0.5);
fontDele->setHorizontal("parent",0.7);
m_scroll->addFixedSizeWidget(dele);
}
m_scroll->setSpacing(10);
}
void SpellIntroPage::onSpellClicked(CCNode *node,void *data)
{
TouchNode *touch = dynamic_cast<TouchNode*>(node);
if(touch){
const std::string &name = touch->getName();
std::map<std::string,BasAnimSprite*>::iterator iter;
iter = m_animMap.find(name);
if(iter != m_animMap.end()){
BasAnimSprite *anim = iter->second;
anim->setVisible(true);
anim->playInLoop(1);
}
}
}
void SpellIntroPage::onSpellFinished(CCNode *node,void *data)
{
BasAnimSprite *anim = dynamic_cast<BasAnimSprite*>(node);
if(anim){
anim->setVisible(false);
}
}
| 33.757576
| 130
| 0.658887
|
zhwsh00
|
efbacafa33087140fee639bcbf225073d62199f8
| 311
|
hpp
|
C++
|
addons/modules/modules/addAction/prep.hpp
|
Krzyciu/A3CS
|
b7144fc9089b5ded6e37cc1fad79b1c2879521be
|
[
"MIT"
] | 1
|
2020-06-07T00:45:49.000Z
|
2020-06-07T00:45:49.000Z
|
addons/modules/modules/addAction/prep.hpp
|
Krzyciu/A3CS
|
b7144fc9089b5ded6e37cc1fad79b1c2879521be
|
[
"MIT"
] | 27
|
2020-05-24T11:09:56.000Z
|
2020-05-25T12:28:10.000Z
|
addons/modules/modules/addAction/prep.hpp
|
Krzyciu/A3CS
|
b7144fc9089b5ded6e37cc1fad79b1c2879521be
|
[
"MIT"
] | 2
|
2020-05-31T08:52:45.000Z
|
2021-04-16T23:16:37.000Z
|
PREP_MODULE(addAction,execActionLocal);
PREP_MODULE(addAction,execActionProgressLocal);
PREP_MODULE(addAction,handleActionExecuted);
PREP_MODULE(addAction,isActionOwner);
PREP_MODULE(addAction,module);
PREP_MODULE(addAction,moduleExec);
PREP_MODULE(addAction,moduleExecLocal);
PREP_MODULE(addAction,validate);
| 31.1
| 47
| 0.868167
|
Krzyciu
|
efbbac95b76395e81d856f30e02d6b304ebb52d9
| 461
|
cpp
|
C++
|
ContaCorrente.cpp
|
marcospatton/Avancando-com-C-plus-plus-Enum-templates-e-mais-recursos
|
080cf98887e8c6a5c594b0f5b4f63024273ca47f
|
[
"MIT"
] | null | null | null |
ContaCorrente.cpp
|
marcospatton/Avancando-com-C-plus-plus-Enum-templates-e-mais-recursos
|
080cf98887e8c6a5c594b0f5b4f63024273ca47f
|
[
"MIT"
] | 1
|
2021-12-30T16:12:17.000Z
|
2021-12-31T02:02:52.000Z
|
ContaCorrente.cpp
|
marcospatton/Avancando-com-C-plus-plus-Enum-templates-e-mais-recursos
|
080cf98887e8c6a5c594b0f5b4f63024273ca47f
|
[
"MIT"
] | null | null | null |
#include "ContaCorrente.hpp"
#include <iostream>
ContaCorrente::ContaCorrente(std::string numero, Titular titular): Conta(numero, titular)
{
}
void ContaCorrente::transferePara(Conta& destino, float valor)
{
auto resultado = sacar(valor);
if (resultado.index() == 1) {
destino.depositar(valor);
}
}
void ContaCorrente::operator+=(ContaCorrente& contaOrigem)
{
contaOrigem.transferePara(*this, contaOrigem.recuperaSaldo() / 2);
}
| 23.05
| 89
| 0.707158
|
marcospatton
|
efbc77f18d2bcd1098b166e05fd43487bb4c2566
| 2,958
|
cpp
|
C++
|
src/ChatManager.cpp
|
Raymonf/OpenFusion
|
243d3d623aac1e02d3b3e318f2383e22d33649af
|
[
"MIT"
] | null | null | null |
src/ChatManager.cpp
|
Raymonf/OpenFusion
|
243d3d623aac1e02d3b3e318f2383e22d33649af
|
[
"MIT"
] | null | null | null |
src/ChatManager.cpp
|
Raymonf/OpenFusion
|
243d3d623aac1e02d3b3e318f2383e22d33649af
|
[
"MIT"
] | null | null | null |
#include "CNShardServer.hpp"
#include "CNStructs.hpp"
#include "ChatManager.hpp"
#include "PlayerManager.hpp"
void ChatManager::init() {
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_FREECHAT_MESSAGE, chatHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT, emoteHandler);
}
void ChatManager::chatHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
return; // malformed packet
sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE* chat = (sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE*)data->buf;
PlayerView plr = PlayerManager::players[sock];
// send to client
sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC* resp = (sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC));
memcpy(resp->szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
resp->iPC_ID = PlayerManager::players[sock].plr.iID;
resp->iEmoteCode = chat->iEmoteCode;
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC), sock->getFEKey()));
// send to visible players
for (CNSocket* otherSock : plr.viewable) {
sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC* resp = (sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC));
memcpy(resp->szFreeChat, chat->szFreeChat, sizeof(chat->szFreeChat));
resp->iPC_ID = PlayerManager::players[sock].plr.iID;
resp->iEmoteCode = chat->iEmoteCode;
otherSock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC), otherSock->getFEKey()));
}
}
void ChatManager::emoteHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT))
return; // ignore the malformed packet
// you can dance with friends!!!!!!!!
sP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT* emote = (sP_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT*)data->buf;
PlayerView plr = PlayerManager::players[sock];
// send to client
sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT* resp = (sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT*)xmalloc(sizeof(sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT));
resp->iEmoteCode = emote->iEmoteCode;
resp->iID_From = plr.plr.iID;
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT, sizeof(sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT), sock->getFEKey()));
// send to visible players (players within render distance)
for (CNSocket* otherSock : plr.viewable) {
resp = (sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT*)xmalloc(sizeof(sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT));
resp->iEmoteCode = emote->iEmoteCode;
resp->iID_From = plr.plr.iID;
otherSock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT, sizeof(sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT), otherSock->getFEKey()));
}
}
| 51
| 173
| 0.759973
|
Raymonf
|
efbcfa2a73a209a198237bce3901c24642794da6
| 3,278
|
cpp
|
C++
|
GRAPHS/EASY/COVID19 - EASY.cpp
|
shresth12-jain/HacktoberFest2021
|
43bd5d99668c104f89f3efef5313e4ddadd9931a
|
[
"Apache-2.0"
] | 11
|
2021-10-01T06:53:31.000Z
|
2022-02-05T20:36:20.000Z
|
GRAPHS/EASY/COVID19 - EASY.cpp
|
shresth12-jain/HacktoberFest2021
|
43bd5d99668c104f89f3efef5313e4ddadd9931a
|
[
"Apache-2.0"
] | 37
|
2021-10-01T06:54:01.000Z
|
2021-10-20T18:02:31.000Z
|
GRAPHS/EASY/COVID19 - EASY.cpp
|
shresth12-jain/HacktoberFest2021
|
43bd5d99668c104f89f3efef5313e4ddadd9931a
|
[
"Apache-2.0"
] | 110
|
2021-10-01T06:51:28.000Z
|
2021-10-31T18:00:55.000Z
|
/*COVID19
Easy Accuracy: 68.87% Submissions: 908 Points: 2
Given the N*M binary matrix, 1 represents the healthy person, and 0 represents a patient affected by a coronavirus. The task is to check the minimum time required for all persons to get affected. A patient at [i, j] cell affects a person at cell [i, j-1], [i, j+1] [i+1, j] and [i-1, j] in one second.
Note: There will be at least one patient
Input:
1. The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
2. The first line of each test case contains two space-separated integers N and M.
3. Next N lines contain M space-separated binary integers.
Output: For each test case, print the minimum time required to all persons affected by COVID19
Constraints:
1. 1 <= T <= 100
2. 1 <= N, M <= 100
3. 0 <= mat[i][j] <= 1
Example:
Input:
2
2 2
1 0
1 0
3 3
1 1 1
1 0 1
1 1 1
Output:
1
2
Explanation:
Test Case 2: After first second matrix will look like {{1, 0, 1}, {0, 0, 0}, {1, 0, 1}}. After two seconds matrix will look like {{0, 0, 0},
{0, 0, 0}, {0, 0, 0}}.*/
//DRIVER CODE
#include<bits/stdc++.h>
using namespace std;
struct Node{
int t;
int r,c;
};
//YOUR CODE
int helpaterp(vector<vector<int>>&grid)
{
//code here
queue<Node*>q;
Node* node;
int n=grid.size(),m=grid[0].size(),count;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(grid[i][j]==0){
node=new Node();
node->t=0;
node->r=i;
node->c=j;
q.push(node);}
while(!q.empty()){
Node* a=q.front();
q.pop();
int i=a->r,j=a->c,ti=a->t;
count=ti;
if(0<=(i+1) && (i+1)<n && grid[i+1][j]==1)
{
grid[i+1][j]=0;
node=new Node();
node->t=ti+1;
node->r=i+1;
node->c=j;
q.push(node);}
if(0<=(j+1) && (j+1)<m && grid[i][j+1]==1)
{
grid[i][j+1]=0;
node=new Node();
node->t=ti+1;
node->r=i;
node->c=j+1;
q.push(node);}
if(0<=(i-1) && (i-1)<n && grid[i-1][j]==1)
{
grid[i-1][j]=0;
node=new Node();
node->t=ti+1;
node->r=i-1;
node->c=j;
q.push(node);}
if(0<=(j-1) && (j-1)<m && grid[i][j-1]==1)
{
grid[i][j-1]=0;
node=new Node();
node->t=ti+1;
node->r=i;
node->c=j-1;
q.push(node);}
}
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(grid[i][j]==1){
return -1;
}
return count;
}
//DRIVER CODE
int main() {
//code
int t,a;cin>>t;
while(t--){
int n,m;cin>>n>>m;
vector<vector<int>>grid;
for(int i=0;i<n;i++){
vector<int>temp;
for(int j=0;j<m;j++){
cin>>a;
temp.push_back(a);
}
grid.push_back(temp);
}
cout<<helpaterp(grid)<<endl;}
return 0;
}
| 25.022901
| 302
| 0.461257
|
shresth12-jain
|
efbdda743ea2b9d9225a23718e2d23b020ec1407
| 2,227
|
cpp
|
C++
|
practice/235-lowest-common-ancestor-of-a-binary-search-tree/LeetCode_235_0144.cpp
|
manajay/algorithm-list
|
828b0baed25a743fdb010427f873b29af9587951
|
[
"MIT"
] | null | null | null |
practice/235-lowest-common-ancestor-of-a-binary-search-tree/LeetCode_235_0144.cpp
|
manajay/algorithm-list
|
828b0baed25a743fdb010427f873b29af9587951
|
[
"MIT"
] | null | null | null |
practice/235-lowest-common-ancestor-of-a-binary-search-tree/LeetCode_235_0144.cpp
|
manajay/algorithm-list
|
828b0baed25a743fdb010427f873b29af9587951
|
[
"MIT"
] | null | null | null |
/**
给定一个二叉搜索树, 找到该树中两个指定节点的最近公共祖先。
百度百科中最近公共祖先的定义为:“对于有根树 T 的两个结点 p、q,最近公共祖先表示为一个结点 x,满足 x 是 p、q 的祖先且 x 的深度尽可能大(一个节点也可以是它自己的祖先)。”
例如,给定如下二叉搜索树: root = [6,2,8,0,4,7,9,null,null,3,5]
示例 1:
输入: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8
输出: 6
解释: 节点 2 和节点 8 的最近公共祖先是 6。
示例 2:
输入: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4
输出: 2
解释: 节点 2 和节点 4 的最近公共祖先是 2, 因为根据定义最近公共祖先节点可以为节点本身。
说明:
所有节点的值都是唯一的。
p、q 为不同节点且均存在于给定的二叉搜索树中。
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/lowest-common-ancestor-of-a-binary-search-tree
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
*
*/
#include <iostream>
#include <vector>
using namespace std;
struct TreeNode
{
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution
{
public:
TreeNode *lowestCommonAncestor(TreeNode *root, TreeNode *p, TreeNode *q)
{
// 注意这个是二叉搜索树,
// 情况1 root p q 为root左子树 , 包括自己为root
// 情况2 root p q 为root右子树 , 包括自己为root
// 情况3 p q 为root不同的子树
int rootVal = root->val, pVal = p->val, qVal = q->val;
if (rootVal > pVal && rootVal > qVal)
{ //左子树
return lowestCommonAncestor(root->left, p, q);
}
else if (rootVal < pVal && rootVal < qVal)
{ //右子树
return lowestCommonAncestor(root->right, p, q);
}
else
{ //根节点
return root;
}
}
};
class Solution
{
public:
TreeNode *lowestCommonAncestor(TreeNode *root, TreeNode *p, TreeNode *q)
{
// 注意这个是二叉搜索树,
// 情况1 root p q 为root左子树 , 包括自己为root
// 情况2 root p q 为root右子树 , 包括自己为root
// 情况3 p q 为root不同的子树
int rootVal = root->val,
pVal = p->val,
qVal = q->val;
TreeNode *node = root;
while (node)
{
rootVal = node->val;
if (rootVal < pVal && rootVal < qVal)
{ // 右子树
node = node->right;
}
else if (rootVal > pVal && rootVal > qVal)
{
node = node->left;
}
else
{
return node;
}
}
return root;
}
};
| 21.621359
| 94
| 0.533453
|
manajay
|
efcd23037c829711734cc835a991905248a61ddb
| 2,943
|
hpp
|
C++
|
fprime-sphinx-drivers/SPIDriverGeneric/test/ut/Tester.hpp
|
fprime-community/fprime-sphinx-drivers
|
ce9efa8564b0eeee46b75bdee79a41a4d0dfd65b
|
[
"Apache-2.0"
] | 1
|
2021-02-22T12:34:25.000Z
|
2021-02-22T12:34:25.000Z
|
fprime-sphinx-drivers/SPIDriverGeneric/test/ut/Tester.hpp
|
fprime-community/fprime-sphinx-drivers
|
ce9efa8564b0eeee46b75bdee79a41a4d0dfd65b
|
[
"Apache-2.0"
] | 2
|
2021-08-11T17:14:54.000Z
|
2021-09-09T22:31:19.000Z
|
fprime-sphinx-drivers/SPIDriverGeneric/test/ut/Tester.hpp
|
fprime-community/fprime-sphinx-drivers
|
ce9efa8564b0eeee46b75bdee79a41a4d0dfd65b
|
[
"Apache-2.0"
] | 1
|
2021-05-19T02:04:10.000Z
|
2021-05-19T02:04:10.000Z
|
// ======================================================================
// \title SPIDriverGeneric/test/ut/Tester.hpp
// \author bsoudry
// \brief hpp file for SPIDriverGeneric test harness implementation class
//
// \copyright
// Copyright 2009-2015, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// ======================================================================
#ifndef TESTER_HPP
#define TESTER_HPP
#include "GTestBase.hpp"
#include "fprime-sphinx-drivers/SPIDriverGeneric/SPIDriverGenericComponentImpl.hpp"
#include "fprime-sphinx-drivers/SPIDriverGeneric/SPIDriverGenericErrorCodes.hpp"
#include "fprime-sphinx-drivers/Random/Random.hpp"
namespace Drv {
class Tester :
public SPIDriverGenericGTestBase
{
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
public:
//! Construct object Tester
//!
Tester(void);
Tester(const char* compName,
U8 loopback_mode,
U8 clock_polarity,
U8 clock_phase,
U8 div_clock_16,
U8 reverse_mode,
U8 word_len,
U8 prescale_modulus,
U8 prescale_modulus_factor,
U8 clock_gap);
//! Destroy object Tester
//!
~Tester(void);
public:
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
void testClaimUnclaimOK(void);
void testDoubleClaim(void);
void testDoubleUnclaim(void);
void testInitOK(void);
void testConfigureOK(void);
void testConfigureNotOwner(void);
void testRWNotOwner(void);
void testConstructor(void);
private:
// ----------------------------------------------------------------------
// Handlers for typed from ports
// ----------------------------------------------------------------------
//! Handler for from_timeCaller
//!
void from_timeCaller_handler(
const NATIVE_INT_TYPE portNum, /*!< The port number*/
Fw::Time &time /*!< The U32 cmd argument*/
);
private:
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
//! Connect ports
//!
void connectPorts(void);
//! Initialize components
//!
void initComponents(void);
protected:
// ----------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------
//! The component under test
//!
SPIDriverGenericComponentImpl component;
};
} // end namespace Drv
#endif
| 28.028571
| 83
| 0.447842
|
fprime-community
|
efd0597666b4a5f6b5547aa365bb15eb4c148396
| 5,793
|
hpp
|
C++
|
include/noarr/pipelines/HardwareManager.hpp
|
ParaCoToUl/noarr-pipelines
|
138f69065e40403a41b95103262b39f2e04dcab8
|
[
"MIT"
] | null | null | null |
include/noarr/pipelines/HardwareManager.hpp
|
ParaCoToUl/noarr-pipelines
|
138f69065e40403a41b95103262b39f2e04dcab8
|
[
"MIT"
] | null | null | null |
include/noarr/pipelines/HardwareManager.hpp
|
ParaCoToUl/noarr-pipelines
|
138f69065e40403a41b95103262b39f2e04dcab8
|
[
"MIT"
] | null | null | null |
#ifndef NOARR_PIPELINES_HARDWARE_MANAGER_HPP
#define NOARR_PIPELINES_HARDWARE_MANAGER_HPP
#include <memory>
#include <cassert>
#include <vector>
#include <map>
#include <functional>
#include <iostream>
#include "noarr/pipelines/Device.hpp"
#include "noarr/pipelines/Buffer.hpp"
#include "noarr/pipelines/MemoryAllocator.hpp"
#include "noarr/pipelines/HostAllocator.hpp"
#include "noarr/pipelines/DummyGpuAllocator.hpp"
#include "noarr/pipelines/MemoryTransferer.hpp"
#include "noarr/pipelines/HostTransferer.hpp"
namespace noarr {
namespace pipelines {
class HardwareManager; // forward declaration for the static variable
namespace {
std::unique_ptr<HardwareManager> default_manager_instance;
}
/**
* Hardware manager tracks and communicates with CPU and GPU devices.
* It is primarily responsible for memory allocations and memory transfers.
*/
class HardwareManager {
public:
/**
* Returns the instance of the default hardware manager (singleton)
* (this instance should be used in most cases, instead of creating a custom one)
*/
static HardwareManager& default_manager() {
if (default_manager_instance == nullptr) {
default_manager_instance = std::make_unique<HardwareManager>();
}
return *default_manager_instance;
}
HardwareManager() {
// register allocator and transferer for the host
set_allocator_for(
Device::HOST_INDEX,
std::make_unique<HostAllocator>()
);
set_transferer_for(
Device::HOST_INDEX, Device::HOST_INDEX,
std::make_unique<HostTransferer>(false)
);
}
/**
* Registers a dummy GPU device that can be used for simulating memory
* transfers on a system without any GPUs
*/
void register_dummy_gpu() {
set_allocator_for(
Device::DUMMY_GPU_INDEX,
std::make_unique<DummyGpuAllocator>()
);
set_transferer_for(
Device::DUMMY_GPU_INDEX, Device::DUMMY_GPU_INDEX,
std::make_unique<HostTransferer>(true)
);
set_transferer_for(
Device::HOST_INDEX, Device::DUMMY_GPU_INDEX,
std::make_unique<HostTransferer>(true)
);
set_transferer_for(
Device::DUMMY_GPU_INDEX, Device::HOST_INDEX,
std::make_unique<HostTransferer>(true)
);
}
/**
* Allocates a new buffer on the given device
*/
Buffer allocate_buffer(Device::index_t device_index, std::size_t bytes) {
MemoryAllocator& allocator = get_allocator_for(device_index);
return Buffer::allocate_new(allocator, bytes);
}
/**
* Transfers data between two buffers, typically on different devices.
* The transfer is asynchronous, so a callback must be provided.
*/
void transfer_data(
const Buffer& from,
const Buffer& to,
std::size_t bytes,
std::function<void()> callback
) {
assert(bytes <= from.bytes && "Transfering too many bytes");
assert(bytes <= to.bytes && "Transfering too many bytes");
MemoryTransferer& transferer = get_transferer(
from.device_index,
to.device_index
);
transferer.transfer(
from.data_pointer,
to.data_pointer,
bytes,
callback
);
}
/**
* Transfers data between two buffers synchronously.
*/
void transfer_data_sync(
const Buffer& from,
const Buffer& to,
std::size_t bytes
) {
assert(bytes <= from.bytes && "Transfering too many bytes");
assert(bytes <= to.bytes && "Transfering too many bytes");
MemoryTransferer& transferer = get_transferer(
from.device_index,
to.device_index
);
transferer.transfer_sync(
from.data_pointer,
to.data_pointer,
bytes
);
}
/////////////////////
// Lower-level API //
/////////////////////
private:
std::map<
Device::index_t,
std::unique_ptr<MemoryAllocator>
> allocators;
std::map<
std::tuple<Device::index_t, Device::index_t>,
std::unique_ptr<MemoryTransferer>
> transferers;
public:
/**
* Returns allocator for a device
*/
MemoryAllocator& get_allocator_for(Device::index_t device_index) {
assert(
allocators.count(device_index) == 1
&& "There is no allocator for the given device index"
);
return *allocators[device_index];
}
/**
* Sets allocator for a device
*/
void set_allocator_for(
Device::index_t device_index,
std::unique_ptr<MemoryAllocator> allocator
) {
assert(
allocator->device_index() == device_index
&& "Given allocator allocated for different device"
);
allocators[device_index] = std::move(allocator);
}
/**
* Returns transferer between two devices
*/
MemoryTransferer& get_transferer(Device::index_t from, Device::index_t to) {
assert(
transferers.count(std::make_tuple(from, to)) == 1
&& "There is no trasferrer between given devices"
);
return *transferers[std::make_tuple(from, to)];
}
/**
* Sets a memory transferer for transfers from one given device to another
* (only in that one direction)
*/
void set_transferer_for(
Device::index_t from,
Device::index_t to,
std::unique_ptr<MemoryTransferer> transferer
) {
transferers[std::make_tuple(from, to)] = std::move(transferer);
}
};
} // pipelines namespace
} // namespace noarr
#endif
| 27.585714
| 85
| 0.617815
|
ParaCoToUl
|
efd6b61dc7ac44cc423b2a902ddce3facd3b07e9
| 3,229
|
cpp
|
C++
|
.LHP/.Lop11/.HSG/.T.Minh/Week 9/GPSF/GPSF/GPSF.cpp
|
sxweetlollipop2912/MaCode
|
661d77a2096e4d772fda2b6a7f80c84113b2cde9
|
[
"MIT"
] | null | null | null |
.LHP/.Lop11/.HSG/.T.Minh/Week 9/GPSF/GPSF/GPSF.cpp
|
sxweetlollipop2912/MaCode
|
661d77a2096e4d772fda2b6a7f80c84113b2cde9
|
[
"MIT"
] | null | null | null |
.LHP/.Lop11/.HSG/.T.Minh/Week 9/GPSF/GPSF/GPSF.cpp
|
sxweetlollipop2912/MaCode
|
661d77a2096e4d772fda2b6a7f80c84113b2cde9
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#define maxN 501
#define minA -99999999
#define cost(x, y) ((x) != (y) ? (maxa)(-1) : (maxa)2)
typedef long maxn, maxa;
maxn na, nb, mxa[maxN][maxN], mxb[maxN][maxN], fina, finb;
std::string a, b, resa, resb;
maxa f[maxN][maxN], res;
void Prepare() {
std::cin >> a >> b;
na = a.size(), nb = b.size();
for (maxn i = 0; i <= na; i++) std::fill(f[i], f[i] + nb + 1, minA);
memset(mxa, 0, sizeof(mxa));
memset(mxb, 0, sizeof(mxb));
resa = resb = "";
}
void Trace(const maxn ia, const maxn ib) {
if (ia < 0 || ib < 0) return;
if (!ia) {
for (maxn i = ib - 1; i >= 0; i--) resb += b[i], resa += '-';
return;
}
if (!ib) {
for (maxn i = ia - 1; i >= 0; i--) resa += a[i], resb += '-';
return;
}
maxn nia = ia, nib = ib;
if (f[ia - 1][ib - 1] + cost(a[ia - 1], b[ib - 1]) == f[ia][ib])
nia = ia - 1, nib = ib - 1;
else if (f[ia - 1][mxa[ia - 1][ib - 1]] - (ib - mxa[ia - 1][ib - 1] - 1) - 4 + cost(a[ia - 1], b[ib - 1]) == f[ia][ib])
nia = ia - 1, nib = mxa[ia - 1][ib - 1];
else if (f[mxb[ib - 1][ia - 1]][ib - 1] - (ia - mxb[ib - 1][ia - 1] - 1) - 4 + cost(a[ia - 1], b[ib - 1]) == f[ia][ib])
nia = mxb[ib - 1][ia - 1], nib = ib - 1;
if (ia) resa += a[ia - 1];
if (ib) resb += b[ib - 1];
for (maxn i = ia - 1; i > std::max(nia, (maxn)0); i--) resb += '-', resa += a[i - 1];
for (maxn i = ib - 1; i > std::max(nib, (maxn)0); i--) resa += '-', resb += b[i - 1];
Trace(nia, nib);
}
void Process() {
for (maxn i = 1; i <= na || i <= nb; i++) f[i][0] = f[0][i] = -4 - i;
f[0][0] = 0, res = minA;
for (maxn ia = 1; ia <= na; ia++) {
for (maxn ib = 1; ib <= nb; ib++) {
f[ia][ib] = f[ia - 1][ib - 1] + cost(a[ia - 1], b[ib - 1]);
f[ia][ib] = std::max(f[ia][ib], f[ia - 1][mxa[ia - 1][ib - 1]] - (ib - mxa[ia - 1][ib - 1] - 1) - 4 + cost(a[ia - 1], b[ib - 1]));
f[ia][ib] = std::max(f[ia][ib], f[mxb[ib - 1][ia - 1]][ib - 1] - (ia - mxb[ib - 1][ia - 1] - 1) - 4 + cost(a[ia - 1], b[ib - 1]));
mxa[ia][ib] = f[ia][ib] + ib > f[ia][mxa[ia][ib - 1]] + mxa[ia][ib - 1] ? ib : mxa[ia][ib - 1];
mxb[ib][ia] = f[ia][ib] + ia > f[mxb[ib][ia - 1]][ib] + mxb[ib][ia - 1] ? ia : mxb[ib][ia - 1];
}
res = std::max(res, f[ia][nb] - (na - ia) - (maxn)4);
}
res = std::max(res, f[na][nb]), fina = na, finb = nb;
for (maxn ib = 0; ib <= nb; ib++) {
if (res >= f[na][ib] - (nb - ib) - (maxa)4) continue;
res = f[na][ib] - (nb - ib) - (maxa)4, fina = na, finb = ib;
}
for (maxn ia = 0; ia <= na; ia++) {
if (res >= f[ia][nb] - (na - ia) - (maxa)4) continue;
res = f[ia][nb] - (na - ia) - (maxa)4, fina = ia, finb = nb;
}
std::cout << res << '\n';
for (maxn i = na; i > std::max(fina, (maxn)0); i--) resb += '-', resa += a[i - 1];
for (maxn i = nb; i > std::max(finb, (maxn)0); i--) resa += '-', resb += b[i - 1];
Trace(fina, finb);
std::reverse(resa.begin(), resa.end()); std::reverse(resb.begin(), resb.end());
std::cout << resa << '\n' << resb << '\n';
}
int main() {
//freopen("gpsf.inp", "r", stdin);
//freopen("gpsf.out", "w", stdout);
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
int t; std::cin >> t;
while (t--) {
Prepare();
Process();
}
}
| 30.462264
| 133
| 0.470115
|
sxweetlollipop2912
|
efd7a593ea132985ed5be5d133c2939c3395a054
| 19,557
|
hh
|
C++
|
include/click/nameinfo.hh
|
MacWR/Click-changed-for-ParaGraph
|
18285e5da578fbb7285d10380836146e738dee6e
|
[
"Apache-2.0"
] | 129
|
2015-10-08T14:38:35.000Z
|
2022-03-06T14:54:44.000Z
|
include/click/nameinfo.hh
|
MacWR/Click-changed-for-ParaGraph
|
18285e5da578fbb7285d10380836146e738dee6e
|
[
"Apache-2.0"
] | 241
|
2016-02-17T16:17:58.000Z
|
2022-03-15T09:08:33.000Z
|
include/click/nameinfo.hh
|
MacWR/Click-changed-for-ParaGraph
|
18285e5da578fbb7285d10380836146e738dee6e
|
[
"Apache-2.0"
] | 61
|
2015-12-17T01:46:58.000Z
|
2022-02-07T22:25:19.000Z
|
// -*- c-basic-offset: 4; related-file-name: "../../lib/nameinfo.cc" -*-
#ifndef CLICK_NAMEINFO_HH
#define CLICK_NAMEINFO_HH
#include <click/args.hh>
#include <click/straccum.hh>
CLICK_DECLS
class Element;
class NameDB;
class ErrorHandler;
class NameInfo { public:
/** @brief Construct a NameInfo element.
*
* Users never need to call this. */
NameInfo();
/** @brief Destroy a NameInfo object.
*
* Also destroys all NameDB objects installed on this NameInfo.
*
* Users never need to call this. */
~NameInfo();
/** @brief Static initialization for NameInfo.
*
* Creates the global NameInfo used for databases unconnected to any
* router. Users never need to call this. */
static void static_initialize();
/** @brief Static cleanup for NameInfo.
*
* Destroys the global NameInfo used for databases unconnected to any
* router. Users never need to call this. */
static void static_cleanup();
/** @brief Known name database types. */
enum DBType {
T_NONE = 0, ///< Nonexistent names database
T_SCHEDULEINFO = 0x00000001, ///< ScheduleInfo database
T_ANNOTATION = 0x00000002, ///< Packet annotation database
T_SCRIPT_INSN = 0x00000003, ///< Script instruction names database
T_SIGNO = 0x00000004, ///< User-level signal names database
T_SPINLOCK = 0x00000005, ///< Spinlock names database
T_ETHERNET_ADDR = 0x01000001, ///< Ethernet address names database
T_IP_ADDR = 0x04000001, ///< IP address names database
T_IP_PREFIX = 0x04000002, ///< IP prefix names database
T_IP_PROTO = 0x04000003, ///< IP protocol names database
T_IPFILTER_TYPE = 0x04000004, ///< IPFilter instruction names database
T_TCP_OPT = 0x04000005, ///< TCP option names database
T_IPREWRITER_PATTERN = 0x04000006, ///< IPRewriterPattern database
T_ICMP_TYPE = 0x04010000, ///< ICMP type names database
T_ICMP_CODE = 0x04010100, ///< ICMP code names database
T_IP_PORT = 0x04020000, ///< Starting point for IP per-protocol port names databases
T_TCP_PORT = 0x04020006, ///< TCP port names database
T_UDP_PORT = 0x04020011, ///< UDP port names database
T_IP_FIELDNAME = 0x04030000, ///< Starting point for IP per-protocol field names databases
T_ICMP_FIELDNAME = 0x04030001, ///< ICMP field names database
T_TCP_FIELDNAME = 0x04030006, ///< TCP field names database
T_UDP_FIELDNAME = 0x04030011, ///< UDP field names database
T_IP6_ADDR = 0x06000001, ///< IPv6 address names database
T_IP6_PREFIX = 0x06000002 ///< IPv6 prefix names database
};
/** @brief Find or create a name database.
* @param type database type
* @param context compound element context
* @param value_size size of values stored in database
* @param create whether to create a DynamicNameDB if no database exists
*
* Returns an installed name database matching @a type and @a context.
* (If @a context is non-null, then the database matches the implied
* router and compound element context. Otherwise, the database is the
* unique global database for the given @a type.) If @a create is true,
* and no database exists exactly matching @a type and @a context, then a
* DynamicNameDB is created and installed with that @a type, @a context,
* and @a value_size. Otherwise, the search bubbles up through the
* prefixes of @a context until an installed database is found.
*
* Returns null if no installed database is found. @a value_size must
* match the value size in the returned database.
*
* Most users will use query() and define() directly, not call getdb().
*/
static NameDB *getdb(uint32_t type, const Element *context,
size_t value_size, bool create);
/** @brief Install a name database.
* @param db name database
* @param context compound element context
*
* Installs the given name database for the compound element context
* implied by @a context. (If @a context is non-null, then the database
* is installed for the implied router and compound element context. If
* it is null, the database is installed globally.) The query() and
* define() operations apply only to installed databases.
*
* It is an error to install a database that has already been installed.
* It is also an error to install a database for a compound element
* context that already has a different database installed. An installed
* NameDB is automatically destroyed when its containing NameInfo is
* destroyed (for example, when @a context's router is destroyed).
*/
static void installdb(NameDB *db, const Element *context);
/** @brief Uninstall a name database.
* @param db name database
*
* Undoes the effects of installdb(). The given database will no longer
* be used for query() and define() operations.
*/
static void uninstalldb(NameDB *db);
/** @brief Query installed databases for @a name.
* @param type database type
* @param context compound element context
* @param name name to look up
* @param value_store value storage
* @param value_size size of value storage
* @return true iff the query succeeded
*
* Queries all installed @a type databases that apply to the compound
* element @a context, returning the most specific value matching @a name.
* The value is stored in @a value_store. The installed databases must
* have the given @a value_size.
*/
static bool query(uint32_t type, const Element *context,
const String &name, void *value_store, size_t value_size);
/** @brief Query installed databases for @a name, returning a 32-bit integer value.
* @param type database type
* @param context compound element context
* @param name name to look up
* @param value_store value storage
* @return true iff the query succeeded
*
* Queries all installed @a type databases that apply to the compound
* element @a context, returning the most specific value matching @a name.
* The value is stored in @a value_store. The installed databases must
* have a value size of 4.
*
* If no matching name is found, query_int checks whether @a name unparses
* into a 32-bit integer value (for example, "30"). If so, *@a
* value_store is set to the corresponding integer and true is returned.
* Otherwise, false is returned.
*/
static bool query_int(uint32_t type, const Element *context,
const String &name, int32_t *value_store);
/** @overload */
static bool query_int(uint32_t type, const Element *context,
const String &name, uint32_t *value_store);
/** @brief Query installed databases for @a value.
* @param type database type
* @param context compound element context
* @param value points to value to look up
* @param value_size size of value
* @return the name, or the empty string if the query failed
*
* Queries all installed @a type databases that apply to the compound
* element @a context, returning the name in the most specific database
* whose value matches @a value, or the empty string if the relevant
* databases don't support reverse queries or no such value exists. The
* installed databases must have the given @a value_size.
*/
static String revquery(uint32_t type, const Element *context,
const void *value, size_t value_size);
/** @brief Query installed databases for a 32-bit integer @a value.
* @param type database type
* @param context compound element context
* @param value value to look up
* @return the name, or the empty string if the query failed
*
* Queries all installed @a type databases that apply to the compound
* element @a context, returning the name in the most specific database
* whose value matches @a value, or the empty string if the relevant
* databases don't support reverse queries or no such value exists. The
* installed databases must have value size 4.
*/
static inline String revquery_int(uint32_t type, const Element *context,
int32_t value);
/** @brief Define @a name to equal @a value in the installed databases.
* @param type database type
* @param context compound element context
* @param name name to define
* @param value points to defined value
* @param value_size size of value
* @return true iff the name was defined
*
* Defines the given @a name to @a value in the installed @a type database
* with compound element @a context. If no database exists exactly
* matching that @a type and @a context, a new DynamicNameDB is created
* and installed with those values (and the given @a value_size). A name
* might not be defined if the existing database for that @a type and @a
* context doesn't support definitions, or if no new database can be
* created. If any database exists, it must match the given @a
* value_size.
*/
static inline bool define(uint32_t type, const Element *context,
const String &name, const void *value, size_t value_size);
/** @brief Define @a name to equal 32-bit integer @a value in the installed databases.
* @param type database type
* @param context compound element context
* @param name name to define
* @param value defined value
* @return true iff the value was defined
*
* Defines the given @a name to @a value in the installed @a type database
* with compound element @a context. If no database exists exactly
* matching that @a type and @a context, a new DynamicNameDB is created
* and installed with those values (and value size 4). A name might not
* be defined if the existing database for that @a type and @a context
* doesn't support definitions, or if no new database can be created. If
* any database exists, it must have value size 4.
*/
static inline bool define_int(uint32_t type, const Element *context,
const String &name, int32_t value);
#if CLICK_NAMEDB_CHECK
/** @cond never */
void check(ErrorHandler *);
static void check(const Element *, ErrorHandler *);
/** @endcond never */
#endif
private:
Vector<NameDB *> _namedb_roots;
Vector<NameDB *> _namedbs;
inline NameDB *install_dynamic_sentinel() { return (NameDB *) this; }
NameDB *namedb(uint32_t type, size_t size, const String &prefix, NameDB *installer);
#if CLICK_NAMEDB_CHECK
uintptr_t _check_generation;
void checkdb(NameDB *db, NameDB *parent, ErrorHandler *errh);
#endif
};
class NameDB { public:
/** @brief Construct a database.
* @param type database type
* @param context database compound element context, as a String
* @param value_size database value size
*
* @a value_size must be greater than 0. */
inline NameDB(uint32_t type, const String &context, size_t value_size);
/** @brief Destroy a database.
*
* Destroying an installed database automatically uninstalls it.
* See NameInfo::uninstalldb(). */
virtual ~NameDB() {
NameInfo::uninstalldb(this);
}
/** @brief Return the database type. */
uint32_t type() const {
return _type;
}
/** @brief Return the database's compound element context as a string. */
const String &context() const {
return _context;
}
/** @brief Return the contextual parent database, if any.
*
* The contextual parent database is the unique database, for the same
* router, with the same type(), whose context() is a prefix of this
* database's context(), that has the longest context() of any matching
* database. If there is no such database returns null. */
NameDB *context_parent() const {
return _context_parent;
}
/** @brief Return the database's value size. */
size_t value_size() const {
return _value_size;
}
/** @brief Query this database for a given name.
* @param name name to look up
* @param value points to value storage
* @param value_size size of value storage
* @return true iff the query succeeded
*
* The @a value_size parameter must equal this database's value size. */
virtual bool query(const String &name, void *value, size_t value_size) = 0;
/** @brief Query this database for a given value.
* @param value points to value to look up
* @param value_size size of value storage
* @return the name for the given value, or an empty string if the value
* has not been defined
*
* The @a value_size parameter must equal this database's value size.
* The default implementation always returns the empty string. */
virtual String revquery(const void *value, size_t value_size);
/** @brief Define a name in this database to a given value.
* @param name name to define
* @param value points to value to define
* @param value_size size of value storage
* @return true iff the name was defined
*
* The @a value_size parameter must equal this database's value size.
* The default implementation always returns false. */
virtual bool define(const String &name, const void *value, size_t value_size);
/** @brief Define a name in this database to a 32-bit integer value.
* @param name name to define
* @param value value to define
* @return true iff the name was defined
*
* The database's value size must equal 4. The implementation is the same
* as <code>define(name, &value, 4)</code>. */
inline bool define_int(const String &name, int32_t value);
#if CLICK_NAMEDB_CHECK
/** @cond never */
virtual void check(ErrorHandler *);
/** @endcond never */
#endif
private:
uint32_t _type;
String _context;
size_t _value_size;
NameDB *_context_parent;
NameDB *_context_sibling;
NameDB *_context_child;
NameInfo *_installed;
#if CLICK_NAMEDB_CHECK
uintptr_t _check_generation;
#endif
friend class NameInfo;
};
class StaticNameDB : public NameDB { public:
struct Entry {
const char *name;
uint32_t value;
};
/** @brief Construct a static name database.
* @param type database type
* @param context database compound element context, as a String
* @param entry pointer to static entry list
* @param nentry number of entries
*
* The entry array specifies the contents of the database. It must be
* sorted by name: entry[i].name < entry[i+1].name for all 0 <= i <
* nentry-1. The entry array must also persist as long as the database is
* in use; the database doesn't copy the entry array into its own memory,
* but continues to use the array passed in. The resulting database has
* value_size() 4. */
inline StaticNameDB(uint32_t type, const String &context,
const Entry *entry, size_t nentry);
/** @brief Query this database for a given name.
* @param name name to look up
* @param value points to value storage
* @param value_size size of value storage
* @return true iff the query succeeded
*
* The @a value_size parameter must equal 4. */
bool query(const String &name, void *value, size_t value_size);
/** @brief Query this database for a given value.
* @param value points to value to look up
* @param value_size size of value storage
* @return the name for the given value, or an empty string if the value
* has not been defined
*
* The @a value_size parameter must equal 4. */
String revquery(const void *value, size_t value_size);
#if CLICK_NAMEDB_CHECK
/** @cond never */
void check(ErrorHandler *);
/** @endcond never */
#endif
private:
const Entry *_entries;
size_t _nentries;
};
class DynamicNameDB : public NameDB { public:
/** @brief Construct a dynamic name database.
* @param type database type
* @param context database compound element context, as a String
* @param value_size database value size
*
* @a value_size must be greater than 0. The database is initially
* empty. */
inline DynamicNameDB(uint32_t type, const String &context, size_t value_size);
/** @brief Query this database for a given name.
* @param name name to look up
* @param value points to value storage
* @param value_size size of value storage
* @return true iff the query succeeded
*
* The @a value_size parameter must equal this database's value size. */
bool query(const String &name, void *value, size_t value_size);
/** @brief Query this database for a given value.
* @param value points to value to look up
* @param value_size size of value storage
* @return the name for the given value, or an empty string if the value
* has not been defined
*
* The @a value_size parameter must equal this database's value size. */
String revquery(const void *value, size_t value_size);
/** @brief Define a name in this database to a given value.
* @param name name to define
* @param value points to value to define
* @param value_size size of value storage
* @return true iff the name was defined
*
* The @a value_size parameter must equal this database's value size. */
bool define(const String &name, const void *value, size_t value_size);
#if CLICK_NAMEDB_CHECK
/** @cond never */
void check(ErrorHandler *);
/** @endcond never */
#endif
private:
Vector<String> _names;
StringAccum _values;
int _sorted;
void *find(const String &name, bool create);
void sort();
};
inline
NameDB::NameDB(uint32_t type, const String &context, size_t vsize)
: _type(type), _context(context), _value_size(vsize),
_context_parent(0), _context_sibling(0), _context_child(0), _installed(0)
{
#if CLICK_NAMEDB_CHECK
_check_generation = 0;
#endif
assert(_value_size > 0);
}
inline
StaticNameDB::StaticNameDB(uint32_t type, const String &context, const Entry *entry, size_t nentry)
: NameDB(type, context, sizeof(entry->value)), _entries(entry), _nentries(nentry)
{
}
inline
DynamicNameDB::DynamicNameDB(uint32_t type, const String &context, size_t vsize)
: NameDB(type, context, vsize), _sorted(0)
{
}
inline String
NameInfo::revquery_int(uint32_t type, const Element *e, int32_t value)
{
return revquery(type, e, &value, sizeof(value));
}
inline bool
NameInfo::define(uint32_t type, const Element *e, const String &name, const void *value, size_t vsize)
{
if (NameDB *db = getdb(type, e, vsize, true))
return db->define(name, value, vsize);
else
return false;
}
inline bool
NameInfo::define_int(uint32_t type, const Element *e, const String &name, const int32_t value)
{
if (NameDB *db = getdb(type, e, sizeof(value), true))
return db->define(name, &value, sizeof(value));
else
return false;
}
inline bool
NameDB::define_int(const String &name, const int32_t value)
{
return define(name, &value, sizeof(value));
}
/** @class NamedIntArg
@brief Parser class for named integers. */
struct NamedIntArg {
NamedIntArg(uint32_t type)
: _type(type) {
}
bool parse(const String &str, int &value, const ArgContext &args) {
return NameInfo::query(_type, args.context(), str,
&value, sizeof(value))
|| IntArg().parse(str, value, args);
}
int _type;
};
CLICK_ENDDECLS
#endif
| 36.969754
| 102
| 0.684154
|
MacWR
|
efd827a27d7de1a4aabbaf54698c263ce1ff733c
| 1,298
|
cpp
|
C++
|
server/Common/Packets/GCBoxItemList.cpp
|
viticm/web-pap
|
7c9b1f49d9ba8d8e40f8fddae829c2e414ccfeca
|
[
"BSD-3-Clause"
] | 3
|
2018-06-19T21:37:38.000Z
|
2021-07-31T21:51:40.000Z
|
server/Common/Packets/GCBoxItemList.cpp
|
viticm/web-pap
|
7c9b1f49d9ba8d8e40f8fddae829c2e414ccfeca
|
[
"BSD-3-Clause"
] | null | null | null |
server/Common/Packets/GCBoxItemList.cpp
|
viticm/web-pap
|
7c9b1f49d9ba8d8e40f8fddae829c2e414ccfeca
|
[
"BSD-3-Clause"
] | 13
|
2015-01-30T17:45:06.000Z
|
2022-01-06T02:29:34.000Z
|
#include "stdafx.h"
#include "GCBoxItemList.h"
using namespace Packets;
BOOL GCBoxItemList::Read( SocketInputStream& iStream )
{
__ENTER_FUNCTION
iStream.Read((CHAR*)&m_ItemBoxID,sizeof(ObjID_t));
iStream.Read((CHAR*)(&m_ItemNumber), sizeof(BYTE));
iStream.Read((CHAR*)(&m_ItemBoxType),sizeof(WORD));
if(m_ItemNumber>MAX_BOXITEM_NUMBER) m_ItemNumber = MAX_BOXITEM_NUMBER;
for(INT i =0;i<m_ItemNumber;i++)
{
m_ItemList[i].Read(iStream);
}
return TRUE ;
__LEAVE_FUNCTION
return FALSE ;
}
BOOL GCBoxItemList::Write( SocketOutputStream& oStream ) const
{
__ENTER_FUNCTION
Assert(m_ItemNumber<=MAX_BOXITEM_NUMBER);
oStream.Write((CHAR*)(&m_ItemBoxID),sizeof(ObjID_t));
oStream.Write( (CHAR*)(&m_ItemNumber), sizeof(BYTE));
oStream.Write((CHAR*)(&m_ItemBoxType),sizeof(WORD));
for(INT i =0;i<m_ItemNumber;i++)
{
m_ItemList[i].Write(oStream);
}
return TRUE ;
__LEAVE_FUNCTION
return FALSE ;
}
UINT GCBoxItemList::Execute( Player* pPlayer )
{
__ENTER_FUNCTION
return GCBoxItemListHandler::Execute( this, pPlayer ) ;
__LEAVE_FUNCTION
return FALSE ;
}
| 26.489796
| 84
| 0.617103
|
viticm
|
efd96a26edb3c0315e8d28081febd59935d735c6
| 2,110
|
hpp
|
C++
|
lib/sparse-bench/src/cpu/BenchmarkUtils.hpp
|
paul-g/spark
|
9e561d7a575c6a984660ba4afc476a0a7aa5264d
|
[
"MIT"
] | 20
|
2015-12-02T22:31:37.000Z
|
2022-03-31T05:18:04.000Z
|
lib/sparse-bench/src/cpu/BenchmarkUtils.hpp
|
caskorg/cask
|
9e561d7a575c6a984660ba4afc476a0a7aa5264d
|
[
"MIT"
] | 15
|
2018-02-02T10:07:08.000Z
|
2018-02-02T10:07:09.000Z
|
lib/sparse-bench/src/cpu/BenchmarkUtils.hpp
|
caskorg/cask
|
9e561d7a575c6a984660ba4afc476a0a7aa5264d
|
[
"MIT"
] | 4
|
2016-07-02T09:36:33.000Z
|
2021-04-19T17:44:55.000Z
|
#ifndef SPARSEBENCH_BENCHMARKUTILS_HPP
#define SPARSEBENCH_BENCHMARKUTILS_HPP
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <fstream>
namespace sparsebench {
namespace benchmarkutils {
void checkFileExists(std::string file) {
std::ifstream f{file};
if (!f.good())
throw std::invalid_argument("File does not exists " + file);
}
void parseArgs(int argc, char** argv) {
// TODO may use a more flexible approach using boost::program_options
if (argc != 7) {
std::stringstream ss;
ss << "Usage " << argv[0] << " -mat <matrix> -rhs <rhs> -lhs <lhs>" <<std::endl;
throw std::invalid_argument(ss.str());
}
if (std::string(argv[1]) != "-mat") {
throw std::invalid_argument("First argument should be -mat");
}
if (std::string(argv[3]) != "-rhs") {
throw std::invalid_argument("Third argument should be -rhs");
}
if (std::string(argv[5]) != "-lhs") {
throw std::invalid_argument("Fifth argument should be -lhs");
}
// check files exists
checkFileExists(argv[2]);
checkFileExists(argv[4]);
checkFileExists(argv[6]);
}
double residual(std::vector<double> got, std::vector<double> exp) {
double residual = 0;
for (int i = 0; i < got.size(); i++) {
residual += (got[i] - exp[i]) * (got[i] - exp[i]);
}
return std::sqrt(residual);
}
template<typename T>
std::string json(std::string key, T value, bool comma=true) {
std::stringstream ss;
ss << "\"" << key << "\":" << "\"" << value << "\"";
if (comma)
ss << ",";
ss << "\\n";
return ss.str();
}
void printSummary(
double setupSeconds,
int iterations,
double solveSeconds,
double estimatedError,
double solutionVersusExpNorm,
double benchmarkRepetitions
) {
std::cout
<< json("setup took", setupSeconds)
<< json("iterations", iterations)
<< json("solve took", solveSeconds)
<< json("estimated error", estimatedError)
<< json("error", solutionVersusExpNorm)
<< json("bench repetitions", benchmarkRepetitions, false);
}
}
}
#endif //SPARSEBENCH_BENCHMARKUTILS_HPP
| 25.421687
| 84
| 0.640758
|
paul-g
|
efdde7bed3fec1d4a5cf43d9d6e7be54a4662808
| 880
|
cpp
|
C++
|
Day 18/A. Shuffle Hashing.cpp
|
shtanriverdi/CS487-Introduction-to-Competitive-Programming-Progress
|
0d7a4fa4346ee08d9b2b2f628c3ffab7f3f81166
|
[
"MIT"
] | 4
|
2019-12-12T19:59:50.000Z
|
2020-01-20T15:44:44.000Z
|
Day 18/A. Shuffle Hashing.cpp
|
shtanriverdi/CS487-Introduction-to-Competitive-Programming-Progress
|
0d7a4fa4346ee08d9b2b2f628c3ffab7f3f81166
|
[
"MIT"
] | null | null | null |
Day 18/A. Shuffle Hashing.cpp
|
shtanriverdi/CS487-Introduction-to-Competitive-Programming-Progress
|
0d7a4fa4346ee08d9b2b2f628c3ffab7f3f81166
|
[
"MIT"
] | null | null | null |
// Question Link ---> http://codeforces.com/contest/1278/problem/A
// Educational Codeforces Round 78 (Rated for Div. 2)
// Day #18 #Contest 3
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
string p, h;
cin >> T;
while (T--) {
cin >> p >> h;
if (h.size() < p.size()) { cout << "NO\n"; }
else {
bool found = false;
unordered_map<char, int> freq;
for (int i = 0; i < p.size(); i++) freq[p[i]]++;
for (int i = 0; i + (p.size() - 1) < h.size(); i++) {
unordered_map<char, int> tmp;
for (int j = i, t = p.size(); t > 0 && j < h.size(); j++, t--) tmp[h[j]]++;
if (freq == tmp) {
found = true;
cout << "YES\n";
break;
}
}
if (!found) cout << "NO\n";
}
}
return 0;
}
| 24.444444
| 80
| 0.515909
|
shtanriverdi
|
efde45ce10a40fd97905ed75cfe5151458fb4455
| 1,201
|
hpp
|
C++
|
mi/functional/minmax.hpp
|
tmichi/xendocast
|
482c7e668423c11b1cc0f6e2fa98bd3b582536a8
|
[
"MIT"
] | null | null | null |
mi/functional/minmax.hpp
|
tmichi/xendocast
|
482c7e668423c11b1cc0f6e2fa98bd3b582536a8
|
[
"MIT"
] | 1
|
2017-06-14T04:32:12.000Z
|
2017-06-14T04:32:12.000Z
|
mi/functional/minmax.hpp
|
tmichi/xendocast
|
482c7e668423c11b1cc0f6e2fa98bd3b582536a8
|
[
"MIT"
] | null | null | null |
/**
* @file minmax.hpp
* @author Takashi Michikawa <michi@den.rcast.u-tokyo.ac.jp>
*/
#ifndef __MI_FUNCTIONAL_MINMAX_HPP__
#define __MI_FUNCTIONAL_MINMAX_HPP__ 1
#include <functional>
#include <utility>
namespace mi
{
template<typename T>
class minmax : public std::unary_function<T, std::pair<T,T> >
{
private:
std::pair<T, T>& _minmax;
bool _isFirst;
public:
minmax ( std::pair<T,T>& minmax ) : _minmax( minmax ), _isFirst ( true ) {
return;
}
std::pair<T, T>& operator () ( const T& v ) {
if ( this->_isFirst ) {
this->_minmax = std::make_pair( v,v );
this->_isFirst = false;
} else {
if( v < this->_minmax.first ) this->_minmax.first = v;
if( this->_minmax.second < v ) this->_minmax.second = v;
}
return this->_minmax;
}
};
};
#endif //__MI_FUNCTIONAL_MINMAX_HPP__
| 34.314286
| 91
| 0.442132
|
tmichi
|
efde7110977a86b293a5cd6e5681d9739d9aff00
| 2,556
|
hpp
|
C++
|
INCLUDE/Vcl/idsntp.hpp
|
earthsiege2/borland-cpp-ide
|
09bcecc811841444338e81b9c9930c0e686f9530
|
[
"Unlicense",
"FSFAP",
"Apache-1.1"
] | 1
|
2022-01-13T01:03:55.000Z
|
2022-01-13T01:03:55.000Z
|
INCLUDE/Vcl/idsntp.hpp
|
earthsiege2/borland-cpp-ide
|
09bcecc811841444338e81b9c9930c0e686f9530
|
[
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null |
INCLUDE/Vcl/idsntp.hpp
|
earthsiege2/borland-cpp-ide
|
09bcecc811841444338e81b9c9930c0e686f9530
|
[
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null |
// Borland C++ Builder
// Copyright (c) 1995, 2002 by Borland Software Corporation
// All rights reserved
// (DO NOT EDIT: machine generated header) 'IdSNTP.pas' rev: 6.00
#ifndef IdSNTPHPP
#define IdSNTPHPP
#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <IdComponent.hpp> // Pascal unit
#include <IdUDPBase.hpp> // Pascal unit
#include <IdUDPClient.hpp> // Pascal unit
#include <IdGlobal.hpp> // Pascal unit
#include <Classes.hpp> // Pascal unit
#include <SysInit.hpp> // Pascal unit
#include <System.hpp> // Pascal unit
//-- user supplied -----------------------------------------------------------
namespace Idsntp
{
//-- type declarations -------------------------------------------------------
#pragma pack(push, 1)
struct TNTPGram
{
Byte Head1;
Byte Head2;
Byte Head3;
Byte Head4;
int RootDelay;
int RootDispersion;
int RefID;
int Ref1;
int Ref2;
int Org1;
int Org2;
int Rcv1;
int Rcv2;
int Xmit1;
int Xmit2;
} ;
#pragma pack(pop)
#pragma pack(push, 1)
struct TLr
{
Byte L1;
Byte L2;
Byte L3;
Byte L4;
} ;
#pragma pack(pop)
class DELPHICLASS TIdSNTP;
class PASCALIMPLEMENTATION TIdSNTP : public Idudpclient::TIdUDPClient
{
typedef Idudpclient::TIdUDPClient inherited;
protected:
System::TDateTime FDestinationTimestamp;
System::TDateTime FLocalClockOffset;
System::TDateTime FOriginateTimestamp;
System::TDateTime FReceiveTimestamp;
System::TDateTime FRoundTripDelay;
System::TDateTime FTransmitTimestamp;
bool __fastcall Disregard(const TNTPGram &NTPMessage);
System::TDateTime __fastcall GetAdjustmentTime(void);
System::TDateTime __fastcall GetDateTime(void);
public:
__fastcall virtual TIdSNTP(Classes::TComponent* AOwner);
bool __fastcall SyncTime(void);
__property System::TDateTime AdjustmentTime = {read=GetAdjustmentTime};
__property System::TDateTime DateTime = {read=GetDateTime};
__property System::TDateTime RoundTripDelay = {read=FRoundTripDelay};
__property Port = {default=123};
public:
#pragma option push -w-inl
/* TIdUDPBase.Destroy */ inline __fastcall virtual ~TIdSNTP(void) { }
#pragma option pop
};
//-- var, const, procedure ---------------------------------------------------
#define NTPMaxInt (4.294967E+09)
} /* namespace Idsntp */
using namespace Idsntp;
#pragma option pop // -w-
#pragma option pop // -Vx
#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // IdSNTP
| 25.818182
| 79
| 0.649061
|
earthsiege2
|
efdef98dbdb93630b13d6e6b9c2633375a97b07a
| 632
|
hpp
|
C++
|
OpenCV-Test/detect_cascade.hpp
|
AndriyBas/diploma2016
|
60b3d1034b229be1bdaf58be247847df2c13e6d7
|
[
"MIT"
] | null | null | null |
OpenCV-Test/detect_cascade.hpp
|
AndriyBas/diploma2016
|
60b3d1034b229be1bdaf58be247847df2c13e6d7
|
[
"MIT"
] | null | null | null |
OpenCV-Test/detect_cascade.hpp
|
AndriyBas/diploma2016
|
60b3d1034b229be1bdaf58be247847df2c13e6d7
|
[
"MIT"
] | null | null | null |
//
// detect_cascade.hpp
// OpenCV-Test
//
// Created by Andriy Bas on 5/29/16.
// Copyright © 2016 Andriy Bas. All rights reserved.
//
#ifndef detect_cascade_hpp
#define detect_cascade_hpp
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>
#include "detector.hpp"
#include "base_video_classifier.hpp"
class DetectCascade {
public:
// constructor
DetectCascade();
// methods
void addDetector(Detector detector);
DetectedResults detect(cv::Mat image);
private:
std::vector<Detector> detectors;
};
#endif /* detect_cascade_hpp */
| 17.555556
| 53
| 0.696203
|
AndriyBas
|
efe0220428f6227351806e063f7a9927f7a6a4bd
| 12,813
|
cpp
|
C++
|
SDK/ARKSurvivalEvolved_Baryonyx_Character_BP_functions.cpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 10
|
2020-02-17T19:08:46.000Z
|
2021-07-31T11:07:19.000Z
|
SDK/ARKSurvivalEvolved_Baryonyx_Character_BP_functions.cpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 9
|
2020-02-17T18:15:41.000Z
|
2021-06-06T19:17:34.000Z
|
SDK/ARKSurvivalEvolved_Baryonyx_Character_BP_functions.cpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 3
|
2020-07-22T17:42:07.000Z
|
2021-06-19T17:16:13.000Z
|
// ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_Baryonyx_Character_BP_parameters.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPSetupTamed
// ()
// Parameters:
// bool* bWasJustTamed (Parm, ZeroConstructor, IsPlainOldData)
void ABaryonyx_Character_BP_C::BPSetupTamed(bool* bWasJustTamed)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPSetupTamed");
ABaryonyx_Character_BP_C_BPSetupTamed_Params params;
params.bWasJustTamed = bWasJustTamed;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.IsActorHealingFish
// ()
// Parameters:
// class AActor* ActorToTest (Parm, ZeroConstructor, IsPlainOldData)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool ABaryonyx_Character_BP_C::IsActorHealingFish(class AActor* ActorToTest)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.IsActorHealingFish");
ABaryonyx_Character_BP_C_IsActorHealingFish_Params params;
params.ActorToTest = ActorToTest;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPTimerServer
// ()
void ABaryonyx_Character_BP_C::BPTimerServer()
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPTimerServer");
ABaryonyx_Character_BP_C_BPTimerServer_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BlueprintCanRiderAttack
// ()
// Parameters:
// int* AttackIndex (Parm, ZeroConstructor, IsPlainOldData)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool ABaryonyx_Character_BP_C::BlueprintCanRiderAttack(int* AttackIndex)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BlueprintCanRiderAttack");
ABaryonyx_Character_BP_C_BlueprintCanRiderAttack_Params params;
params.AttackIndex = AttackIndex;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BaryCanAttack
// ()
// Parameters:
// int AttackIndex (Parm, ZeroConstructor, IsPlainOldData)
// bool Retval (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void ABaryonyx_Character_BP_C::BaryCanAttack(int AttackIndex, bool* Retval)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BaryCanAttack");
ABaryonyx_Character_BP_C_BaryCanAttack_Params params;
params.AttackIndex = AttackIndex;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (Retval != nullptr)
*Retval = params.Retval;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BlueprintCanAttack
// ()
// Parameters:
// int* AttackIndex (Parm, ZeroConstructor, IsPlainOldData)
// float* Distance (Parm, ZeroConstructor, IsPlainOldData)
// float* attackRangeOffset (Parm, ZeroConstructor, IsPlainOldData)
// class AActor** OtherTarget (Parm, ZeroConstructor, IsPlainOldData)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool ABaryonyx_Character_BP_C::BlueprintCanAttack(int* AttackIndex, float* Distance, float* attackRangeOffset, class AActor** OtherTarget)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BlueprintCanAttack");
ABaryonyx_Character_BP_C_BlueprintCanAttack_Params params;
params.AttackIndex = AttackIndex;
params.Distance = Distance;
params.attackRangeOffset = attackRangeOffset;
params.OtherTarget = OtherTarget;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPKilledSomethingEvent
// ()
// Parameters:
// class APrimalCharacter** killedTarget (Parm, ZeroConstructor, IsPlainOldData)
void ABaryonyx_Character_BP_C::BPKilledSomethingEvent(class APrimalCharacter** killedTarget)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPKilledSomethingEvent");
ABaryonyx_Character_BP_C_BPKilledSomethingEvent_Params params;
params.killedTarget = killedTarget;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.K2_OnMovementModeChanged
// (Native, Event, NetResponse, Static, NetMulticast, MulticastDelegate, Private, Protected, Delegate, NetServer, HasDefaults, BlueprintCallable, BlueprintEvent, BlueprintPure)
// Parameters:
// TEnumAsByte<EMovementMode>* PrevMovementMode (Parm, ZeroConstructor, IsPlainOldData)
// TEnumAsByte<EMovementMode>* NewMovementMode (Parm, ZeroConstructor, IsPlainOldData)
// unsigned char* PrevCustomMode (Parm, ZeroConstructor, IsPlainOldData)
// unsigned char* NewCustomMode (Parm, ZeroConstructor, IsPlainOldData)
void ABaryonyx_Character_BP_C::STATIC_K2_OnMovementModeChanged(TEnumAsByte<EMovementMode>* PrevMovementMode, TEnumAsByte<EMovementMode>* NewMovementMode, unsigned char* PrevCustomMode, unsigned char* NewCustomMode)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.K2_OnMovementModeChanged");
ABaryonyx_Character_BP_C_K2_OnMovementModeChanged_Params params;
params.PrevMovementMode = PrevMovementMode;
params.NewMovementMode = NewMovementMode;
params.PrevCustomMode = PrevCustomMode;
params.NewCustomMode = NewCustomMode;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BlueprintAdjustOutputDamage
// (Exec, MulticastDelegate, Private, Protected, NetServer, HasDefaults, BlueprintCallable, BlueprintEvent, BlueprintPure)
// Parameters:
// int* AttackIndex (Parm, ZeroConstructor, IsPlainOldData)
// float* OriginalDamageAmount (Parm, ZeroConstructor, IsPlainOldData)
// class AActor** HitActor (Parm, ZeroConstructor, IsPlainOldData)
// class UClass* OutDamageType (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// float OutDamageImpulse (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
float ABaryonyx_Character_BP_C::BlueprintAdjustOutputDamage(int* AttackIndex, float* OriginalDamageAmount, class AActor** HitActor, class UClass** OutDamageType, float* OutDamageImpulse)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BlueprintAdjustOutputDamage");
ABaryonyx_Character_BP_C_BlueprintAdjustOutputDamage_Params params;
params.AttackIndex = AttackIndex;
params.OriginalDamageAmount = OriginalDamageAmount;
params.HitActor = HitActor;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (OutDamageType != nullptr)
*OutDamageType = params.OutDamageType;
if (OutDamageImpulse != nullptr)
*OutDamageImpulse = params.OutDamageImpulse;
return params.ReturnValue;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPGetMultiUseEntries
// (NetRequest, Native, Static, NetMulticast, Public, Private, Protected, NetServer, HasDefaults, BlueprintCallable, BlueprintEvent, BlueprintPure)
// Parameters:
// class APlayerController** ForPC (Parm, ZeroConstructor, IsPlainOldData)
// TArray<struct FMultiUseEntry> MultiUseEntries (Parm, OutParm, ZeroConstructor, ReferenceParm)
// TArray<struct FMultiUseEntry> ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm)
TArray<struct FMultiUseEntry> ABaryonyx_Character_BP_C::STATIC_BPGetMultiUseEntries(class APlayerController** ForPC, TArray<struct FMultiUseEntry>* MultiUseEntries)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPGetMultiUseEntries");
ABaryonyx_Character_BP_C_BPGetMultiUseEntries_Params params;
params.ForPC = ForPC;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (MultiUseEntries != nullptr)
*MultiUseEntries = params.MultiUseEntries;
return params.ReturnValue;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPTryMultiUse
// ()
// Parameters:
// class APlayerController** ForPC (Parm, ZeroConstructor, IsPlainOldData)
// int* UseIndex (Parm, ZeroConstructor, IsPlainOldData)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool ABaryonyx_Character_BP_C::BPTryMultiUse(class APlayerController** ForPC, int* UseIndex)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.BPTryMultiUse");
ABaryonyx_Character_BP_C_BPTryMultiUse_Params params;
params.ForPC = ForPC;
params.UseIndex = UseIndex;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.UserConstructionScript
// ()
void ABaryonyx_Character_BP_C::UserConstructionScript()
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.UserConstructionScript");
ABaryonyx_Character_BP_C_UserConstructionScript_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.AnimNotify_StunAttackStart
// ()
void ABaryonyx_Character_BP_C::AnimNotify_StunAttackStart()
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.AnimNotify_StunAttackStart");
ABaryonyx_Character_BP_C_AnimNotify_StunAttackStart_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.AnimNotify_StunAttackMid
// ()
void ABaryonyx_Character_BP_C::AnimNotify_StunAttackMid()
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.AnimNotify_StunAttackMid");
ABaryonyx_Character_BP_C_AnimNotify_StunAttackMid_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.ExecuteUbergraph_Baryonyx_Character_BP
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void ABaryonyx_Character_BP_C::ExecuteUbergraph_Baryonyx_Character_BP(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function Baryonyx_Character_BP.Baryonyx_Character_BP_C.ExecuteUbergraph_Baryonyx_Character_BP");
ABaryonyx_Character_BP_C_ExecuteUbergraph_Baryonyx_Character_BP_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 35.493075
| 214
| 0.731679
|
2bite
|
efe0e12b479da21c52836c93629a5efa8fef1b68
| 1,407
|
cpp
|
C++
|
net/packethandler.cpp
|
dllexport/libtunosocks
|
6ffba81bf7e105ab92a1f09893856f8526d45978
|
[
"MIT"
] | 1
|
2020-07-06T02:51:20.000Z
|
2020-07-06T02:51:20.000Z
|
net/packethandler.cpp
|
dllexport/libtunosocks
|
6ffba81bf7e105ab92a1f09893856f8526d45978
|
[
"MIT"
] | 1
|
2021-08-06T11:22:33.000Z
|
2021-08-08T09:17:16.000Z
|
net/packethandler.cpp
|
dllexport/libtunosocks
|
6ffba81bf7e105ab92a1f09893856f8526d45978
|
[
"MIT"
] | 2
|
2020-07-06T02:51:30.000Z
|
2021-08-06T11:04:17.000Z
|
#include "packethandler.h"
#include "lwiphelper.h"
#include "filter/udp_filter.h"
#include <lwip/sockets.h>
#include <lwip/ip4.h>
#include <iostream>
#include "udp/udphandler.h"
const int PROTO_TCP = 6;
const int PROTO_UDP = 17;
const int PROTO_ICMP = 1;
void PacketHandler::Input(void* packet, uint64_t size)
{
#if defined(__APPLE__) || defined(__linux__)
auto ip_header = (ip_hdr*)((char*)packet + 4);
#elif _WIN32
auto ip_header = (ip_hdr*)packet;
#endif
if ((ip_header->_v_hl & 0xf0) >> 4 != 0x04) {
return;
}
if (IPH_PROTO(ip_header) == PROTO_UDP)
{
if (UdpFilter::Pass(ip_header->dest.addr))
{
UdpHandler::GetInstance()->Handle(ip_header);
}
return;
}
if (IPH_PROTO(ip_header) != PROTO_TCP
&& IPH_PROTO(ip_header) != PROTO_UDP
&& IPH_PROTO(ip_header) != PROTO_ICMP) return;
#if defined(__APPLE__) || defined(__linux__)
struct pbuf *p = pbuf_alloc(PBUF_IP, size - 4, PBUF_RAM);
if (!packet) {
std::cout << "pbuf_alloc err\n";
}
if (ERR_OK == pbuf_take(p, (char*)packet + 4, size - 4)) {
assert(p->len == size - 4);
}
#elif _WIN32
struct pbuf *p = pbuf_alloc(PBUF_IP, size, PBUF_RAM);
if (!packet) {
std::cout << "pbuf_alloc err\n";
}
if (ERR_OK == pbuf_take(p, packet, size)) {
LWIP_ASSERT("len err", p->len == size);
}
#endif
auto netif = LwipHelper::GetInstance()->GetNetIf();
netif.input(p, &netif);
}
| 20.691176
| 62
| 0.643213
|
dllexport
|
efe12691c965cb1abb71efe65af3b171ad9eeae3
| 3,763
|
cpp
|
C++
|
src/cmd/cmdget.cpp
|
pirobtumen/Remember
|
5d218d9c0e353ff1df7695486c794288f1ba0a96
|
[
"MIT"
] | null | null | null |
src/cmd/cmdget.cpp
|
pirobtumen/Remember
|
5d218d9c0e353ff1df7695486c794288f1ba0a96
|
[
"MIT"
] | null | null | null |
src/cmd/cmdget.cpp
|
pirobtumen/Remember
|
5d218d9c0e353ff1df7695486c794288f1ba0a96
|
[
"MIT"
] | null | null | null |
// -----------------------------------------------------------------------------
//
// MIT License
//
// Copyright (c) 2016 Alberto Sola
//
// 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 "cmd/cmdget.hpp"
// -----------------------------------------------------------------------------
CmdGet::CmdGet(int argc, char * argv[]){
add_option("-f"); // Show finished only
add_option("-a"); // Show all
add_argument("-t"); // Tag
parse(argc,argv);
}
// -----------------------------------------------------------------------------
void CmdGet::print_task(const Task & task) const{
std::cout << task.get_id() << " | " << task.get_tag() << " | " << task.get_task() << std::endl;
}
// -----------------------------------------------------------------------------
void CmdGet::execute(){
/*
Show tasks.
Default: not finished tasks.
-a: show all tasks.
-f: show finished tasks.
If a task end date is today, the color is bold green.
*/
bool show_finished = false;
Date today_date;
Date finish_date;
std::vector<Task> task_list;
std::string tag_arg = get_argument("-t");
// Get tasks
if( tag_arg.empty() )
tasker -> get_task_list(task_list);
else
tasker -> get_task_list(task_list,get_argument("-t"));
// Get current date
today_date.set_current();
// Show header
std::cout << std::endl;
std::cout << "-------------------------------------------" << std::endl;
std::cout << "ID" << " | " << "Tag" << " | " << "Task" << std::endl;
std::cout << "-------------------------------------------" << std::endl;
// Print finished tasks
if(check_option("-f")){
for(auto & task: task_list){
if(task.is_finished())
print_task(task);
}
}
else{
// Check "all" option
show_finished = check_option("-a");
// Print tasks
for(auto & task: task_list){
if(!task.is_finished()){
finish_date = task.get_finish_date();
// Text: bold green
if(finish_date == today_date)
std::cout << "\033[32;1m";
// Text: bold red
else if(!finish_date.empty() && finish_date < today_date)
std::cout << "\033[31;1m";
print_task(task);
}
else if(show_finished){
std::cout << "\033[9m";
print_task(task);
}
// Clear text effects
std::cout << "\033[0m";
}
}
std::cout << "-------------------------------------------" << std::endl;
std::cout << std::endl;
}
// -----------------------------------------------------------------------------
| 29.865079
| 97
| 0.513154
|
pirobtumen
|
efeab3902b56717f0ab5e210968a7e0a0fcdcc6f
| 4,450
|
cc
|
C++
|
msg/Messenger.cc
|
liucxer/ceph-msg
|
2e5c18c0c72253b283bfd3d0576033c0b515ce55
|
[
"Apache-2.0"
] | null | null | null |
msg/Messenger.cc
|
liucxer/ceph-msg
|
2e5c18c0c72253b283bfd3d0576033c0b515ce55
|
[
"Apache-2.0"
] | null | null | null |
msg/Messenger.cc
|
liucxer/ceph-msg
|
2e5c18c0c72253b283bfd3d0576033c0b515ce55
|
[
"Apache-2.0"
] | null | null | null |
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include <netdb.h>
#include "include/types.h"
#include "include/random.h"
#include "Messenger.h"
#include "msg/simple/SimpleMessenger.h"
#include "msg/async/AsyncMessenger.h"
#ifdef HAVE_XIO
#include "msg/xio/XioMessenger.h"
#endif
Messenger *Messenger::create_client_messenger(CephContext *cct, string lname)
{
std::string public_msgr_type = cct->_conf->ms_public_type.empty() ? cct->_conf.get_val<std::string>("ms_type") : cct->_conf->ms_public_type;
auto nonce = ceph::util::generate_random_number<uint64_t>();
return Messenger::create(cct, public_msgr_type, entity_name_t::CLIENT(),
std::move(lname), nonce, 0);
}
Messenger *Messenger::create(CephContext *cct, const string &type,
entity_name_t name, string lname,
uint64_t nonce, uint64_t cflags)
{
int r = -1;
if (type == "random") {
r = ceph::util::generate_random_number(0, 1);
}
if (r == 0 || type == "simple")
return new SimpleMessenger(cct, name, std::move(lname), nonce);
else if (r == 1 || type.find("async") != std::string::npos)
return new AsyncMessenger(cct, name, type, std::move(lname), nonce);
#ifdef HAVE_XIO
else if ((type == "xio") &&
cct->check_experimental_feature_enabled("ms-type-xio"))
return new XioMessenger(cct, name, std::move(lname), nonce, cflags);
#endif
lderr(cct) << "unrecognized ms_type '" << type << "'" << dendl;
return nullptr;
}
/**
* Get the default crc flags for this messenger.
* but not yet dispatched.
*/
static int get_default_crc_flags(const ConfigProxy&);
Messenger::Messenger(CephContext *cct_, entity_name_t w)
: trace_endpoint("0.0.0.0", 0, "Messenger"),
my_name(w),
default_send_priority(CEPH_MSG_PRIO_DEFAULT),
started(false),
magic(0),
socket_priority(-1),
cct(cct_),
crcflags(get_default_crc_flags(cct->_conf)),
auth_registry(cct)
{
auth_registry.refresh_config();
}
void Messenger::set_endpoint_addr(const entity_addr_t& a,
const entity_name_t &name)
{
size_t hostlen;
if (a.get_family() == AF_INET)
hostlen = sizeof(struct sockaddr_in);
else if (a.get_family() == AF_INET6)
hostlen = sizeof(struct sockaddr_in6);
else
hostlen = 0;
if (hostlen) {
char buf[NI_MAXHOST] = { 0 };
getnameinfo(a.get_sockaddr(), hostlen, buf, sizeof(buf),
NULL, 0, NI_NUMERICHOST);
trace_endpoint.copy_ip(buf);
}
trace_endpoint.set_port(a.get_port());
}
/**
* Get the default crc flags for this messenger.
* but not yet dispatched.
*
* Pre-calculate desired software CRC settings. CRC computation may
* be disabled by default for some transports (e.g., those with strong
* hardware checksum support).
*/
int get_default_crc_flags(const ConfigProxy& conf)
{
int r = 0;
if (conf->ms_crc_data)
r |= MSG_CRC_DATA;
if (conf->ms_crc_header)
r |= MSG_CRC_HEADER;
return r;
}
int Messenger::bindv(const entity_addrvec_t& addrs)
{
return bind(addrs.legacy_addr());
}
bool Messenger::ms_deliver_verify_authorizer(
Connection *con,
int peer_type,
int protocol,
bufferlist& authorizer,
bufferlist& authorizer_reply,
bool& isvalid,
CryptoKey& session_key,
std::string *connection_secret,
std::unique_ptr<AuthAuthorizerChallenge> *challenge)
{
if (authorizer.length() == 0) {
for (auto dis : dispatchers) {
if (!dis->require_authorizer) {
//ldout(cct,10) << __func__ << " tolerating missing authorizer" << dendl;
isvalid = true;
return true;
}
}
}
AuthAuthorizeHandler *ah = auth_registry.get_handler(peer_type, protocol);
if (get_mytype() == CEPH_ENTITY_TYPE_MON &&
peer_type != CEPH_ENTITY_TYPE_MON) {
// the monitor doesn't do authenticators for msgr1.
isvalid = true;
return true;
}
if (!ah) {
lderr(cct) << __func__ << " no AuthAuthorizeHandler found for protocol "
<< protocol << dendl;
isvalid = false;
return false;
}
for (auto dis : dispatchers) {
KeyStore *ks = dis->ms_get_auth1_authorizer_keystore();
if (ks) {
isvalid = ah->verify_authorizer(
cct,
ks,
authorizer,
0,
&authorizer_reply,
&con->peer_name,
&con->peer_global_id,
&con->peer_caps_info,
&session_key,
connection_secret,
challenge);
if (isvalid) {
return dis->ms_handle_authentication(con)>=0;
}
return true;
}
}
return false;
}
| 26.646707
| 142
| 0.673933
|
liucxer
|
efeeacb2c305b970cff402cccdd90313d772ccee
| 387
|
cpp
|
C++
|
matu144.cpp
|
NewtonVan/Fxxk_Y0u_m47u
|
d303c7f13c074b5462ac8390a9ff94e546099fac
|
[
"MIT"
] | 1
|
2020-09-26T16:47:16.000Z
|
2020-09-26T16:47:16.000Z
|
matu144.cpp
|
NewtonVan/Fxxk_Y0u_m47u
|
d303c7f13c074b5462ac8390a9ff94e546099fac
|
[
"MIT"
] | null | null | null |
matu144.cpp
|
NewtonVan/Fxxk_Y0u_m47u
|
d303c7f13c074b5462ac8390a9ff94e546099fac
|
[
"MIT"
] | 1
|
2020-09-26T16:47:40.000Z
|
2020-09-26T16:47:40.000Z
|
#include <iostream>
#include <cstdio>
using std::cin;
using std::cout;
using std::endl;
int main()
{
int width= 0;
cin>>width;
if (0==width%2 || width< 1 || width >80){
cout<<"error"<<endl;
}
else{
for (int i= 0; 2*i< width; ++i){
for (int j= 0; j< i; ++j){
cout<<' ';
}
for (int j= 0; j< width-2*i; ++j){
cout<<'*';
}
cout<<endl;
}
}
return 0;
}
| 12.9
| 42
| 0.498708
|
NewtonVan
|
eff6e48e5691e512938560bf0be0227e1252a6e4
| 1,931
|
cpp
|
C++
|
src/TemporalFrequencyWidget.cpp
|
scribblemaniac/OUnit
|
f8a6e966b850a2c877660e24da51d7da0d4e97f6
|
[
"MIT"
] | null | null | null |
src/TemporalFrequencyWidget.cpp
|
scribblemaniac/OUnit
|
f8a6e966b850a2c877660e24da51d7da0d4e97f6
|
[
"MIT"
] | null | null | null |
src/TemporalFrequencyWidget.cpp
|
scribblemaniac/OUnit
|
f8a6e966b850a2c877660e24da51d7da0d4e97f6
|
[
"MIT"
] | null | null | null |
#include "TemporalFrequencyWidget.h"
#include "ui_TemporalFrequencyWidget.h"
#include <QDebug>
#include "ConversionUtilities.h"
TemporalFrequencyWidget::TemporalFrequencyWidget(QApplication *app, QWidget *parent) :
QWidget(parent),
ui(new Ui::TemporalFrequencyWidget),
m_app(app)
{
ui->setupUi(this);
ui->iNum->setValidator( new QDoubleValidator(this) );
ui->iNum->setInputMethodHints(Qt::ImhPreferNumbers);
connect(ui->iNum, &QLineEdit::textChanged, this, &TemporalFrequencyWidget::updateConversion);
connect(ui->iPrefix, &QComboBox::currentTextChanged, [this] () { updateConversion(ui->iNum->text()); });
connect(ui->oPrefix, &QComboBox::currentTextChanged, [this] () { updateConversion(ui->iNum->text()); });
connect(m_app->inputMethod(), &QInputMethod::visibleChanged, this, &TemporalFrequencyWidget::updateKeyboardSpace);
connect(m_app->inputMethod(), &QInputMethod::keyboardRectangleChanged, this, &TemporalFrequencyWidget::updateKeyboardSpace);
updateKeyboardSpace();
}
TemporalFrequencyWidget::~TemporalFrequencyWidget()
{
delete ui;
}
void TemporalFrequencyWidget::updateConversion(const QString &input)
{
QStringList inputModifiers, outputModifiers;
if(ui->iPrefix->isVisible()) inputModifiers.append(ui->iPrefix->currentText());
if(ui->oPrefix->isVisible()) outputModifiers.append(ui->oPrefix->currentText());
ui->oNum->setText(QString::number(converter.convert(input.toDouble(), QString("Hertz"), QString("Hertz"), inputModifiers, outputModifiers)));
}
void TemporalFrequencyWidget::updateKeyboardSpace()
{
if(m_app->inputMethod()->isVisible()) {
ui->keyboardSpacer->changeSize(20, m_app->inputMethod()->keyboardRectangle().height(), QSizePolicy::Minimum, QSizePolicy::Minimum);
}
else {
ui->keyboardSpacer->changeSize(20, 0, QSizePolicy::Minimum, QSizePolicy::Minimum);
}
this->layout()->invalidate();
}
| 37.862745
| 145
| 0.733299
|
scribblemaniac
|
eff8ff7599feefe8524bff005dff84ad873b288e
| 671
|
hpp
|
C++
|
Game/GUI/GUILabel.hpp
|
Mateusz00/Space-Invasion
|
a5c2b501454377f7496db91abbdebcb97ab3c814
|
[
"BSD-2-Clause"
] | null | null | null |
Game/GUI/GUILabel.hpp
|
Mateusz00/Space-Invasion
|
a5c2b501454377f7496db91abbdebcb97ab3c814
|
[
"BSD-2-Clause"
] | 1
|
2018-11-18T14:48:56.000Z
|
2018-11-26T19:21:07.000Z
|
Game/GUI/GUILabel.hpp
|
Mateusz00/2D-Fighter-Jet-Game
|
a5c2b501454377f7496db91abbdebcb97ab3c814
|
[
"BSD-2-Clause"
] | null | null | null |
#ifndef GUILABEL_HPP
#define GUILABEL_HPP
#include "GUIObject.hpp"
#include "../ResourcesID.hpp"
#include <SFML/Graphics/Text.hpp>
class GUILabel : public GUIObject
{
public:
GUILabel(const std::string&, const FontHolder&);
void setText(const std::string&);
virtual bool isSelectable() const override;
virtual void handleEvent(const sf::Event&) override;
virtual sf::FloatRect getBoundingRect() const override;
private:
void draw(sf::RenderTarget&, sf::RenderStates) const;
sf::Text mText;
};
#endif // GUILABEL_HPP
| 27.958333
| 80
| 0.593145
|
Mateusz00
|
56039914aaacc6b6256d8ed75c785c194058345a
| 1,502
|
hpp
|
C++
|
ultra/network/stream_packet.hpp
|
badryasuo/UltraDark
|
c9f60e3a754b051db33c29129f943807c6010b9e
|
[
"MIT"
] | null | null | null |
ultra/network/stream_packet.hpp
|
badryasuo/UltraDark
|
c9f60e3a754b051db33c29129f943807c6010b9e
|
[
"MIT"
] | null | null | null |
ultra/network/stream_packet.hpp
|
badryasuo/UltraDark
|
c9f60e3a754b051db33c29129f943807c6010b9e
|
[
"MIT"
] | null | null | null |
#pragma once
#include <string>
#include <time.h>
#include <thread>
#include "defines.h"
#include "Encryption.hpp"
#include "../ro_string.hpp"
namespace u
{
/*- -----------------*/
/*- TCP stream_packet Class-*/
/*- -----------------*/
struct stream_packet
{
int size;
stream_packet() : bytes(""), size(0)
{}
stream_packet(int size) : bytes(""), size(size)
{}
stream_packet(const char* packet) : bytes(packet ? packet : ""), size(strlen(packet)) {}
stream_packet(std::string packet) : bytes(packet), size(packet.size()) {}
stream_packet(const char * bytes, int length) : bytes(bytes ? bytes : ""), size(length)
{}
stream_packet& setData(std::string packet)
{
this->bytes = packet;
this->size = packet.size();
return *this;
}
const std::string& data()
{
return this->bytes;
}
bool operator<(stream_packet packet)
{
return this->size < packet.size;
}
stream_packet operator+(stream_packet packet)
{
stream_packet newData = this->bytes + packet.bytes;
return newData;
}
protected:
friend struct stream_socket;
friend struct seasion;
private:
friend std::string operator+(const std::string &, const stream_packet &);
friend std::ostream& operator<<(std::ostream&, stream_packet &);
std::string bytes;
};
inline std::string operator+(const std::string &s, const stream_packet &p)
{
return s + p.bytes;
}
inline std::ostream& operator<<(std::ostream& os, stream_packet &packet)
{
os << packet.bytes;
return os;
}
}
| 24.225806
| 90
| 0.646471
|
badryasuo
|
560501d69b75a594a1fc601731a1fef37c233249
| 6,265
|
hpp
|
C++
|
third-party/Empirical/include/emp/web/init.hpp
|
koellingh/empirical-p53-simulator
|
aa6232f661e8fc65852ab6d3e809339557af521b
|
[
"MIT"
] | null | null | null |
third-party/Empirical/include/emp/web/init.hpp
|
koellingh/empirical-p53-simulator
|
aa6232f661e8fc65852ab6d3e809339557af521b
|
[
"MIT"
] | null | null | null |
third-party/Empirical/include/emp/web/init.hpp
|
koellingh/empirical-p53-simulator
|
aa6232f661e8fc65852ab6d3e809339557af521b
|
[
"MIT"
] | null | null | null |
/**
* @note This file is part of Empirical, https://github.com/devosoft/Empirical
* @copyright Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
* @date 2015-2018.
*
* @file init.hpp
* @brief Define Initialize() and other functions to set up Empirical to build Emscripten projects.
*/
#ifndef EMP_INIT_H
#define EMP_INIT_H
#include <type_traits>
/// If __EMSCRIPTEN__ is defined, initialize everything. Otherwise create useful stubs.
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include "../tools/string_utils.hpp"
#ifdef __EMSCRIPTEN_PTHREADS__
#include <pthread.h>
#endif // __EMSCRIPTEN_PTHREADS__
extern "C" {
extern void EMP_Initialize();
}
namespace emp {
/// Setup timings on animations through Emscripten.
static void InitializeAnim() {
thread_local bool init = false; // Make sure we only initialize once!
if (!init) {
// Setup the animation callback in Javascript
MAIN_THREAD_EM_ASM({
window.requestAnimFrame = (function(callback) {
return window.requestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.oRequestAnimationFrame
|| window.msRequestAnimationFrame
|| function(callback) { window.setTimeout(callback, 1000 / 60); };
})();
});
}
init = true;
}
/// Add a listener on the browser thread that will look for incoming
/// bitmaps and transfer them into web canvases.
static void InitializeBitmapListener() {
#ifdef __EMSCRIPTEN_PTHREADS__
// adapted from https://stackoverflow.com/a/18002694
if ( EM_ASM_INT({ // detect if we are a web worker
return typeof WorkerGlobalScope !== 'undefined'
&& self instanceof WorkerGlobalScope;
}) ) {
MAIN_THREAD_EM_ASM({
console.assert( Object.keys( PThread.pthreads ).length === 1 );
Object.values(PThread.pthreads)[0].worker.addEventListener(
'message',
function( event ){
if ( event.data.emp_canvas_id ) {
document.getElementById(
event.data.emp_canvas_id
).getContext("bitmaprenderer").transferFromImageBitmap( event.data.emp_bitmap
);
}
}
)
});
}
#endif // __EMSCRIPTEN_PTHREADS__
}
/// Create a offscreen canvases registry that maps id to impl and a registry
/// for updated canvases that need to be sent to the main thread.
static void InitializeOffscreenCanvasRegistries() {
#ifdef __EMSCRIPTEN_PTHREADS__
// adapted from https://stackoverflow.com/a/18002694
if ( EM_ASM_INT({ // detect if we are a web worker
return typeof WorkerGlobalScope !== 'undefined'
&& self instanceof WorkerGlobalScope;
}) ) EM_ASM({
emp_i.offscreen_canvases = {};
emp_i.pending_offscreen_canvas_ids = new Set();
});
#endif // __EMSCRIPTEN_PTHREADS__
}
/// globalThis polyfill to provide globalThis support in older environments
/// adapted from https://mathiasbynens.be/notes/globalthis
static void SetupGlobalThisPolyfill() {
EM_ASM({
(function() {
if (typeof globalThis === 'object') return;
Object.prototype.__defineGetter__('__magic__', function() {
return this;
});
__magic__.globalThis = __magic__; // lolwat
delete Object.prototype.__magic__;
}());
});
}
/// Do all initializations for using EMP tricks with Emscripten.
static void Initialize() {
SetupGlobalThisPolyfill();
// have to dip into javascript because static and thread_local are wonky
// with pthreads
const bool should_run = EM_ASM_INT({
if ( !globalThis.emp_init_once_flag ) {
globalThis.emp_init_once_flag = true;
return true;
} else return false;
});
if ( should_run ) {
EMP_Initialize(); // Call JS initializations
InitializeAnim();
#ifdef __EMSCRIPTEN_PTHREADS__
MAIN_THREAD_EM_ASM({ _EMP_Initialize(); });
InitializeBitmapListener();
InitializeOffscreenCanvasRegistries();
#endif
}
}
namespace web {
// Some helper functions.
// Live keyword means that whatever is passed in needs to be re-evaluated every update.
namespace internal {
/// If a variable is passed in to Live(), construct a function to look up its current value.
template <typename VAR_TYPE>
std::function<std::string()> Live_impl(VAR_TYPE & var, int) {
return [&var](){ return emp::to_string(var); };
}
/// If a non-variable is passed in to Live(), assume it is a function and print it each redraw.
template <
typename IN_TYPE,
typename = std::enable_if_t< std::is_invocable<IN_TYPE>::value >
>
std::function<std::string()> Live_impl(IN_TYPE && fun, bool) {
return [fun](){ return emp::to_string(fun()); };
}
}
/// Take a function or variable and set it up so that it can update each time a text box is redrawn.
template <typename T>
std::function<std::string()> Live(T && val) {
return internal::Live_impl(std::forward<T>(val), bool{});
}
inline std::string ToJSLiteral(bool x) {
if (x == true) return "true";
else return "false";
}
}
}
// === Initialization for NON-emscripten to ignore macros ===
#else
#define MAIN_THREAD_EM_ASM(...)
#define MAIN_THREAD_EM_ASM(...)
#define MAIN_THREAD_EM_ASM_INT(...) 0
#define MAIN_THREAD_EM_ASM_DOUBLE(...) 0.0
#define MAIN_THREAD_EM_ASM_INT_V(...) 0
#define MAIN_THREAD_EM_ASM_DOUBLE_V(...) 0.0
#include <fstream>
namespace emp {
std::ofstream debug_file("debug_file");
/// Stub for when Emscripten is not in use.
static bool Initialize() {
// Nothing to do here yet...
static_assert(false, "Emscripten web tools require emcc for compilation (for now).");
return true;
}
/// Stub for when Emscripten is not in use.
static bool InitializeAnim() {
// Nothing to do here yet...
return true;
}
namespace web {
inline std::string ToJSLiteral(bool x) {
if (x == true) return "true";
else return "false";
}
}
}
#endif
#endif
| 29.00463
| 104
| 0.648843
|
koellingh
|
56052fc0e88c08da5a3a0ab3a226e526ec88d9af
| 1,012
|
hpp
|
C++
|
boost/tti/detail/dptmf.hpp
|
smart-make/boost
|
46509a094f8a844eefd5bb8a0030b739a04d79e1
|
[
"BSL-1.0"
] | 1
|
2018-12-15T19:55:56.000Z
|
2018-12-15T19:55:56.000Z
|
boost/tti/detail/dptmf.hpp
|
smart-make/boost
|
46509a094f8a844eefd5bb8a0030b739a04d79e1
|
[
"BSL-1.0"
] | null | null | null |
boost/tti/detail/dptmf.hpp
|
smart-make/boost
|
46509a094f8a844eefd5bb8a0030b739a04d79e1
|
[
"BSL-1.0"
] | null | null | null |
// (C) Copyright Edward Diener 2011,2012
// Use, modification and distribution are subject to 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).
#if !defined(BOOST_TTI_DETAIL_PTMF_HPP)
#define BOOST_TTI_DETAIL_PTMF_HPP
#include <boost/config.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/function_types/member_function_pointer.hpp>
namespace boost
{
namespace tti
{
namespace detail
{
template
<
class T,
class R,
class FS,
class TAG
>
struct ptmf_seq
{
typedef typename
boost::function_types::member_function_pointer
<
typename
boost::mpl::push_front
<
typename
boost::mpl::push_front<FS,T>::type,
R
>::type,
TAG
>::type type;
};
}
}
}
#endif // BOOST_TTI_DETAIL_PTMF_HPP
| 21.531915
| 81
| 0.58498
|
smart-make
|
560a0d213236e2e5874888fd7f8bf5127b5b33fa
| 2,165
|
cpp
|
C++
|
LeetCode/ThousandOne/0407-trap_rain_water.cpp
|
Ginkgo-Biloba/Cpp-Repo1-VS
|
231c68a055e6bf69a3f7c224e7c0182b67ce5b67
|
[
"Apache-2.0"
] | null | null | null |
LeetCode/ThousandOne/0407-trap_rain_water.cpp
|
Ginkgo-Biloba/Cpp-Repo1-VS
|
231c68a055e6bf69a3f7c224e7c0182b67ce5b67
|
[
"Apache-2.0"
] | null | null | null |
LeetCode/ThousandOne/0407-trap_rain_water.cpp
|
Ginkgo-Biloba/Cpp-Repo1-VS
|
231c68a055e6bf69a3f7c224e7c0182b67ce5b67
|
[
"Apache-2.0"
] | null | null | null |
#include "leetcode.hpp"
/* 407. 接雨水 II
给定一个 m x n 的矩阵,其中的值均为正整数,代表二维高度图每个单元的高度,请计算图中形状最多能接多少体积的雨水。
说明:
m 和 n 都是小于 110 的整数。每一个单位的高度都大于 0 且小于 20000。
示例:
给出如下 3x6 的高度图:
[
[1,4,3,1,3,2],
[3,2,1,3,2,4],
[2,3,3,2,3,1]
]
返回 4。
*/
// https://leetcode.com/problems/trapping-rain-water-ii/discuss/89495/How-to-get-the-solution-to-2-D-%22Trapping-Rain-Water%22-problem-from-1-D-case
// 抄的
class Solution
{
int rows, cols, acml;
vector<char> visit;
struct cell
{
int y, x, h;
cell(int _y, int _x, int _h) : y(_y), x(_x), h(_h) {}
cell(cell const&) = default;
cell& operator =(cell const&) = default;
bool operator <(cell const& c) const { return h > c.h; }
};
int at(int y, int x)
{
return y * cols + x;
}
public:
int trapRainWater(vector<vector<int>>& hmap)
{
rows = static_cast<int>(hmap.size());
if (rows == 0 || hmap[0].empty())
return 0;
cols = static_cast<int>(hmap[0].size());
acml = rows * cols;
if (visit.size() < static_cast<unsigned>(acml))
visit.resize(acml);
memset(visit.data(), 0, acml * sizeof(char));
acml = 0;
int const ys[4] = { -1, 0, 0, 1 };
int const xs[4] = { 0, -1, 1, 0 };
std::priority_queue<cell> q;
for (int w = 0; w < cols; ++w)
{
q.emplace(0, w, hmap[0][w]);
q.emplace(rows - 1, w, hmap[rows - 1][w]);
visit[at(0, w)] = visit[at(rows - 1, w)] = 1;
}
for (int h = 1; h < rows - 1; ++h)
{
q.emplace(h, 0, hmap[h][0]);
q.emplace(h, cols - 1, hmap[h][cols - 1]);
visit[at(h, 0)] = visit[at(h, cols - 1)] = 1;
}
while (!q.empty())
{
cell cur = q.top();
q.pop();
for (int i = 0; i < 4; ++i)
{
int x = cur.x + xs[i];
int y = cur.y + ys[i];
if (static_cast<unsigned>(y) >= static_cast<unsigned>(rows)
|| static_cast<unsigned>(x) >= static_cast<unsigned>(cols)
|| visit[at(y, x)])
continue;
int h = hmap[y][x];
acml += std::max(0, cur.h - h);
q.emplace(y, x, std::max(cur.h, h));
visit[at(y, x)] = 1;
}
}
return acml;
}
};
int main()
{
vector<vector<int>> hmap = {
{ 1, 4, 3, 1, 3, 2 },
{ 3, 2, 1, 3, 2, 4 },
{ 2, 3, 3, 2, 3, 1 }
};
OutExpr(Solution().trapRainWater(hmap), "%d");
};
| 20.046296
| 148
| 0.549192
|
Ginkgo-Biloba
|
560a622453fb4d8e9320e7764488426c351ab274
| 762
|
cpp
|
C++
|
Fudl/easy/solved/Next growing number.cpp
|
AhmedMostafa7474/Codingame-Solutions
|
da696a095c143c5d216bc06f6689ad1c0e25d0e0
|
[
"MIT"
] | 1
|
2022-03-16T08:56:31.000Z
|
2022-03-16T08:56:31.000Z
|
Fudl/easy/solved/Next growing number.cpp
|
AhmedMostafa7474/Codingame-Solutions
|
da696a095c143c5d216bc06f6689ad1c0e25d0e0
|
[
"MIT"
] | 2
|
2022-03-17T11:27:14.000Z
|
2022-03-18T07:41:00.000Z
|
Fudl/easy/solved/Next growing number.cpp
|
AhmedMostafa7474/Codingame-Solutions
|
da696a095c143c5d216bc06f6689ad1c0e25d0e0
|
[
"MIT"
] | 6
|
2022-03-13T19:56:11.000Z
|
2022-03-17T12:08:22.000Z
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
int main()
{
unsigned long long num;
cin >> num;
num++;
string n = to_string(num);
int pos = -1;
char ch;
for (int i = 0; i < n.size() - 1; i++) {
if (n[i] > n[i+1]) {
pos = i+1;
ch = n[i];
break;
}
}
if (pos == -1) cout << n << '\n';
else {
for (int i = 0; i < pos; i++)
cout << n[i];
for (int i = pos; i < n.size(); i++)
cout << ch;
cout << endl;
}
// Write an answer using cout. DON'T FORGET THE "<< endl"
// To debug: cerr << "Debug messages..." << endl;
}
| 18.585366
| 59
| 0.524934
|
AhmedMostafa7474
|
5617c92726412a5ecf7848e388795223ac20acc7
| 743
|
hpp
|
C++
|
src/rendering/mesh.hpp
|
Thanduriel/func-renderer
|
99582272d8e34cb6e2f6bc9735c8eba5076bb29c
|
[
"MIT"
] | 1
|
2019-01-27T17:54:45.000Z
|
2019-01-27T17:54:45.000Z
|
src/rendering/mesh.hpp
|
Thanduriel/func-renderer
|
99582272d8e34cb6e2f6bc9735c8eba5076bb29c
|
[
"MIT"
] | null | null | null |
src/rendering/mesh.hpp
|
Thanduriel/func-renderer
|
99582272d8e34cb6e2f6bc9735c8eba5076bb29c
|
[
"MIT"
] | null | null | null |
#pragma once
#include "vertexbuffer.hpp"
namespace Graphic{
class Mesh
{
public:
Mesh();
const VertexBuffer<>& GetVertices() const { return m_vertices; }
const VertexBuffer<>& GetNormals() const { return m_normals; }
const VertexBuffer<uint32_t, GL_ELEMENT_ARRAY_BUFFER>& GetIndices() const { return m_indices; }
void translate(glm::vec3 _dir);
const glm::mat4& GetModelMatrix() const { return m_modelMatrix; }
uint32_t GetColor() const { return m_color; }
//calculates the normals for the current triangles
void updateNormals();
protected:
glm::mat4 m_modelMatrix;
VertexBuffer<uint32_t, GL_ELEMENT_ARRAY_BUFFER> m_indices;
VertexBuffer<> m_vertices;
VertexBuffer<> m_normals;
uint32_t m_color;
};
}
| 22.515152
| 97
| 0.736205
|
Thanduriel
|
561c419aeaaefcc75f5505d396a5f2cdf789c182
| 4,363
|
hpp
|
C++
|
nearest_centroid_classifier.hpp
|
clustifier/kaggle-lshtc
|
18350ff36350c401efea0338bd31819d039808fa
|
[
"MIT"
] | 35
|
2015-01-02T09:09:40.000Z
|
2019-12-27T10:17:28.000Z
|
nearest_centroid_classifier.hpp
|
nagadomi/kaggle-lshtc
|
18350ff36350c401efea0338bd31819d039808fa
|
[
"MIT"
] | null | null | null |
nearest_centroid_classifier.hpp
|
nagadomi/kaggle-lshtc
|
18350ff36350c401efea0338bd31819d039808fa
|
[
"MIT"
] | 24
|
2015-01-02T09:10:34.000Z
|
2021-05-23T04:26:38.000Z
|
#ifndef NEAREST_CENTROID_CLASSIFIER_HPP
#define NEAREST_CENTROID_CLASSIFIER_HPP
#include "util.hpp"
#include "inverted_index.hpp"
class NearestCentroidClassifier
{
private:
std::vector<fv_t> m_centroids;
std::vector<int> m_centroid_labels;
InvertedIndex m_inverted_index;
static void
vector_sum(fv_t &sum,
const std::vector<int> &indexes,
const std::vector<fv_t> &data)
{
sum.clear();
for (auto i = indexes.begin(); i != indexes.end(); ++i) {
const fv_t &x = data[*i];
for (auto word = x.begin(); word != x.end(); ++word) {
auto s = sum.find(word->first);
if (s != sum.end()) {
s->second += word->second;
} else {
sum.insert(std::make_pair(word->first, word->second));
}
}
}
}
static void
vector_normalize_l2(fv_t &x)
{
double dot = 0.0f;
for (auto i = x.begin(); i != x.end(); ++i) {
dot += i->second * i->second;
}
if (dot > 0.0f) {
double scale = 1.0f / std::sqrt(dot);
for (auto i = x.begin(); i != x.end(); ++i) {
i->second *= scale;
}
}
}
public:
NearestCentroidClassifier(){}
void
train(const category_index_t &category_index,
const std::vector<fv_t> &data)
{
for (auto l = category_index.begin(); l != category_index.end(); ++l) {
fv_t centroid;
vector_sum(centroid, l->second, data);
vector_normalize_l2(centroid);
m_centroids.push_back(centroid);
m_centroid_labels.push_back(l->first);
}
m_inverted_index.build(&m_centroids);
}
inline void
predict(std::vector<int> &results,
size_t k,
const fv_t &query) const
{
InvertedIndex::result_t knn;
m_inverted_index.knn(knn, k, query);
results.clear();
for (auto i = knn.begin(); i != knn.end(); ++i) {
results.push_back(m_centroid_labels[i->id]);
}
}
size_t
size(void) const
{
return m_centroids.size();
}
bool
save(const char *file) const
{
FILE *fp = std::fopen(file, "wb");
if (fp == 0) {
return false;
}
size_t size = m_centroids.size();
std::fwrite(&size, sizeof(size), 1, fp);
for (auto centroid = m_centroids.begin();
centroid != m_centroids.end(); ++centroid)
{
size = centroid->size();
std::fwrite(&size, sizeof(size), 1, fp);
for (auto w = centroid->begin(); w != centroid->end(); ++w) {
std::fwrite(&w->first, sizeof(w->first), 1, fp);
std::fwrite(&w->second, sizeof(w->second), 1, fp);
}
}
size = m_centroid_labels.size();
std::fwrite(&size, sizeof(size), 1, fp);
std::fwrite(m_centroid_labels.data(), sizeof(int), size, fp);
fclose(fp);
return true;
}
bool
load(const char *file)
{
FILE *fp = std::fopen(file, "rb");
if (fp == 0) {
return false;
}
m_centroids.clear();
m_centroid_labels.clear();
m_inverted_index.clear();
size_t centroid_num = 0;
size_t ret = std::fread(¢roid_num, sizeof(centroid_num), 1, fp);
if (ret != 1) {
std::fprintf(stderr, "%s: invalid format 1\n", file);
fclose(fp);
return false;
}
for (size_t i = 0; i < centroid_num; ++i) {
fv_t centroid;
size_t word_num = 0;
ret = fread(&word_num, sizeof(word_num), 1, fp);
if (ret != 1) {
std::fprintf(stderr, "%s: invalid format 2\n", file);
fclose(fp);
return false;
}
for (size_t j = 0; j < word_num; ++j) {
int word_id;
float word_weight;
ret = std::fread(&word_id, sizeof(word_id), 1, fp);
if (ret != 1) {
std::fprintf(stderr, "%s: invalid format 3\n", file);
fclose(fp);
return false;
}
ret = std::fread(&word_weight, sizeof(word_weight), 1, fp);
if (ret != 1) {
std::fprintf(stderr, "%s: invalid format 4\n", file);
fclose(fp);
return false;
}
centroid.insert(std::make_pair(word_id, word_weight));
}
m_centroids.push_back(centroid);
}
ret = std::fread(¢roid_num, sizeof(centroid_num), 1, fp);
if (ret != 1) {
std::fprintf(stderr, "%s: invalid format 5\n", file);
fclose(fp);
return false;
}
int *buffer = new int[centroid_num];
ret = std::fread(buffer, sizeof(int), centroid_num, fp);
if (ret != centroid_num) {
std::fprintf(stderr, "%s: invalid format 6\n", file);
delete buffer;
fclose(fp);
return false;
}
std::copy(buffer, buffer + centroid_num,
std::back_inserter(m_centroid_labels));
delete buffer;
fclose(fp);
m_inverted_index.build(&m_centroids);
return true;
}
};
#endif
| 23.583784
| 73
| 0.613569
|
clustifier
|
56235b42e92e62b2c824ef5db29b60893f325edb
| 79,076
|
cpp
|
C++
|
Source/SystemQOR/MSWindows/WinQAPI/src/Kernel/kProcessThread.cpp
|
mfaithfull/QOR
|
0fa51789344da482e8c2726309265d56e7271971
|
[
"BSL-1.0"
] | 9
|
2016-05-27T01:00:39.000Z
|
2021-04-01T08:54:46.000Z
|
Source/SystemQOR/MSWindows/WinQAPI/src/Kernel/kProcessThread.cpp
|
mfaithfull/QOR
|
0fa51789344da482e8c2726309265d56e7271971
|
[
"BSL-1.0"
] | 1
|
2016-03-03T22:54:08.000Z
|
2016-03-03T22:54:08.000Z
|
Source/SystemQOR/MSWindows/WinQAPI/src/Kernel/kProcessThread.cpp
|
mfaithfull/QOR
|
0fa51789344da482e8c2726309265d56e7271971
|
[
"BSL-1.0"
] | 4
|
2016-05-27T01:00:43.000Z
|
2018-08-19T08:47:49.000Z
|
//kProcessThread.cpp
// Copyright Querysoft Limited 2013
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#include "WinQAPI/Kernel32.h"
#include "../Source/SystemQOR/MSWindows/WinQAPI/include/ReturnCheck.h"
//------------------------------------------------------------------------------
namespace nsWinQAPI
{
//--------------------------------------------------------------------------------
BOOL CKernel32::AssignProcessToJobObject( HANDLE hJob, HANDLE hProcess )
{
_WINQ_SFCONTEXT( "CKernel32::AssignProcessToJobObject" );
CCheckReturn< BOOL, CBoolCheck<> >::TType bResult;
# if ( _WIN32_WINNT >= 0x0500 )
bResult = ::AssignProcessToJobObject( hJob, hProcess );
# else
QOR_PP_UNREF2( hProcess, hJob );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "AssignProcessToJobObject" ), _T( "Windows 2000" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::BindIoCompletionCallback( HANDLE FileHandle, ::LPOVERLAPPED_COMPLETION_ROUTINE Function, ULONG Flags )
{
_WINQ_SFCONTEXT( "CKernel32::BindIoCompletionCallback" );
CCheckReturn< BOOL, CBoolCheck<> >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "BindIoCompletionCallback" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0500 )
bResult = ::BindIoCompletionCallback( FileHandle, Function, Flags );
# else
QOR_PP_UNREF3( Flags, Function, FileHandle );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "BindIoCompletionCallback" ), _T( "Windows 2000" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::CallbackMayRunLong( ::PTP_CALLBACK_INSTANCE pci )
{
_WINQ_SFCONTEXT( "CKernel32::CallbackMayRunLong" );
CCheckReturn< BOOL, CBoolCheck<> >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CallbackMayRunLong" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::CallbackMayRunLong( pci );
# else
QOR_PP_UNREF( pci );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "BindIoCompletionCallback" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::CancelThreadpoolIo( ::PTP_IO pio )
{
_WINQ_SFCONTEXT( "CKernel32::CancelThreadpoolIo" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CancelThreadpoolIo" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::CancelThreadpoolIo( pio );
# else
QOR_PP_UNREF( pio );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CancelThreadpoolIo" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::CloseThreadpool( ::PTP_POOL ptpp )
{
_WINQ_SFCONTEXT( "CKernel32::CloseThreadpool" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CloseThreadpool" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::CloseThreadpool( ptpp );
# else
QOR_PP_UNREF( ptpp );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CloseThreadpool" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::CloseThreadpoolCleanupGroup( ::PTP_CLEANUP_GROUP ptpcg )
{
_WINQ_SFCONTEXT( "CKernel32::CloseThreadpoolCleanupGroup" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CloseThreadpoolCleanupGroup" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::CloseThreadpoolCleanupGroup( ptpcg );
# else
QOR_PP_UNREF( ptpcg );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CloseThreadpoolCleanupGroup" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::CloseThreadpoolCleanupGroupMembers( ::PTP_CLEANUP_GROUP ptpcg, BOOL fCancelPendingCallbacks, PVOID pvCleanupContext )
{
_WINQ_SFCONTEXT( "CKernel32::CloseThreadpoolCleanupGroupMembers" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CloseThreadpoolCleanupGroupMembers" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::CloseThreadpoolCleanupGroupMembers( ptpcg, fCancelPendingCallbacks, pvCleanupContext );
# else
QOR_PP_UNREF( pvCleanupContext, fCancelPendingCallbacks, ptpcg );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CloseThreadpoolCleanupGroupMembers" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::CloseThreadpoolIo( ::PTP_IO pio )
{
_WINQ_SFCONTEXT( "CKernel32::CloseThreadpoolIo" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CloseThreadpoolIo" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::CloseThreadpoolIo( pio );
# else
QOR_PP_UNREF( pio );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CloseThreadpoolIo" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::CloseThreadpoolTimer( ::PTP_TIMER pti )
{
_WINQ_SFCONTEXT( "CKernel32::CloseThreadpoolTimer" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CloseThreadpoolTimer" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::CloseThreadpoolTimer( pti );
# else
QOR_PP_UNREF( pti );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CloseThreadpoolTimer" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::CloseThreadpoolWait( ::PTP_WAIT pwa )
{
_WINQ_SFCONTEXT( "CKernel32::CloseThreadpoolWait" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CloseThreadpoolWait" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::CloseThreadpoolWait( pwa );
# else
QOR_PP_UNREF( pwa );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CloseThreadpoolWait" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::CloseThreadpoolWork( ::PTP_WORK pwk )
{
_WINQ_SFCONTEXT( "CKernel32::CloseThreadpoolWork" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CloseThreadpoolWork" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::CloseThreadpoolWork( pwk );
# else
QOR_PP_UNREF( pwk );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CloseThreadpoolWork" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
BOOL CKernel32::ConvertFiberToThread(void)
{
_WINQ_SFCONTEXT( "CKernel32::ConvertFiberToThread" );
CCheckReturn< BOOL, CBoolCheck<> >::TType bResult;
# if ( _WIN32_WINNT >= 0x0501 )
bResult = ::ConvertFiberToThread();
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "ConvertFiberToThread" ), _T( "Windows XP" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
void* CKernel32::ConvertThreadToFiber( void* lpParameter )
{
_WINQ_SFCONTEXT( "CKernel32::ConvertThreadToFiber" );
CCheckReturn< void*, CCheckNonZero< void* > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "ConvertThreadToFiber" ), 0 ));
#else
# if ( _WIN32_WINNT > 0x0400 )
pResult = ::ConvertThreadToFiber( lpParameter );
# else
QOR_PP_UNREF( lpParameter );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "ConvertThreadToFiber" ), _T( "Windows NT 4.0" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
LPVOID CKernel32::ConvertThreadToFiberEx( void* lpParameter, DWORD dwFlags )
{
_WINQ_SFCONTEXT( "CKernel32::ConvertThreadToFiberEx" );
CCheckReturn< LPVOID, CCheckNonZero< LPVOID > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "ConvertThreadToFiberEx" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
pResult = ::ConvertThreadToFiberEx( lpParameter, dwFlags );
# else
QOR_PP_UNREF2( dwFlags, lpParameter );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "ConvertThreadToFiberEx" ), _T( "Windows NT 4.0" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
void* CKernel32::CreateFiber( SIZE_T dwStackSize, ::LPFIBER_START_ROUTINE lpStartAddress, void* lpParameter )
{
_WINQ_SFCONTEXT( "CKernel32::CreateFiber" );
CCheckReturn< LPVOID, CCheckNonZero< LPVOID > >::TType pResult;
# if ( _WIN32_WINNT >= 0x0400 )
pResult = ::CreateFiber( dwStackSize, lpStartAddress, lpParameter );
# else
QOR_PP_UNREF3( lpParameter, lpStartAddress, dwStackSize );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateFiber" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return pResult;
}
//--------------------------------------------------------------------------------
void* CKernel32::CreateFiberEx( SIZE_T dwStackCommitSize, SIZE_T dwStackReserveSize, DWORD dwFlags, ::LPFIBER_START_ROUTINE lpStartAddress, void* lpParameter )
{
_WINQ_SFCONTEXT( "CKernel32::CreateFiberEx" );
CCheckReturn< void*, CCheckNonZero< void* > >::TType pResult;
# if ( _WIN32_WINNT >= 0x0500 )
pResult = ::CreateFiberEx( dwStackCommitSize, dwStackReserveSize, dwFlags, lpStartAddress, lpParameter );
# else
QOR_PP_UNREF5( lpParameter, lpStartAddress, dwFlags, dwStackReserveSize, dwStackCommitSize );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateFiberEx" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return pResult;
}
//--------------------------------------------------------------------------------
HANDLE CKernel32::CreateJobObject( ::LPSECURITY_ATTRIBUTES lpJobAttributes, LPCTSTR lpName )
{
_WINQ_SFCONTEXT( "CKernel32::CreateJobObject" );
CCheckReturn< HANDLE, CHandleNullCheck< > >::TType h;
# if ( _WIN32_WINNT >= 0x0500 )
h = ::CreateJobObject( lpJobAttributes, lpName );
# else
QOR_PP_UNREF2( lpName, lpJobAttributes );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateJobObject" ), _T( "Windows 2000" ), 0 ));
# endif
return h;
}
//------------------------------------------------------------------------------
BOOL CKernel32::CreateProcess( LPCTSTR lpApplicationName, LPTSTR lpCommandLine, ::LPSECURITY_ATTRIBUTES lpProcessAttributes, ::LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, void* lpEnvironment, LPCTSTR lpCurrentDirectory, ::LPSTARTUPINFO lpStartupInfo, ::LPPROCESS_INFORMATION lpProcessInformation )
{
_WINQ_SFCONTEXT( "CKernel32::CreateProcess" );
CCheckReturn< BOOL, CBoolCheck<> >::TType bResult;
bResult = ::CreateProcess( lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation );
return bResult;
}
//------------------------------------------------------------------------------
HANDLE CKernel32::CreateRemoteThread( HANDLE hProcess, ::LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, void* lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId )
{
_WINQ_SFCONTEXT( "CKernel32::CreateRemoteThread" );
CCheckReturn< HANDLE, CHandleNullCheck<> >::TType h;
h = ::CreateRemoteThread( hProcess, lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpThreadId );
return h;
}
//------------------------------------------------------------------------------
HANDLE CKernel32::CreateThread( ::LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, ::LPTHREAD_START_ROUTINE lpStartAddress, void* lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId )
{
_WINQ_SFCONTEXT( "CKernel32::CreateThread" );
CCheckReturn< HANDLE, CHandleNullCheck<> >::TType h;
h = ::CreateThread( lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpThreadId );
return h;
}
//--------------------------------------------------------------------------------
::PTP_POOL CKernel32::CreateThreadpool( PVOID reserved )
{
_WINQ_SFCONTEXT( "CKernel32::CreateThreadpool" );
CCheckReturn< ::PTP_POOL, CCheckNonZero< ::PTP_POOL > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CreateThreadpool" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
pResult = ::CreateThreadpool( reserved );
# else
QOR_PP_UNREF( reserved );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateThreadpool" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
::PTP_CLEANUP_GROUP CKernel32::CreateThreadpoolCleanupGroup(void)
{
_WINQ_SFCONTEXT( "CKernel32::CreateThreadpoolCleanupGroup" );
CCheckReturn< ::PTP_CLEANUP_GROUP, CCheckNonZero< ::PTP_CLEANUP_GROUP > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CreateThreadpoolCleanupGroup" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
pResult = ::CreateThreadpoolCleanupGroup();
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateThreadpoolCleanupGroup" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
::PTP_IO CKernel32::CreateThreadpoolIo( HANDLE fl, ::PTP_WIN32_IO_CALLBACK pfnio, PVOID pv, ::PTP_CALLBACK_ENVIRON pcbe )
{
_WINQ_SFCONTEXT( "CKernel32::CreateThreadpoolIo" );
CCheckReturn< ::PTP_IO, CCheckNonZero< ::PTP_IO > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CreateThreadpoolIo" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
pResult = ::CreateThreadpoolIo( fl, pfnio, pv, pcbe );
# else
QOR_PP_UNREF4( pcbe, pv, pfnio, fl );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateThreadpoolIo" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
::PTP_TIMER CKernel32::CreateThreadpoolTimer( ::PTP_TIMER_CALLBACK pfnti, PVOID pv, ::PTP_CALLBACK_ENVIRON pcbe )
{
_WINQ_SFCONTEXT( "CKernel32::CreateThreadpoolTimer" );
CCheckReturn< ::PTP_TIMER, CCheckNonZero< ::PTP_TIMER > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CreateThreadpoolTimer" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
pResult = ::CreateThreadpoolTimer( pfnti, pv, pcbe );
# else
QOR_PP_UNREF3( pcbe, pv, pfnti );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateThreadpoolTimer" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
::PTP_WAIT CKernel32::CreateThreadpoolWait( ::PTP_WAIT_CALLBACK pfnwa, PVOID pv, ::PTP_CALLBACK_ENVIRON pcbe )
{
_WINQ_SFCONTEXT( "CKernel32::CreateThreadpoolWait" );
CCheckReturn< ::PTP_WAIT, CCheckNonZero< ::PTP_WAIT > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CreateThreadpoolWait" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
pResult = ::CreateThreadpoolWait( pfnwa, pv, pcbe );
# else
QOR_PP_UNREF3( pcbe, pv, pfnwa );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateThreadpoolWait" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
::PTP_WORK CKernel32::CreateThreadpoolWork( ::PTP_WORK_CALLBACK pfnwk, PVOID pv, ::PTP_CALLBACK_ENVIRON pcbe )
{
_WINQ_SFCONTEXT( "CKernel32::CreateThreadpoolWork" );
CCheckReturn< ::PTP_WORK, CCheckNonZero< ::PTP_WORK > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "CreateThreadpoolWork" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
pResult = ::CreateThreadpoolWork( pfnwk, pv, pcbe );
# else
QOR_PP_UNREF3( pcbe, pv, pfnwk );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "CreateThreadpoolWork" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::DeleteFiber( void* lpFiber )
{
_WINQ_SFCONTEXT( "CKernel32::DeleteFiber" );
# if ( _WIN32_WINNT >= 0x0400 )
::DeleteFiber( lpFiber );
# else
QOR_PP_UNREF( lpFiber );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "DeleteFiber" ), _T( "Windows NT 4.0" ), 0 ));
# endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::DeleteProcThreadAttributeList( ::LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList )
{
_WINQ_SFCONTEXT( "CKernel32::DeleteProcThreadAttributeList" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "DeleteProcThreadAttributeList" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::DeleteProcThreadAttributeList( lpAttributeList );
# else
QOR_PP_UNREF( lpAttributeList );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "DeleteProcThreadAttributeList" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::DisassociateCurrentThreadFromCallback( ::PTP_CALLBACK_INSTANCE pci )
{
_WINQ_SFCONTEXT( "CKernel32::DisassociateCurrentThreadFromCallback" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "DisassociateCurrentThreadFromCallback" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::DisassociateCurrentThreadFromCallback( pci );
# else
QOR_PP_UNREF( pci );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "DisassociateCurrentThreadFromCallback" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//------------------------------------------------------------------------------
VOID CKernel32::ExitProcess( UINT uExitCode )
{
_WINQ_SFCONTEXT( "CKernel32::ExitProcess" );
::ExitProcess( uExitCode );
}
//------------------------------------------------------------------------------
VOID CKernel32::ExitThread( DWORD dwExitCode )
{
_WINQ_SFCONTEXT( "CKernel32::ExitThread" );
::ExitThread( dwExitCode );
}
//--------------------------------------------------------------------------------
DWORD CKernel32::FlsAlloc( ::PFLS_CALLBACK_FUNCTION lpCallback )
{
_WINQ_SFCONTEXT( "CKernel32::FlsAlloc" );
CCheckReturn< DWORD, CTCheckFailureValue< DWORD, FLS_OUT_OF_INDEXES > >::TType dwResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "FlsAlloc" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
dwResult = ::FlsAlloc( lpCallback );
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "FlsAlloc" ), _T( "Windows Server 2003" ), 0 ));
# endif
#endif
return dwResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::FlsFree( DWORD dwFlsIndex )
{
_WINQ_SFCONTEXT( "CKernel32::FlsFree" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "FlsFree" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
bResult = ::FlsFree( dwFlsIndex );
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "FlsFree" ), _T( "Windows Server 2003" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
PVOID CKernel32::FlsGetValue( DWORD dwFlsIndex )
{
_WINQ_SFCONTEXT( "CKernel32::FlsGetValue" );
CCheckReturn< PVOID, CCheckNonZero< PVOID > >::TType pResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "FlsGetValue" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
pResult = ::FlsGetValue( dwFlsIndex );
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "FlsGetValue" ), _T( "Windows Server 2003" ), 0 ));
# endif
#endif
return pResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::FlsSetValue( DWORD dwFlsIndex, PVOID lpFlsData )
{
_WINQ_SFCONTEXT( "CKernel32::FlsSetValue" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "FlsSetValue" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
bResult = ::FlsSetValue( dwFlsIndex, lpFlsData );
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "FlsSetValue" ), _T( "Windows Server 2003" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::FlushProcessWriteBuffers(void)
{
_WINQ_SFCONTEXT( "CKernel32::FlushProcessWriteBuffers" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "FlushProcessWriteBuffers" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::FlushProcessWriteBuffers();
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "FlushProcessWriteBuffers" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//------------------------------------------------------------------------------
BOOL CKernel32::FreeEnvironmentStrings( LPTSTR lpszEnvironmentBlock )
{
_WINQ_SFCONTEXT( "CKernel32::FreeEnvironmentStrings" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::FreeEnvironmentStrings( lpszEnvironmentBlock );
return bResult;
}
#ifdef UNICODE
//------------------------------------------------------------------------------
BOOL CKernel32::FreeEnvironmentStringsA( LPSTR lpszEnvironmentBlock )
{
_WINQ_SFCONTEXT( "CKernel32::FreeEnvironmentStringsA" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::FreeEnvironmentStringsA( lpszEnvironmentBlock );
return bResult;
}
#else
//------------------------------------------------------------------------------
BOOL CKernel32::FreeEnvironmentStringsW( LPWSTR lpszEnvironmentBlock )
{
_WINQ_SFCONTEXT( "CKernel32::FreeEnvironmentStringsW" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::FreeEnvironmentStringsW( lpszEnvironmentBlock );
return bResult;
}
#endif
//--------------------------------------------------------------------------------
VOID CKernel32::FreeLibraryWhenCallbackReturns( ::PTP_CALLBACK_INSTANCE pci, HMODULE mod )
{
_WINQ_SFCONTEXT( "CKernel32::FreeLibraryWhenCallbackReturns" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "FreeLibraryWhenCallbackReturns" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::FreeLibraryWhenCallbackReturns( pci, mod );
# else
QOR_PP_UNREF2( mod, pci );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "FreeLibraryWhenCallbackReturns" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//------------------------------------------------------------------------------
LPTSTR CKernel32::GetCommandLine(void)
{
_WINQ_SFCONTEXT( "CKernel32::GetCommandLine" );
LPTSTR pResult = 0;
pResult = ::GetCommandLine();
return pResult;
}
//------------------------------------------------------------------------------
HANDLE CKernel32::GetCurrentProcess(void)
{
_WINQ_SFCONTEXT( "CKernel32::GetCurrentProcess" );
return ::GetCurrentProcess();
}
//------------------------------------------------------------------------------
DWORD CKernel32::GetCurrentProcessId(void)
{
_WINQ_SFCONTEXT( "CKernel32::GetCurrentProcessId" );
DWORD dwResult = ::GetCurrentProcessId();
return dwResult;
}
//--------------------------------------------------------------------------------
DWORD CKernel32::GetCurrentProcessorNumber(void)
{
_WINQ_SFCONTEXT( "CKernel32::GetCurrentProcessorNumber" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetCurrentProcessorNumber" ), 0 ));
#else
# if( _MSC_VER >= 1700 )
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetCurrentProcessorNumber" ), _T( "Windows 7" ), 0 ));
# else
# if ( _WIN32_WINNT >= 0x0502 )
return ::GetCurrentProcessorNumber();
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetCurrentProcessorNumber" ), _T( "Windows Server 2003" ), 0 ));
# endif
# endif
#endif
return 0;
}
//------------------------------------------------------------------------------
HANDLE CKernel32::GetCurrentThread(void)
{
_WINQ_SFCONTEXT( "CKernel32::GetCurrentThread" );
CCheckReturn< HANDLE, CHandleCheck<> >::TType h = ::GetCurrentThread();
return h;
}
//------------------------------------------------------------------------------
DWORD CKernel32::GetCurrentThreadId(void)
{
_WINQ_SFCONTEXT( "CKernel32::GetCurrentThreadId" );
return ::GetCurrentThreadId();
}
//------------------------------------------------------------------------------
LPVOID CKernel32::GetEnvironmentStringsA(void)
{
_WINQ_SFCONTEXT( "CKernel32::GetEnvironmentStringsA" );
CCheckReturn< LPVOID, CCheckNonZero< LPVOID > >::TType pResult;
pResult = ::GetEnvironmentStrings();
return pResult;
}
//------------------------------------------------------------------------------
LPVOID CKernel32::GetEnvironmentStringsW(void)
{
_WINQ_SFCONTEXT( "CKernel32::GetEnvironmentStringsW" );
CCheckReturn< LPVOID, CCheckNonZero< LPVOID > >::TType pResult;
pResult = ::GetEnvironmentStringsW();
return pResult;
}
//------------------------------------------------------------------------------
DWORD CKernel32::GetEnvironmentVariable( LPCTSTR lpName, LPTSTR lpBuffer, DWORD nSize )
{
_WINQ_SFCONTEXT( "CKernel32::GetEnvironmentVariable" );
CCheckReturn< DWORD, CCheckNonZero< DWORD > >::TType dwResult;
dwResult = ::GetEnvironmentVariable( lpName, lpBuffer, nSize );
return dwResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetExitCodeProcess( HANDLE hProcess, LPDWORD lpExitCode )
{
_WINQ_SFCONTEXT( "CKernel32::GetExitCodeProcess" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::GetExitCodeProcess( hProcess, lpExitCode );
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetExitCodeThread( HANDLE hThread, LPDWORD lpExitCode )
{
_WINQ_SFCONTEXT( "CKernel32::GetExitCodeThread" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::GetExitCodeThread( hThread, lpExitCode );
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetLogicalProcessorInformation( ::PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer, PDWORD ReturnLength )
{
_WINQ_SFCONTEXT( "CKernel32::GetLogicalProcessorInformation" );
BOOL bResult = FALSE;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetLogicalProcessorInformation" ), 0 ));
#else
bResult = ::GetLogicalProcessorInformation( Buffer, ReturnLength );
if( bResult == FALSE && Buffer != 0 )//If you just want to query the needed size pass a NULL Buffer
{
__WINQAPI_CONT_ERROR(( GENERAL_API_ERROR, _T( "GetLogicalProcessorInformation" ), 0 ));
}
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetNumaAvailableMemoryNode( UCHAR Node, PULONGLONG AvailableBytes )
{
_WINQ_SFCONTEXT( "CKernel32::GetNumaAvailableMemoryNode" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetNumaAvailableMemoryNode" ), 0 ));
#else
bResult = ::GetNumaAvailableMemoryNode( Node, AvailableBytes );
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetNumaHighestNodeNumber( PULONG HighestNodeNumber )
{
_WINQ_SFCONTEXT( "CKernel32::GetNumaHighestNodeNumber" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetNumaHighestNodeNumber" ), 0 ));
#else
bResult = ::GetNumaHighestNodeNumber( HighestNodeNumber );
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetNumaNodeProcessorMask( UCHAR Node, PULONGLONG ProcessorMask )
{
_WINQ_SFCONTEXT( "CKernel32::GetNumaNodeProcessorMask" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetNumaNodeProcessorMask" ), 0 ));
#else
bResult = ::GetNumaNodeProcessorMask( Node, ProcessorMask );
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetNumaProcessorNode( UCHAR Processor, PUCHAR NodeNumber )
{
_WINQ_SFCONTEXT( "CKernel32::GetNumaProcessorNode" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetNumaProcessorNode" ), 0 ));
#else
bResult = ::GetNumaProcessorNode( Processor, NodeNumber );
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetNumaProximityNode( ULONG ProximityId, PUCHAR NodeNumber )
{
_WINQ_SFCONTEXT( "CKernel32::GetNumaProximityNode" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetNumaProximityNode" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::GetNumaProximityNode( ProximityId, NodeNumber );
# else
QOR_PP_UNREF2( NodeNumber, ProximityId );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetNumaProximityNode" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//------------------------------------------------------------------------------
DWORD CKernel32::GetPriorityClass( HANDLE hProcess )
{
_WINQ_SFCONTEXT( "CKernel32::GetPriorityClass" );
CCheckReturn< DWORD, CCheckNonZero< DWORD > >::TType dwResult;
dwResult = ::GetPriorityClass( hProcess );
return dwResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetProcessAffinityMask( HANDLE hProcess, PDWORD_PTR lpProcessAffinityMask, PDWORD_PTR lpSystemAffinityMask )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessAffinityMask" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::GetProcessAffinityMask( hProcess, lpProcessAffinityMask, lpSystemAffinityMask );
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetProcessHandleCount( HANDLE hProcess, PDWORD pdwHandleCount )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessHandleCount" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT >= 0x0501 )
bResult = ::GetProcessHandleCount( hProcess, pdwHandleCount );
# else
QOR_PP_UNREF2( pdwHandleCount, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessHandleCount" ), _T( "Windows XP Service Pack 1" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
DWORD CKernel32::GetProcessId( HANDLE Process )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessId" );
CCheckReturn< DWORD, CCheckNonZero< DWORD > >::TType dwResult;
dwResult = ::GetProcessId( Process );
return dwResult;
}
//--------------------------------------------------------------------------------
DWORD CKernel32::GetProcessIdOfThread( HANDLE Thread )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessIdOfThread" );
CCheckReturn< DWORD, CCheckNonZero< DWORD > >::TType dwResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetProcessIdOfThread" ), 0 ));
#else
# if( _MSC_VER >= 1700 )
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessIdOfThread" ), _T( "Windows 7" ), 0 ));
# else
# if ( _WIN32_WINNT >= 0x0502 )
dwResult = ::GetProcessIdOfThread( Thread );
# else
QOR_PP_UNREF( Thread );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessIdOfThread" ), _T( "Windows Server 2003" ), 0 ));
# endif
# endif
#endif
return dwResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetProcessIoCounters( HANDLE hProcess, ::PIO_COUNTERS lpIoCounters )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessIoCounters" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT >= 0x0500 )//Win2K
bResult = ::GetProcessIoCounters( hProcess, lpIoCounters );
# else
QOR_PP_UNREF( lpIoCounters, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessIoCounters" ), _T( "Windows 2000" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetProcessPriorityBoost( HANDLE hProcess, PBOOL pDisablePriorityBoost )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessPriorityBoost" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT >= 0x0400 )
bResult = ::GetProcessPriorityBoost( hProcess, pDisablePriorityBoost );
# else
QOR_PP_UNREF2( pDisablePriorityBoost, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessPriorityBoost" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetProcessShutdownParameters( LPDWORD lpdwLevel, LPDWORD lpdwFlags )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessShutdownParameters" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT > 0x0500 )
bResult = ::GetProcessShutdownParameters( lpdwLevel, lpdwFlags );
# else
QOR_PP_UNREF2( lpdwFlags, lpdwLevel );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessShutdownParameters" ), _T( "Windows 2000" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetProcessTimes( HANDLE hProcess, ::LPFILETIME lpCreationTime, ::LPFILETIME lpExitTime, ::LPFILETIME lpKernelTime, ::LPFILETIME lpUserTime )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessTimes" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT > 0x0400 )//NT4
bResult = ::GetProcessTimes( hProcess, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime );
# else
QOR_PP_UNREF5( lpUserTime, lpKernelTime, lpExitTime, lpCreationTime, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessTimes" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
DWORD CKernel32::GetProcessVersion( DWORD ProcessId )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessVersion" );
CCheckReturn< DWORD, CCheckNonZero< DWORD > >::TType dwResult;
dwResult = ::GetProcessVersion( ProcessId );
return dwResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetProcessWorkingSetSize( HANDLE hProcess, PSIZE_T lpMinimumWorkingSetSize, PSIZE_T lpMaximumWorkingSetSize )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessWorkingSetSize" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT > 0x0400 )
bResult = ::GetProcessWorkingSetSize( hProcess, lpMinimumWorkingSetSize, lpMaximumWorkingSetSize );
# else
QOR_PP_UNREF3( lpMaximumWorkingSetSize, lpMinimumWorkingSetSize, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessWorkingSetSize" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetProcessWorkingSetSizeEx( HANDLE hProcess, PSIZE_T lpMinimumWorkingSetSize, PSIZE_T lpMaximumWorkingSetSize, PDWORD Flags )
{
_WINQ_SFCONTEXT( "CKernel32::GetProcessWorkingSetSizeEx" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetProcessWorkingSetSizeEx" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
bResult = ::GetProcessWorkingSetSizeEx( hProcess, lpMinimumWorkingSetSize, lpMaximumWorkingSetSize, Flags );
# else
QOR_PP_UNREF4( hProcess, lpMinimumWorkingSetSize, lpMaximumWorkingSetSize, Flags );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetProcessWorkingSetSizeEx" ), _T( "Windows Server 2003" ), 0 ));
# endif
#endif
return bResult;
}
//------------------------------------------------------------------------------
VOID CKernel32::GetStartupInfo( CCheckParam< ::LPSTARTUPINFO, CTRWPointerCheck< sizeof( ::STARTUPINFO ) > >::TType pStartupInfo )
{
_WINQ_SFCONTEXT( "CKernel32::GetStartupInfo" );
::GetStartupInfo( pStartupInfo );
}
//--------------------------------------------------------------------------------
DWORD CKernel32::GetThreadId( HANDLE Thread )
{
_WINQ_SFCONTEXT( "CKernel32::GetThreadId" );
CCheckReturn< DWORD, CCheckNonZero< DWORD > >::TType dwResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "GetProcessWorkingSetSizeEx" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
dwResult = ::GetThreadId( Thread );
# else
QOR_PP_UNREF( Thread );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetThreadId" ), _T( "Windows Server 2003" ), 0 ));
# endif
#endif
return dwResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::GetThreadIOPendingFlag( HANDLE hThread, PBOOL lpIOIsPending )
{
_WINQ_SFCONTEXT( "CKernel32::GetThreadIOPendingFlag" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if( _WIN32_WINNT >= 0x0501 )
bResult = ::GetThreadIOPendingFlag( hThread, lpIOIsPending );
# else
QOR_PP_UNREF2( lpIOIsPending, hThread );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "GetThreadIOPendingFlag" ), _T( "Windows XP" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
int CKernel32::GetThreadPriority( HANDLE hThread )
{
_WINQ_SFCONTEXT( "CKernel32::GetThreadPriority" );
CCheckReturn< int, CTCheckFailureValue< int, THREAD_PRIORITY_ERROR_RETURN > >::TType iResult;
iResult = ::GetThreadPriority( hThread );
return iResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetThreadPriorityBoost( HANDLE hThread, PBOOL pDisablePriorityBoost )
{
_WINQ_SFCONTEXT( "CKernel32::GetThreadPriorityBoost" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::GetThreadPriorityBoost( hThread, pDisablePriorityBoost );
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::GetThreadTimes( HANDLE hThread, ::LPFILETIME lpCreationTime, ::LPFILETIME lpExitTime, ::LPFILETIME lpKernelTime, ::LPFILETIME lpUserTime )
{
_WINQ_SFCONTEXT( "CKernel32::GetThreadTimes" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::GetThreadTimes( hThread, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime );
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::InitializeProcThreadAttributeList( ::LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, DWORD dwAttributeCount, DWORD dwFlags, PSIZE_T lpSize )
{
_WINQ_SFCONTEXT( "CKernel32::InitializeProcThreadAttributeList" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "InitializeProcThreadAttributeList" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::InitializeProcThreadAttributeList( lpAttributeList, dwAttributeCount, dwFlags, lpSize );
# else
QOR_PP_UNREF4( lpSize, dwFlags, dwAttributeCount, lpAttributeList );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "InitializeProcThreadAttributeList" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::InitializeThreadpoolEnvironment( ::PTP_CALLBACK_ENVIRON pcbe )
{
_WINQ_SFCONTEXT( "CKernel32::InitializeThreadpoolEnvironment" );
# if ( _WIN32_WINNT >= 0x0600 )
::InitializeThreadpoolEnvironment( pcbe );
# else
QOR_PP_UNREF( pcbe );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "InitializeThreadpoolEnvironment" ), _T( "Windows Vista" ), 0 ));
# endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::DestroyThreadpoolEnvironment( ::PTP_CALLBACK_ENVIRON pcbe )
{
_WINQ_SFCONTEXT( "CKernel32::DestroyThreadpoolEnvironment" );
# if ( _WIN32_WINNT >= 0x0600 )
::DestroyThreadpoolEnvironment( pcbe );
# else
QOR_PP_UNREF( pcbe );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "InitializeThreadpoolEnvironment" ), _T( "Windows Vista" ), 0 ));
# endif
}
//--------------------------------------------------------------------------------
BOOL CKernel32::IsProcessInJob( HANDLE ProcessHandle, HANDLE JobHandle, PBOOL Result )
{
_WINQ_SFCONTEXT( "CKernel32::IsProcessInJob" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "IsProcessInJob" ), 0 ));
#else
# if( _WIN32_WINNT >= 0x0501 )
bResult = ::IsProcessInJob( ProcessHandle, JobHandle, Result );
# else
QOR_PP_UNREF3( Result, JobHandle, ProcessHandle );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "IsProcessInJob" ), _T( "Windows XP" ), 0 ));
#endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::IsThreadAFiber(void)
{
_WINQ_SFCONTEXT( "CKernel32::IsThreadAFiber" );
BOOL bResult = FALSE;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "IsThreadAFiber" ), 0 ));
#else
# if( _WIN32_WINNT >= 0x0600 )
bResult = ::IsThreadAFiber();
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "IsThreadAFiber" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::IsThreadpoolTimerSet( ::PTP_TIMER pti )
{
_WINQ_SFCONTEXT( "CKernel32::IsThreadpoolTimerSet" );
BOOL bResult = FALSE;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "IsThreadpoolTimerSet" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::IsThreadpoolTimerSet( pti );
# else
QOR_PP_UNREF( pti );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "IsThreadpoolTimerSet" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::IsWow64Process( HANDLE hProcess, PBOOL Wow64Process )
{
_WINQ_SFCONTEXT( "CKernel32::IsWow64Process" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if( _WIN32_WINNT >= 0x0501 )
bResult = ::IsWow64Process( hProcess, Wow64Process );
# else
QOR_PP_UNREF2( Wow64Process, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "IsWow64Process" ), _T( "Windows XP" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::LeaveCriticalSectionWhenCallbackReturns( ::PTP_CALLBACK_INSTANCE pci, ::PCRITICAL_SECTION pcs )
{
_WINQ_SFCONTEXT( "CKernel32::LeaveCriticalSectionWhenCallbackReturns" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "LeaveCriticalSectionWhenCallbackReturns" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::LeaveCriticalSectionWhenCallbackReturns( pci, pcs );
# else
QOR_PP_UNREF2( pcs, pci );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "LeaveCriticalSectionWhenCallbackReturns" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
BOOL CKernel32::NeedCurrentDirectoryForExePath( LPCTSTR ExeName )
{
_WINQ_SFCONTEXT( "CKernel32::NeedCurrentDirectoryForExePath" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "NeedCurrentDirectoryForExePath" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
bResult = ::NeedCurrentDirectoryForExePath( ExeName );
# else
QOR_PP_UNREF( ExeName );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "NeedCurrentDirectoryForExePath" ), _T( "Windows Server 2003" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
HANDLE CKernel32::OpenJobObject( DWORD dwDesiredAccess, BOOL bInheritHandles, LPCTSTR lpName )
{
_WINQ_SFCONTEXT( "CKernel32::OpenJobObject" );
CCheckReturn< HANDLE, CHandleNullCheck< > >::TType h;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "OpenJobObject" ), 0 ));
#else
# if( _WIN32_WINNT >= 0x0500 )
h = ::OpenJobObject( dwDesiredAccess, bInheritHandles, lpName );
# else
QOR_PP_UNREF3( lpName, bInheritHandles, dwDesiredAccess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "OpenJobObject" ), _T( "Windows 2000" ), 0 ));
# endif
#endif
return h;
}
//------------------------------------------------------------------------------
HANDLE CKernel32::OpenProcess( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId )
{
_WINQ_SFCONTEXT( "CKernel32::OpenProcess" );
CCheckReturn< HANDLE, CHandleNullCheck< > >::TType h;
h = ::OpenProcess( dwDesiredAccess, bInheritHandle, dwProcessId );
return h;
}
//------------------------------------------------------------------------------
HANDLE CKernel32::OpenThread( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId )
{
_WINQ_SFCONTEXT( "CKernel32::OpenThread" );
CCheckReturn< HANDLE, CHandleNullCheck< > >::TType h;
h = ::OpenThread( dwDesiredAccess, bInheritHandle, dwThreadId );
return h;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::QueryFullProcessImageName( HANDLE hProcess, DWORD dwFlags, LPTSTR lpExeName, PDWORD lpdwSize )
{
_WINQ_SFCONTEXT( "CKernel32::QueryFullProcessImageName" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "QueryFullProcessImageName" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::QueryFullProcessImageName( hProcess, dwFlags, lpExeName, lpdwSize );
# else
QOR_PP_UNREF4( lpdwSize, lpExeName, dwFlags, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "QueryFullProcessImageName" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::QueryIdleProcessorCycleTime( PULONG BufferLength, PULONG64 ProcessorIdleCycleTime )
{
_WINQ_SFCONTEXT( "CKernel32::QueryIdleProcessorCycleTime" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "QueryIdleProcessorCycleTime" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::QueryIdleProcessorCycleTime( BufferLength, ProcessorIdleCycleTime );
# else
QOR_PP_UNREF( ProcessorIdleCycleTime, BufferLength );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "QueryIdleProcessorCycleTime" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::QueryInformationJobObject( HANDLE hJob, ::JOBOBJECTINFOCLASS JobObjectInfoClass, void* lpJobObjectInfo, DWORD cbJobObjectInfoLength, LPDWORD lpReturnLength )
{
_WINQ_SFCONTEXT( "CKernel32::QueryInformationJobObject" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if( _WIN32_WINNT >= 0x0500 )
bResult = ::QueryInformationJobObject( hJob, JobObjectInfoClass, lpJobObjectInfo, cbJobObjectInfoLength, lpReturnLength );
# else
QOR_PP_UNREF5( lpReturnLength, cbJobObjectInfoLength, lpJobObjectInfo, JobObjectInfoClass, hJob );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "QueryInformationJobObject" ), _T( "Windows 2000" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
//Requires Windows Vista SP1. Server Requires Windows Server 2008.
BOOL CKernel32::QueryProcessAffinityUpdateMode( HANDLE ProcessHandle, LPDWORD lpdwFlags )
{
_WINQ_SFCONTEXT( "CKernel32::QueryProcessAffinityUpdateMode" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "QueryProcessAffinityUpdateMode" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 && NTDDI_VERSION >= NTDDI_VISTASP1 )
bResult = ::QueryProcessAffinityUpdateMode( ProcessHandle, lpdwFlags );
# else
QOR_PP_UNREF2( lpdwFlags, ProcessHandle );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "QueryProcessAffinityUpdateMode" ), _T( "Windows Vista Service Pack 1" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::QueryProcessCycleTime( HANDLE ProcessHandle, PULONG64 CycleTime )
{
_WINQ_SFCONTEXT( "CKernel32::QueryProcessCycleTime" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "QueryProcessCycleTime" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::QueryProcessCycleTime( ProcessHandle, CycleTime );
# else
QOR_PP_UNREF2( CycleTime, ProcessHandle );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "QueryProcessCycleTime" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::QueryThreadCycleTime( HANDLE ThreadHandle, PULONG64 CycleTime )
{
_WINQ_SFCONTEXT( "CKernel32::QueryThreadCycleTime" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "QueryThreadCycleTime" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::QueryThreadCycleTime( ThreadHandle, CycleTime );
# else
QOR_PP_UNREF2( CycleTime, ThreadHandle );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "QueryThreadCycleTime" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::QueueUserWorkItem( LPTHREAD_START_ROUTINE Function, PVOID Context, ULONG Flags )
{
_WINQ_SFCONTEXT( "CKernel32::QueueUserWorkItem" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if( _WIN32_WINNT >= 0x0500 )
bResult = ::QueueUserWorkItem( Function, Context, Flags );
# else
QOR_PP_UNREF3( Flags, Context, Function );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "QueueUserWorkItem" ), _T( "Windows 2000" ), 0 ));
#endif
return bResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::ReleaseMutexWhenCallbackReturns( ::PTP_CALLBACK_INSTANCE pci, HANDLE mut )
{
_WINQ_SFCONTEXT( "CKernel32::ReleaseMutexWhenCallbackReturns" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "ReleaseMutexWhenCallbackReturns" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::ReleaseMutexWhenCallbackReturns( pci, mut );
# else
QOR_PP_UNREF2( mut, pci );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "ReleaseMutexWhenCallbackReturns" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::ReleaseSemaphoreWhenCallbackReturns( ::PTP_CALLBACK_INSTANCE pci, HANDLE sem, DWORD crel )
{
_WINQ_SFCONTEXT( "CKernel32::ReleaseSemaphoreWhenCallbackReturns" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "ReleaseSemaphoreWhenCallbackReturns" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::ReleaseSemaphoreWhenCallbackReturns( pci, sem, crel );
# else
QOR_PP_UNREF3( crel, sem, pci );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "ReleaseSemaphoreWhenCallbackReturns" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//------------------------------------------------------------------------------
DWORD CKernel32::ResumeThread( HANDLE hThread )
{
_WINQ_SFCONTEXT( "CKernel32::ResumeThread" );
CCheckReturn< DWORD, CTCheckFailureValue< DWORD, 0xFFFFFFFF > >::TType dwResult;
dwResult = ::ResumeThread( hThread );
return dwResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::SetEnvironmentVariable( LPCTSTR lpName, LPCTSTR lpValue )
{
_WINQ_SFCONTEXT( "CKernel32::SetEnvironmentVariable" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::SetEnvironmentVariable( lpName, lpValue );
return bResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::SetEventWhenCallbackReturns( ::PTP_CALLBACK_INSTANCE pci, HANDLE evt )
{
_WINQ_SFCONTEXT( "CKernel32::SetEventWhenCallbackReturns" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "SetEventWhenCallbackReturns" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::SetEventWhenCallbackReturns( pci, evt );
# else
QOR_PP_UNREF2( evt, pci );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetEventWhenCallbackReturns" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
BOOL CKernel32::SetInformationJobObject( HANDLE hJob, ::JOBOBJECTINFOCLASS JobObjectInfoClass, void* lpJobObjectInfo, DWORD cbJobObjectInfoLength )
{
_WINQ_SFCONTEXT( "CKernel32::SetInformationJobObject" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if( _WIN32_WINNT >= 0x0500 )
bResult = ::SetInformationJobObject( hJob, JobObjectInfoClass, lpJobObjectInfo, cbJobObjectInfoLength );
# else
QOR_PP_UNREF4( cbJobObjectInfoLength, lpJobObjectInfo, JobObjectInfoClass, hJob );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetInformationJobObject" ), _T( "Windows 2000" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::SetPriorityClass( HANDLE hProcess, DWORD dwPriorityClass )
{
_WINQ_SFCONTEXT( "CKernel32::SetPriorityClass" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::SetPriorityClass( hProcess, dwPriorityClass );
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::SetProcessAffinityMask( HANDLE hProcess, DWORD_PTR dwProcessAffinityMask )
{
_WINQ_SFCONTEXT( "CKernel32::SetProcessAffinityMask" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT > 0x0400 )//NT4
bResult= ::SetProcessAffinityMask( hProcess, dwProcessAffinityMask );
# else
QOR_PP_UNREF2( dwProcessAffinityMask, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetProcessAffinityMask" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::SetProcessAffinityUpdateMode( HANDLE ProcessHandle, DWORD dwFlags )
{
_WINQ_SFCONTEXT( "CKernel32::SetProcessAffinityUpdateMode" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "SetProcessAffinityUpdateMode" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 && NTDDI_VERSION >= NTDDI_VISTASP1 )
bResult = ::SetProcessAffinityUpdateMode( ProcessHandle, dwFlags );
# else
QOR_PP_UNREF2( dwFlags, ProcessHandle );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetProcessAffinityUpdateMode" ), _T( "Windows Vista Service Pack 1" ), 0 ));
# endif
#endif
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::SetProcessPriorityBoost( HANDLE hProcess, BOOL DisablePriorityBoost )
{
_WINQ_SFCONTEXT( "CKernel32::SetProcessPriorityBoost" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT > 0x0400 )
bResult = ::SetProcessPriorityBoost( hProcess, DisablePriorityBoost );
# else
QOR_PP_UNREF2( DisablePriorityBoost, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetProcessPriorityBoost" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::SetProcessShutdownParameters( DWORD dwLevel, DWORD dwFlags )
{
_WINQ_SFCONTEXT( "CKernel32::SetProcessShutdownParameters" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT > 0x0000 )
bResult = ::SetProcessShutdownParameters( dwLevel, dwFlags );
# else
QOR_PP_UNREF2( dwFlags, dwLevel );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetProcessShutdownParameters" ), _T( "Windows NT" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::SetProcessWorkingSetSize( HANDLE hProcess, SIZE_T dwMinimumWorkingSetSize, SIZE_T dwMaximumWorkingSetSize )
{
_WINQ_SFCONTEXT( "CKernel32::SetProcessWorkingSetSize" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT > 0x0400 )
bResult = ::SetProcessWorkingSetSize( hProcess, dwMinimumWorkingSetSize, dwMaximumWorkingSetSize );
# else
QOR_PP_UNREF3( dwMaximumWorkingSetSize, dwMinimumWorkingSetSize, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetProcessWorkingSetSize" ), _T( "Windows NT" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::SetProcessWorkingSetSizeEx( HANDLE hProcess, SIZE_T dwMinimumWorkingSetSize, SIZE_T dwMaximumWorkingSetSize, DWORD Flags )
{
_WINQ_SFCONTEXT( "CKernel32::SetProcessWorkingSetSizeEx" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "SetProcessWorkingSetSizeEx" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
bResult = ::SetProcessWorkingSetSizeEx( hProcess, dwMinimumWorkingSetSize, dwMaximumWorkingSetSize, Flags );
# else
QOR_PP_UNREF4( Flags, dwMaximumWorkingSetSize, dwMinimumWorkingSetSize, hProcess );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetProcessWorkingSetSizeEx" ), _T( "Windows 2003" ), 0 ));
# endif
#endif
return bResult;
}
//------------------------------------------------------------------------------
DWORD_PTR CKernel32::SetThreadAffinityMask( HANDLE hThread, DWORD_PTR dwThreadAffinityMask )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadAffinityMask" );
CCheckReturn< DWORD_PTR, CCheckNonZero< DWORD_PTR > >::TType dwResult;
dwResult = ::SetThreadAffinityMask( hThread, dwThreadAffinityMask );
return dwResult;
}
//------------------------------------------------------------------------------
DWORD CKernel32::SetThreadIdealProcessor( HANDLE hThread, DWORD dwIdealProcessor )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadIdealProcessor" );
CCheckReturn< DWORD, CTCheckFailureValue< DWORD, 0xFFFFFFFF > >::TType dwResult;
# if ( _WIN32_WINNT >= 0x0400 )
dwResult = ::SetThreadIdealProcessor( hThread, dwIdealProcessor );
# else
QOR_PP_UNREF2( dwIdealProcessor, hThread );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadIdealProcessor" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return dwResult;
}
//------------------------------------------------------------------------------
VOID CKernel32::SetThreadpoolCallbackCleanupGroup( ::PTP_CALLBACK_ENVIRON pcbe, ::PTP_CLEANUP_GROUP ptpcg, ::PTP_CLEANUP_GROUP_CANCEL_CALLBACK pfng )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadpoolCallbackCleanupGroup" );
# if ( _WIN32_WINNT >= 0x0600 )
::SetThreadpoolCallbackCleanupGroup( pcbe, ptpcg, pfng );
# else
QOR_PP_UNREF3( pfng, ptpcg, pcbe );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadpoolCallbackCleanupGroup" ), _T( "Windows Vista" ), 0 ));
# endif
}
//------------------------------------------------------------------------------
VOID CKernel32::SetThreadpoolCallbackLibrary( ::PTP_CALLBACK_ENVIRON pcbe, PVOID mod )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadpoolCallbackLibrary" );
# if ( _WIN32_WINNT >= 0x0600 )
::SetThreadpoolCallbackLibrary( pcbe, mod );
# else
QOR_PP_UNREF( mod, pcbe );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadpoolCallbackLibrary" ), _T( "Windows Vista" ), 0 ));
# endif
}
//------------------------------------------------------------------------------
VOID CKernel32::SetThreadpoolCallbackPool( ::PTP_CALLBACK_ENVIRON pcbe, ::PTP_POOL ptpp )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadpoolCallbackPool" );
# if ( _WIN32_WINNT >= 0x0600 )
::SetThreadpoolCallbackPool( pcbe, ptpp );
# else
QOR_PP_UNREF( ptpp, pcbe );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadpoolCallbackPool" ), _T( "Windows Vista" ), 0 ));
# endif
}
//------------------------------------------------------------------------------
VOID CKernel32::SetThreadpoolCallbackRunsLong( ::PTP_CALLBACK_ENVIRON pcbe )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadpoolCallbackRunsLong" );
# if ( _WIN32_WINNT >= 0x0600 )
::SetThreadpoolCallbackRunsLong( pcbe );
# else
QOR_PP_UNREF( pcbe );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadpoolCallbackRunsLong" ), _T( "Windows Vista" ), 0 ));
# endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::SetThreadpoolThreadMaximum( ::PTP_POOL ptpp, DWORD cthrdMost )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadpoolThreadMaximum" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "SetThreadpoolThreadMaximum" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::SetThreadpoolThreadMaximum( ptpp, cthrdMost );
# else
QOR_PP_UNREF( cthrdMost, ptpp );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadpoolThreadMaximum" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
BOOL CKernel32::SetThreadpoolThreadMinimum( ::PTP_POOL ptpp, DWORD cthrdMic )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadpoolThreadMinimum" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "SetThreadpoolThreadMinimum" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::SetThreadpoolThreadMinimum( ptpp, cthrdMic );
# else
QOR_PP_UNREF( cthrdMic, ptpp );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadpoolThreadMinimum" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::SetThreadpoolTimer( ::PTP_TIMER pti, ::PFILETIME pftDueTime, DWORD msPeriod, DWORD msWindowLength )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadpoolTimer" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "SetThreadpoolTimer" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::SetThreadpoolTimer( pti, pftDueTime, msPeriod, msWindowLength );
# else
QOR_PP_UNREF4( msWindowLength, msPeriod, pftDueTime, pti );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadpoolTimer" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::SetThreadpoolWait( ::PTP_WAIT pwa, HANDLE h, ::PFILETIME pftTimeout )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadpoolWait" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "SetThreadpoolWait" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::SetThreadpoolWait( pwa, h, pftTimeout );
# else
QOR_PP_UNREF3( pftTimeout, h, pwa );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadpoolWait" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//------------------------------------------------------------------------------
BOOL CKernel32::SetThreadPriority( HANDLE hThread, int nPriority )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadPriority" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::SetThreadPriority( hThread, nPriority );
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::SetThreadPriorityBoost( HANDLE hThread, BOOL bDisablePriorityBoost )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadPriorityBoost" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::SetThreadPriorityBoost( hThread, bDisablePriorityBoost );
return bResult;
}
//--------------------------------------------------------------------------------
//Client Requires Windows XP Professional x64 Edition.
//Server Requires Windows Server 2003 SP1.
BOOL CKernel32::SetThreadStackGuarantee( PULONG StackSizeInBytes )
{
_WINQ_SFCONTEXT( "CKernel32::SetThreadStackGuarantee" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "SetThreadStackGuarantee" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0502 )
bResult = ::SetThreadStackGuarantee( StackSizeInBytes );
# else
QOR_PP_UNREF( StackSizeInBytes );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SetThreadStackGuarantee" ), _T( "Windows Server 2003" ), 0 ));
# endif
#endif
return bResult;
}
//------------------------------------------------------------------------------
VOID CKernel32::Sleep( DWORD dwMilliseconds )
{
_WINQ_SFCONTEXT( "CKernel32::Sleep" );
::Sleep( dwMilliseconds );
}
//------------------------------------------------------------------------------
DWORD CKernel32::SleepEx( DWORD dwMilliseconds, BOOL bAlertable )
{
_WINQ_SFCONTEXT( "CKernel32::SleepEx" );
DWORD dwResult = 0;
dwResult = ::SleepEx( dwMilliseconds, bAlertable );
return dwResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::StartThreadpoolIo( ::PTP_IO pio )
{
_WINQ_SFCONTEXT( "CKernel32::StartThreadpoolIo" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "StartThreadpoolIo" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::StartThreadpoolIo( pio );
# else
QOR_PP_UNREF( pio );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "StartThreadpoolIo" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::SubmitThreadpoolWork( ::PTP_WORK pwk )
{
_WINQ_SFCONTEXT( "CKernel32::SubmitThreadpoolWork" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "StartThreadpoolIo" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::SubmitThreadpoolWork( pwk );
# else
QOR_PP_UNREF( pwk );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SubmitThreadpoolWork" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//------------------------------------------------------------------------------
DWORD CKernel32::SuspendThread( HANDLE hThread )
{
_WINQ_SFCONTEXT( "CKernel32::SuspendThread" );
CCheckReturn< DWORD, CTCheckFailureValue< DWORD, 0xFFFFFFFF > >::TType dwResult;
dwResult = ::SuspendThread( hThread );
return dwResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::SwitchToFiber( void* lpFiber )
{
_WINQ_SFCONTEXT( "CKernel32::SwitchToFiber" );
# if( _WIN32_WINNT >= 0x0400 )
::SwitchToFiber( lpFiber );
# else
QOR_PP_UNREF( lpFiber );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SwitchToFiber" ), _T( "Windows NT 4.0" ), 0 ));
# endif
}
//------------------------------------------------------------------------------
BOOL CKernel32::SwitchToThread(void)
{
_WINQ_SFCONTEXT( "CKernel32::SwitchToThread" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if ( _WIN32_WINNT >= 0x0400 )
bResult = ::SwitchToThread();
# else
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "SwitchToThread" ), _T( "Windows NT 4.0" ), 0 ));
# endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::TerminateJobObject( HANDLE hJob, UINT uExitCode )
{
_WINQ_SFCONTEXT( "CKernel32::TerminateJobObject" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
# if( _WIN32_WINNT >= 0x0500 )
bResult = ::TerminateJobObject( hJob, uExitCode );
# else
QOR_PP_UNREF2( uExitCode, hJob );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "TerminateJobObject" ), _T( "Windows 2000" ), 0 ));
# endif
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::TerminateProcess( HANDLE hProcess, UINT uExitCode )
{
_WINQ_SFCONTEXT( "CKernel32::TerminateProcess" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::TerminateProcess( hProcess, uExitCode );
return bResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::TerminateThread( HANDLE hThread, DWORD dwExitCode )
{
_WINQ_SFCONTEXT( "CKernel32::TerminateThread" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::TerminateThread( hThread, dwExitCode );
return bResult;
}
//------------------------------------------------------------------------------
DWORD CKernel32::TlsAlloc(void)
{
_WINQ_SFCONTEXT( "CKernel32::TlsAlloc" );
CCheckReturn< DWORD, CTCheckFailureValue< DWORD, TLS_OUT_OF_INDEXES > >::TType dwResult;
dwResult = ::TlsAlloc();
return dwResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::TlsFree( DWORD dwTlsIndex )
{
_WINQ_SFCONTEXT( "CKernel32::TlsFree" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::TlsFree( dwTlsIndex );
return bResult;
}
//------------------------------------------------------------------------------
void* CKernel32::TlsGetValue( DWORD dwTlsIndex )
{
_WINQ_SFCONTEXT( "CKernel32::TlsGetValue" );
void* pResult = 0;
pResult = ::TlsGetValue( dwTlsIndex );
if( pResult == 0 )
{
DWORD dwError = CKernel32::GetLastError();
if( dwError != ERROR_SUCCESS )
{
__WINQAPI_CONT_ERROR(( GENERAL_API_ERROR, _T( "TlsGetValue" ), 0 ));
}
}
return pResult;
}
//------------------------------------------------------------------------------
BOOL CKernel32::TlsSetValue( DWORD dwTlsIndex, void* lpTlsValue )
{
_WINQ_SFCONTEXT( "CKernel32::TlsSetValue" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
bResult = ::TlsSetValue( dwTlsIndex, lpTlsValue );
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::TrySubmitThreadpoolCallback( ::PTP_SIMPLE_CALLBACK pfns, PVOID pv, ::PTP_CALLBACK_ENVIRON pcbe )
{
_WINQ_SFCONTEXT( "CKernel32::TrySubmitThreadpoolCallback" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "TrySubmitThreadpoolCallback" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::TrySubmitThreadpoolCallback( pfns, pv, pcbe );
# else
QOR_PP_UNREF3( pcbe, pv, pfns );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "TrySubmitThreadpoolCallback" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
BOOL CKernel32::UpdateProcThreadAttribute( ::LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, DWORD dwFlags, DWORD_PTR Attribute, PVOID lpValue, SIZE_T cbSize, PVOID lpPreviousValue, PSIZE_T lpReturnSize )
{
_WINQ_SFCONTEXT( "CKernel32::UpdateProcThreadAttribute" );
CCheckReturn< BOOL, CBoolCheck< > >::TType bResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "UpdateProcThreadAttribute" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
bResult = ::UpdateProcThreadAttribute( lpAttributeList, dwFlags, Attribute, lpValue, cbSize, lpPreviousValue, lpReturnSize );
# else
QOR_PP_UNREF7( lpAttributeList, dwFlags, Attribute, lpValue, cbSize, lpPreviousValue, lpReturnSize );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "UpdateProcThreadAttribute" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return bResult;
}
//--------------------------------------------------------------------------------
VOID CKernel32::WaitForThreadpoolIoCallbacks( ::PTP_IO pio, BOOL fCancelPendingCallbacks )
{
_WINQ_SFCONTEXT( "CKernel32::WaitForThreadpoolIoCallbacks" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "WaitForThreadpoolIoCallbacks" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::WaitForThreadpoolIoCallbacks( pio, fCancelPendingCallbacks );
# else
QOR_PP_UNREF2( fCancelPendingCallbacks, pio );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "WaitForThreadpoolIoCallbacks" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::WaitForThreadpoolTimerCallbacks( ::PTP_TIMER pti, BOOL fCancelPendingCallbacks )
{
_WINQ_SFCONTEXT( "CKernel32::WaitForThreadpoolTimerCallbacks" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "WaitForThreadpoolTimerCallbacks" ), 0 ));
#else
#if ( _WIN32_WINNT >= 0x0600 )
::WaitForThreadpoolTimerCallbacks( pti, fCancelPendingCallbacks );
# else
QOR_PP_UNREF2( fCancelPendingCallbacks, pti );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "WaitForThreadpoolTimerCallbacks" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::WaitForThreadpoolWaitCallbacks( ::PTP_WAIT pwa, BOOL fCancelPendingCallbacks )
{
_WINQ_SFCONTEXT( "CKernel32::WaitForThreadpoolWaitCallbacks" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "WaitForThreadpoolWaitCallbacks" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::WaitForThreadpoolWaitCallbacks( pwa, fCancelPendingCallbacks );
# else
QOR_PP_UNREF2( fCancelPendingCallbacks, pwa );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "WaitForThreadpoolWaitCallbacks" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
VOID CKernel32::WaitForThreadpoolWorkCallbacks( ::PTP_WORK pwk, BOOL fCancelPendingCallbacks )
{
_WINQ_SFCONTEXT( "CKernel32::WaitForThreadpoolWorkCallbacks" );
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "WaitForThreadpoolWorkCallbacks" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
::WaitForThreadpoolWorkCallbacks( pwk, fCancelPendingCallbacks );
# else
QOR_PP_UNREF2( fCancelPendingCallbacks, pwk );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "WaitForThreadpoolWorkCallbacks" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
}
//--------------------------------------------------------------------------------
UINT CKernel32::WinExec( LPCSTR lpCmdLine, UINT uCmdShow )
{
_WINQ_SFCONTEXT( "CKernel32::WinExec" );
UINT uiResult = ::WinExec( lpCmdLine, uCmdShow );
switch ( uiResult )
{
case 0:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "WinExec" ), _T( "The system is out of memory or resources." ), 0 ));
break;
case ERROR_BAD_FORMAT:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "WinExec" ), _T( "The .exe file is invalid." ), 0 ));
break;
case ERROR_FILE_NOT_FOUND:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "WinExec" ), _T( "The specified file was not found." ), 0 ));
break;
case ERROR_PATH_NOT_FOUND:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "WinExec" ), _T( "The specified path was not found." ), 0 ));
break;
default:
break;
}
return uiResult;
}
//--------------------------------------------------------------------------------
DWORD CKernel32::Wow64SuspendThread( HANDLE hThread )
{
_WINQ_SFCONTEXT( "CKernel32::Wow64SuspendThread" );
CCheckReturn< DWORD, CTCheckFailureValue< DWORD, 0xFFFFFFFF > >::TType dwResult;
#ifdef __MINGW32__
__WINQAPI_CONT_ERROR(( API_NOT_IN_MINGW32, _T( "Wow64SuspendThread" ), 0 ));
#else
# if ( _WIN32_WINNT >= 0x0600 )
dwResult = ::Wow64SuspendThread( hThread );
# else
QOR_PP_UNREF( hThread );
__WINQAPI_CONT_ERROR(( API_REQUIRES_VERSION, _T( "Wow64SuspendThread" ), _T( "Windows Vista" ), 0 ));
# endif
#endif
return dwResult;
}
//--------------------------------------------------------------------------------
DWORD CKernel32::LoadModule( LPCSTR lpModuleName, void* lpParameterBlock )
{
_WINQ_SFCONTEXT( "CKernel32::LoadModule" );
DWORD dwResult = ::LoadModule( lpModuleName, lpParameterBlock );
if( dwResult <= 31 )
{
switch ( dwResult )
{
case 0:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "LoadModule" ), _T( "The system is out of memory or resources." ), 0 ));
break;
case ERROR_BAD_FORMAT:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "LoadModule" ), _T( "The .exe file is invalid." ), 0 ));
break;
case ERROR_FILE_NOT_FOUND:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "LoadModule" ), _T( "The specified file was not found." ), 0 ));
break;
case ERROR_PATH_NOT_FOUND:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "LoadModule" ), _T( "The specified path was not found." ), 0 ));
break;
default:
__WINQAPI_CONT_ERROR(( WINEXEC_API_ERROR, _T( "LoadModule" ), _T( "Unknown error." ), 0 ));
break;
}
}
return dwResult;
}
}//nsWinQAPI
| 38.743753
| 341
| 0.631481
|
mfaithfull
|
56265ff78e926a840bede08994dc0891c27e500e
| 3,394
|
cpp
|
C++
|
scene.cpp
|
HeckMina/CGI
|
976dfe064ec8021ef615354c46ca93637c56b8c6
|
[
"MIT"
] | 2
|
2021-07-06T01:01:55.000Z
|
2021-07-07T01:30:31.000Z
|
scene.cpp
|
HeckMina/CGI
|
976dfe064ec8021ef615354c46ca93637c56b8c6
|
[
"MIT"
] | null | null | null |
scene.cpp
|
HeckMina/CGI
|
976dfe064ec8021ef615354c46ca93637c56b8c6
|
[
"MIT"
] | 1
|
2021-03-31T05:36:27.000Z
|
2021-03-31T05:36:27.000Z
|
#include "scene.h"
#include "ggl.h"
#include "utils.h"
#include "shader.h"
#include "ShaderPipeline.h"
#include "Material.h"
#include "model.h"
#include "SceneNode.h"
#include "framebufferobject.h"
#include "fullscreenquad.h"
#include "TextureCubeMap.h"
#include "InputUniform.h"
#include <thread>
using namespace Alice;
static int sCanvasWidth = 0, sCanvasHeight = 0;
static SceneNode* sRootNode1 = nullptr, * sRootNode2 = nullptr;
Alice::Camera sMainCamera;
glm::mat4 model_matrix;
Alice::Model* model_sphere;
Alice::Material* material_sphere;
UniformBufferObject* sViewUniformBuffer;
void AddSceneNode(SceneNode**root, SceneNode*node) {
if (*root==nullptr){
*root = node;
}
else {
(*root)->Append(node);
}
}
void AddSceneNodeToRoot1(SceneNode*node) {
AddSceneNode(&sRootNode1, node);
}
void AddSceneNodeToRoot2(SceneNode*node) {
AddSceneNode(&sRootNode2, node);
}
void InitGeometries() {
model_sphere = Model::LoadModel("Res/Model/Sphere.raw");
}
void InitShaders() {
ShaderStage::CacheShaderFromPath(kShaderTypeVertex, "Test330VS", "Res/Shader/Test330.vsb");
ShaderStage::CacheShaderFromPath(kShaderTypeFragment, "Test330FS", "Res/Shader/Test330.fsb");
}
void InitMaterials() {
}
void RenderPBRMaterialSpheresInsRGB() {
}
void Init() {
InitGeometries();
InitShaders();
sViewUniformBuffer = new UniformBufferObject;
sViewUniformBuffer->InitBuffer();
SceneNode* node = new SceneNode;
node->mGeometry = model_sphere;
node->mModelMatrix = glm::translate(0.0f, 0.0f, -5.0f);
node->mUniformInputDescription.AddUniformInput(0, kUniformInputAccessShaderStageVertex | kUniformInputAccessShaderStageFragment, kUniformTypeUniformBuffer);
node->mUniformInputDescription.AddUniformInput(1, kUniformInputAccessShaderStageVertex | kUniformInputAccessShaderStageFragment, kUniformTypeUniformBuffer);
material_sphere = new Alice::Material;
material_sphere->mShaderPipeline.SetShaderStage<kShaderTypeVertex>(ShaderStage::GetShaderStage("Test330VS"));
material_sphere->mShaderPipeline.SetShaderStage<kShaderTypeFragment>(ShaderStage::GetShaderStage("Test330FS"));
material_sphere->mShaderPipeline.CompileShaderPipeline();
node->mMaterial = material_sphere;
AddSceneNodeToRoot1(node);
}
void SetViewPortSize(float width, float height) {
sCanvasWidth = int(width);
sCanvasHeight = int(height);
OnVulkanViewportChanged(width, height);
sMainCamera.mProjectionMatrix = glm::perspective(45.0f, width / height, 0.1f, 1000.0f);
sMainCamera.mViewMatrix = glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, 1.0f, 0.0f));
sViewUniformBuffer->SetMat4(0, glm::value_ptr(sMainCamera.mViewMatrix));
sViewUniformBuffer->SetMat4(sizeof(float) * 16, glm::value_ptr(sMainCamera.mProjectionMatrix));
}
void Draw(float deltaTime) {
float frameTime = GetFrameTime();
sViewUniformBuffer->SyncDataFromCPUToGPU();
ALICE_BEGIN_RENDER_PASS(0);
ALICE_VIEWPORT(GetViewportWidth(), GetViewportHeight());
ALICE_DEPTH_BIAS(0.0f, 0.0f);
sRootNode1->Update(sViewUniformBuffer,deltaTime);
sRootNode1->Render();
#if ALICE_OGL_RENDERER
OGL_CALL(glClearColor(0.1f, 0.4f, 0.6f, 1.0f));
OGL_CALL(glViewport(0, 0, sCanvasWidth, sCanvasHeight));
OGL_CALL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
#endif
}
void OnKeyDown(int key) {
switch (key) {
case 'W':
break;
case 'S':
break;
case 'D':
break;
case 'A':
break;
}
}
void OnKeyUp(int key) {
}
| 33.60396
| 157
| 0.769888
|
HeckMina
|
562ae6dbcbdc1213cf9c8ed90992413ad2618ff6
| 473
|
cc
|
C++
|
March/20220328/practice/02.cc
|
RecklessTeikon/MyCPPJourney
|
0f11b810703f487cdbaf7a19e1ed6f999340a66a
|
[
"MIT"
] | 1
|
2022-03-28T15:59:22.000Z
|
2022-03-28T15:59:22.000Z
|
March/20220328/practice/02.cc
|
RecklessTeikon/MyCPPJourney
|
0f11b810703f487cdbaf7a19e1ed6f999340a66a
|
[
"MIT"
] | null | null | null |
March/20220328/practice/02.cc
|
RecklessTeikon/MyCPPJourney
|
0f11b810703f487cdbaf7a19e1ed6f999340a66a
|
[
"MIT"
] | null | null | null |
#include <iostream>
using std::cout;
using std::endl;
void f2(int &x, int &y)
{
int z = x;
x = y;
y = z;
}
void f3(int *x, int *y)
{
int z = *x;
*x = *y;
*y = z;
}
int main()
{
int x, y;
x = 10; y = 26;
cout << "x, y = " << x << ", " << y << endl;
f2(x, y);
cout << "x, y = " << x << ", " << y << endl;
f3(&x, &y);
cout << "x, y = " << x << ", " << y << endl;
x++; // ++x
y--;
f2(y, x);
cout << "x, y = " << x << ", " << y << endl;
return 0;
}
| 13.911765
| 45
| 0.365751
|
RecklessTeikon
|
562f573891ea07c72278d94baa205050279984d0
| 12,091
|
cpp
|
C++
|
source/Bezier.cpp
|
Osumi-Akari/energytycoon
|
25d18a0ee4a9f8833e678af297734602918a92e9
|
[
"Unlicense"
] | null | null | null |
source/Bezier.cpp
|
Osumi-Akari/energytycoon
|
25d18a0ee4a9f8833e678af297734602918a92e9
|
[
"Unlicense"
] | null | null | null |
source/Bezier.cpp
|
Osumi-Akari/energytycoon
|
25d18a0ee4a9f8833e678af297734602918a92e9
|
[
"Unlicense"
] | null | null | null |
#include "StdAfx.h"
#include "Bezier.h"
/*-----------------------------------------------------------------------------------------------*/
BezierCurve2D::BezierCurve2D(std::vector< Ogre::Vector2 > pPoints, double pError, int pSubdivision)
: mSubdivision(pSubdivision),
mPoints(pPoints)
{
fitCubic(0, pPoints.size() - 1 , computeLeftTangent(0),
computeRightTangent(pPoints.size() - 1), pError);
}
/*-----------------------------------------------------------------------------------------------*/
std::vector< Ogre::Vector2 > BezierCurve2D::getPoints(void)
{
return mCurveDone;
}
/*-----------------------------------------------------------------------------------------------*/
Ogre::Vector2 BezierCurve2D::approximatePoint(float pT, std::vector< Ogre::Vector2 > pCurve)
{
std::vector< std::vector< Ogre::Vector2 > > lData;
lData.push_back(pCurve);
lData.resize(4);
lData[1].resize(4);
lData[2].resize(4);
lData[3].resize(4);
for (size_t j = 1; j < 4; j++) {
for (size_t i = 0; i < (lData[0].size() - j); i++) {
// subdivision with factor t
lData[j][i] = ((1.0 - pT) * lData[j-1][i]) + pT * lData[j-1][i+1];
}
}
return lData[3][0];
}
/*-----------------------------------------------------------------------------------------------*/
void BezierCurve2D::approximateCurve(std::vector< Ogre::Vector2 > pCurve)
{
std::vector< Ogre::Vector2 > lPointsOnBez;
for (int i = 0; i <= mSubdivision; i++) {
lPointsOnBez.push_back(approximatePoint((float)i / (float)mSubdivision, pCurve));
}
for (size_t i = 0; i < lPointsOnBez.size(); i++) {
if (i > 0) {
if (lPointsOnBez[i] != lPointsOnBez[i-1])
mCurveDone.push_back(lPointsOnBez[i]);
else
int z = 7;
} else if (mCurveDone.size() == 0) {
mCurveDone.push_back(lPointsOnBez[i]);
}
}
}
/*-----------------------------------------------------------------------------------------------*/
void BezierCurve2D::fitCubic(int pFirst, int pLast, Ogre::Vector2 pHat1, Ogre::Vector2 pHat2,
double pError)
{
std::vector< double > lU; // parameter values for point
std::vector< double > lUPrime; // improved parameter values
double lMaxError; // maximum fitting error
int lSplitPoint; // point to split point set at
int lMaxIterations = 4; // max times to try iterating
double lIterationError = pError * pError;
int lNumberPoints = pLast - pFirst + 1;
// use heuristic if region only has two points in it
if (lNumberPoints == 2) {
double lDistance = (mPoints[pLast] - mPoints[pFirst]).length() / 3.0;
mControlPoints.resize(4);
mControlPoints[0] = mPoints[pFirst];
mControlPoints[3] = mPoints[pLast];
mControlPoints[1] = mControlPoints[0] + (pHat1 * lDistance);
mControlPoints[2] = mControlPoints[3] + (pHat2 * lDistance);
approximateCurve(mControlPoints);
return;
}
// parameterize points, and attempt to fit curve
lU = chordLengthParameterize(pFirst, pLast);
mControlPoints = generateBezier(pFirst, pLast, lU, pHat1, pHat2);
// find max deviation of points to fitted curve
lMaxError = computeMaxError(pFirst, pLast, lU, lSplitPoint);
if (lMaxError < pError) {
approximateCurve(mControlPoints);
return;
}
// if error not too large, try some reparameterization
// and iteration
if(lMaxError < lIterationError) {
for(int i = 0; i < lMaxIterations; i++) {
lUPrime = reparameterize(pFirst, pLast, lU);
mControlPoints = generateBezier(pFirst, pLast, lUPrime, pHat1, pHat2);
lMaxError = computeMaxError(pFirst, pLast, lUPrime, lSplitPoint);
if (lMaxError < pError) {
approximateCurve(mControlPoints);
return;
}
lU = lUPrime;
}
}
// fitting failed - split at max error point and fit recursively
Ogre::Vector2 lHatCenter = computeCenterTangent(lSplitPoint);
fitCubic(pFirst, lSplitPoint, pHat1, lHatCenter, pError);
lHatCenter = lHatCenter * -1;
fitCubic(lSplitPoint, pLast, lHatCenter, pHat2, pError);
}
/*-----------------------------------------------------------------------------------------------*/
std::vector< Ogre::Vector2 > BezierCurve2D::generateBezier(int pFirst, int pLast,
std::vector< double > pUPrime,
Ogre::Vector2 pHat1,
Ogre::Vector2 pHat2)
{
Ogre::Vector2 lA[cMaxPoints][2]; // precomputed rhs for eqn
double lC[2][2]; // matrix C
double lX[2]; // matrix X
Ogre::Vector2 lTemp;
mControlPoints.resize(4);
int lNumberPoints = pLast - pFirst + 1;
// compute the A's
for(int i = 0; i < lNumberPoints; i++) {
Ogre::Vector2 lV1, lV2;
lV1 = pHat1;
lV2 = pHat2;
lV1 = lV1 * b1(pUPrime[i]);
lV2 = lV2 * b2(pUPrime[i]);
lA[i][0] = lV1;
lA[i][1] = lV2;
}
// create the C and X matrices
lC[0][0] = 0.0;
lC[0][1] = 0.0;
lC[1][0] = 0.0;
lC[1][1] = 0.0;
lX[0] = 0.0;
lX[1] = 0.0;
for(int j = 0; j < lNumberPoints; j++) {
lC[0][0] += lA[j][0].dotProduct(lA[j][0]);
lC[0][1] += lA[j][0].dotProduct(lA[j][1]);
lC[1][0] = lC[0][1];
lC[1][1] += lA[j][1].dotProduct(lA[j][1]);
lTemp = mPoints[pFirst + j] - ((mPoints[pFirst] * b0(pUPrime[j]))
+ ((mPoints[pFirst] * b1(pUPrime[j]))
+ ((mPoints[pLast] * b2(pUPrime[j]))
+ (mPoints[pLast] * b3(pUPrime[j])))));
lX[0] += lA[j][0].dotProduct(lTemp);
lX[1] += lA[j][1].dotProduct(lTemp);
}
// compute the determinants of C and X
double lDetC0C1 = lC[0][0] * lC[1][1] - lC[1][0] * lC[0][1];
double lDetC0X = lC[0][0] * lX[1] - lC[1][0] * lX[0];
double lDetXC1 = lX[0] * lC[1][1] - lX[1] * lC[0][1];
// finally, derive alpha values
double lAlphaL = (lDetC0C1 == 0) ? 0.0 : lDetXC1 / lDetC0C1;
double lAlphaR = (lDetC0C1 == 0) ? 0.0 : lDetC0X / lDetC0C1;
double lSegmentLength = (mPoints[pLast] - mPoints[pFirst]).length();
double lEpsilon = 1.0e-6 * lSegmentLength;
if(lAlphaL < lEpsilon || lAlphaR < lEpsilon) {
// fall back on standard formula, and subdivide further if needed
double lDistance = lSegmentLength / 3.0;
mControlPoints[0] = mPoints[pFirst];
mControlPoints[3] = mPoints[pLast];
mControlPoints[1] = mControlPoints[0] + (pHat1 * lDistance);
mControlPoints[2] = mControlPoints[3] + (pHat2 * lDistance);
return mControlPoints;
}
mControlPoints[0] = mPoints[pFirst];
mControlPoints[3] = mPoints[pLast];
mControlPoints[1] = mControlPoints[0] + (pHat1 * lAlphaL);
mControlPoints[2] = mControlPoints[3] + (pHat2 * lAlphaR);
return mControlPoints;
}
/*-----------------------------------------------------------------------------------------------*/
std::vector< double > BezierCurve2D::reparameterize(int pFirst, int pLast,
std::vector< double > pU)
{
int lNumberPoints = pLast - pFirst + 1;
std::vector< double > lUPrime; // new parameter values
lUPrime.resize(lNumberPoints);
for(int i = pFirst; i <= pLast; i++)
lUPrime[i - pFirst] = newtonRaphsonRootFind(mControlPoints, mPoints[i], pU[i - pFirst]);
return lUPrime;
}
/*-----------------------------------------------------------------------------------------------*/
double BezierCurve2D::newtonRaphsonRootFind(std::vector< Ogre::Vector2 > pQ, Ogre::Vector2 pP,
double pU)
{
std::vector< Ogre::Vector2 > lQ1, lQ2; // Q' and Q''
lQ1.resize(3);
lQ2.resize(2);
Ogre::Vector2 lQU, lQ1U, lQ2U; // u evaluated at Q, Q', & Q''
// compute Q(u)
lQU = bezierII(3, pQ, pU);
// generate control vertices for Q'
for(int i = 0; i <= 2; i++)
{
lQ1[i].x = (pQ[i + 1].x - pQ[i].x) * 3.0;
lQ1[i].y = (pQ[i + 1].y - pQ[i].y) * 3.0;
}
// generate control vertices for Q''
for(int j = 0; j <= 1; j++)
{
lQ2[j].x = (lQ1[j + 1].x - lQ1[j].x) * 2.0;
lQ2[j].y = (lQ1[j + 1].y - lQ1[j].y) * 2.0;
}
// compute Q'(u) and Q''(u)
lQ1U = bezierII(2, lQ1, pU);
lQ2U = bezierII(1, lQ2, pU);
// compute f(u)/f'(u)
double lNumerator = (lQU.x - pP.x) * (lQ1U.x) + (lQU.y - pP.y) * (lQ1U.y);
double lDenominator = (lQ1U.x) * (lQ1U.x) + (lQ1U.y) * (lQ1U.y) +
(lQU.x - pP.x) * (lQ2U.x) + (lQU.y - pP.y) * (lQ2U.y);
if(lDenominator == 0.0f)
return pU;
// u = u - f(u)/f'(u)
return (pU - (lNumerator / lDenominator));
}
/*-----------------------------------------------------------------------------------------------*/
Ogre::Vector2 BezierCurve2D::bezierII(int pDegree, std::vector< Ogre::Vector2 > pV, double pT)
{
Ogre::Vector2 lQ;
std::vector< Ogre::Vector2 > lVTemp = pV;
for(int i = 1; i <= pDegree; i++) {
for(int j = 0; j <= pDegree - i; j++) {
lVTemp[j].x = (1.0 - pT) * lVTemp[j].x + pT * lVTemp[j + 1].x;
lVTemp[j].y = (1.0 - pT) * lVTemp[j].y + pT * lVTemp[j + 1].y;
}
}
lQ = lVTemp[0];
return lQ;
}
/*-----------------------------------------------------------------------------------------------*/
double BezierCurve2D::b0(double pU)
{
double lTemp = 1.0 - pU;
return (lTemp * lTemp * lTemp);
}
/*-----------------------------------------------------------------------------------------------*/
double BezierCurve2D::b1(double pU)
{
double lTemp = 1.0 - pU;
return (3 * pU * (lTemp * lTemp));
}
/*-----------------------------------------------------------------------------------------------*/
double BezierCurve2D::b2(double pU)
{
double lTemp = 1.0 - pU;
return (3 * pU * pU * lTemp);
}
/*-----------------------------------------------------------------------------------------------*/
double BezierCurve2D::b3(double pU)
{
return (pU * pU * pU);
}
/*-----------------------------------------------------------------------------------------------*/
Ogre::Vector2 BezierCurve2D::computeLeftTangent(int pEnd)
{
Ogre::Vector2 lHat1;
lHat1 = mPoints[pEnd + 1] - mPoints[pEnd];
lHat1.normalise();
return lHat1;
}
/*-----------------------------------------------------------------------------------------------*/
Ogre::Vector2 BezierCurve2D::computeRightTangent(int pEnd)
{
Ogre::Vector2 lHat2;
lHat2 = mPoints[pEnd - 1] - mPoints[pEnd];
lHat2.normalise();
return lHat2;
}
/*-----------------------------------------------------------------------------------------------*/
Ogre::Vector2 BezierCurve2D::computeCenterTangent(int pCenter)
{
Ogre::Vector2 lV1, lV2, lHatCenter;
lV1 = mPoints[pCenter - 1] - mPoints[pCenter];
lV2 = mPoints[pCenter] - mPoints[pCenter + 1];
lHatCenter.x = (lV1.x + lV2.x) / 2.0;
lHatCenter.y = (lV1.y + lV2.y) / 2.0;
lHatCenter.normalise();
return lHatCenter;
}
/*-----------------------------------------------------------------------------------------------*/
std::vector< double > BezierCurve2D::chordLengthParameterize(int pFirst, int pLast)
{
std::vector< double > lU; // parameterization
lU.resize(pLast - pFirst + 1);
lU[0] = 0.0;
for(int i = pFirst + 1; i <= pLast; i++)
lU[i - pFirst] = lU[i - pFirst - 1] + (mPoints[i]- mPoints[i-1]).length();
for(int j = pFirst + 1; j <= pLast; j++)
lU[j - pFirst] = lU[j - pFirst] / lU[pLast - pFirst];
return lU;
}
/*-----------------------------------------------------------------------------------------------*/
double BezierCurve2D::computeMaxError(int pFirst, int pLast, std::vector< double > u,
int &pSplitPoint)
{
double lMaxDistance = 0.0;
double lCurrentDistance;
Ogre::Vector2 lPointOnCurve;
Ogre::Vector2 lPointToCurve;
pSplitPoint = (pLast - pFirst + 1) / 2;
for(int i = pFirst + 1; i < pLast; i++) {
lPointOnCurve = bezierII(3, mControlPoints, u[i - pFirst]);
lPointToCurve = lPointOnCurve - mPoints[i];
lCurrentDistance = lPointToCurve.squaredLength();
if(lCurrentDistance >= lMaxDistance){
lMaxDistance = lCurrentDistance;
pSplitPoint = i;
}
}
return lMaxDistance;
}
| 29.634804
| 99
| 0.510297
|
Osumi-Akari
|
563477cefa788b8323ae2b4dbbdd66a70b70bb77
| 90
|
cpp
|
C++
|
XI/recursivitate/info.mcip.ro/197.cpp
|
rlodina99/Learn_cpp
|
0c5bd9e6c52ca21e2eb95eb91597272ddc842c08
|
[
"MIT"
] | null | null | null |
XI/recursivitate/info.mcip.ro/197.cpp
|
rlodina99/Learn_cpp
|
0c5bd9e6c52ca21e2eb95eb91597272ddc842c08
|
[
"MIT"
] | null | null | null |
XI/recursivitate/info.mcip.ro/197.cpp
|
rlodina99/Learn_cpp
|
0c5bd9e6c52ca21e2eb95eb91597272ddc842c08
|
[
"MIT"
] | null | null | null |
#197. [2010-02-28 - 23:22:52]
Sa se calculeze recursiv suma primelor n patrate perfecte.
| 30
| 59
| 0.733333
|
rlodina99
|
56381cfd635865967ba3d1c4596e929350e18ae5
| 1,862
|
hpp
|
C++
|
tau/TauEngine/include/texture/NullTexture.hpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | 1
|
2020-04-22T04:07:01.000Z
|
2020-04-22T04:07:01.000Z
|
tau/TauEngine/include/texture/NullTexture.hpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | null | null | null |
tau/TauEngine/include/texture/NullTexture.hpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | null | null | null |
#pragma once
#include "Texture.hpp"
class TAU_DLL NullTexture final : public ITexture
{
DEFAULT_CONSTRUCT_PU(NullTexture);
DEFAULT_DESTRUCT(NullTexture);
TEXTURE_IMPL(NullTexture);
public:
[[nodiscard]] ETexture::Format dataFormat() const noexcept override { return static_cast<ETexture::Format>(0); }
[[nodiscard]] ETexture::Type textureType() const noexcept override { return static_cast<ETexture::Type>(0); }
};
class TAU_DLL NullTexture2D final : public ITexture2D
{
DEFAULT_DESTRUCT(NullTexture2D);
TEXTURE_IMPL(NullTexture2D);
public:
inline NullTexture2D() noexcept
: ITexture2D(0, 0, static_cast<ETexture::Format>(0))
{ }
void set(IRenderingContext& context, u32 mipLevel, const void* data) noexcept override { }
};
class TAU_DLL NullTexture3D final : public ITexture3D
{
DEFAULT_DESTRUCT(NullTexture3D);
TEXTURE_IMPL(NullTexture3D);
public:
inline NullTexture3D() noexcept
: ITexture3D(0, 0, 0, static_cast<ETexture::Format>(0))
{ }
void set(IRenderingContext& context, u32 depthLevel, u32 mipLevel, const void* data) noexcept override { }
};
class TAU_DLL NullTextureCube final : public ITextureCube
{
DEFAULT_DESTRUCT(NullTextureCube);
TEXTURE_IMPL(NullTextureCube);
public:
inline NullTextureCube() noexcept
: ITextureCube(0, 0, static_cast<ETexture::Format>(0))
{ }
void set(IRenderingContext& context, u32 mipLevel, ETexture::CubeSide side, const void* data) noexcept override { }
};
class TAU_DLL NullTextureDepthStencil final : public ITextureDepthStencil
{
DEFAULT_DESTRUCT(NullTextureDepthStencil);
TEXTURE_IMPL(NullTextureDepthStencil);
public:
inline NullTextureDepthStencil() noexcept
: ITextureDepthStencil(0, 0)
{ }
void set(IRenderingContext& context, const void* data) noexcept override { }
};
| 30.032258
| 119
| 0.731472
|
hyfloac
|
563f4c3b021a63b25af6520c4961cb5e53482894
| 8,487
|
hpp
|
C++
|
Nacro/SDK/FN_LegacyRatingWidget_classes.hpp
|
Milxnor/Nacro
|
eebabf662bbce6d5af41820ea0342d3567a0aecc
|
[
"BSD-2-Clause"
] | 11
|
2021-08-08T23:25:10.000Z
|
2022-02-19T23:07:22.000Z
|
Nacro/SDK/FN_LegacyRatingWidget_classes.hpp
|
Milxnor/Nacro
|
eebabf662bbce6d5af41820ea0342d3567a0aecc
|
[
"BSD-2-Clause"
] | 1
|
2022-01-01T22:51:59.000Z
|
2022-01-08T16:14:15.000Z
|
Nacro/SDK/FN_LegacyRatingWidget_classes.hpp
|
Milxnor/Nacro
|
eebabf662bbce6d5af41820ea0342d3567a0aecc
|
[
"BSD-2-Clause"
] | 8
|
2021-08-09T13:51:54.000Z
|
2022-01-26T20:33:37.000Z
|
#pragma once
// Fortnite (1.8) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// WidgetBlueprintGeneratedClass LegacyRatingWidget.LegacyRatingWidget_C
// 0x15C1 (0x1E29 - 0x0868)
class ULegacyRatingWidget_C : public UFortBaseButton
{
public:
struct FPointerToUberGraphFrame UberGraphFrame; // 0x0868(0x0008) (Transient, DuplicateTransient)
class UBorder* Border_Base; // 0x0870(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData, RepSkip, RepNotify, Interp, NonTransactional, EditorOnly, NoDestructor, AutoWeak, ContainsInstancedReference, AssetRegistrySearchable, SimpleDisplay, AdvancedDisplay, Protected, BlueprintCallable, BlueprintAuthorityOnly, TextExportTransient, NonPIEDuplicateTransient, ExposeOnSpawn, PersistentInstance, UObjectWrapper, HasGetValueTypeHash, NativeAccessSpecifierPublic, NativeAccessSpecifierProtected, NativeAccessSpecifierPrivate)
class UHorizontalBox* HorizontalBox; // 0x0878(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData, RepSkip, RepNotify, Interp, NonTransactional, EditorOnly, NoDestructor, AutoWeak, ContainsInstancedReference, AssetRegistrySearchable, SimpleDisplay, AdvancedDisplay, Protected, BlueprintCallable, BlueprintAuthorityOnly, TextExportTransient, NonPIEDuplicateTransient, ExposeOnSpawn, PersistentInstance, UObjectWrapper, HasGetValueTypeHash, NativeAccessSpecifierPublic, NativeAccessSpecifierProtected, NativeAccessSpecifierPrivate)
class UFortNumericTextBlock* NumericText_RatingValue; // 0x0880(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData, RepSkip, RepNotify, Interp, NonTransactional, EditorOnly, NoDestructor, AutoWeak, ContainsInstancedReference, AssetRegistrySearchable, SimpleDisplay, AdvancedDisplay, Protected, BlueprintCallable, BlueprintAuthorityOnly, TextExportTransient, NonPIEDuplicateTransient, ExposeOnSpawn, PersistentInstance, UObjectWrapper, HasGetValueTypeHash, NativeAccessSpecifierPublic, NativeAccessSpecifierProtected, NativeAccessSpecifierPrivate)
class USizeBox* SizeBox; // 0x0888(0x0008) (BlueprintVisible, ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData, RepSkip, RepNotify, Interp, NonTransactional, EditorOnly, NoDestructor, AutoWeak, ContainsInstancedReference, AssetRegistrySearchable, SimpleDisplay, AdvancedDisplay, Protected, BlueprintCallable, BlueprintAuthorityOnly, TextExportTransient, NonPIEDuplicateTransient, ExposeOnSpawn, PersistentInstance, UObjectWrapper, HasGetValueTypeHash, NativeAccessSpecifierPublic, NativeAccessSpecifierProtected, NativeAccessSpecifierPrivate)
int RatingValue; // 0x0890(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x4]; // 0x0894(0x0004) MISSED OFFSET
struct FUniqueNetIdRepl UniqueId; // 0x0898(0x0018) (Edit, BlueprintVisible, DisableEditOnInstance)
float InterpDuration; // 0x08B0(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x4]; // 0x08B4(0x0004) MISSED OFFSET
struct FFortMultiSizeBrush MBrush_Silhouette; // 0x08B8(0x0360) (Edit, BlueprintVisible)
struct FFortMultiSizeBrush MBrush_Chamfer; // 0x0C18(0x0360) (Edit, BlueprintVisible)
struct FFortMultiSizeBrush MBrush_Shadow; // 0x0F78(0x0360) (Edit, BlueprintVisible)
struct FFortMultiSizeBrush MBrush_Icon; // 0x12D8(0x0360) (Edit, BlueprintVisible)
bool OverrideDefaultColor; // 0x1638(0x0001) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData)
unsigned char UnknownData02[0x3]; // 0x1639(0x0003) MISSED OFFSET
struct FLinearColor Color_Light; // 0x163C(0x0010) (Edit, BlueprintVisible, DisableEditOnInstance, IsPlainOldData)
struct FLinearColor Color_Medium; // 0x164C(0x0010) (Edit, BlueprintVisible, DisableEditOnInstance, IsPlainOldData)
struct FLinearColor Color_Dark; // 0x165C(0x0010) (Edit, BlueprintVisible, DisableEditOnInstance, IsPlainOldData)
struct FLinearColor Default_Color_Light; // 0x166C(0x0010) (Edit, BlueprintVisible, DisableEditOnInstance, IsPlainOldData)
struct FLinearColor Default_Color_Medium; // 0x167C(0x0010) (Edit, BlueprintVisible, DisableEditOnInstance, IsPlainOldData)
struct FLinearColor Default_Color_Dark; // 0x168C(0x0010) (Edit, BlueprintVisible, DisableEditOnInstance, IsPlainOldData)
unsigned char UnknownData03[0x4]; // 0x169C(0x0004) MISSED OFFSET
struct FFortMultiSizeBrush MBrush_Icon_Alt; // 0x16A0(0x0360) (Edit, BlueprintVisible)
bool UseAlternateIcon; // 0x1A00(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData04[0x7]; // 0x1A01(0x0007) MISSED OFFSET
struct FFortMultiSizeBrush MBrush_Shadow_Alt; // 0x1A08(0x0360) (Edit, BlueprintVisible)
struct FFortMultiSizeMargin MMargin_Alt; // 0x1D68(0x0060) (Edit, BlueprintVisible)
struct FFortMultiSizeMargin MMargin; // 0x1DC8(0x0060) (Edit, BlueprintVisible)
bool ShowTeamPowerRating; // 0x1E28(0x0001) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("WidgetBlueprintGeneratedClass LegacyRatingWidget.LegacyRatingWidget_C");
return ptr;
}
void SetShouldShowTeamPowerRating(bool ShowTeamRating);
void Override_Default_Color_Set(bool Override, const struct FLinearColor& Light_Color, const struct FLinearColor& Medium_Color, const struct FLinearColor& Dark_Color);
void Set_Texture2D_Parameter_From_Multi_Size_Brush(class UMaterialInstanceDynamic* Mid, const struct FName& Parameter, const struct FFortMultiSizeBrush& MBrush);
void Update_Base_Material();
void Update_From_Unique_ID();
void Set_Unique_ID(const struct FUniqueNetIdRepl& ID);
void Update();
void Set_Padding();
void Set_Size_Box();
void Update_Rating_Value(int Rating);
void PreConstruct(bool* IsDesignTime);
void PlayerInfoChanged(const struct FUniqueNetIdRepl& UniqueId);
void Construct();
void PlayerStateChanged(const struct FFortTeamMemberInfo& PlayerInfo);
void ExecuteUbergraph_LegacyRatingWidget(int EntryPoint);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 104.777778
| 644
| 0.60575
|
Milxnor
|
5640746e8722acdc65f6bddc246365bfe7db9a9f
| 475
|
cpp
|
C++
|
GradientDescent/GradientDescent/UnaryOperation.cpp
|
skostrov/GradientDescent
|
aed56fa9d1452252f76e8841227283372f2e761d
|
[
"MIT"
] | null | null | null |
GradientDescent/GradientDescent/UnaryOperation.cpp
|
skostrov/GradientDescent
|
aed56fa9d1452252f76e8841227283372f2e761d
|
[
"MIT"
] | null | null | null |
GradientDescent/GradientDescent/UnaryOperation.cpp
|
skostrov/GradientDescent
|
aed56fa9d1452252f76e8841227283372f2e761d
|
[
"MIT"
] | null | null | null |
#include "stdafx.h"
#include "UnaryOperation.h"
UnaryOperation::UnaryOperation(const string& name_, AbstractOperation* operand_) :
AbstractOperation(name_),
operand(operand_)
{
}
UnaryOperation::~UnaryOperation()
{
}
OperationPriority UnaryOperation::GetPriority() const
{
return OperationPriority::HIGH;
}
double UnaryOperation::Eval(const Point& point) const
{
return operand->Eval(point);
}
string UnaryOperation::ToString() const
{
return operand->ToString();
}
| 16.37931
| 82
| 0.766316
|
skostrov
|
564138bfdc400ea41af453df1757d3e57c983fe4
| 103,801
|
cc
|
C++
|
test/aarch64/test-disasm-morello-c64-aarch64.cc
|
capablevms/VIXL
|
769c8e46a09bb077e9a2148b86a2093addce8233
|
[
"BSD-3-Clause"
] | null | null | null |
test/aarch64/test-disasm-morello-c64-aarch64.cc
|
capablevms/VIXL
|
769c8e46a09bb077e9a2148b86a2093addce8233
|
[
"BSD-3-Clause"
] | null | null | null |
test/aarch64/test-disasm-morello-c64-aarch64.cc
|
capablevms/VIXL
|
769c8e46a09bb077e9a2148b86a2093addce8233
|
[
"BSD-3-Clause"
] | null | null | null |
// Copyright 2020, VIXL authors
// 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 ARM Limited 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 CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdio>
#include <cstring>
#include <string>
#include "test-runner.h"
#include "aarch64/test-utils-aarch64.h"
#include "aarch64/disasm-aarch64.h"
#include "aarch64/macro-assembler-aarch64.h"
#include "test-disasm-aarch64.h"
#include "test-utils-aarch64.h"
namespace vixl {
namespace aarch64 {
// Tests of instructions new to Morello, in the C64 ISA.
TEST(morello_c64_adr_c_i_c) {
SETUP();
COMPARE_PREFIX_C64(adr(c0, 0), "adr c0, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(adr(c0, 1), "adr c0, #+0x1 (addr 0x");
COMPARE_PREFIX_C64(adr(c0, -1), "adr c0, #-0x1 (addr 0x");
COMPARE_PREFIX_C64(adr(c0, 42), "adr c0, #+0x2a (addr 0x");
COMPARE_PREFIX_C64(adr(c0, 0xfffff), "adr c0, #+0xfffff (addr 0x");
COMPARE_PREFIX_C64(adr(c0, -0x100000), "adr c0, #-0x100000 (addr 0x");
COMPARE_PREFIX_C64(adr(czr, 42), "adr czr, #+0x2a (addr 0x");
COMPARE_PREFIX_C64(adr(c30, 42), "adr c30, #+0x2a (addr 0x");
}
TEST(morello_c64_adr_label) {
typedef DisasmTestUtilMacroAssembler MacroAssembler;
SETUP();
auto adr_c4 = [&masm](Label* l) { masm.adr(c4, l); };
auto adr_czr = [&masm](Label* l) { masm.adr(czr, l); };
// When targeting C64, the bottom bit should be set (for use in `br`, etc).
COMPARE_PREFIX_C64(WithA64LabelBefore(adr_c4), "adr c4, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(WithC64LabelBefore(adr_czr), "adr czr, #+0x1 (addr 0x");
COMPARE_PREFIX_C64(WithDataLabelBefore(adr_c4), "adr c4, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(WithA64LabelAfter(adr_c4), "adr c4, #+0x4 (addr 0x");
COMPARE_PREFIX_C64(WithC64LabelAfter(adr_c4), "adr c4, #+0x5 (addr 0x");
COMPARE_PREFIX_C64(WithDataLabelAfter(adr_c4), "adr c4, #+0x4 (addr 0x");
auto macro_adr_c4 = [&masm](Label* l) { masm.Adr(c4, l); };
COMPARE_MACRO_PREFIX_C64(WithA64LabelBefore(macro_adr_c4),
"adr c4, #+0x0 (addr 0x");
COMPARE_MACRO_PREFIX_C64(WithC64LabelAfter(macro_adr_c4),
"adr c4, #+0x5 (addr 0x");
}
TEST(morello_c64_adrdp_c_id_c) {
SETUP();
COMPARE_C64(adrdp(c0, 0), "adrdp c0, #+0x0");
COMPARE_C64(adrdp(c0, 1), "adrdp c0, #+0x1");
COMPARE_C64(adrdp(c0, 42), "adrdp c0, #+0x2a");
COMPARE_C64(adrdp(c0, 0xfffff), "adrdp c0, #+0xfffff");
COMPARE_C64(adrdp(czr, 42), "adrdp czr, #+0x2a");
COMPARE_C64(adrdp(c30, 42), "adrdp c30, #+0x2a");
// We don't implement adrdp(CRegister, Label*) because VIXL labels can only be
// PC or PCC-relative.
COMPARE_MACRO_C64(Adrdp(c0, 0), "adrdp c0, #+0x0");
COMPARE_MACRO_C64(Adrdp(c0, 42), "adrdp c0, #+0x2a");
}
TEST(morello_c64_adrp_c_ip_c) {
SETUP();
COMPARE_PREFIX_C64(adrp(c0, 0), "adrp c0, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(adrp(c0, 1), "adrp c0, #+0x1 (addr 0x");
COMPARE_PREFIX_C64(adrp(c0, -1), "adrp c0, #-0x1 (addr 0x");
COMPARE_PREFIX_C64(adrp(c0, 42), "adrp c0, #+0x2a (addr 0x");
COMPARE_PREFIX_C64(adrp(c0, 0x7ffff), "adrp c0, #+0x7ffff (addr 0x");
COMPARE_PREFIX_C64(adrp(c0, -0x80000), "adrp c0, #-0x80000 (addr 0x");
COMPARE_PREFIX_C64(adrp(czr, 42), "adrp czr, #+0x2a (addr 0x");
COMPARE_PREFIX_C64(adrp(c30, 42), "adrp c30, #+0x2a (addr 0x");
}
TEST(morello_c64_adrp_label) {
typedef DisasmTestUtilMacroAssembler MacroAssembler;
SETUP();
auto adrp_c4 = [&masm](Label* l) { masm.adrp(c4, l); };
auto adrp_czr = [&masm](Label* l) { masm.adrp(czr, l); };
// Check that the C64 interworking bit is not applied when the offset is
// page-scaled.
COMPARE_PREFIX_C64(WithA64LabelBefore(adrp_c4), "adrp c4, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(WithC64LabelBefore(adrp_czr), "adrp czr, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(WithDataLabelBefore(adrp_c4), "adrp c4, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(WithA64LabelAfter(adrp_c4), "adrp c4, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(WithC64LabelAfter(adrp_c4), "adrp c4, #+0x0 (addr 0x");
COMPARE_PREFIX_C64(WithDataLabelAfter(adrp_c4), "adrp c4, #+0x0 (addr 0x");
auto macro_adrp_c4 = [&masm](Label* l) { masm.Adrp(c4, l); };
COMPARE_MACRO_PREFIX_C64(WithA64LabelBefore(macro_adrp_c4),
"adrp c4, #+0x0 (addr 0x");
COMPARE_MACRO_PREFIX_C64(WithC64LabelAfter(macro_adrp_c4),
"adrp c4, #+0x0 (addr 0x");
}
TEST(morello_c64_aldar_c_r_c) {
SETUP();
COMPARE_C64(ldar(c0, MemOperand(x1)), "ldar c0, [x1]");
COMPARE_C64(ldar(c0, MemOperand(sp)), "ldar c0, [sp]");
COMPARE_C64(ldar(czr, MemOperand(x1)), "ldar czr, [x1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldar(c30, MemOperand(x29)), "ldar c30, [x29]");
COMPARE_MACRO_C64(Ldar(czr, MemOperand(sp)), "ldar czr, [sp]");
}
TEST(morello_c64_aldar_r_r_32) {
SETUP();
COMPARE_C64(ldar(w0, MemOperand(x1)), "ldar w0, [x1]");
COMPARE_C64(ldar(w0, MemOperand(sp)), "ldar w0, [sp]");
COMPARE_C64(ldar(wzr, MemOperand(x1)), "ldar wzr, [x1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldar(w30, MemOperand(x29)), "ldar w30, [x29]");
COMPARE_MACRO_C64(Ldar(wzr, MemOperand(sp)), "ldar wzr, [sp]");
}
TEST(morello_c64_aldarb_r_r_b) {
SETUP();
COMPARE_C64(ldarb(w0, MemOperand(x1)), "ldarb w0, [x1]");
COMPARE_C64(ldarb(w0, MemOperand(sp)), "ldarb w0, [sp]");
COMPARE_C64(ldarb(wzr, MemOperand(x1)), "ldarb wzr, [x1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldarb(w30, MemOperand(x29)), "ldarb w30, [x29]");
COMPARE_MACRO_C64(Ldarb(wzr, MemOperand(sp)), "ldarb wzr, [sp]");
}
TEST(morello_c64_aldr_c_ri_c) {
SETUP();
COMPARE_C64(ldr(c0, MemOperand(x1, 6928)), "ldr c0, [x1, #6928]");
COMPARE_C64(ldr(c0, MemOperand(x1, 0)), "ldr c0, [x1]");
COMPARE_C64(ldr(c0, MemOperand(x1, 8176)), "ldr c0, [x1, #8176]");
COMPARE_C64(ldr(c0, MemOperand(sp, 6928)), "ldr c0, [sp, #6928]");
COMPARE_C64(ldr(czr, MemOperand(x1, 6928)), "ldr czr, [x1, #6928]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(c0), MemOperand(x1, 0)), "ldr c0, [x1]");
COMPARE_C64(ldr(CPURegister(czr), MemOperand(x1, 8176)),
"ldr czr, [x1, #8176]");
}
TEST(morello_c64_aldr_c_rrb_c) {
SETUP();
COMPARE_C64(ldr(c0, MemOperand(x1, w2, UXTW, 4)),
"ldr c0, [x1, w2, uxtw #4]");
COMPARE_C64(ldr(c0, MemOperand(x1, x2, SXTX, 0)), "ldr c0, [x1, x2, sxtx]");
COMPARE_C64(ldr(c0, MemOperand(x1, x2, LSL, 4)), "ldr c0, [x1, x2, lsl #4]");
COMPARE_C64(ldr(c0, MemOperand(x1, xzr, LSL, 4)),
"ldr c0, [x1, xzr, lsl #4]");
COMPARE_C64(ldr(c0, MemOperand(sp, x2, LSL, 4)), "ldr c0, [sp, x2, lsl #4]");
COMPARE_C64(ldr(czr, MemOperand(x1, x2, LSL, 4)),
"ldr czr, [x1, x2, lsl #4]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(c0), MemOperand(x1, w2, UXTW, 4)),
"ldr c0, [x1, w2, uxtw #4]");
COMPARE_C64(ldr(CPURegister(czr), MemOperand(x1, x2, LSL, 4)),
"ldr czr, [x1, x2, lsl #4]");
}
TEST(morello_c64_aldr_c_macro) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldr(c0, MemOperand(x1, 0)), "ldr c0, [x1]");
COMPARE_MACRO_C64(Ldr(czr, MemOperand(sp, 0)), "ldr czr, [sp]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(x1, 8176)), "ldr c0, [x1, #8176]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(x1, w2, UXTW, 4)),
"ldr c0, [x1, w2, uxtw #4]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(x1, x2, SXTX, 0)),
"ldr c0, [x1, x2, sxtx]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldr(c0, MemOperand(x1, 0x4242)),
"mov x16, #0x4242\n"
"add x16, x1, x16\n"
"ldr c0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Ldr(c0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"ldr c0, [x1]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(x1, -16, PostIndex)),
"ldr c0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldr(CPURegister(c0), MemOperand(x1)), "ldr c0, [x1]");
}
TEST(morello_c64_aldr_r_ri_32) {
SETUP();
COMPARE_C64(ldr(w0, MemOperand(x1, 420)), "ldr w0, [x1, #420]");
COMPARE_C64(ldr(w0, MemOperand(x1, 0)), "ldr w0, [x1]");
COMPARE_C64(ldr(w0, MemOperand(x1, 2044)), "ldr w0, [x1, #2044]");
COMPARE_C64(ldr(w0, MemOperand(sp, 420)), "ldr w0, [sp, #420]");
COMPARE_C64(ldr(wzr, MemOperand(x1, 420)), "ldr wzr, [x1, #420]");
// `ldur` can assemble to `ldr`, according to its LoadStoreScalingOption.
COMPARE_C64(ldur(w0, MemOperand(c1, 256)), "ldr w0, [c1, #256]");
COMPARE_C64(ldur(w0, MemOperand(c1, 2044)), "ldr w0, [c1, #2044]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(w0), MemOperand(x1, 0)), "ldr w0, [x1]");
COMPARE_C64(ldr(CPURegister(wzr), MemOperand(x1, 2044)),
"ldr wzr, [x1, #2044]");
}
TEST(morello_c64_aldr_r_ri_64) {
SETUP();
COMPARE_C64(ldr(x0, MemOperand(x1, 840)), "ldr x0, [x1, #840]");
COMPARE_C64(ldr(x0, MemOperand(x1, 0)), "ldr x0, [x1]");
COMPARE_C64(ldr(x0, MemOperand(x1, 4088)), "ldr x0, [x1, #4088]");
COMPARE_C64(ldr(x0, MemOperand(sp, 840)), "ldr x0, [sp, #840]");
COMPARE_C64(ldr(xzr, MemOperand(x1, 840)), "ldr xzr, [x1, #840]");
// `ldur` can assemble to `ldr`, according to its LoadStoreScalingOption.
COMPARE_C64(ldur(x0, MemOperand(c1, 256)), "ldr x0, [c1, #256]");
COMPARE_C64(ldur(x0, MemOperand(c1, 4088)), "ldr x0, [c1, #4088]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(x0), MemOperand(x1, 0)), "ldr x0, [x1]");
COMPARE_C64(ldr(CPURegister(xzr), MemOperand(x1, 4088)),
"ldr xzr, [x1, #4088]");
}
TEST(morello_c64_aldr_r_rrb_32) {
SETUP();
COMPARE_C64(ldr(w0, MemOperand(x1, w2, UXTW, 2)),
"ldr w0, [x1, w2, uxtw #2]");
COMPARE_C64(ldr(w0, MemOperand(x1, x2, SXTX, 0)), "ldr w0, [x1, x2, sxtx]");
COMPARE_C64(ldr(w0, MemOperand(x1, x2, LSL, 2)), "ldr w0, [x1, x2, lsl #2]");
COMPARE_C64(ldr(w0, MemOperand(x1, xzr, LSL, 2)),
"ldr w0, [x1, xzr, lsl #2]");
COMPARE_C64(ldr(w0, MemOperand(sp, x2, LSL, 2)), "ldr w0, [sp, x2, lsl #2]");
COMPARE_C64(ldr(wzr, MemOperand(x1, x2, LSL, 2)),
"ldr wzr, [x1, x2, lsl #2]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(w0), MemOperand(x1, w2, UXTW, 2)),
"ldr w0, [x1, w2, uxtw #2]");
COMPARE_C64(ldr(CPURegister(wzr), MemOperand(x1, x2, LSL, 2)),
"ldr wzr, [x1, x2, lsl #2]");
}
TEST(morello_c64_aldr_r_rrb_64) {
SETUP();
COMPARE_C64(ldr(x0, MemOperand(x1, w2, UXTW, 3)),
"ldr x0, [x1, w2, uxtw #3]");
COMPARE_C64(ldr(x0, MemOperand(x1, x2, SXTX, 0)), "ldr x0, [x1, x2, sxtx]");
COMPARE_C64(ldr(x0, MemOperand(x1, x2, LSL, 3)), "ldr x0, [x1, x2, lsl #3]");
COMPARE_C64(ldr(x0, MemOperand(x1, xzr, LSL, 3)),
"ldr x0, [x1, xzr, lsl #3]");
COMPARE_C64(ldr(x0, MemOperand(sp, x2, LSL, 3)), "ldr x0, [sp, x2, lsl #3]");
COMPARE_C64(ldr(xzr, MemOperand(x1, x2, LSL, 3)),
"ldr xzr, [x1, x2, lsl #3]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(x0), MemOperand(x1, w2, UXTW, 3)),
"ldr x0, [x1, w2, uxtw #3]");
COMPARE_C64(ldr(CPURegister(xzr), MemOperand(x1, x2, LSL, 3)),
"ldr xzr, [x1, x2, lsl #3]");
}
TEST(morello_c64_aldr_v_rrb_d) {
SETUP();
COMPARE_C64(ldr(d0, MemOperand(x1, w2, UXTW, 3)),
"ldr d0, [x1, w2, uxtw #3]");
COMPARE_C64(ldr(d0, MemOperand(x1, x2, SXTX, 0)), "ldr d0, [x1, x2, sxtx]");
COMPARE_C64(ldr(d0, MemOperand(x1, x2, LSL, 3)), "ldr d0, [x1, x2, lsl #3]");
COMPARE_C64(ldr(d0, MemOperand(x1, xzr, LSL, 3)),
"ldr d0, [x1, xzr, lsl #3]");
COMPARE_C64(ldr(d0, MemOperand(sp, x2, LSL, 3)), "ldr d0, [sp, x2, lsl #3]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(d0), MemOperand(x1, w2, UXTW, 3)),
"ldr d0, [x1, w2, uxtw #3]");
}
TEST(morello_c64_aldr_v_rrb_s) {
SETUP();
COMPARE_C64(ldr(s0, MemOperand(x1, w2, UXTW, 2)),
"ldr s0, [x1, w2, uxtw #2]");
COMPARE_C64(ldr(s0, MemOperand(x1, x2, SXTX, 0)), "ldr s0, [x1, x2, sxtx]");
COMPARE_C64(ldr(s0, MemOperand(x1, x2, LSL, 2)), "ldr s0, [x1, x2, lsl #2]");
COMPARE_C64(ldr(s0, MemOperand(x1, xzr, LSL, 2)),
"ldr s0, [x1, xzr, lsl #2]");
COMPARE_C64(ldr(s0, MemOperand(sp, x2, LSL, 2)), "ldr s0, [sp, x2, lsl #2]");
COMPARE_C64(ldr(wzr, MemOperand(x1, x2, LSL, 2)),
"ldr wzr, [x1, x2, lsl #2]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(w0), MemOperand(x1, w2, UXTW, 2)),
"ldr w0, [x1, w2, uxtw #2]");
COMPARE_C64(ldr(CPURegister(wzr), MemOperand(x1, x2, LSL, 2)),
"ldr wzr, [x1, x2, lsl #2]");
}
TEST(morello_c64_aldr_v_macro_q) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldr(q0, MemOperand(x1, 0)), "ldur q0, [x1]");
COMPARE_MACRO_C64(Ldr(q0, MemOperand(sp, 0)), "ldur q0, [sp]");
COMPARE_MACRO_C64(Ldr(q31, MemOperand(x1, 0)), "ldur q31, [x1]");
COMPARE_MACRO_C64(Ldr(q0, MemOperand(x1, 255)), "ldur q0, [x1, #255]");
COMPARE_MACRO_C64(Ldr(q0, MemOperand(x1, -256)), "ldur q0, [x1, #-256]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldr(q0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldur q0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Ldr(q0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"ldur q0, [x1]");
COMPARE_MACRO_C64(Ldr(q0, MemOperand(x1, -16, PostIndex)),
"ldur q0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// There are no register-offset modes for Q.
COMPARE_MACRO_C64(Ldr(q0, MemOperand(x1, w2, UXTW, 4)),
"add x16, x1, w2, uxtw #4\n"
"ldur q0, [x16]");
COMPARE_MACRO_C64(Ldr(q0, MemOperand(x1, x2, SXTX, 0)),
"add x16, x1, x2, sxtx\n"
"ldur q0, [x16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldr(CPURegister(q0), MemOperand(x1)), "ldur q0, [x1]");
}
TEST(morello_c64_aldr_v_macro_d) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldr(d0, MemOperand(x1, 0)), "ldur d0, [x1]");
COMPARE_MACRO_C64(Ldr(d0, MemOperand(sp, 0)), "ldur d0, [sp]");
COMPARE_MACRO_C64(Ldr(d31, MemOperand(x1, 0)), "ldur d31, [x1]");
COMPARE_MACRO_C64(Ldr(d0, MemOperand(x1, 255)), "ldur d0, [x1, #255]");
COMPARE_MACRO_C64(Ldr(d0, MemOperand(x1, -256)), "ldur d0, [x1, #-256]");
COMPARE_MACRO_C64(Ldr(d0, MemOperand(x1, w2, UXTW, 3)),
"ldr d0, [x1, w2, uxtw #3]");
COMPARE_MACRO_C64(Ldr(d0, MemOperand(x1, x2, SXTX, 0)),
"ldr d0, [x1, x2, sxtx]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldr(d0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldur d0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Ldr(d0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"ldur d0, [x1]");
COMPARE_MACRO_C64(Ldr(d0, MemOperand(x1, -16, PostIndex)),
"ldur d0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldr(CPURegister(d0), MemOperand(x1)), "ldur d0, [x1]");
}
TEST(morello_c64_aldr_v_macro_s) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldr(s0, MemOperand(x1, 0)), "ldur s0, [x1]");
COMPARE_MACRO_C64(Ldr(s0, MemOperand(sp, 0)), "ldur s0, [sp]");
COMPARE_MACRO_C64(Ldr(s31, MemOperand(x1, 0)), "ldur s31, [x1]");
COMPARE_MACRO_C64(Ldr(s0, MemOperand(x1, 255)), "ldur s0, [x1, #255]");
COMPARE_MACRO_C64(Ldr(s0, MemOperand(x1, -256)), "ldur s0, [x1, #-256]");
COMPARE_MACRO_C64(Ldr(s0, MemOperand(x1, w2, UXTW, 2)),
"ldr s0, [x1, w2, uxtw #2]");
COMPARE_MACRO_C64(Ldr(s0, MemOperand(x1, x2, SXTX, 0)),
"ldr s0, [x1, x2, sxtx]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldr(s0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldur s0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Ldr(s0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"ldur s0, [x1]");
COMPARE_MACRO_C64(Ldr(s0, MemOperand(x1, -16, PostIndex)),
"ldur s0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldr(CPURegister(s0), MemOperand(x1)), "ldur s0, [x1]");
}
TEST(morello_c64_aldr_v_macro_h) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldr(h0, MemOperand(x1, 0)), "ldur h0, [x1]");
COMPARE_MACRO_C64(Ldr(h0, MemOperand(sp, 0)), "ldur h0, [sp]");
COMPARE_MACRO_C64(Ldr(h31, MemOperand(x1, 0)), "ldur h31, [x1]");
COMPARE_MACRO_C64(Ldr(h0, MemOperand(x1, 255)), "ldur h0, [x1, #255]");
COMPARE_MACRO_C64(Ldr(h0, MemOperand(x1, -256)), "ldur h0, [x1, #-256]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldr(h0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldur h0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Ldr(h0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"ldur h0, [x1]");
COMPARE_MACRO_C64(Ldr(h0, MemOperand(x1, -16, PostIndex)),
"ldur h0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// There are no register-offset modes for h.
COMPARE_MACRO_C64(Ldr(h0, MemOperand(x1, w2, UXTW, 1)),
"add x16, x1, w2, uxtw #1\n"
"ldur h0, [x16]");
COMPARE_MACRO_C64(Ldr(h0, MemOperand(x1, x2, SXTX, 0)),
"add x16, x1, x2, sxtx\n"
"ldur h0, [x16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldr(CPURegister(h0), MemOperand(x1)), "ldur h0, [x1]");
}
TEST(morello_c64_aldr_v_macro_b) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldr(b0, MemOperand(x1, 0)), "ldur b0, [x1]");
COMPARE_MACRO_C64(Ldr(b0, MemOperand(sp, 0)), "ldur b0, [sp]");
COMPARE_MACRO_C64(Ldr(b31, MemOperand(x1, 0)), "ldur b31, [x1]");
COMPARE_MACRO_C64(Ldr(b0, MemOperand(x1, 255)), "ldur b0, [x1, #255]");
COMPARE_MACRO_C64(Ldr(b0, MemOperand(x1, -256)), "ldur b0, [x1, #-256]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldr(b0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldur b0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Ldr(b0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"ldur b0, [x1]");
COMPARE_MACRO_C64(Ldr(b0, MemOperand(x1, -16, PostIndex)),
"ldur b0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// There are no register-offset modes for b.
COMPARE_MACRO_C64(Ldr(b0, MemOperand(x1, w2, UXTW)),
"add x16, x1, w2, uxtw\n"
"ldur b0, [x16]");
COMPARE_MACRO_C64(Ldr(b0, MemOperand(x1, x2, SXTX)),
"add x16, x1, x2, sxtx\n"
"ldur b0, [x16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldr(CPURegister(b0), MemOperand(x1)), "ldur b0, [x1]");
}
TEST(morello_c64_aldrb_r_ri_b) {
SETUP();
COMPARE_C64(ldrb(w0, MemOperand(x1, 42)), "ldrb w0, [x1, #42]");
COMPARE_C64(ldrb(w0, MemOperand(x1, 0)), "ldrb w0, [x1]");
COMPARE_C64(ldrb(w0, MemOperand(x1, 511)), "ldrb w0, [x1, #511]");
COMPARE_C64(ldrb(w0, MemOperand(sp, 42)), "ldrb w0, [sp, #42]");
COMPARE_C64(ldrb(wzr, MemOperand(x1, 42)), "ldrb wzr, [x1, #42]");
// `ldurb` can assemble to `ldrb`, according to its LoadStoreScalingOption.
COMPARE_C64(ldurb(w0, MemOperand(c1, 256)), "ldrb w0, [c1, #256]");
COMPARE_C64(ldurb(w0, MemOperand(c1, 511)), "ldrb w0, [c1, #511]");
}
TEST(morello_c64_aldrb_r_rrb_b) {
SETUP();
COMPARE_C64(ldrb(w0, MemOperand(x1, w2, UXTW)), "ldrb w0, [x1, w2, uxtw]");
COMPARE_C64(ldrb(w0, MemOperand(x1, x2, SXTX, 0)), "ldrb w0, [x1, x2, sxtx]");
COMPARE_C64(ldrb(w0, MemOperand(x1, x2, LSL, 0)), "ldrb w0, [x1, x2]");
COMPARE_C64(ldrb(w0, MemOperand(x1, xzr)), "ldrb w0, [x1, xzr]");
COMPARE_C64(ldrb(w0, MemOperand(sp, x2)), "ldrb w0, [sp, x2]");
COMPARE_C64(ldrb(wzr, MemOperand(x1, x2)), "ldrb wzr, [x1, x2]");
}
TEST(morello_c64_aldrh_r_rrb_32) {
SETUP();
COMPARE_C64(ldrh(w0, MemOperand(x1, x2)), "ldrh w0, [x1, x2]");
COMPARE_C64(ldrh(w0, MemOperand(x1, w2, SXTW, 0)), "ldrh w0, [x1, w2, sxtw]");
COMPARE_C64(ldrh(w0, MemOperand(x1, x2, LSL, 1)),
"ldrh w0, [x1, x2, lsl #1]");
COMPARE_C64(ldrh(w0, MemOperand(x1, xzr, LSL, 1)),
"ldrh w0, [x1, xzr, lsl #1]");
COMPARE_C64(ldrh(w0, MemOperand(sp, x2, LSL, 1)),
"ldrh w0, [sp, x2, lsl #1]");
COMPARE_C64(ldrh(wzr, MemOperand(x1, x2, LSL, 1)),
"ldrh wzr, [x1, x2, lsl #1]");
}
TEST(morello_c64_aldrsb_r_rrb_32) {
SETUP();
COMPARE_C64(ldrsb(w0, MemOperand(x1, w2, UXTW)), "ldrsb w0, [x1, w2, uxtw]");
COMPARE_C64(ldrsb(w0, MemOperand(x1, x2, SXTX, 0)),
"ldrsb w0, [x1, x2, sxtx]");
COMPARE_C64(ldrsb(w0, MemOperand(x1, x2, LSL, 0)), "ldrsb w0, [x1, x2]");
COMPARE_C64(ldrsb(w0, MemOperand(x1, xzr)), "ldrsb w0, [x1, xzr]");
COMPARE_C64(ldrsb(w0, MemOperand(sp, x2)), "ldrsb w0, [sp, x2]");
COMPARE_C64(ldrsb(wzr, MemOperand(x1, x2)), "ldrsb wzr, [x1, x2]");
}
TEST(morello_c64_aldrsb_r_rrb_64) {
SETUP();
COMPARE_C64(ldrsb(x0, MemOperand(x1, w2, UXTW)), "ldrsb x0, [x1, w2, uxtw]");
COMPARE_C64(ldrsb(x0, MemOperand(x1, x2, SXTX, 0)),
"ldrsb x0, [x1, x2, sxtx]");
COMPARE_C64(ldrsb(x0, MemOperand(x1, x2, LSL, 0)), "ldrsb x0, [x1, x2]");
COMPARE_C64(ldrsb(x0, MemOperand(x1, xzr)), "ldrsb x0, [x1, xzr]");
COMPARE_C64(ldrsb(x0, MemOperand(sp, x2)), "ldrsb x0, [sp, x2]");
COMPARE_C64(ldrsb(wzr, MemOperand(x1, x2)), "ldrsb wzr, [x1, x2]");
}
TEST(morello_c64_aldrsh_r_rrb_32) {
SETUP();
COMPARE_C64(ldrsh(w0, MemOperand(x1, x2)), "ldrsh w0, [x1, x2]");
COMPARE_C64(ldrsh(w0, MemOperand(x1, x2, SXTX, 0)),
"ldrsh w0, [x1, x2, sxtx]");
COMPARE_C64(ldrsh(w0, MemOperand(x1, x2, LSL, 1)),
"ldrsh w0, [x1, x2, lsl #1]");
COMPARE_C64(ldrsh(w0, MemOperand(x1, xzr, LSL, 1)),
"ldrsh w0, [x1, xzr, lsl #1]");
COMPARE_C64(ldrsh(w0, MemOperand(sp, w2, UXTW)), "ldrsh w0, [sp, w2, uxtw]");
COMPARE_C64(ldrsh(wzr, MemOperand(x1, x2, LSL, 1)),
"ldrsh wzr, [x1, x2, lsl #1]");
}
TEST(morello_c64_aldrsh_r_rrb_64) {
SETUP();
COMPARE_C64(ldrsh(x0, MemOperand(x1, w2, UXTW)), "ldrsh x0, [x1, w2, uxtw]");
COMPARE_C64(ldrsh(x0, MemOperand(x1, x2, SXTX)), "ldrsh x0, [x1, x2, sxtx]");
COMPARE_C64(ldrsh(x0, MemOperand(x1, x2, LSL, 1)),
"ldrsh x0, [x1, x2, lsl #1]");
COMPARE_C64(ldrsh(x0, MemOperand(x1, xzr, SXTX, 1)),
"ldrsh x0, [x1, xzr, sxtx #1]");
COMPARE_C64(ldrsh(x0, MemOperand(sp, x2, LSL, 1)),
"ldrsh x0, [sp, x2, lsl #1]");
COMPARE_C64(ldrsh(xzr, MemOperand(x1, x2, LSL, 1)),
"ldrsh xzr, [x1, x2, lsl #1]");
}
TEST(morello_c64_aldrb_macro) {
SETUP();
// Encodable cases.
// "unsigned offset"
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, 42)), "ldrb w0, [x1, #42]");
COMPARE_MACRO_C64(Ldrb(wzr, MemOperand(sp, 42)), "ldrb wzr, [sp, #42]");
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, 511)), "ldrb w0, [x1, #511]");
// "unscaled"
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, -256)), "ldurb w0, [x1, #-256]");
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, -1)), "ldurb w0, [x1, #-1]");
COMPARE_MACRO_C64(Ldrb(wzr, MemOperand(sp, -1)), "ldurb wzr, [sp, #-1]");
// "register"
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, x2)), "ldrb w0, [x1, x2]");
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, w2, SXTW)),
"ldrb w0, [x1, w2, sxtw]");
// The MacroAssembler permits an X-sized result for zero-extending loads.
COMPARE_MACRO_C64(Ldrb(x0, MemOperand(x1, 42)), "ldrb w0, [x1, #42]");
COMPARE_MACRO_C64(Ldrb(x0, MemOperand(x1, -1)), "ldurb w0, [x1, #-1]");
COMPARE_MACRO_C64(Ldrb(x0, MemOperand(x1, w2, UXTW)),
"ldrb w0, [x1, w2, uxtw]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, 512)),
"add x16, x1, #0x200 (512)\n"
"ldrb w0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"ldrb w0, [x1]");
COMPARE_MACRO_C64(Ldrb(w0, MemOperand(x1, 16, PostIndex)),
"ldrb w0, [x1]\n"
"add x1, x1, #0x10 (16)");
}
TEST(morello_c64_aldrsb_macro_32) {
SETUP();
// Encodable cases.
// "unscaled"
COMPARE_MACRO_C64(Ldrsb(w0, MemOperand(x1, -256)), "ldursb w0, [x1, #-256]");
COMPARE_MACRO_C64(Ldrsb(w0, MemOperand(x1, -1)), "ldursb w0, [x1, #-1]");
COMPARE_MACRO_C64(Ldrsb(wzr, MemOperand(sp, -1)), "ldursb wzr, [sp, #-1]");
// "register"
COMPARE_MACRO_C64(Ldrsb(w0, MemOperand(x1, x2)), "ldrsb w0, [x1, x2]");
COMPARE_MACRO_C64(Ldrsb(w0, MemOperand(x1, w2, SXTW)),
"ldrsb w0, [x1, w2, sxtw]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldrsb(w0, MemOperand(x1, 512)),
"add x16, x1, #0x200 (512)\n"
"ldursb w0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Ldrsb(w0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"ldursb w0, [x1]");
COMPARE_MACRO_C64(Ldrsb(w0, MemOperand(x1, 16, PostIndex)),
"ldursb w0, [x1]\n"
"add x1, x1, #0x10 (16)");
// There is no "unsigned offset" mode.
COMPARE_MACRO_C64(Ldrsb(w0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldursb w0, [x16]");
}
TEST(morello_c64_aldrsb_macro_64) {
SETUP();
// Encodable cases.
// "unscaled"
COMPARE_MACRO_C64(Ldrsb(x0, MemOperand(x1, -256)), "ldursb x0, [x1, #-256]");
COMPARE_MACRO_C64(Ldrsb(x0, MemOperand(x1, -1)), "ldursb x0, [x1, #-1]");
COMPARE_MACRO_C64(Ldrsb(xzr, MemOperand(sp, -1)), "ldursb xzr, [sp, #-1]");
// "register"
COMPARE_MACRO_C64(Ldrsb(x0, MemOperand(x1, x2)), "ldrsb x0, [x1, x2]");
COMPARE_MACRO_C64(Ldrsb(x0, MemOperand(x1, w2, SXTW)),
"ldrsb x0, [x1, w2, sxtw]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldrsb(x0, MemOperand(x1, 512)),
"add x16, x1, #0x200 (512)\n"
"ldursb x0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Ldrsb(x0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"ldursb x0, [x1]");
COMPARE_MACRO_C64(Ldrsb(x0, MemOperand(x1, 16, PostIndex)),
"ldursb x0, [x1]\n"
"add x1, x1, #0x10 (16)");
// There is no "unsigned offset" mode.
COMPARE_MACRO_C64(Ldrsb(x0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldursb x0, [x16]");
}
TEST(morello_c64_aldrh_macro) {
SETUP();
// Encodable cases.
// "unscaled"
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, -256)), "ldurh w0, [x1, #-256]");
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, 255)), "ldurh w0, [x1, #255]");
COMPARE_MACRO_C64(Ldrh(wzr, MemOperand(sp, 42)), "ldurh wzr, [sp, #42]");
// "register"
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, x2)), "ldrh w0, [x1, x2]");
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, w2, SXTW)),
"ldrh w0, [x1, w2, sxtw]");
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, x2, LSL, 1)),
"ldrh w0, [x1, x2, lsl #1]");
// The MacroAssembler permits an X-sized result for zero-extending loads.
COMPARE_MACRO_C64(Ldrh(x0, MemOperand(x1, 42)), "ldurh w0, [x1, #42]");
COMPARE_MACRO_C64(Ldrh(x0, MemOperand(x1, x2, SXTX, 1)),
"ldrh w0, [x1, x2, sxtx #1]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, 0x4242)),
"mov x16, #0x4242\n"
"add x16, x1, x16\n"
"ldurh w0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"ldurh w0, [x1]");
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, 16, PostIndex)),
"ldurh w0, [x1]\n"
"add x1, x1, #0x10 (16)");
// There is no "unsigned offset" mode.
COMPARE_MACRO_C64(Ldrh(w0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldurh w0, [x16]");
}
TEST(morello_c64_aldrsh_macro_32) {
SETUP();
// Encodable cases.
// "unscaled"
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, -256)), "ldursh w0, [x1, #-256]");
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, 255)), "ldursh w0, [x1, #255]");
COMPARE_MACRO_C64(Ldrsh(wzr, MemOperand(sp, 42)), "ldursh wzr, [sp, #42]");
// "register"
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, x2)), "ldrsh w0, [x1, x2]");
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, w2, SXTW)),
"ldrsh w0, [x1, w2, sxtw]");
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, x2, LSL, 1)),
"ldrsh w0, [x1, x2, lsl #1]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, 0x4242)),
"mov x16, #0x4242\n"
"add x16, x1, x16\n"
"ldursh w0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"ldursh w0, [x1]");
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, 16, PostIndex)),
"ldursh w0, [x1]\n"
"add x1, x1, #0x10 (16)");
// There is no "unsigned offset" mode.
COMPARE_MACRO_C64(Ldrsh(w0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldursh w0, [x16]");
}
TEST(morello_c64_aldrsh_macro_64) {
SETUP();
// Encodable cases.
// "unscaled"
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, -256)), "ldursh x0, [x1, #-256]");
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, 255)), "ldursh x0, [x1, #255]");
COMPARE_MACRO_C64(Ldrsh(xzr, MemOperand(sp, 42)), "ldursh xzr, [sp, #42]");
// "register"
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, x2)), "ldrsh x0, [x1, x2]");
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, w2, SXTW)),
"ldrsh x0, [x1, w2, sxtw]");
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, x2, LSL, 1)),
"ldrsh x0, [x1, x2, lsl #1]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, 0x4242)),
"mov x16, #0x4242\n"
"add x16, x1, x16\n"
"ldursh x0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"ldursh x0, [x1]");
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, 16, PostIndex)),
"ldursh x0, [x1]\n"
"add x1, x1, #0x10 (16)");
// There is no "unsigned offset" mode.
COMPARE_MACRO_C64(Ldrsh(x0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldursh x0, [x16]");
}
TEST(morello_c64_aldrsw_macro_64) {
SETUP();
// Encodable cases.
// "unscaled"
COMPARE_MACRO_C64(Ldrsw(x0, MemOperand(x1, -256)), "ldursw x0, [x1, #-256]");
COMPARE_MACRO_C64(Ldrsw(x0, MemOperand(x1, 255)), "ldursw x0, [x1, #255]");
COMPARE_MACRO_C64(Ldrsw(xzr, MemOperand(sp, 44)), "ldursw xzr, [sp, #44]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldrsw(x0, MemOperand(x1, 0x4242)),
"mov x16, #0x4242\n"
"add x16, x1, x16\n"
"ldursw x0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Ldrsw(x0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"ldursw x0, [x1]");
COMPARE_MACRO_C64(Ldrsw(x0, MemOperand(x1, 16, PostIndex)),
"ldursw x0, [x1]\n"
"add x1, x1, #0x10 (16)");
// There is no "unsigned offset" mode.
COMPARE_MACRO_C64(Ldrsw(x0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"ldursw x0, [x16]");
// There is no "register" mode.
COMPARE_MACRO_C64(Ldrsw(x0, MemOperand(x1, x2)),
"add x16, x1, x2\n"
"ldursw x0, [x16]");
}
TEST(morello_c64_aldur_c_ri_c) {
SETUP();
COMPARE_C64(ldur(c0, MemOperand(x1, 255)), "ldur c0, [x1, #255]");
COMPARE_C64(ldur(c0, MemOperand(x1, -256)), "ldur c0, [x1, #-256]");
COMPARE_C64(ldur(c0, MemOperand(x1, 0)), "ldur c0, [x1]");
COMPARE_C64(ldur(c0, MemOperand(sp, 42)), "ldur c0, [sp, #42]");
COMPARE_C64(ldur(czr, MemOperand(x1, 42)), "ldur czr, [x1, #42]");
// `ldr` can assemble to `ldur`, according to its LoadStoreScalingOption.
COMPARE_C64(ldr(c0, MemOperand(x1, -1)), "ldur c0, [x1, #-1]");
COMPARE_C64(ldr(c0, MemOperand(x1, 42)), "ldur c0, [x1, #42]");
// A generic CPURegister works the same.
COMPARE_C64(ldur(CPURegister(c0), MemOperand(x1, 0)), "ldur c0, [x1]");
COMPARE_C64(ldur(CPURegister(czr), MemOperand(x1, 42)),
"ldur czr, [x1, #42]");
}
TEST(morello_c64_aldur_r_ri_32) {
SETUP();
COMPARE_C64(ldur(w0, MemOperand(x1, 255)), "ldur w0, [x1, #255]");
COMPARE_C64(ldur(w0, MemOperand(x1, -256)), "ldur w0, [x1, #-256]");
COMPARE_C64(ldur(w0, MemOperand(x1, 0)), "ldur w0, [x1]");
COMPARE_C64(ldur(w0, MemOperand(sp, 42)), "ldur w0, [sp, #42]");
COMPARE_C64(ldur(wzr, MemOperand(x1, 42)), "ldur wzr, [x1, #42]");
// `ldr` can assemble to `ldur`, according to its LoadStoreScalingOption.
COMPARE_C64(ldr(w0, MemOperand(x1, -1)), "ldur w0, [x1, #-1]");
COMPARE_C64(ldr(w0, MemOperand(x1, 42)), "ldur w0, [x1, #42]");
// A generic CPURegister works the same.
COMPARE_C64(ldur(CPURegister(w0), MemOperand(x1, 0)), "ldur w0, [x1]");
COMPARE_C64(ldur(CPURegister(wzr), MemOperand(x1, 42)),
"ldur wzr, [x1, #42]");
}
TEST(morello_c64_aldur_r_ri_64) {
SETUP();
COMPARE_C64(ldur(x0, MemOperand(x1, 255)), "ldur x0, [x1, #255]");
COMPARE_C64(ldur(x0, MemOperand(x1, -256)), "ldur x0, [x1, #-256]");
COMPARE_C64(ldur(x0, MemOperand(x1, 0)), "ldur x0, [x1]");
COMPARE_C64(ldur(x0, MemOperand(sp, 42)), "ldur x0, [sp, #42]");
COMPARE_C64(ldur(xzr, MemOperand(x1, 42)), "ldur xzr, [x1, #42]");
// `ldr` can assemble to `ldur`, according to its LoadStoreScalingOption.
COMPARE_C64(ldr(x0, MemOperand(x1, -1)), "ldur x0, [x1, #-1]");
COMPARE_C64(ldr(x0, MemOperand(x1, 42)), "ldur x0, [x1, #42]");
// A generic CPURegister works the same.
COMPARE_C64(ldur(CPURegister(x0), MemOperand(x1, 0)), "ldur x0, [x1]");
COMPARE_C64(ldur(CPURegister(xzr), MemOperand(x1, 42)),
"ldur xzr, [x1, #42]");
}
TEST(morello_c64_aldur_v_ri_b) {
SETUP();
COMPARE_C64(ldur(b0, MemOperand(x1, 255)), "ldur b0, [x1, #255]");
COMPARE_C64(ldur(b0, MemOperand(x1, -256)), "ldur b0, [x1, #-256]");
COMPARE_C64(ldur(b0, MemOperand(x1, 0)), "ldur b0, [x1]");
COMPARE_C64(ldur(b0, MemOperand(sp, 42)), "ldur b0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(ldur(CPURegister(b0), MemOperand(x1, 0)), "ldur b0, [x1]");
}
TEST(morello_c64_aldur_v_ri_d) {
SETUP();
COMPARE_C64(ldur(d0, MemOperand(x1, 255)), "ldur d0, [x1, #255]");
COMPARE_C64(ldur(d0, MemOperand(x1, -256)), "ldur d0, [x1, #-256]");
COMPARE_C64(ldur(d0, MemOperand(x1, 0)), "ldur d0, [x1]");
COMPARE_C64(ldur(d0, MemOperand(sp, 42)), "ldur d0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(ldur(CPURegister(d0), MemOperand(x1, 0)), "ldur d0, [x1]");
}
TEST(morello_c64_aldur_v_ri_h) {
SETUP();
COMPARE_C64(ldur(h0, MemOperand(x1, 255)), "ldur h0, [x1, #255]");
COMPARE_C64(ldur(h0, MemOperand(x1, -256)), "ldur h0, [x1, #-256]");
COMPARE_C64(ldur(h0, MemOperand(x1, 0)), "ldur h0, [x1]");
COMPARE_C64(ldur(h0, MemOperand(sp, 42)), "ldur h0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(ldur(CPURegister(h0), MemOperand(x1, 0)), "ldur h0, [x1]");
}
TEST(morello_c64_aldur_v_ri_q) {
SETUP();
COMPARE_C64(ldur(q0, MemOperand(x1, 255)), "ldur q0, [x1, #255]");
COMPARE_C64(ldur(q0, MemOperand(x1, -256)), "ldur q0, [x1, #-256]");
COMPARE_C64(ldur(q0, MemOperand(x1, 0)), "ldur q0, [x1]");
COMPARE_C64(ldur(q0, MemOperand(sp, 42)), "ldur q0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(ldur(CPURegister(q0), MemOperand(x1, 0)), "ldur q0, [x1]");
}
TEST(morello_c64_aldur_v_ri_s) {
SETUP();
COMPARE_C64(ldur(s0, MemOperand(x1, 255)), "ldur s0, [x1, #255]");
COMPARE_C64(ldur(s0, MemOperand(x1, -256)), "ldur s0, [x1, #-256]");
COMPARE_C64(ldur(s0, MemOperand(x1, 0)), "ldur s0, [x1]");
COMPARE_C64(ldur(s0, MemOperand(sp, 42)), "ldur s0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(ldur(CPURegister(s0), MemOperand(x1, 0)), "ldur s0, [x1]");
}
TEST(morello_c64_aldurb_r_ri_32) {
SETUP();
COMPARE_C64(ldurb(w0, MemOperand(x1, 42)), "ldurb w0, [x1, #42]");
COMPARE_C64(ldurb(w0, MemOperand(x1, 0)), "ldurb w0, [x1]");
COMPARE_C64(ldurb(w0, MemOperand(x1, -256)), "ldurb w0, [x1, #-256]");
COMPARE_C64(ldurb(w0, MemOperand(x1, 255)), "ldurb w0, [x1, #255]");
COMPARE_C64(ldurb(w0, MemOperand(sp, 42)), "ldurb w0, [sp, #42]");
COMPARE_C64(ldurb(wzr, MemOperand(x1, 42)), "ldurb wzr, [x1, #42]");
// `ldrb` can assemble to `ldurb`, according to its LoadStoreScalingOption.
COMPARE_C64(ldurb(w0, MemOperand(c1, -1)), "ldurb w0, [c1, #-1]");
}
TEST(morello_c64_aldurh_r_ri_32) {
SETUP();
COMPARE_C64(ldurh(w0, MemOperand(x1, 42)), "ldurh w0, [x1, #42]");
COMPARE_C64(ldurh(w0, MemOperand(x1, 0)), "ldurh w0, [x1]");
COMPARE_C64(ldurh(w0, MemOperand(x1, -256)), "ldurh w0, [x1, #-256]");
COMPARE_C64(ldurh(w0, MemOperand(x1, 255)), "ldurh w0, [x1, #255]");
COMPARE_C64(ldurh(w0, MemOperand(sp, 42)), "ldurh w0, [sp, #42]");
COMPARE_C64(ldurh(wzr, MemOperand(x1, 42)), "ldurh wzr, [x1, #42]");
// `ldrh` can assemble to `ldurh`, according to its LoadStoreScalingOption.
COMPARE_C64(ldurh(w0, MemOperand(c1, -1)), "ldurh w0, [c1, #-1]");
}
TEST(morello_c64_aldursb_r_ri_32) {
SETUP();
COMPARE_C64(ldursb(w0, MemOperand(x1, 42)), "ldursb w0, [x1, #42]");
COMPARE_C64(ldursb(w0, MemOperand(x1, 0)), "ldursb w0, [x1]");
COMPARE_C64(ldursb(w0, MemOperand(x1, -256)), "ldursb w0, [x1, #-256]");
COMPARE_C64(ldursb(w0, MemOperand(x1, 255)), "ldursb w0, [x1, #255]");
COMPARE_C64(ldursb(w0, MemOperand(sp, 42)), "ldursb w0, [sp, #42]");
COMPARE_C64(ldursb(wzr, MemOperand(x1, 42)), "ldursb wzr, [x1, #42]");
// `ldrsb` can assemble to `ldursb`, according to its LoadStoreScalingOption.
COMPARE_C64(ldursb(w0, MemOperand(c1, -1)), "ldursb w0, [c1, #-1]");
}
TEST(morello_c64_aldursb_r_ri_64) {
SETUP();
COMPARE_C64(ldursb(x0, MemOperand(x1, 42)), "ldursb x0, [x1, #42]");
COMPARE_C64(ldursb(x0, MemOperand(x1, 0)), "ldursb x0, [x1]");
COMPARE_C64(ldursb(x0, MemOperand(x1, -256)), "ldursb x0, [x1, #-256]");
COMPARE_C64(ldursb(x0, MemOperand(x1, 255)), "ldursb x0, [x1, #255]");
COMPARE_C64(ldursb(x0, MemOperand(sp, 42)), "ldursb x0, [sp, #42]");
COMPARE_C64(ldursb(xzr, MemOperand(x1, 42)), "ldursb xzr, [x1, #42]");
// `ldrsb` can assemble to `ldursb`, according to its LoadStoreScalingOption.
COMPARE_C64(ldursb(x0, MemOperand(c1, -1)), "ldursb x0, [c1, #-1]");
}
TEST(morello_c64_aldursh_r_ri_32) {
SETUP();
COMPARE_C64(ldursh(w0, MemOperand(x1, 42)), "ldursh w0, [x1, #42]");
COMPARE_C64(ldursh(w0, MemOperand(x1, 0)), "ldursh w0, [x1]");
COMPARE_C64(ldursh(w0, MemOperand(x1, -256)), "ldursh w0, [x1, #-256]");
COMPARE_C64(ldursh(w0, MemOperand(x1, 255)), "ldursh w0, [x1, #255]");
COMPARE_C64(ldursh(w0, MemOperand(sp, 42)), "ldursh w0, [sp, #42]");
COMPARE_C64(ldursh(wzr, MemOperand(x1, 42)), "ldursh wzr, [x1, #42]");
// `ldrsh` can assemble to `ldursh`, according to its LoadStoreScalingOption.
COMPARE_C64(ldursh(w0, MemOperand(c1, -1)), "ldursh w0, [c1, #-1]");
}
TEST(morello_c64_aldursh_r_ri_64) {
SETUP();
COMPARE_C64(ldursh(x0, MemOperand(x1, 42)), "ldursh x0, [x1, #42]");
COMPARE_C64(ldursh(x0, MemOperand(x1, 0)), "ldursh x0, [x1]");
COMPARE_C64(ldursh(x0, MemOperand(x1, -256)), "ldursh x0, [x1, #-256]");
COMPARE_C64(ldursh(x0, MemOperand(x1, 255)), "ldursh x0, [x1, #255]");
COMPARE_C64(ldursh(x0, MemOperand(sp, 42)), "ldursh x0, [sp, #42]");
COMPARE_C64(ldursh(xzr, MemOperand(x1, 42)), "ldursh xzr, [x1, #42]");
// `ldrsh` can assemble to `ldursh`, according to its LoadStoreScalingOption.
COMPARE_C64(ldursh(x0, MemOperand(c1, -1)), "ldursh x0, [c1, #-1]");
}
TEST(morello_c64_aldursw_r_ri_64) {
SETUP();
COMPARE_C64(ldursw(x0, MemOperand(x1, 42)), "ldursw x0, [x1, #42]");
COMPARE_C64(ldursw(x0, MemOperand(x1, 0)), "ldursw x0, [x1]");
COMPARE_C64(ldursw(x0, MemOperand(x1, -256)), "ldursw x0, [x1, #-256]");
COMPARE_C64(ldursw(x0, MemOperand(x1, 255)), "ldursw x0, [x1, #255]");
COMPARE_C64(ldursw(x0, MemOperand(sp, 42)), "ldursw x0, [sp, #42]");
COMPARE_C64(ldursw(xzr, MemOperand(x1, 42)), "ldursw xzr, [x1, #42]");
// `ldrsw` can assemble to `ldursw`, according to its LoadStoreScalingOption.
COMPARE_C64(ldursw(x0, MemOperand(c1, -1)), "ldursw x0, [c1, #-1]");
}
TEST(morello_c64_astlr_c_r_c) {
SETUP();
COMPARE_C64(stlr(c0, MemOperand(x1)), "stlr c0, [x1]");
COMPARE_C64(stlr(c0, MemOperand(sp)), "stlr c0, [sp]");
COMPARE_C64(stlr(czr, MemOperand(x1)), "stlr czr, [x1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Stlr(c30, MemOperand(x29)), "stlr c30, [x29]");
COMPARE_MACRO_C64(Stlr(czr, MemOperand(sp)), "stlr czr, [sp]");
}
TEST(morello_c64_astlr_r_r_32) {
SETUP();
COMPARE_C64(stlr(w0, MemOperand(x1)), "stlr w0, [x1]");
COMPARE_C64(stlr(w0, MemOperand(sp)), "stlr w0, [sp]");
COMPARE_C64(stlr(wzr, MemOperand(x1)), "stlr wzr, [x1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Stlr(w30, MemOperand(x29)), "stlr w30, [x29]");
COMPARE_MACRO_C64(Stlr(wzr, MemOperand(sp)), "stlr wzr, [sp]");
}
TEST(morello_c64_astlrb_r_r_b) {
SETUP();
COMPARE_C64(stlrb(w0, MemOperand(x1)), "stlrb w0, [x1]");
COMPARE_C64(stlrb(w0, MemOperand(sp)), "stlrb w0, [sp]");
COMPARE_C64(stlrb(wzr, MemOperand(x1)), "stlrb wzr, [x1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Stlrb(w30, MemOperand(x29)), "stlrb w30, [x29]");
COMPARE_MACRO_C64(Stlrb(wzr, MemOperand(sp)), "stlrb wzr, [sp]");
}
TEST(morello_c64_astr_c_ri_c) {
SETUP();
COMPARE_C64(str(c0, MemOperand(x1, 6928)), "str c0, [x1, #6928]");
COMPARE_C64(str(c0, MemOperand(x1, 0)), "str c0, [x1]");
COMPARE_C64(str(c0, MemOperand(x1, 8176)), "str c0, [x1, #8176]");
COMPARE_C64(str(c0, MemOperand(sp, 6928)), "str c0, [sp, #6928]");
COMPARE_C64(str(czr, MemOperand(x1, 6928)), "str czr, [x1, #6928]");
// A generic CPURegister works the same.
COMPARE_C64(str(CPURegister(c0), MemOperand(x1, 0)), "str c0, [x1]");
COMPARE_C64(str(CPURegister(czr), MemOperand(x1, 8176)),
"str czr, [x1, #8176]");
}
TEST(morello_c64_astr_c_rrb_c) {
SETUP();
COMPARE_C64(str(c0, MemOperand(x1, w2, UXTW, 4)),
"str c0, [x1, w2, uxtw #4]");
COMPARE_C64(str(c0, MemOperand(x1, x2, SXTX, 0)), "str c0, [x1, x2, sxtx]");
COMPARE_C64(str(c0, MemOperand(x1, x2, LSL, 4)), "str c0, [x1, x2, lsl #4]");
COMPARE_C64(str(c0, MemOperand(x1, xzr, LSL, 4)),
"str c0, [x1, xzr, lsl #4]");
COMPARE_C64(str(c0, MemOperand(sp, x2, LSL, 4)), "str c0, [sp, x2, lsl #4]");
COMPARE_C64(str(czr, MemOperand(x1, x2, LSL, 4)),
"str czr, [x1, x2, lsl #4]");
// A generic CPURegister works the same.
COMPARE_C64(str(CPURegister(c0), MemOperand(x1, w2, UXTW, 4)),
"str c0, [x1, w2, uxtw #4]");
COMPARE_C64(str(CPURegister(czr), MemOperand(x1, x2, LSL, 4)),
"str czr, [x1, x2, lsl #4]");
}
TEST(morello_c64_astr_c_macro) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Str(c0, MemOperand(x1, 0)), "str c0, [x1]");
COMPARE_MACRO_C64(Str(czr, MemOperand(sp, 0)), "str czr, [sp]");
COMPARE_MACRO_C64(Str(c0, MemOperand(x1, 8176)), "str c0, [x1, #8176]");
COMPARE_MACRO_C64(Str(c0, MemOperand(x1, w2, UXTW, 4)),
"str c0, [x1, w2, uxtw #4]");
COMPARE_MACRO_C64(Str(c0, MemOperand(x1, x2, SXTX, 0)),
"str c0, [x1, x2, sxtx]");
// Unencodable cases.
COMPARE_MACRO_C64(Str(c0, MemOperand(x1, 0x4242)),
"mov x16, #0x4242\n"
"add x16, x1, x16\n"
"str c0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Str(c0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"str c0, [x1]");
COMPARE_MACRO_C64(Str(c0, MemOperand(x1, -16, PostIndex)),
"str c0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Str(CPURegister(c0), MemOperand(x1)), "str c0, [x1]");
}
TEST(morello_c64_astr_r_ri_32) {
SETUP();
COMPARE_C64(str(w0, MemOperand(x1, 420)), "str w0, [x1, #420]");
COMPARE_C64(str(w0, MemOperand(x1, 0)), "str w0, [x1]");
COMPARE_C64(str(w0, MemOperand(x1, 2044)), "str w0, [x1, #2044]");
COMPARE_C64(str(w0, MemOperand(sp, 420)), "str w0, [sp, #420]");
COMPARE_C64(str(wzr, MemOperand(x1, 420)), "str wzr, [x1, #420]");
// `stur` can assemble to `str`, according to its LoadStoreScalingOption.
COMPARE_C64(stur(w0, MemOperand(c1, 256)), "str w0, [c1, #256]");
COMPARE_C64(stur(w0, MemOperand(c1, 2044)), "str w0, [c1, #2044]");
// A generic CPURegister works the same.
COMPARE_C64(str(CPURegister(w0), MemOperand(x1, 0)), "str w0, [x1]");
COMPARE_C64(str(CPURegister(wzr), MemOperand(x1, 2044)),
"str wzr, [x1, #2044]");
}
TEST(morello_c64_astr_r_ri_64) {
SETUP();
COMPARE_C64(str(x0, MemOperand(x1, 840)), "str x0, [x1, #840]");
COMPARE_C64(str(x0, MemOperand(x1, 0)), "str x0, [x1]");
COMPARE_C64(str(x0, MemOperand(x1, 4088)), "str x0, [x1, #4088]");
COMPARE_C64(str(x0, MemOperand(sp, 840)), "str x0, [sp, #840]");
COMPARE_C64(str(xzr, MemOperand(x1, 840)), "str xzr, [x1, #840]");
// `stur` can assemble to `str`, according to its LoadStoreScalingOption.
COMPARE_C64(stur(x0, MemOperand(c1, 256)), "str x0, [c1, #256]");
COMPARE_C64(stur(x0, MemOperand(c1, 4088)), "str x0, [c1, #4088]");
// A generic CPURegister works the same.
COMPARE_C64(str(CPURegister(x0), MemOperand(x1, 0)), "str x0, [x1]");
COMPARE_C64(str(CPURegister(xzr), MemOperand(x1, 4088)),
"str xzr, [x1, #4088]");
}
TEST(morello_c64_astr_r_rrb_32) {
SETUP();
COMPARE_C64(str(w0, MemOperand(x1, w2, UXTW, 2)),
"str w0, [x1, w2, uxtw #2]");
COMPARE_C64(str(w0, MemOperand(x1, x2, SXTX, 0)), "str w0, [x1, x2, sxtx]");
COMPARE_C64(str(w0, MemOperand(x1, x2, LSL, 2)), "str w0, [x1, x2, lsl #2]");
COMPARE_C64(str(w0, MemOperand(x1, xzr, LSL, 2)),
"str w0, [x1, xzr, lsl #2]");
COMPARE_C64(str(w0, MemOperand(sp, x2, LSL, 2)), "str w0, [sp, x2, lsl #2]");
COMPARE_C64(str(wzr, MemOperand(x1, x2, LSL, 2)),
"str wzr, [x1, x2, lsl #2]");
// A generic CPURegister works the same.
COMPARE_C64(str(CPURegister(w0), MemOperand(x1, w2, UXTW, 2)),
"str w0, [x1, w2, uxtw #2]");
COMPARE_C64(str(CPURegister(wzr), MemOperand(x1, x2, LSL, 2)),
"str wzr, [x1, x2, lsl #2]");
}
TEST(morello_c64_astr_r_rrb_64) {
SETUP();
COMPARE_C64(str(x0, MemOperand(x1, w2, UXTW, 3)),
"str x0, [x1, w2, uxtw #3]");
COMPARE_C64(str(x0, MemOperand(x1, x2, SXTX, 0)), "str x0, [x1, x2, sxtx]");
COMPARE_C64(str(x0, MemOperand(x1, x2, LSL, 3)), "str x0, [x1, x2, lsl #3]");
COMPARE_C64(str(x0, MemOperand(x1, xzr, LSL, 3)),
"str x0, [x1, xzr, lsl #3]");
COMPARE_C64(str(x0, MemOperand(sp, x2, LSL, 3)), "str x0, [sp, x2, lsl #3]");
COMPARE_C64(str(xzr, MemOperand(x1, x2, LSL, 3)),
"str xzr, [x1, x2, lsl #3]");
// A generic CPURegister works the same.
COMPARE_C64(str(CPURegister(x0), MemOperand(x1, w2, UXTW, 3)),
"str x0, [x1, w2, uxtw #3]");
COMPARE_C64(str(CPURegister(xzr), MemOperand(x1, x2, LSL, 3)),
"str xzr, [x1, x2, lsl #3]");
}
TEST(morello_c64_astr_v_rrb_d) {
SETUP();
COMPARE_C64(str(d0, MemOperand(x1, w2, UXTW, 3)),
"str d0, [x1, w2, uxtw #3]");
COMPARE_C64(str(d0, MemOperand(x1, x2, SXTX, 0)), "str d0, [x1, x2, sxtx]");
COMPARE_C64(str(d0, MemOperand(x1, x2, LSL, 3)), "str d0, [x1, x2, lsl #3]");
COMPARE_C64(str(d0, MemOperand(x1, xzr, LSL, 3)),
"str d0, [x1, xzr, lsl #3]");
COMPARE_C64(str(d0, MemOperand(sp, x2, LSL, 3)), "str d0, [sp, x2, lsl #3]");
// A generic CPURegister works the same.
COMPARE_C64(str(CPURegister(d0), MemOperand(x1, w2, UXTW, 3)),
"str d0, [x1, w2, uxtw #3]");
}
TEST(morello_c64_astr_v_rrb_s) {
SETUP();
COMPARE_C64(str(s0, MemOperand(x1, w2, UXTW, 2)),
"str s0, [x1, w2, uxtw #2]");
COMPARE_C64(str(s0, MemOperand(x1, x2, SXTX, 0)), "str s0, [x1, x2, sxtx]");
COMPARE_C64(str(s0, MemOperand(x1, x2, LSL, 2)), "str s0, [x1, x2, lsl #2]");
COMPARE_C64(str(s0, MemOperand(x1, xzr, LSL, 2)),
"str s0, [x1, xzr, lsl #2]");
COMPARE_C64(str(s0, MemOperand(sp, x2, LSL, 2)), "str s0, [sp, x2, lsl #2]");
COMPARE_C64(str(wzr, MemOperand(x1, x2, LSL, 2)),
"str wzr, [x1, x2, lsl #2]");
// A generic CPURegister works the same.
COMPARE_C64(str(CPURegister(w0), MemOperand(x1, w2, UXTW, 2)),
"str w0, [x1, w2, uxtw #2]");
COMPARE_C64(str(CPURegister(wzr), MemOperand(x1, x2, LSL, 2)),
"str wzr, [x1, x2, lsl #2]");
}
TEST(morello_c64_astr_v_macro_q) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Str(q0, MemOperand(x1, 0)), "stur q0, [x1]");
COMPARE_MACRO_C64(Str(q0, MemOperand(sp, 0)), "stur q0, [sp]");
COMPARE_MACRO_C64(Str(q31, MemOperand(x1, 0)), "stur q31, [x1]");
COMPARE_MACRO_C64(Str(q0, MemOperand(x1, 255)), "stur q0, [x1, #255]");
COMPARE_MACRO_C64(Str(q0, MemOperand(x1, -256)), "stur q0, [x1, #-256]");
// Unencodable cases.
COMPARE_MACRO_C64(Str(q0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"stur q0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Str(q0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"stur q0, [x1]");
COMPARE_MACRO_C64(Str(q0, MemOperand(x1, -16, PostIndex)),
"stur q0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// There are no register-offset modes for Q.
COMPARE_MACRO_C64(Str(q0, MemOperand(x1, w2, UXTW, 4)),
"add x16, x1, w2, uxtw #4\n"
"stur q0, [x16]");
COMPARE_MACRO_C64(Str(q0, MemOperand(x1, x2, SXTX, 0)),
"add x16, x1, x2, sxtx\n"
"stur q0, [x16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Str(CPURegister(q0), MemOperand(x1)), "stur q0, [x1]");
}
TEST(morello_c64_astr_v_macro_d) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Str(d0, MemOperand(x1, 0)), "stur d0, [x1]");
COMPARE_MACRO_C64(Str(d0, MemOperand(sp, 0)), "stur d0, [sp]");
COMPARE_MACRO_C64(Str(d31, MemOperand(x1, 0)), "stur d31, [x1]");
COMPARE_MACRO_C64(Str(d0, MemOperand(x1, 255)), "stur d0, [x1, #255]");
COMPARE_MACRO_C64(Str(d0, MemOperand(x1, -256)), "stur d0, [x1, #-256]");
COMPARE_MACRO_C64(Str(d0, MemOperand(x1, w2, UXTW, 3)),
"str d0, [x1, w2, uxtw #3]");
COMPARE_MACRO_C64(Str(d0, MemOperand(x1, x2, SXTX, 0)),
"str d0, [x1, x2, sxtx]");
// Unencodable cases.
COMPARE_MACRO_C64(Str(d0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"stur d0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Str(d0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"stur d0, [x1]");
COMPARE_MACRO_C64(Str(d0, MemOperand(x1, -16, PostIndex)),
"stur d0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Str(CPURegister(d0), MemOperand(x1)), "stur d0, [x1]");
}
TEST(morello_c64_astr_v_macro_s) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Str(s0, MemOperand(x1, 0)), "stur s0, [x1]");
COMPARE_MACRO_C64(Str(s0, MemOperand(sp, 0)), "stur s0, [sp]");
COMPARE_MACRO_C64(Str(s31, MemOperand(x1, 0)), "stur s31, [x1]");
COMPARE_MACRO_C64(Str(s0, MemOperand(x1, 255)), "stur s0, [x1, #255]");
COMPARE_MACRO_C64(Str(s0, MemOperand(x1, -256)), "stur s0, [x1, #-256]");
COMPARE_MACRO_C64(Str(s0, MemOperand(x1, w2, UXTW, 2)),
"str s0, [x1, w2, uxtw #2]");
COMPARE_MACRO_C64(Str(s0, MemOperand(x1, x2, SXTX, 0)),
"str s0, [x1, x2, sxtx]");
// Unencodable cases.
COMPARE_MACRO_C64(Str(s0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"stur s0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Str(s0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"stur s0, [x1]");
COMPARE_MACRO_C64(Str(s0, MemOperand(x1, -16, PostIndex)),
"stur s0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Str(CPURegister(s0), MemOperand(x1)), "stur s0, [x1]");
}
TEST(morello_c64_astr_v_macro_h) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Str(h0, MemOperand(x1, 0)), "stur h0, [x1]");
COMPARE_MACRO_C64(Str(h0, MemOperand(sp, 0)), "stur h0, [sp]");
COMPARE_MACRO_C64(Str(h31, MemOperand(x1, 0)), "stur h31, [x1]");
COMPARE_MACRO_C64(Str(h0, MemOperand(x1, 255)), "stur h0, [x1, #255]");
COMPARE_MACRO_C64(Str(h0, MemOperand(x1, -256)), "stur h0, [x1, #-256]");
// Unencodable cases.
COMPARE_MACRO_C64(Str(h0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"stur h0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Str(h0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"stur h0, [x1]");
COMPARE_MACRO_C64(Str(h0, MemOperand(x1, -16, PostIndex)),
"stur h0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// There are no register-offset modes for h.
COMPARE_MACRO_C64(Str(h0, MemOperand(x1, w2, UXTW, 1)),
"add x16, x1, w2, uxtw #1\n"
"stur h0, [x16]");
COMPARE_MACRO_C64(Str(h0, MemOperand(x1, x2, SXTX, 0)),
"add x16, x1, x2, sxtx\n"
"stur h0, [x16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Str(CPURegister(h0), MemOperand(x1)), "stur h0, [x1]");
}
TEST(morello_c64_astr_v_macro_b) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Str(b0, MemOperand(x1, 0)), "stur b0, [x1]");
COMPARE_MACRO_C64(Str(b0, MemOperand(sp, 0)), "stur b0, [sp]");
COMPARE_MACRO_C64(Str(b31, MemOperand(x1, 0)), "stur b31, [x1]");
COMPARE_MACRO_C64(Str(b0, MemOperand(x1, 255)), "stur b0, [x1, #255]");
COMPARE_MACRO_C64(Str(b0, MemOperand(x1, -256)), "stur b0, [x1, #-256]");
// Unencodable cases.
COMPARE_MACRO_C64(Str(b0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"stur b0, [x16]");
// There are no index modes so these are always unencodable.
COMPARE_MACRO_C64(Str(b0, MemOperand(x1, 16, PreIndex)),
"add x1, x1, #0x10 (16)\n"
"stur b0, [x1]");
COMPARE_MACRO_C64(Str(b0, MemOperand(x1, -16, PostIndex)),
"stur b0, [x1]\n"
"sub x1, x1, #0x10 (16)");
// There are no register-offset modes for b.
COMPARE_MACRO_C64(Str(b0, MemOperand(x1, w2, UXTW)),
"add x16, x1, w2, uxtw\n"
"stur b0, [x16]");
COMPARE_MACRO_C64(Str(b0, MemOperand(x1, x2, SXTX)),
"add x16, x1, x2, sxtx\n"
"stur b0, [x16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Str(CPURegister(b0), MemOperand(x1)), "stur b0, [x1]");
}
TEST(morello_c64_astrb_r_ri_b) {
SETUP();
COMPARE_C64(strb(w0, MemOperand(x1, 42)), "strb w0, [x1, #42]");
COMPARE_C64(strb(w0, MemOperand(x1, 0)), "strb w0, [x1]");
COMPARE_C64(strb(w0, MemOperand(x1, 511)), "strb w0, [x1, #511]");
COMPARE_C64(strb(w0, MemOperand(sp, 42)), "strb w0, [sp, #42]");
COMPARE_C64(strb(wzr, MemOperand(x1, 42)), "strb wzr, [x1, #42]");
// `sturb` can assemble to `strb`, according to its LoadStoreScalingOption.
COMPARE_C64(sturb(w0, MemOperand(c1, 256)), "strb w0, [c1, #256]");
COMPARE_C64(sturb(w0, MemOperand(c1, 511)), "strb w0, [c1, #511]");
}
TEST(morello_c64_astrb_r_rrb_b) {
SETUP();
COMPARE_C64(strb(w0, MemOperand(x1, w2, UXTW)), "strb w0, [x1, w2, uxtw]");
COMPARE_C64(strb(w0, MemOperand(x1, x2, SXTX, 0)), "strb w0, [x1, x2, sxtx]");
COMPARE_C64(strb(w0, MemOperand(x1, x2, LSL, 0)), "strb w0, [x1, x2]");
COMPARE_C64(strb(w0, MemOperand(x1, xzr)), "strb w0, [x1, xzr]");
COMPARE_C64(strb(w0, MemOperand(sp, x2)), "strb w0, [sp, x2]");
COMPARE_C64(strb(wzr, MemOperand(x1, x2)), "strb wzr, [x1, x2]");
}
TEST(morello_c64_astrh_r_rrb_32) {
SETUP();
COMPARE_C64(strh(w0, MemOperand(x1, x2)), "strh w0, [x1, x2]");
COMPARE_C64(strh(w0, MemOperand(x1, w2, SXTW, 0)), "strh w0, [x1, w2, sxtw]");
COMPARE_C64(strh(w0, MemOperand(x1, x2, LSL, 1)),
"strh w0, [x1, x2, lsl #1]");
COMPARE_C64(strh(w0, MemOperand(x1, xzr, LSL, 1)),
"strh w0, [x1, xzr, lsl #1]");
COMPARE_C64(strh(w0, MemOperand(sp, x2, LSL, 1)),
"strh w0, [sp, x2, lsl #1]");
COMPARE_C64(strh(wzr, MemOperand(x1, x2, LSL, 1)),
"strh wzr, [x1, x2, lsl #1]");
}
TEST(morello_c64_astrb_macro) {
SETUP();
// Encodable cases.
// "unsigned offset"
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, 42)), "strb w0, [x1, #42]");
COMPARE_MACRO_C64(Strb(wzr, MemOperand(sp, 42)), "strb wzr, [sp, #42]");
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, 511)), "strb w0, [x1, #511]");
// "unscaled"
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, -256)), "sturb w0, [x1, #-256]");
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, -1)), "sturb w0, [x1, #-1]");
COMPARE_MACRO_C64(Strb(wzr, MemOperand(sp, -1)), "sturb wzr, [sp, #-1]");
// "register"
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, x2)), "strb w0, [x1, x2]");
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, w2, SXTW)),
"strb w0, [x1, w2, sxtw]");
// The MacroAssembler permits an X-sized source for truncating stores.
COMPARE_MACRO_C64(Strb(x0, MemOperand(x1, 42)), "strb w0, [x1, #42]");
COMPARE_MACRO_C64(Strb(x0, MemOperand(x1, -1)), "sturb w0, [x1, #-1]");
COMPARE_MACRO_C64(Strb(x0, MemOperand(x1, w2, UXTW)),
"strb w0, [x1, w2, uxtw]");
// Unencodable cases.
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, 512)),
"add x16, x1, #0x200 (512)\n"
"strb w0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"strb w0, [x1]");
COMPARE_MACRO_C64(Strb(w0, MemOperand(x1, 16, PostIndex)),
"strb w0, [x1]\n"
"add x1, x1, #0x10 (16)");
}
TEST(morello_c64_astrh_macro) {
SETUP();
// Encodable cases.
// "unscaled"
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, -256)), "sturh w0, [x1, #-256]");
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, 255)), "sturh w0, [x1, #255]");
COMPARE_MACRO_C64(Strh(wzr, MemOperand(sp, 42)), "sturh wzr, [sp, #42]");
// "register"
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, x2)), "strh w0, [x1, x2]");
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, w2, SXTW)),
"strh w0, [x1, w2, sxtw]");
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, x2, LSL, 1)),
"strh w0, [x1, x2, lsl #1]");
// The MacroAssembler permits an X-sized source for truncating stores.
COMPARE_MACRO_C64(Strh(x0, MemOperand(x1, 42)), "sturh w0, [x1, #42]");
COMPARE_MACRO_C64(Strh(x0, MemOperand(x1, x2, SXTX, 1)),
"strh w0, [x1, x2, sxtx #1]");
// Unencodable cases.
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, 0x4242)),
"mov x16, #0x4242\n"
"add x16, x1, x16\n"
"sturh w0, [x16]");
// There are no index modes.
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, -16, PreIndex)),
"sub x1, x1, #0x10 (16)\n"
"sturh w0, [x1]");
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, 16, PostIndex)),
"sturh w0, [x1]\n"
"add x1, x1, #0x10 (16)");
// There is no "unsigned offset" mode.
COMPARE_MACRO_C64(Strh(w0, MemOperand(x1, 256)),
"add x16, x1, #0x100 (256)\n"
"sturh w0, [x16]");
}
TEST(morello_c64_astur_c_ri_c) {
SETUP();
COMPARE_C64(stur(c0, MemOperand(x1, 255)), "stur c0, [x1, #255]");
COMPARE_C64(stur(c0, MemOperand(x1, -256)), "stur c0, [x1, #-256]");
COMPARE_C64(stur(c0, MemOperand(x1, 0)), "stur c0, [x1]");
COMPARE_C64(stur(c0, MemOperand(sp, 42)), "stur c0, [sp, #42]");
COMPARE_C64(stur(czr, MemOperand(x1, 42)), "stur czr, [x1, #42]");
// `str` can assemble to `stur`, according to its LoadStoreScalingOption.
COMPARE_C64(str(c0, MemOperand(x1, -1)), "stur c0, [x1, #-1]");
COMPARE_C64(str(c0, MemOperand(x1, 42)), "stur c0, [x1, #42]");
// A generic CPURegister works the same.
COMPARE_C64(stur(CPURegister(c0), MemOperand(x1, 0)), "stur c0, [x1]");
COMPARE_C64(stur(CPURegister(czr), MemOperand(x1, 42)),
"stur czr, [x1, #42]");
}
TEST(morello_c64_astur_r_ri_32) {
SETUP();
COMPARE_C64(stur(w0, MemOperand(x1, 255)), "stur w0, [x1, #255]");
COMPARE_C64(stur(w0, MemOperand(x1, -256)), "stur w0, [x1, #-256]");
COMPARE_C64(stur(w0, MemOperand(x1, 0)), "stur w0, [x1]");
COMPARE_C64(stur(w0, MemOperand(sp, 42)), "stur w0, [sp, #42]");
COMPARE_C64(stur(wzr, MemOperand(x1, 42)), "stur wzr, [x1, #42]");
// `str` can assemble to `stur`, according to its LoadStoreScalingOption.
COMPARE_C64(str(w0, MemOperand(x1, -1)), "stur w0, [x1, #-1]");
COMPARE_C64(str(w0, MemOperand(x1, 42)), "stur w0, [x1, #42]");
// A generic CPURegister works the same.
COMPARE_C64(stur(CPURegister(w0), MemOperand(x1, 0)), "stur w0, [x1]");
COMPARE_C64(stur(CPURegister(wzr), MemOperand(x1, 42)),
"stur wzr, [x1, #42]");
}
TEST(morello_c64_astur_r_ri_64) {
SETUP();
COMPARE_C64(stur(x0, MemOperand(x1, 255)), "stur x0, [x1, #255]");
COMPARE_C64(stur(x0, MemOperand(x1, -256)), "stur x0, [x1, #-256]");
COMPARE_C64(stur(x0, MemOperand(x1, 0)), "stur x0, [x1]");
COMPARE_C64(stur(x0, MemOperand(sp, 42)), "stur x0, [sp, #42]");
COMPARE_C64(stur(xzr, MemOperand(x1, 42)), "stur xzr, [x1, #42]");
// `str` can assemble to `stur`, according to its LoadStoreScalingOption.
COMPARE_C64(str(x0, MemOperand(x1, -1)), "stur x0, [x1, #-1]");
COMPARE_C64(str(x0, MemOperand(x1, 42)), "stur x0, [x1, #42]");
// A generic CPURegister works the same.
COMPARE_C64(stur(CPURegister(x0), MemOperand(x1, 0)), "stur x0, [x1]");
COMPARE_C64(stur(CPURegister(xzr), MemOperand(x1, 42)),
"stur xzr, [x1, #42]");
}
TEST(morello_c64_astur_v_ri_b) {
SETUP();
COMPARE_C64(stur(b0, MemOperand(x1, 255)), "stur b0, [x1, #255]");
COMPARE_C64(stur(b0, MemOperand(x1, -256)), "stur b0, [x1, #-256]");
COMPARE_C64(stur(b0, MemOperand(x1, 0)), "stur b0, [x1]");
COMPARE_C64(stur(b0, MemOperand(sp, 42)), "stur b0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(stur(CPURegister(b0), MemOperand(x1, 0)), "stur b0, [x1]");
}
TEST(morello_c64_astur_v_ri_d) {
SETUP();
COMPARE_C64(stur(d0, MemOperand(x1, 255)), "stur d0, [x1, #255]");
COMPARE_C64(stur(d0, MemOperand(x1, -256)), "stur d0, [x1, #-256]");
COMPARE_C64(stur(d0, MemOperand(x1, 0)), "stur d0, [x1]");
COMPARE_C64(stur(d0, MemOperand(sp, 42)), "stur d0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(stur(CPURegister(d0), MemOperand(x1, 0)), "stur d0, [x1]");
}
TEST(morello_c64_astur_v_ri_h) {
SETUP();
COMPARE_C64(stur(h0, MemOperand(x1, 255)), "stur h0, [x1, #255]");
COMPARE_C64(stur(h0, MemOperand(x1, -256)), "stur h0, [x1, #-256]");
COMPARE_C64(stur(h0, MemOperand(x1, 0)), "stur h0, [x1]");
COMPARE_C64(stur(h0, MemOperand(sp, 42)), "stur h0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(stur(CPURegister(h0), MemOperand(x1, 0)), "stur h0, [x1]");
}
TEST(morello_c64_astur_v_ri_q) {
SETUP();
COMPARE_C64(stur(q0, MemOperand(x1, 255)), "stur q0, [x1, #255]");
COMPARE_C64(stur(q0, MemOperand(x1, -256)), "stur q0, [x1, #-256]");
COMPARE_C64(stur(q0, MemOperand(x1, 0)), "stur q0, [x1]");
COMPARE_C64(stur(q0, MemOperand(sp, 42)), "stur q0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(stur(CPURegister(q0), MemOperand(x1, 0)), "stur q0, [x1]");
}
TEST(morello_c64_astur_v_ri_s) {
SETUP();
COMPARE_C64(stur(s0, MemOperand(x1, 255)), "stur s0, [x1, #255]");
COMPARE_C64(stur(s0, MemOperand(x1, -256)), "stur s0, [x1, #-256]");
COMPARE_C64(stur(s0, MemOperand(x1, 0)), "stur s0, [x1]");
COMPARE_C64(stur(s0, MemOperand(sp, 42)), "stur s0, [sp, #42]");
// A generic CPURegister works the same.
COMPARE_C64(stur(CPURegister(s0), MemOperand(x1, 0)), "stur s0, [x1]");
}
TEST(morello_c64_asturb_r_ri_32) {
SETUP();
COMPARE_C64(sturb(w0, MemOperand(x1, 42)), "sturb w0, [x1, #42]");
COMPARE_C64(sturb(w0, MemOperand(x1, 0)), "sturb w0, [x1]");
COMPARE_C64(sturb(w0, MemOperand(x1, -256)), "sturb w0, [x1, #-256]");
COMPARE_C64(sturb(w0, MemOperand(x1, 255)), "sturb w0, [x1, #255]");
COMPARE_C64(sturb(w0, MemOperand(sp, 42)), "sturb w0, [sp, #42]");
COMPARE_C64(sturb(wzr, MemOperand(x1, 42)), "sturb wzr, [x1, #42]");
// `strb` can assemble to `sturb`, according to its LoadStoreScalingOption.
COMPARE_C64(sturb(w0, MemOperand(c1, -1)), "sturb w0, [c1, #-1]");
}
TEST(morello_c64_asturh_r_ri_32) {
SETUP();
COMPARE_C64(sturh(w0, MemOperand(x1, 42)), "sturh w0, [x1, #42]");
COMPARE_C64(sturh(w0, MemOperand(x1, 0)), "sturh w0, [x1]");
COMPARE_C64(sturh(w0, MemOperand(x1, -256)), "sturh w0, [x1, #-256]");
COMPARE_C64(sturh(w0, MemOperand(x1, 255)), "sturh w0, [x1, #255]");
COMPARE_C64(sturh(w0, MemOperand(sp, 42)), "sturh w0, [sp, #42]");
COMPARE_C64(sturh(wzr, MemOperand(x1, 42)), "sturh wzr, [x1, #42]");
// `strh` can assemble to `sturh`, according to its LoadStoreScalingOption.
COMPARE_C64(sturh(w0, MemOperand(c1, -1)), "sturh w0, [c1, #-1]");
}
TEST(morello_c64_cas_c_r_c) {
SETUP();
COMPARE_C64(cas(c0, c1, MemOperand(c2)), "cas c0, c1, [c2]");
COMPARE_C64(cas(c0, c1, MemOperand(csp)), "cas c0, c1, [csp]");
COMPARE_C64(cas(c0, czr, MemOperand(c2)), "cas c0, czr, [c2]");
COMPARE_C64(cas(czr, c1, MemOperand(c2)), "cas czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Cas(c30, c29, MemOperand(c28)), "cas c30, c29, [c28]");
COMPARE_MACRO_C64(Cas(c30, czr, MemOperand(csp)), "cas c30, czr, [csp]");
}
TEST(morello_c64_casa_c_r_c) {
SETUP();
COMPARE_C64(casa(c0, c1, MemOperand(c2)), "casa c0, c1, [c2]");
COMPARE_C64(casa(c0, c1, MemOperand(csp)), "casa c0, c1, [csp]");
COMPARE_C64(casa(c0, czr, MemOperand(c2)), "casa c0, czr, [c2]");
COMPARE_C64(casa(czr, c1, MemOperand(c2)), "casa czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Casa(c30, c29, MemOperand(c28)), "casa c30, c29, [c28]");
COMPARE_MACRO_C64(Casa(c30, czr, MemOperand(csp)), "casa c30, czr, [csp]");
}
TEST(morello_c64_casal_c_r_c) {
SETUP();
COMPARE_C64(casal(c0, c1, MemOperand(c2)), "casal c0, c1, [c2]");
COMPARE_C64(casal(c0, c1, MemOperand(csp)), "casal c0, c1, [csp]");
COMPARE_C64(casal(c0, czr, MemOperand(c2)), "casal c0, czr, [c2]");
COMPARE_C64(casal(czr, c1, MemOperand(c2)), "casal czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Casal(c30, c29, MemOperand(c28)), "casal c30, c29, [c28]");
COMPARE_MACRO_C64(Casal(c30, czr, MemOperand(csp)), "casal c30, czr, [csp]");
}
TEST(morello_c64_casl_c_r_c) {
SETUP();
COMPARE_C64(casl(c0, c1, MemOperand(c2)), "casl c0, c1, [c2]");
COMPARE_C64(casl(c0, c1, MemOperand(csp)), "casl c0, c1, [csp]");
COMPARE_C64(casl(c0, czr, MemOperand(c2)), "casl c0, czr, [c2]");
COMPARE_C64(casl(czr, c1, MemOperand(c2)), "casl czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Casl(c30, c29, MemOperand(c28)), "casl c30, c29, [c28]");
COMPARE_MACRO_C64(Casl(c30, czr, MemOperand(csp)), "casl c30, czr, [csp]");
}
TEST(morello_c64_ldapr_c_r_c) {
SETUP();
COMPARE_C64(ldapr(c0, MemOperand(c1)), "ldapr c0, [c1]");
COMPARE_C64(ldapr(c0, MemOperand(csp)), "ldapr c0, [csp]");
COMPARE_C64(ldapr(czr, MemOperand(c1)), "ldapr czr, [c1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldapr(c30, MemOperand(c29)), "ldapr c30, [c29]");
COMPARE_MACRO_C64(Ldapr(czr, MemOperand(csp)), "ldapr czr, [csp]");
}
TEST(morello_c64_ldar_c_r_c) {
SETUP();
COMPARE_C64(ldar(c0, MemOperand(c1)), "ldar c0, [c1]");
COMPARE_C64(ldar(c0, MemOperand(csp)), "ldar c0, [csp]");
COMPARE_C64(ldar(czr, MemOperand(c1)), "ldar czr, [c1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldar(c30, MemOperand(c29)), "ldar c30, [c29]");
COMPARE_MACRO_C64(Ldar(czr, MemOperand(csp)), "ldar czr, [csp]");
}
TEST(morello_c64_ldaxp_c_r_c) {
SETUP();
COMPARE_C64(ldaxp(c0, c1, MemOperand(c2)), "ldaxp c0, c1, [c2]");
COMPARE_C64(ldaxp(c0, c1, MemOperand(csp)), "ldaxp c0, c1, [csp]");
COMPARE_C64(ldaxp(c0, czr, MemOperand(c2)), "ldaxp c0, czr, [c2]");
COMPARE_C64(ldaxp(czr, c1, MemOperand(c2)), "ldaxp czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldaxp(c30, c29, MemOperand(c28)), "ldaxp c30, c29, [c28]");
COMPARE_MACRO_C64(Ldaxp(c30, czr, MemOperand(csp)), "ldaxp c30, czr, [csp]");
}
TEST(morello_c64_ldaxr_c_r_c) {
SETUP();
COMPARE_C64(ldaxr(c0, MemOperand(c1)), "ldaxr c0, [c1]");
COMPARE_C64(ldaxr(c0, MemOperand(csp)), "ldaxr c0, [csp]");
COMPARE_C64(ldaxr(czr, MemOperand(c1)), "ldaxr czr, [c1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldar(c30, MemOperand(c29)), "ldar c30, [c29]");
COMPARE_MACRO_C64(Ldar(czr, MemOperand(csp)), "ldar czr, [csp]");
}
TEST(morello_c64_ldct_r_r) {
SETUP();
COMPARE_C64(ldct(x0, MemOperand(c1)), "ldct x0, [c1]");
COMPARE_C64(ldct(x0, MemOperand(csp)), "ldct x0, [csp]");
COMPARE_C64(ldct(xzr, MemOperand(c1)), "ldct xzr, [c1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldct(x30, MemOperand(c29)), "ldct x30, [c29]");
COMPARE_MACRO_C64(Ldct(xzr, MemOperand(csp)), "ldct xzr, [csp]");
}
TEST(morello_c64_ldnp_c_rib_c) {
SETUP();
COMPARE_C64(ldnp(c0, c1, MemOperand(c2, 272)), "ldnp c0, c1, [c2, #272]");
COMPARE_C64(ldnp(c0, c1, MemOperand(csp, 272)), "ldnp c0, c1, [csp, #272]");
COMPARE_C64(ldnp(c0, czr, MemOperand(c2, 272)), "ldnp c0, czr, [c2, #272]");
COMPARE_C64(ldnp(czr, c1, MemOperand(c2, 272)), "ldnp czr, c1, [c2, #272]");
COMPARE_C64(ldnp(c0, c1, MemOperand(c2, 0)), "ldnp c0, c1, [c2]");
COMPARE_C64(ldnp(c0, c1, MemOperand(c2, -1024)), "ldnp c0, c1, [c2, #-1024]");
COMPARE_C64(ldnp(c0, c1, MemOperand(c2, 1008)), "ldnp c0, c1, [c2, #1008]");
}
TEST(morello_c64_ldnp_c_macro) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldnp(c0, c1, MemOperand(c2)), "ldnp c0, c1, [c2]");
COMPARE_MACRO_C64(Ldnp(c0, c1, MemOperand(c2, 1008)),
"ldnp c0, c1, [c2, #1008]");
COMPARE_MACRO_C64(Ldnp(c0, c1, MemOperand(c2, -1024)),
"ldnp c0, c1, [c2, #-1024]");
COMPARE_MACRO_C64(Ldnp(czr, c30, MemOperand(csp)), "ldnp czr, c30, [csp]");
COMPARE_MACRO_C64(Ldnp(c30, czr, MemOperand(csp)), "ldnp c30, czr, [csp]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldnp(c0, c1, MemOperand(c2, 0x4242)),
"mov x16, #0x4242\n"
"add c16, c2, x16, uxtx\n"
"ldnp c0, c1, [c16]");
// There are no addressing modes other than immediate offset.
COMPARE_MACRO_C64(Ldnp(c0, c1, MemOperand(c2, x3)),
"add c16, c2, x3, uxtx\n"
"ldnp c0, c1, [c16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldnp(CPURegister(c0), CPURegister(c1), MemOperand(c2)),
"ldnp c0, c1, [c2]");
}
TEST(morello_c64_ldp_c_rib_c) {
SETUP();
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 272)), "ldp c0, c1, [c2, #272]");
COMPARE_C64(ldp(c0, c1, MemOperand(csp, 272)), "ldp c0, c1, [csp, #272]");
COMPARE_C64(ldp(c0, czr, MemOperand(c2, 272)), "ldp c0, czr, [c2, #272]");
COMPARE_C64(ldp(czr, c1, MemOperand(c2, 272)), "ldp czr, c1, [c2, #272]");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 0)), "ldp c0, c1, [c2]");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, -1024)), "ldp c0, c1, [c2, #-1024]");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 1008)), "ldp c0, c1, [c2, #1008]");
}
TEST(morello_c64_ldp_c_ribw_c) {
SETUP();
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 272, PreIndex)),
"ldp c0, c1, [c2, #272]!");
COMPARE_C64(ldp(c0, c1, MemOperand(csp, 272, PreIndex)),
"ldp c0, c1, [csp, #272]!");
COMPARE_C64(ldp(c0, czr, MemOperand(c2, 272, PreIndex)),
"ldp c0, czr, [c2, #272]!");
COMPARE_C64(ldp(czr, c1, MemOperand(c2, 272, PreIndex)),
"ldp czr, c1, [c2, #272]!");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 0, PreIndex)),
"ldp c0, c1, [c2, #0]!");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, -1024, PreIndex)),
"ldp c0, c1, [c2, #-1024]!");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 1008, PreIndex)),
"ldp c0, c1, [c2, #1008]!");
}
TEST(morello_c64_ldp_cc_riaw_c) {
SETUP();
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 272, PostIndex)),
"ldp c0, c1, [c2], #272");
COMPARE_C64(ldp(c0, c1, MemOperand(csp, 272, PostIndex)),
"ldp c0, c1, [csp], #272");
COMPARE_C64(ldp(c0, czr, MemOperand(c2, 272, PostIndex)),
"ldp c0, czr, [c2], #272");
COMPARE_C64(ldp(czr, c1, MemOperand(c2, 272, PostIndex)),
"ldp czr, c1, [c2], #272");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 0, PostIndex)),
"ldp c0, c1, [c2], #0");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, -1024, PostIndex)),
"ldp c0, c1, [c2], #-1024");
COMPARE_C64(ldp(c0, c1, MemOperand(c2, 1008, PostIndex)),
"ldp c0, c1, [c2], #1008");
}
TEST(morello_c64_ldp_c_macro) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2)), "ldp c0, c1, [c2]");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, 1008)),
"ldp c0, c1, [c2, #1008]");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, -1024)),
"ldp c0, c1, [c2, #-1024]");
COMPARE_MACRO_C64(Ldp(czr, c30, MemOperand(csp)), "ldp czr, c30, [csp]");
COMPARE_MACRO_C64(Ldp(c30, czr, MemOperand(csp)), "ldp c30, czr, [csp]");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, 0, PostIndex)),
"ldp c0, c1, [c2], #0");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, -1024, PostIndex)),
"ldp c0, c1, [c2], #-1024");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, 1008, PostIndex)),
"ldp c0, c1, [c2], #1008");
COMPARE_MACRO_C64(Ldp(czr, c30, MemOperand(csp, 0, PostIndex)),
"ldp czr, c30, [csp], #0");
COMPARE_MACRO_C64(Ldp(c30, czr, MemOperand(csp, 0, PostIndex)),
"ldp c30, czr, [csp], #0");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, 0, PreIndex)),
"ldp c0, c1, [c2, #0]!");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, -1024, PreIndex)),
"ldp c0, c1, [c2, #-1024]!");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, 1008, PreIndex)),
"ldp c0, c1, [c2, #1008]!");
COMPARE_MACRO_C64(Ldp(czr, c30, MemOperand(csp, 0, PreIndex)),
"ldp czr, c30, [csp, #0]!");
COMPARE_MACRO_C64(Ldp(c30, czr, MemOperand(csp, 0, PreIndex)),
"ldp c30, czr, [csp, #0]!");
// Unencodable cases.
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, 0x4242)),
"mov x16, #0x4242\n"
"add c16, c2, x16, uxtx\n"
"ldp c0, c1, [c16]");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, 0x4242, PreIndex)),
"mov x16, #0x4242\n"
"add c2, c2, x16, uxtx\n"
"ldp c0, c1, [c2]");
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, 0x4242, PostIndex)),
"ldp c0, c1, [c2]\n"
"mov x16, #0x4242\n"
"add c2, c2, x16, uxtx");
// There is no register-offset mode.
COMPARE_MACRO_C64(Ldp(c0, c1, MemOperand(c2, x3)),
"add c16, c2, x3, uxtx\n"
"ldp c0, c1, [c16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldp(CPURegister(c0),
CPURegister(c1),
MemOperand(c2, 0, PostIndex)),
"ldp c0, c1, [c2], #0");
}
TEST(morello_c64_ldr_c_riaw_c) {
SETUP();
COMPARE_C64(ldr(c0, MemOperand(c1, 0, PostIndex)), "ldr c0, [c1], #0");
COMPARE_C64(ldr(c0, MemOperand(c1, 672, PostIndex)), "ldr c0, [c1], #672");
COMPARE_C64(ldr(c0, MemOperand(csp, 672, PostIndex)), "ldr c0, [csp], #672");
COMPARE_C64(ldr(czr, MemOperand(c1, 672, PostIndex)), "ldr czr, [c1], #672");
COMPARE_C64(ldr(c0, MemOperand(c1, -4096, PostIndex)),
"ldr c0, [c1], #-4096");
COMPARE_C64(ldr(c0, MemOperand(c1, 4080, PostIndex)), "ldr c0, [c1], #4080");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(c0), MemOperand(c1, 0, PostIndex)),
"ldr c0, [c1], #0");
COMPARE_C64(ldr(CPURegister(czr), MemOperand(c1, 672, PostIndex)),
"ldr czr, [c1], #672");
}
TEST(morello_c64_ldr_c_rib_c) {
SETUP();
// Direct encodings.
COMPARE_C64(ldr(c0, MemOperand(c1)), "ldr c0, [c1]");
COMPARE_C64(ldr(c0, MemOperand(c1, 6928)), "ldr c0, [c1, #6928]");
COMPARE_C64(ldr(c0, MemOperand(csp, 6928)), "ldr c0, [csp, #6928]");
COMPARE_C64(ldr(czr, MemOperand(c1, 6928)), "ldr czr, [c1, #6928]");
COMPARE_C64(ldr(c0, MemOperand(c1, 65520)), "ldr c0, [c1, #65520]");
// `ldur` can assemble to `ldr`, according to its LoadStoreScalingOption.
COMPARE_C64(ldur(c0, MemOperand(c1, 256)), "ldr c0, [c1, #256]");
COMPARE_C64(ldur(c0, MemOperand(c1, 65520)), "ldr c0, [c1, #65520]");
// A generic CPURegister works the same.
COMPARE_C64(ldr(CPURegister(c0), MemOperand(c1)), "ldr c0, [c1]");
COMPARE_C64(ldr(CPURegister(czr), MemOperand(c1, 6928)),
"ldr czr, [c1, #6928]");
}
TEST(morello_c64_ldr_c_ribw_c) {
SETUP();
COMPARE_C64(ldr(c0, MemOperand(c1, 0, PreIndex)), "ldr c0, [c1, #0]!");
COMPARE_C64(ldr(c0, MemOperand(c1, 672, PreIndex)), "ldr c0, [c1, #672]!");
COMPARE_C64(ldr(c0, MemOperand(csp, 672, PreIndex)), "ldr c0, [csp, #672]!");
COMPARE_C64(ldr(czr, MemOperand(c1, 672, PreIndex)), "ldr czr, [c1, #672]!");
COMPARE_C64(ldr(c0, MemOperand(c1, -4096, PreIndex)),
"ldr c0, [c1, #-4096]!");
COMPARE_C64(ldr(c0, MemOperand(c1, 4080, PreIndex)), "ldr c0, [c1, #4080]!");
// The generic (CPURegister) API calls the same helper.
COMPARE_C64(ldr(CPURegister(c0), MemOperand(c1, 0, PreIndex)),
"ldr c0, [c1, #0]!");
COMPARE_C64(ldr(CPURegister(czr), MemOperand(c1, 672, PreIndex)),
"ldr czr, [c1, #672]!");
}
TEST(morello_c64_ldr_c_rrb_c) {
SETUP();
COMPARE_C64(ldr(c0, MemOperand(c1, w2, UXTW, 4)),
"ldr c0, [c1, w2, uxtw #4]");
COMPARE_C64(ldr(c0, MemOperand(c1, w2, SXTW)), "ldr c0, [c1, w2, sxtw]");
COMPARE_C64(ldr(c0, MemOperand(c1, wzr, SXTW)), "ldr c0, [c1, wzr, sxtw]");
COMPARE_C64(ldr(c0, MemOperand(csp, w2, SXTW)), "ldr c0, [csp, w2, sxtw]");
COMPARE_C64(ldr(czr, MemOperand(c1, w2, SXTW)), "ldr czr, [c1, w2, sxtw]");
COMPARE_C64(ldr(c0, MemOperand(c1, x2, SXTX)), "ldr c0, [c1, x2, sxtx]");
COMPARE_C64(ldr(c0, MemOperand(c1, xzr, SXTX)), "ldr c0, [c1, xzr, sxtx]");
COMPARE_C64(ldr(c0, MemOperand(c1, x2)), "ldr c0, [c1, x2]");
COMPARE_C64(ldr(c0, MemOperand(c1, x2, LSL, 4)), "ldr c0, [c1, x2, lsl #4]");
// The generic (CPURegister) API calls the same helper.
COMPARE_C64(ldr(CPURegister(c0), MemOperand(c1, w2, UXTW, 4)),
"ldr c0, [c1, w2, uxtw #4]");
COMPARE_C64(ldr(CPURegister(czr), MemOperand(c1, w2, SXTW)),
"ldr czr, [c1, w2, sxtw]");
}
TEST(morello_c64_ldr_c_macro) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, 0, PostIndex)), "ldr c0, [c1], #0");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, -4096, PostIndex)),
"ldr c0, [c1], #-4096");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, 4080, PostIndex)),
"ldr c0, [c1], #4080");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1)), "ldr c0, [c1]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, 65520)), "ldr c0, [c1, #65520]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, 0, PreIndex)), "ldr c0, [c1, #0]!");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, -4096, PreIndex)),
"ldr c0, [c1, #-4096]!");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, 4080, PreIndex)),
"ldr c0, [c1, #4080]!");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, w2, SXTW, 4)),
"ldr c0, [c1, w2, sxtw #4]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, x2)), "ldr c0, [c1, x2]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, -16)), "ldur c0, [c1, #-16]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, -256)), "ldur c0, [c1, #-256]");
COMPARE_MACRO_C64(Ldr(czr, MemOperand(c1, 255)), "ldur czr, [c1, #255]");
// Unencodable cases.
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, 0x4242)),
"mov x16, #0x4242\n"
"add c16, c1, x16, uxtx\n"
"ldr c0, [c16]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, 0x4242, PreIndex)),
"mov x16, #0x4242\n"
"add c1, c1, x16, uxtx\n"
"ldr c0, [c1]");
COMPARE_MACRO_C64(Ldr(c0, MemOperand(c1, 0x4242, PostIndex)),
"ldr c0, [c1]\n"
"mov x16, #0x4242\n"
"add c1, c1, x16, uxtx");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Ldr(CPURegister(c0), MemOperand(c1, 0, PostIndex)),
"ldr c0, [c1], #0");
}
TEST(morello_c64_ldxp_c_r_c) {
SETUP();
COMPARE_C64(ldxp(c0, c1, MemOperand(c2)), "ldxp c0, c1, [c2]");
COMPARE_C64(ldxp(c0, c1, MemOperand(csp)), "ldxp c0, c1, [csp]");
COMPARE_C64(ldxp(c0, czr, MemOperand(c2)), "ldxp c0, czr, [c2]");
COMPARE_C64(ldxp(czr, c1, MemOperand(c2)), "ldxp czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldxp(c30, c29, MemOperand(c28)), "ldxp c30, c29, [c28]");
COMPARE_MACRO_C64(Ldxp(c30, czr, MemOperand(csp)), "ldxp c30, czr, [csp]");
}
TEST(morello_c64_ldxr_c_r_c) {
SETUP();
COMPARE_C64(ldxr(c0, MemOperand(c1)), "ldxr c0, [c1]");
COMPARE_C64(ldxr(c0, MemOperand(csp)), "ldxr c0, [csp]");
COMPARE_C64(ldxr(czr, MemOperand(c1)), "ldxr czr, [c1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Ldxr(c30, MemOperand(c29)), "ldxr c30, [c29]");
COMPARE_MACRO_C64(Ldxr(czr, MemOperand(csp)), "ldxr czr, [csp]");
}
TEST(morello_c64_ret_default) {
SETUP();
// `ret()` defaults to `ret(lr)` in A64, but we disassemble this as `ret`.
COMPARE_C64(ret(), "ret c30");
COMPARE_MACRO_C64(Ret(), "ret c30");
// Check that we disassemble `ret(lr)` and `ret(clr)` unambiguously regardless
// of the ISA.
COMPARE_C64(dci(RET | Assembler::Rn(lr)), "ret x30");
COMPARE_C64(dci(RET_c | Assembler::Rn(clr)), "ret c30");
}
TEST(morello_c64_stlr_c_r_c) {
SETUP();
COMPARE_C64(stlr(c0, MemOperand(c1)), "stlr c0, [c1]");
COMPARE_C64(stlr(c0, MemOperand(csp)), "stlr c0, [csp]");
COMPARE_C64(stlr(czr, MemOperand(c1)), "stlr czr, [c1]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Stlr(c30, MemOperand(c29)), "stlr c30, [c29]");
COMPARE_MACRO_C64(Stlr(czr, MemOperand(csp)), "stlr czr, [csp]");
}
TEST(morello_c64_stlxp_r_cr_c) {
SETUP();
COMPARE_C64(stlxp(w0, c1, c2, MemOperand(c3)), "stlxp w0, c1, c2, [c3]");
COMPARE_C64(stlxp(w0, c1, c2, MemOperand(csp)), "stlxp w0, c1, c2, [csp]");
COMPARE_C64(stlxp(w0, c1, czr, MemOperand(c3)), "stlxp w0, c1, czr, [c3]");
COMPARE_C64(stlxp(w0, czr, c2, MemOperand(c3)), "stlxp w0, czr, c2, [c3]");
COMPARE_C64(stlxp(wzr, c1, c2, MemOperand(c3)), "stlxp wzr, c1, c2, [c3]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Stlxp(w30, c29, c28, MemOperand(c27)),
"stlxp w30, c29, c28, [c27]");
COMPARE_MACRO_C64(Stlxp(w30, c29, czr, MemOperand(csp)),
"stlxp w30, c29, czr, [csp]");
}
TEST(morello_c64_stlxr_r_cr_c) {
SETUP();
COMPARE_C64(stlxr(w0, c1, MemOperand(c2)), "stlxr w0, c1, [c2]");
COMPARE_C64(stlxr(w0, c1, MemOperand(csp)), "stlxr w0, c1, [csp]");
COMPARE_C64(stlxr(w0, czr, MemOperand(c2)), "stlxr w0, czr, [c2]");
COMPARE_C64(stlxr(wzr, c1, MemOperand(c2)), "stlxr wzr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Stlxr(w30, c29, MemOperand(c28)), "stlxr w30, c29, [c28]");
COMPARE_MACRO_C64(Stlxr(wzr, czr, MemOperand(csp)), "stlxr wzr, czr, [csp]");
}
TEST(morello_c64_stnp_c_rib_c) {
SETUP();
COMPARE_C64(stnp(c0, c1, MemOperand(c2, 272)), "stnp c0, c1, [c2, #272]");
COMPARE_C64(stnp(c0, c1, MemOperand(csp, 272)), "stnp c0, c1, [csp, #272]");
COMPARE_C64(stnp(c0, czr, MemOperand(c2, 272)), "stnp c0, czr, [c2, #272]");
COMPARE_C64(stnp(czr, c1, MemOperand(c2, 272)), "stnp czr, c1, [c2, #272]");
COMPARE_C64(stnp(c0, c1, MemOperand(c2, 0)), "stnp c0, c1, [c2]");
COMPARE_C64(stnp(c0, c1, MemOperand(c2, -1024)), "stnp c0, c1, [c2, #-1024]");
COMPARE_C64(stnp(c0, c1, MemOperand(c2, 1008)), "stnp c0, c1, [c2, #1008]");
}
TEST(morello_c64_stnp_c_macro) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Stnp(c0, c1, MemOperand(c2)), "stnp c0, c1, [c2]");
COMPARE_MACRO_C64(Stnp(c0, c1, MemOperand(c2, 1008)),
"stnp c0, c1, [c2, #1008]");
COMPARE_MACRO_C64(Stnp(c0, c1, MemOperand(c2, -1024)),
"stnp c0, c1, [c2, #-1024]");
COMPARE_MACRO_C64(Stnp(czr, c30, MemOperand(csp)), "stnp czr, c30, [csp]");
COMPARE_MACRO_C64(Stnp(c30, czr, MemOperand(csp)), "stnp c30, czr, [csp]");
// Unencodable cases.
COMPARE_MACRO_C64(Stnp(c0, c1, MemOperand(c2, 0x4242)),
"mov x16, #0x4242\n"
"add c16, c2, x16, uxtx\n"
"stnp c0, c1, [c16]");
// There are no addressing modes other than immediate offset.
COMPARE_MACRO_C64(Stnp(c0, c1, MemOperand(c2, x3)),
"add c16, c2, x3, uxtx\n"
"stnp c0, c1, [c16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Stnp(CPURegister(c0), CPURegister(c1), MemOperand(c2)),
"stnp c0, c1, [c2]");
}
TEST(morello_c64_stp_c_rib_c) {
SETUP();
COMPARE_C64(stp(c0, c1, MemOperand(c2, 272)), "stp c0, c1, [c2, #272]");
COMPARE_C64(stp(c0, c1, MemOperand(csp, 272)), "stp c0, c1, [csp, #272]");
COMPARE_C64(stp(c0, czr, MemOperand(c2, 272)), "stp c0, czr, [c2, #272]");
COMPARE_C64(stp(czr, c1, MemOperand(c2, 272)), "stp czr, c1, [c2, #272]");
COMPARE_C64(stp(c0, c1, MemOperand(c2, 0)), "stp c0, c1, [c2]");
COMPARE_C64(stp(c0, c1, MemOperand(c2, -1024)), "stp c0, c1, [c2, #-1024]");
COMPARE_C64(stp(c0, c1, MemOperand(c2, 1008)), "stp c0, c1, [c2, #1008]");
}
TEST(morello_c64_stp_c_ribw_c) {
SETUP();
COMPARE_C64(stp(c0, c1, MemOperand(c2, 272, PreIndex)),
"stp c0, c1, [c2, #272]!");
COMPARE_C64(stp(c0, c1, MemOperand(csp, 272, PreIndex)),
"stp c0, c1, [csp, #272]!");
COMPARE_C64(stp(c0, czr, MemOperand(c2, 272, PreIndex)),
"stp c0, czr, [c2, #272]!");
COMPARE_C64(stp(czr, c1, MemOperand(c2, 272, PreIndex)),
"stp czr, c1, [c2, #272]!");
COMPARE_C64(stp(c0, c1, MemOperand(c2, 0, PreIndex)),
"stp c0, c1, [c2, #0]!");
COMPARE_C64(stp(c0, c1, MemOperand(c2, -1024, PreIndex)),
"stp c0, c1, [c2, #-1024]!");
COMPARE_C64(stp(c0, c1, MemOperand(c2, 1008, PreIndex)),
"stp c0, c1, [c2, #1008]!");
}
TEST(morello_c64_stp_cc_riaw_c) {
SETUP();
COMPARE_C64(stp(c0, c1, MemOperand(c2, 272, PostIndex)),
"stp c0, c1, [c2], #272");
COMPARE_C64(stp(c0, c1, MemOperand(csp, 272, PostIndex)),
"stp c0, c1, [csp], #272");
COMPARE_C64(stp(c0, czr, MemOperand(c2, 272, PostIndex)),
"stp c0, czr, [c2], #272");
COMPARE_C64(stp(czr, c1, MemOperand(c2, 272, PostIndex)),
"stp czr, c1, [c2], #272");
COMPARE_C64(stp(c0, c1, MemOperand(c2, 0, PostIndex)),
"stp c0, c1, [c2], #0");
COMPARE_C64(stp(c0, c1, MemOperand(c2, -1024, PostIndex)),
"stp c0, c1, [c2], #-1024");
COMPARE_C64(stp(c0, c1, MemOperand(c2, 1008, PostIndex)),
"stp c0, c1, [c2], #1008");
}
TEST(morello_c64_stp_c_macro) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2)), "stp c0, c1, [c2]");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, 1008)),
"stp c0, c1, [c2, #1008]");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, -1024)),
"stp c0, c1, [c2, #-1024]");
COMPARE_MACRO_C64(Stp(czr, c30, MemOperand(csp)), "stp czr, c30, [csp]");
COMPARE_MACRO_C64(Stp(c30, czr, MemOperand(csp)), "stp c30, czr, [csp]");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, 0, PostIndex)),
"stp c0, c1, [c2], #0");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, -1024, PostIndex)),
"stp c0, c1, [c2], #-1024");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, 1008, PostIndex)),
"stp c0, c1, [c2], #1008");
COMPARE_MACRO_C64(Stp(czr, c30, MemOperand(csp, 0, PostIndex)),
"stp czr, c30, [csp], #0");
COMPARE_MACRO_C64(Stp(c30, czr, MemOperand(csp, 0, PostIndex)),
"stp c30, czr, [csp], #0");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, 0, PreIndex)),
"stp c0, c1, [c2, #0]!");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, -1024, PreIndex)),
"stp c0, c1, [c2, #-1024]!");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, 1008, PreIndex)),
"stp c0, c1, [c2, #1008]!");
COMPARE_MACRO_C64(Stp(czr, c30, MemOperand(csp, 0, PreIndex)),
"stp czr, c30, [csp, #0]!");
COMPARE_MACRO_C64(Stp(c30, czr, MemOperand(csp, 0, PreIndex)),
"stp c30, czr, [csp, #0]!");
// Unencodable cases.
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, 0x4242)),
"mov x16, #0x4242\n"
"add c16, c2, x16, uxtx\n"
"stp c0, c1, [c16]");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, 0x4242, PreIndex)),
"mov x16, #0x4242\n"
"add c2, c2, x16, uxtx\n"
"stp c0, c1, [c2]");
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, 0x4242, PostIndex)),
"stp c0, c1, [c2]\n"
"mov x16, #0x4242\n"
"add c2, c2, x16, uxtx");
// There is no register-offset mode.
COMPARE_MACRO_C64(Stp(c0, c1, MemOperand(c2, x3)),
"add c16, c2, x3, uxtx\n"
"stp c0, c1, [c16]");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Stp(CPURegister(c0),
CPURegister(c1),
MemOperand(c2, 0, PostIndex)),
"stp c0, c1, [c2], #0");
}
TEST(morello_c64_str_c_riaw_c) {
SETUP();
COMPARE_C64(str(c0, MemOperand(c1, 0, PostIndex)), "str c0, [c1], #0");
COMPARE_C64(str(c0, MemOperand(c1, 672, PostIndex)), "str c0, [c1], #672");
COMPARE_C64(str(c0, MemOperand(csp, 672, PostIndex)), "str c0, [csp], #672");
COMPARE_C64(str(czr, MemOperand(c1, 672, PostIndex)), "str czr, [c1], #672");
COMPARE_C64(str(c0, MemOperand(c1, -4096, PostIndex)),
"str c0, [c1], #-4096");
COMPARE_C64(str(c0, MemOperand(c1, 4080, PostIndex)), "str c0, [c1], #4080");
// The generic (CPURegister) API calls the same helper.
COMPARE_C64(str(CPURegister(c0), MemOperand(c1, 0, PostIndex)),
"str c0, [c1], #0");
COMPARE_C64(str(CPURegister(czr), MemOperand(c1, 672, PostIndex)),
"str czr, [c1], #672");
}
TEST(morello_c64_str_c_rib_c) {
SETUP();
// Direct encodings.
COMPARE_C64(str(c0, MemOperand(c1)), "str c0, [c1]");
COMPARE_C64(str(c0, MemOperand(c1, 6928)), "str c0, [c1, #6928]");
COMPARE_C64(str(c0, MemOperand(csp, 6928)), "str c0, [csp, #6928]");
COMPARE_C64(str(czr, MemOperand(c1, 6928)), "str czr, [c1, #6928]");
COMPARE_C64(str(c0, MemOperand(c1, 65520)), "str c0, [c1, #65520]");
// `stur` can assemble to `str`, according to its LoadStoreScalingOption.
COMPARE_C64(stur(c0, MemOperand(c1, 256)), "str c0, [c1, #256]");
COMPARE_C64(stur(c0, MemOperand(c1, 65520)), "str c0, [c1, #65520]");
// The generic (CPURegister) API calls the same helper.
COMPARE_C64(str(CPURegister(c0), MemOperand(c1)), "str c0, [c1]");
COMPARE_C64(str(CPURegister(czr), MemOperand(c1, 6928)),
"str czr, [c1, #6928]");
}
TEST(morello_c64_str_c_ribw_c) {
SETUP();
COMPARE_C64(str(c0, MemOperand(c1, 0, PreIndex)), "str c0, [c1, #0]!");
COMPARE_C64(str(c0, MemOperand(c1, 672, PreIndex)), "str c0, [c1, #672]!");
COMPARE_C64(str(c0, MemOperand(csp, 672, PreIndex)), "str c0, [csp, #672]!");
COMPARE_C64(str(czr, MemOperand(c1, 672, PreIndex)), "str czr, [c1, #672]!");
COMPARE_C64(str(c0, MemOperand(c1, -4096, PreIndex)),
"str c0, [c1, #-4096]!");
COMPARE_C64(str(c0, MemOperand(c1, 4080, PreIndex)), "str c0, [c1, #4080]!");
// The generic (CPURegister) API calls the same helper.
COMPARE_C64(str(CPURegister(c0), MemOperand(c1, 0, PreIndex)),
"str c0, [c1, #0]!");
COMPARE_C64(str(CPURegister(czr), MemOperand(c1, 672, PreIndex)),
"str czr, [c1, #672]!");
}
TEST(morello_c64_str_c_rrb_c) {
SETUP();
COMPARE_C64(str(c0, MemOperand(c1, w2, UXTW, 4)),
"str c0, [c1, w2, uxtw #4]");
COMPARE_C64(str(c0, MemOperand(c1, w2, SXTW)), "str c0, [c1, w2, sxtw]");
COMPARE_C64(str(c0, MemOperand(c1, wzr, SXTW)), "str c0, [c1, wzr, sxtw]");
COMPARE_C64(str(c0, MemOperand(csp, w2, SXTW)), "str c0, [csp, w2, sxtw]");
COMPARE_C64(str(czr, MemOperand(c1, w2, SXTW)), "str czr, [c1, w2, sxtw]");
COMPARE_C64(str(c0, MemOperand(c1, x2, SXTX)), "str c0, [c1, x2, sxtx]");
COMPARE_C64(str(c0, MemOperand(c1, xzr, SXTX)), "str c0, [c1, xzr, sxtx]");
COMPARE_C64(str(c0, MemOperand(c1, x2)), "str c0, [c1, x2]");
COMPARE_C64(str(c0, MemOperand(c1, x2, LSL, 4)), "str c0, [c1, x2, lsl #4]");
// The generic (CPURegister) API calls the same helper.
COMPARE_C64(str(CPURegister(c0), MemOperand(c1, w2, UXTW, 4)),
"str c0, [c1, w2, uxtw #4]");
COMPARE_C64(str(CPURegister(czr), MemOperand(c1, w2, SXTW)),
"str czr, [c1, w2, sxtw]");
}
TEST(morello_c64_str_c_macro) {
SETUP();
// Encodable cases.
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, 0, PostIndex)), "str c0, [c1], #0");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, -4096, PostIndex)),
"str c0, [c1], #-4096");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, 4080, PostIndex)),
"str c0, [c1], #4080");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1)), "str c0, [c1]");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, 65520)), "str c0, [c1, #65520]");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, 0, PreIndex)), "str c0, [c1, #0]!");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, -4096, PreIndex)),
"str c0, [c1, #-4096]!");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, 4080, PreIndex)),
"str c0, [c1, #4080]!");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, w2, SXTW, 4)),
"str c0, [c1, w2, sxtw #4]");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, x2)), "str c0, [c1, x2]");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, -16)), "stur c0, [c1, #-16]");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, -256)), "stur c0, [c1, #-256]");
COMPARE_MACRO_C64(Str(czr, MemOperand(c1, 255)), "stur czr, [c1, #255]");
// Unencodable cases.
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, 0x4242)),
"mov x16, #0x4242\n"
"add c16, c1, x16, uxtx\n"
"str c0, [c16]");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, 0x4242, PreIndex)),
"mov x16, #0x4242\n"
"add c1, c1, x16, uxtx\n"
"str c0, [c1]");
COMPARE_MACRO_C64(Str(c0, MemOperand(c1, 0x4242, PostIndex)),
"str c0, [c1]\n"
"mov x16, #0x4242\n"
"add c1, c1, x16, uxtx");
// A generic CPURegister produces the same result.
COMPARE_MACRO_C64(Str(CPURegister(c0), MemOperand(c1, 0, PostIndex)),
"str c0, [c1], #0");
}
TEST(morello_c64_stxp_r_cr_c) {
SETUP();
COMPARE_C64(stxp(w0, c1, c2, MemOperand(c3)), "stxp w0, c1, c2, [c3]");
COMPARE_C64(stxp(w0, c1, c2, MemOperand(csp)), "stxp w0, c1, c2, [csp]");
COMPARE_C64(stxp(w0, c1, czr, MemOperand(c3)), "stxp w0, c1, czr, [c3]");
COMPARE_C64(stxp(w0, czr, c2, MemOperand(c3)), "stxp w0, czr, c2, [c3]");
COMPARE_C64(stxp(wzr, c1, c2, MemOperand(c3)), "stxp wzr, c1, c2, [c3]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Stxp(w30, c29, c28, MemOperand(c27)),
"stxp w30, c29, c28, [c27]");
COMPARE_MACRO_C64(Stxp(w30, c29, czr, MemOperand(csp)),
"stxp w30, c29, czr, [csp]");
}
TEST(morello_c64_stxr_r_cr_c) {
SETUP();
COMPARE_C64(stxr(w0, c1, MemOperand(c2)), "stxr w0, c1, [c2]");
COMPARE_C64(stxr(w0, c1, MemOperand(csp)), "stxr w0, c1, [csp]");
COMPARE_C64(stxr(w0, czr, MemOperand(c2)), "stxr w0, czr, [c2]");
COMPARE_C64(stxr(wzr, c1, MemOperand(c2)), "stxr wzr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Stxr(w30, c29, MemOperand(c28)), "stxr w30, c29, [c28]");
COMPARE_MACRO_C64(Stxr(wzr, czr, MemOperand(csp)), "stxr wzr, czr, [csp]");
}
TEST(morello_c64_swp_cc_r_c) {
SETUP();
COMPARE_C64(swp(c0, c1, MemOperand(c2)), "swp c0, c1, [c2]");
COMPARE_C64(swp(c0, c1, MemOperand(csp)), "swp c0, c1, [csp]");
COMPARE_C64(swp(c0, czr, MemOperand(c2)), "swp c0, czr, [c2]");
COMPARE_C64(swp(czr, c1, MemOperand(c2)), "swp czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Swp(c30, c29, MemOperand(c28)), "swp c30, c29, [c28]");
COMPARE_MACRO_C64(Swp(c30, czr, MemOperand(csp)), "swp c30, czr, [csp]");
}
TEST(morello_c64_swpa_cc_r_c) {
SETUP();
COMPARE_C64(swpa(c0, c1, MemOperand(c2)), "swpa c0, c1, [c2]");
COMPARE_C64(swpa(c0, c1, MemOperand(csp)), "swpa c0, c1, [csp]");
COMPARE_C64(swpa(c0, czr, MemOperand(c2)), "swpa c0, czr, [c2]");
COMPARE_C64(swpa(czr, c1, MemOperand(c2)), "swpa czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Swpa(c30, c29, MemOperand(c28)), "swpa c30, c29, [c28]");
COMPARE_MACRO_C64(Swpa(c30, czr, MemOperand(csp)), "swpa c30, czr, [csp]");
}
TEST(morello_c64_swpal_cc_r_c) {
SETUP();
COMPARE_C64(swpal(c0, c1, MemOperand(c2)), "swpal c0, c1, [c2]");
COMPARE_C64(swpal(c0, c1, MemOperand(csp)), "swpal c0, c1, [csp]");
COMPARE_C64(swpal(c0, czr, MemOperand(c2)), "swpal c0, czr, [c2]");
COMPARE_C64(swpal(czr, c1, MemOperand(c2)), "swpal czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Swpal(c30, c29, MemOperand(c28)), "swpal c30, c29, [c28]");
COMPARE_MACRO_C64(Swpal(c30, czr, MemOperand(csp)), "swpal c30, czr, [csp]");
}
TEST(morello_c64_swpl_cc_r_c) {
SETUP();
COMPARE_C64(swpl(c0, c1, MemOperand(c2)), "swpl c0, c1, [c2]");
COMPARE_C64(swpl(c0, c1, MemOperand(csp)), "swpl c0, c1, [csp]");
COMPARE_C64(swpl(c0, czr, MemOperand(c2)), "swpl c0, czr, [c2]");
COMPARE_C64(swpl(czr, c1, MemOperand(c2)), "swpl czr, c1, [c2]");
// The MacroAssembler is a simple pass-through.
COMPARE_MACRO_C64(Swpl(c30, c29, MemOperand(c28)), "swpl c30, c29, [c28]");
COMPARE_MACRO_C64(Swpl(c30, czr, MemOperand(csp)), "swpl c30, czr, [csp]");
}
} // namespace aarch64
} // namespace vixl
| 41.687149
| 80
| 0.60117
|
capablevms
|
56464054c5a2a8ec94faac8484921f56cff92f5f
| 153
|
cpp
|
C++
|
test/shared/class.cpp
|
PredatorCZ/PreCore
|
98f5896e35371d034e6477dd0ce9edeb4fd8d814
|
[
"Apache-2.0"
] | 5
|
2019-10-17T15:52:38.000Z
|
2021-08-10T18:57:32.000Z
|
test/shared/class.cpp
|
PredatorCZ/PreCore
|
98f5896e35371d034e6477dd0ce9edeb4fd8d814
|
[
"Apache-2.0"
] | null | null | null |
test/shared/class.cpp
|
PredatorCZ/PreCore
|
98f5896e35371d034e6477dd0ce9edeb4fd8d814
|
[
"Apache-2.0"
] | 1
|
2021-01-31T20:37:42.000Z
|
2021-01-31T20:37:42.000Z
|
#include "datas/reflector.hpp"
struct SimpleStruct {
uint32 field0;
uint32 field1;
};
REFLECT(CLASS(SimpleStruct), MEMBER(field0), MEMBER(field1))
| 17
| 60
| 0.745098
|
PredatorCZ
|
5646ff388563153ca3d87ad144efdcd5eb8e7d15
| 2,323
|
cpp
|
C++
|
3. Red/1 Week/8. Deque/deque.cpp
|
freeraisor/yandexcplusplus
|
9708fdb6cd7e039672ebc2e77f131fbc7a765750
|
[
"MIT"
] | 14
|
2019-08-29T12:34:07.000Z
|
2022-03-09T13:31:18.000Z
|
3. Red/1 Week/8. Deque/deque.cpp
|
freeraisor/yandexcplusplus
|
9708fdb6cd7e039672ebc2e77f131fbc7a765750
|
[
"MIT"
] | null | null | null |
3. Red/1 Week/8. Deque/deque.cpp
|
freeraisor/yandexcplusplus
|
9708fdb6cd7e039672ebc2e77f131fbc7a765750
|
[
"MIT"
] | 8
|
2020-09-10T11:40:03.000Z
|
2022-03-24T00:34:38.000Z
|
//
// Created by ilya on 27.09.2019.
//
#include <vector>
#include <stdexcept>
#include <iostream>
#include <sstream>
#define LOG(name) \
//std::cerr << #name << std::endl
template <typename T>
class Deque {
public:
Deque() = default;
bool Empty() const {
LOG(empty);
return front_.empty() && back_.empty();
}
size_t Size() const {
LOG(size);
return front_.size() + back_.size();
}
T& operator[](size_t idx) {
LOG(op);
if (idx >= front_.size()) {
idx -= front_.size();
return back_[idx];
}
else {
return front_[front_.size() - 1 - idx];
}
}
const T& operator[](size_t idx) const {
LOG(opcon);
if (idx >= front_.size()) {
idx %= front_.size();
return back_[idx];
}
else {
return front_[front_.size() - 1 - idx];
}
}
T& At(size_t idx) {
LOG(at);
if (idx >= (front_.size() + back_.size())) {
throw std::out_of_range("");
}
else {
return this->operator[](idx);
}
}
const T& At(size_t idx) const {
LOG(atconst);
if (idx >= (front_.size() + back_.size())) {
throw std::out_of_range("");
}
else {
return this->operator[](idx);
}
}
T& Front() {
LOG(front);
if (front_.empty()) {
return back_.front();
}
else {
return front_.back();
}
}
const T& Front() const {
LOG(frontconst);
if (front_.empty()) {
return back_.front();
}
else {
return front_.back();
}
}
T& Back() {
LOG(back);
if (back_.empty()) {
return front_.front();
}
else {
return back_.back();
}
}
const T& Back() const {
LOG(backconst);
if (back_.empty()) {
return front_.front();
}
else {
return back_.back();
}
}
void PushFront(const T& obj) {
LOG(pushf);
front_.push_back(obj);
}
void PushBack(const T& obj) {
LOG(pushb);
back_.push_back(obj);
}
private:
std::vector<T> front_;
std::vector<T> back_;
};
#define PRINT(x) std::cout << x << std::endl
int main() {
Deque<int> d;
d.PushBack(1);
d.PushBack(2);
d.PushBack(3);
d.PushFront(4);
d.PushFront(5);
PRINT(d.Front());
PRINT(d.Back());
PRINT("--");
PRINT(d[0]);
PRINT(d[1]);
PRINT(d[2]);
PRINT(d[3]);
PRINT(d[4]);
}
| 16.475177
| 48
| 0.519587
|
freeraisor
|
8722f4049c4041e0e63d11533b0c0cd6d3f6602f
| 10,558
|
cpp
|
C++
|
GenerateTypedPropertyEnums.cpp
|
ChristophHaag/steamvr-plugin-loader
|
72ed904b1c0fa03f7d5b1e872e883fa511d700a4
|
[
"Apache-2.0"
] | null | null | null |
GenerateTypedPropertyEnums.cpp
|
ChristophHaag/steamvr-plugin-loader
|
72ed904b1c0fa03f7d5b1e872e883fa511d700a4
|
[
"Apache-2.0"
] | null | null | null |
GenerateTypedPropertyEnums.cpp
|
ChristophHaag/steamvr-plugin-loader
|
72ed904b1c0fa03f7d5b1e872e883fa511d700a4
|
[
"Apache-2.0"
] | null | null | null |
/** @file
@brief Implementation
@date 2016
@author
Sensics, Inc.
<http://sensics.com/osvr>
*/
// Copyright 2016 Razer, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Internal Includes
// - none
// Library/third-party includes
#include <boost/range/adaptor/reversed.hpp>
#include <json/reader.h>
#include <json/value.h>
#include <osvr/Util/UniqueContainer.h>
// Standard includes
#include <fstream>
#include <iostream>
#include <map>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <vector>
static const auto indent = " ";
static const auto outFilename = "PropertyTraits.h";
static const auto startOfOutput = R"(/** @file
@brief Header - partially generated from parsing openvr_api.json
@date 2016
@author
Sensics, Inc.
<http://sensics.com/osvr>
*/
/*
Copyright 2016 Razer Inc.
SPDX-License-Identifier: BSD-3-Clause
OpenVR input data:
Copyright (c) 2015, Valve Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
*/
#ifndef INCLUDED_PropertyTraits_h_GUID_6CC473E5_C8B9_46B7_237B_1E0C08E91076
#define INCLUDED_PropertyTraits_h_GUID_6CC473E5_C8B9_46B7_237B_1E0C08E91076
#ifndef _INCLUDE_VRTYPES_H
#error "Please include exactly one of openvr.h or openvr_driver.h before including this file"
#endif
#include <cstddef>
#include <string>
namespace osvr {
namespace vive {
)";
static const auto endOfOutput = R"(
} // namespace vive
} // namespace osvr
#endif // INCLUDED_PropertyTraits_h_GUID_6CC473E5_C8B9_46B7_237B_1E0C08E91076
)";
inline bool shouldIgnoreType(std::string const &t) {
return t == "Start" ||
t == "End"; // ignore the sentinels that look like types.
}
std::vector<std::pair<std::string, std::string>> g_fullNameToTypeSuffix;
std::vector<std::pair<std::string, std::string>> g_cleanNameToFullName;
std::map<std::string, std::string> g_typeSuffixToTypename = {
{"String", "std::string"}, {"Bool", "bool"},
{"Float", "float"}, {"Matrix34", "vr::HmdMatrix34_t"},
{"Uint64", "uint64_t"}, {"Int32", "int32_t"},
{"Binary", "void *"}};
std::set<std::string> g_ambiguousNames;
osvr::util::UniqueContainer<std::vector<std::string>> g_typeSuffixes;
osvr::util::UniqueContainer<std::vector<std::string>> g_cleanNames;
inline std::string getTypenameForTypeSuffix(std::string const &suffix) {
auto it = g_typeSuffixToTypename.find(suffix);
if (end(g_typeSuffixToTypename) == it) {
throw std::logic_error("Missing mapping for suffix " + suffix);
}
return it->second;
}
/// Structure that decomposes a full name of an enum value into a clean name and
/// a type suffix.
struct NameDecomp {
explicit NameDecomp(std::string const &name) {
static const auto fullDecomposeRegex =
std::regex{"^Prop_(.*)_([^_]*)$"};
std::regex_search(name, m, fullDecomposeRegex);
cleanName = m[1];
typeSuffix = m[2];
}
std::smatch m;
std::ssub_match cleanName;
std::ssub_match typeSuffix;
};
/// Helper function that uses a simpler regex to just extract the type suffix,
/// when that's all you want.
inline std::string getTypeSuffix(std::string const &name) {
static const auto valTypeRegex = std::regex{"_([^_]*)$"};
std::smatch m;
std::regex_search(name, m, valTypeRegex);
return m[1];
}
bool processEnumValues(Json::Value const &values, std::ostream &output) {
std::vector<std::string> names;
for (auto &enumVal : values) {
auto name = enumVal["name"].asString();
auto d = NameDecomp{name};
if (shouldIgnoreType(d.typeSuffix) || (d.typeSuffix.length() == 0)) {
continue;
}
names.push_back(name);
#if 0
std::cout << "Name: " << name << " Clean name: " << d.cleanName << " Value type: " << d.typeSuffix << std::endl;
#endif
if (g_cleanNames.contains(d.cleanName)) {
std::cerr << "Ambiguous clean name found! " << d.cleanName
<< " (second type was " << d.typeSuffix << ")"
<< std::endl;
g_ambiguousNames.insert(d.cleanName);
} else {
g_cleanNames.insert(d.cleanName);
}
g_typeSuffixes.insert(d.typeSuffix);
g_fullNameToTypeSuffix.emplace_back(name, d.typeSuffix);
}
bool success = true;
/// OK, so that was the first pass through the list. Quick safety check.
for (auto &suffix : g_typeSuffixes.container()) {
if (end(g_typeSuffixToTypename) ==
g_typeSuffixToTypename.find(suffix)) {
std::cerr << "Type suffix found in the data file that's not "
"accounted for in the application: "
<< suffix << std::endl;
std::cerr << "Tool must be updated to add a mapping to "
"g_typeSuffixToTypename for this type suffix!"
<< std::endl;
success = false;
}
}
if (!success) {
return success;
}
/// Second pass: output the shortcut enum class for everything but the
/// ambiguous
/// names.
{
std::vector<std::string> lines;
for (auto &name : names) {
std::ostringstream os;
auto d = NameDecomp{name};
auto isAmbiguous =
(end(g_ambiguousNames) != g_ambiguousNames.find(d.cleanName));
if (isAmbiguous) {
os << "// shortcut omitted due to ambiguity for " << name;
} else {
os << d.cleanName << " = vr::" << name << ",";
}
lines.emplace_back(os.str());
}
// take the comma off the last actual entry.
for (auto &line : boost::adaptors::reverse(lines)) {
if (line.front() == '/') {
continue;
}
if (line.back() == ',') {
// should always be true if we get here!
line.pop_back();
break;
}
throw std::logic_error(
"Found a non-comment line that didn't end in a comma!");
}
output << "enum class Props {" << std::endl;
for (auto &line : lines) {
output << indent << line << std::endl;
}
output << "};" << std::endl;
}
/// Third pass: output the traits class specializations to associate types
/// with each property enum.
output << "namespace detail {" << std::endl;
output << indent
<< "template<std::size_t EnumVal> struct PropertyTypeTrait;"
<< std::endl;
output << indent << "template<std::size_t EnumVal> using PropertyType = "
"typename PropertyTypeTrait<EnumVal>::type;"
<< std::endl;
for (auto &name : names) {
auto enumTypename = getTypenameForTypeSuffix(getTypeSuffix(name));
output << indent << "template<> struct PropertyTypeTrait<vr::" << name
<< "> { using type = " << enumTypename << "; };" << std::endl;
}
output << "} // namespace detail" << std::endl;
return success;
}
int main(int argc, char *argv[]) {
if (argc < 2) {
std::cout << "Must pass path to openvr_api.json as first argument!"
<< std::endl;
return -1;
}
Json::Value root;
{
std::ifstream is(argv[1]);
if (!is) {
std::cerr << "Could not open expected 'openvr_api.json' file at "
"provided path: "
<< argv[1] << std::endl;
return -1;
}
Json::Reader reader;
if (!reader.parse(is, root)) {
std::cerr << "Could not parse " << argv[1]
<< " as JSON: " << reader.getFormattedErrorMessages()
<< std::endl;
return -1;
}
}
std::ostringstream os;
auto &enums = root["enums"];
bool success = false;
for (auto const &enumObj : enums) {
if (enumObj["enumname"] == "vr::ETrackedDeviceProperty") {
success = processEnumValues(enumObj["values"], os);
break;
}
}
if (success) {
std::cout << "Succeeded in processing JSON: will now write file "
<< outFilename << std::endl;
std::ofstream of(outFilename);
if (!of) {
std::cerr << "Could not open file " << outFilename << std::endl;
return -1;
}
of << startOfOutput;
of << os.str();
of << endOfOutput;
of.close();
std::cout << "Done writing file!" << std::endl;
}
return success ? 0 : 1;
}
| 33.201258
| 120
| 0.615836
|
ChristophHaag
|
8728cc211da420fe04d229bf285637f73ab7ce87
| 1,386
|
cpp
|
C++
|
1742/5586185_AC_2032MS_19816K.cpp
|
vandreas19/POJ_sol
|
4895764ab800e8c2c4b2334a562dec2f07fa243e
|
[
"MIT"
] | 18
|
2017-08-14T07:34:42.000Z
|
2022-01-29T14:20:29.000Z
|
1742/5586185_AC_2032MS_19816K.cpp
|
pinepara/poj_solutions
|
4895764ab800e8c2c4b2334a562dec2f07fa243e
|
[
"MIT"
] | null | null | null |
1742/5586185_AC_2032MS_19816K.cpp
|
pinepara/poj_solutions
|
4895764ab800e8c2c4b2334a562dec2f07fa243e
|
[
"MIT"
] | 14
|
2016-12-21T23:37:22.000Z
|
2021-07-24T09:38:57.000Z
|
#include<cstdio>
#include<algorithm>
using namespace std;
const int COIN_CLASS_NUM_MAX=100,PRICE_RANGE_MAX=100000;
short remain[COIN_CLASS_NUM_MAX][PRICE_RANGE_MAX+1];
bool pay[PRICE_RANGE_MAX+1];
struct Coin{
int value,num;
};
Coin coins[COIN_CLASS_NUM_MAX];
bool CoinCompare(const Coin& left,const Coin& right){
return left.value*left.num<right.value*right.num;
}
int main(){
while(true){
int coinClassNum,priceRange;
scanf("%d%d",&coinClassNum,&priceRange);
if(coinClassNum==0 && priceRange==0)
break;
for(int i=0;i<coinClassNum;i++)
scanf("%d",&coins[i].value);
for(int i=0;i<coinClassNum;i++)
scanf("%d",&coins[i].num);
sort(coins,coins+coinClassNum,CoinCompare);
memset(remain,-1,sizeof(short)*coinClassNum*(PRICE_RANGE_MAX+1));
memset(pay,false,sizeof(bool)*(priceRange+1));
int priceMax=0,count=0;
for(int i=0;i<coinClassNum;i++){
remain[i][0]=coins[i].num;
int limit=min(priceMax+coins[i].value*coins[i].num,priceRange);
for(int price=1;price<=limit;price++){
if(pay[price])
remain[i][price]=coins[i].num;
else if(price>=coins[i].value && remain[i][price-coins[i].value]>0){
remain[i][price]=remain[i][price-coins[i].value]-1;
pay[price]=true;
count++;
if(priceMax<price)
priceMax=price;
}
}
}
printf("%d\n",count);
}
return 0;
}
| 27.176471
| 73
| 0.65368
|
vandreas19
|
872bbb6294723baaac3e078c7416ba11e0d3793b
| 911
|
cpp
|
C++
|
restresponse.cpp
|
mholyoak/SampleWeatherReport
|
0947f865efeff93fcee8abc88d307809a3ab5055
|
[
"MIT"
] | null | null | null |
restresponse.cpp
|
mholyoak/SampleWeatherReport
|
0947f865efeff93fcee8abc88d307809a3ab5055
|
[
"MIT"
] | null | null | null |
restresponse.cpp
|
mholyoak/SampleWeatherReport
|
0947f865efeff93fcee8abc88d307809a3ab5055
|
[
"MIT"
] | null | null | null |
#include "restresponse.h"
CRestResponse::CRestResponse()
{
}
CRestResponse::CRestResponse(bool success, int code, std::string body) :
_success(success),
_code(code),
_stringBody(body)
{
}
CRestResponse::CRestResponse(bool success, int code, BinaryData body) :
_success(success),
_code(code),
_binaryBody(body)
{
}
void CRestResponse::SetError(const char* errorMsg)
{
_success = false;
_errorMessage = errorMsg;
}
bool CRestResponse::RequestSuccess() const
{
return _success && _code == 200;
}
bool CRestResponse::Success() const
{
return _success;
}
int CRestResponse::GetCode() const
{
return _code;
}
std::string CRestResponse::GetStringBody() const
{
return _stringBody;
}
CRestResponse::BinaryData CRestResponse::GetBinaryBody() const
{
return _binaryBody;
}
std::string CRestResponse::GetErrorMessage() const
{
return _errorMessage;
}
| 14.934426
| 72
| 0.706915
|
mholyoak
|
8730baa767df6df918a8e5903197b5220ca84cc8
| 1,929
|
cpp
|
C++
|
Code/GUI/Memo.cpp
|
BomjSoft/BCL
|
f6863035d987b3fad184db8533d395d73beaf601
|
[
"MIT"
] | null | null | null |
Code/GUI/Memo.cpp
|
BomjSoft/BCL
|
f6863035d987b3fad184db8533d395d73beaf601
|
[
"MIT"
] | null | null | null |
Code/GUI/Memo.cpp
|
BomjSoft/BCL
|
f6863035d987b3fad184db8533d395d73beaf601
|
[
"MIT"
] | null | null | null |
//---------------------------------------------------------------------------
#include "Memo.h"
//---------------------------------------------------------------------------
namespace bcl {
//---------------------------------------------------------------------------
CMemo::CMemo() : CComponent()
{
readOnly = false;
}
//---------------------------------------------------------------------------
CMemo::~CMemo()
{
}
//---------------------------------------------------------------------------
void CMemo::CreateObject(HWND Parent, DWORD Id)
{
hwnd = CreateWindowEx(0, _T("edit"), caption, WS_CHILD | (visible?WS_VISIBLE:0) | WS_HSCROLL | WS_VSCROLL | WS_BORDER | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, left, top, width, height, Parent, HMENU(Id), GetModuleHandle(nullptr), nullptr);
created = true;
if (!enable)
{
SetEnable(false);
}
if (readOnly)
{
SendMessage(hwnd, EM_SETREADONLY, TRUE, 0);
}
}
//---------------------------------------------------------------------------
LRESULT CMemo::Message(UINT Type)
{
return 0;
}
//---------------------------------------------------------------------------
std::tstring CMemo::GetText()
{
int lineLength = SendMessage(hwnd, EM_GETLIMITTEXT, 0, 0);
TCHAR buffer[lineLength];
SendMessage(hwnd, WM_GETTEXT, lineLength, LPARAM(buffer));
return buffer;
}
//---------------------------------------------------------------------------
void CMemo::SetText(const TCHAR *Text)
{
SendMessage(hwnd, WM_SETTEXT, lstrlen(Text), LPARAM(Text));
}
//---------------------------------------------------------------------------
void CMemo::SetReadOnly(bool ReadOnly)
{
readOnly = ReadOnly;
if (created)
{
SendMessage(hwnd, EM_SETREADONLY, readOnly?TRUE:FALSE, 0);
}
}
//---------------------------------------------------------------------------
}
| 30.619048
| 252
| 0.378434
|
BomjSoft
|
87325b081c7667402448db6529bcae25e6ddd34c
| 7,724
|
cpp
|
C++
|
Source/Scripting/bsfScript/Generated/BsScriptCD6Joint.generated.cpp
|
bsf2dev/bsf
|
b318cd4eb1b0299773d625e6c870b8d503cf539e
|
[
"MIT"
] | 1,745
|
2018-03-16T02:10:28.000Z
|
2022-03-26T17:34:21.000Z
|
Source/Scripting/bsfScript/Generated/BsScriptCD6Joint.generated.cpp
|
bsf2dev/bsf
|
b318cd4eb1b0299773d625e6c870b8d503cf539e
|
[
"MIT"
] | 395
|
2018-03-16T10:18:20.000Z
|
2021-08-04T16:52:08.000Z
|
Source/Scripting/bsfScript/Generated/BsScriptCD6Joint.generated.cpp
|
bsf2dev/bsf
|
b318cd4eb1b0299773d625e6c870b8d503cf539e
|
[
"MIT"
] | 267
|
2018-03-17T19:32:54.000Z
|
2022-02-17T16:55:50.000Z
|
//********************************* bs::framework - Copyright 2018-2019 Marko Pintera ************************************//
//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
#include "BsScriptCD6Joint.generated.h"
#include "BsMonoMethod.h"
#include "BsMonoClass.h"
#include "BsMonoUtil.h"
#include "../../../Foundation/bsfCore/Components/BsCD6Joint.h"
#include "BsScriptD6JointDrive.generated.h"
#include "Wrappers/BsScriptVector.h"
#include "BsScriptLimitLinear.generated.h"
#include "BsScriptLimitAngularRange.generated.h"
#include "BsScriptLimitConeRange.generated.h"
#include "Wrappers/BsScriptQuaternion.h"
namespace bs
{
ScriptCD6Joint::ScriptCD6Joint(MonoObject* managedInstance, const GameObjectHandle<CD6Joint>& value)
:TScriptComponent(managedInstance, value)
{
}
void ScriptCD6Joint::initRuntimeData()
{
metaData.scriptClass->addInternalCall("Internal_getMotion", (void*)&ScriptCD6Joint::Internal_getMotion);
metaData.scriptClass->addInternalCall("Internal_setMotion", (void*)&ScriptCD6Joint::Internal_setMotion);
metaData.scriptClass->addInternalCall("Internal_getTwist", (void*)&ScriptCD6Joint::Internal_getTwist);
metaData.scriptClass->addInternalCall("Internal_getSwingY", (void*)&ScriptCD6Joint::Internal_getSwingY);
metaData.scriptClass->addInternalCall("Internal_getSwingZ", (void*)&ScriptCD6Joint::Internal_getSwingZ);
metaData.scriptClass->addInternalCall("Internal_getLimitLinear", (void*)&ScriptCD6Joint::Internal_getLimitLinear);
metaData.scriptClass->addInternalCall("Internal_setLimitLinear", (void*)&ScriptCD6Joint::Internal_setLimitLinear);
metaData.scriptClass->addInternalCall("Internal_getLimitTwist", (void*)&ScriptCD6Joint::Internal_getLimitTwist);
metaData.scriptClass->addInternalCall("Internal_setLimitTwist", (void*)&ScriptCD6Joint::Internal_setLimitTwist);
metaData.scriptClass->addInternalCall("Internal_getLimitSwing", (void*)&ScriptCD6Joint::Internal_getLimitSwing);
metaData.scriptClass->addInternalCall("Internal_setLimitSwing", (void*)&ScriptCD6Joint::Internal_setLimitSwing);
metaData.scriptClass->addInternalCall("Internal_getDrive", (void*)&ScriptCD6Joint::Internal_getDrive);
metaData.scriptClass->addInternalCall("Internal_setDrive", (void*)&ScriptCD6Joint::Internal_setDrive);
metaData.scriptClass->addInternalCall("Internal_getDrivePosition", (void*)&ScriptCD6Joint::Internal_getDrivePosition);
metaData.scriptClass->addInternalCall("Internal_getDriveRotation", (void*)&ScriptCD6Joint::Internal_getDriveRotation);
metaData.scriptClass->addInternalCall("Internal_setDriveTransform", (void*)&ScriptCD6Joint::Internal_setDriveTransform);
metaData.scriptClass->addInternalCall("Internal_getDriveLinearVelocity", (void*)&ScriptCD6Joint::Internal_getDriveLinearVelocity);
metaData.scriptClass->addInternalCall("Internal_getDriveAngularVelocity", (void*)&ScriptCD6Joint::Internal_getDriveAngularVelocity);
metaData.scriptClass->addInternalCall("Internal_setDriveVelocity", (void*)&ScriptCD6Joint::Internal_setDriveVelocity);
}
D6JointMotion ScriptCD6Joint::Internal_getMotion(ScriptCD6Joint* thisPtr, D6JointAxis axis)
{
D6JointMotion tmp__output;
tmp__output = thisPtr->getHandle()->getMotion(axis);
D6JointMotion __output;
__output = tmp__output;
return __output;
}
void ScriptCD6Joint::Internal_setMotion(ScriptCD6Joint* thisPtr, D6JointAxis axis, D6JointMotion motion)
{
thisPtr->getHandle()->setMotion(axis, motion);
}
void ScriptCD6Joint::Internal_getTwist(ScriptCD6Joint* thisPtr, Radian* __output)
{
Radian tmp__output;
tmp__output = thisPtr->getHandle()->getTwist();
*__output = tmp__output;
}
void ScriptCD6Joint::Internal_getSwingY(ScriptCD6Joint* thisPtr, Radian* __output)
{
Radian tmp__output;
tmp__output = thisPtr->getHandle()->getSwingY();
*__output = tmp__output;
}
void ScriptCD6Joint::Internal_getSwingZ(ScriptCD6Joint* thisPtr, Radian* __output)
{
Radian tmp__output;
tmp__output = thisPtr->getHandle()->getSwingZ();
*__output = tmp__output;
}
void ScriptCD6Joint::Internal_getLimitLinear(ScriptCD6Joint* thisPtr, __LimitLinearInterop* __output)
{
LimitLinear tmp__output;
tmp__output = thisPtr->getHandle()->getLimitLinear();
__LimitLinearInterop interop__output;
interop__output = ScriptLimitLinear::toInterop(tmp__output);
MonoUtil::valueCopy(__output, &interop__output, ScriptLimitLinear::getMetaData()->scriptClass->_getInternalClass());
}
void ScriptCD6Joint::Internal_setLimitLinear(ScriptCD6Joint* thisPtr, __LimitLinearInterop* limit)
{
LimitLinear tmplimit;
tmplimit = ScriptLimitLinear::fromInterop(*limit);
thisPtr->getHandle()->setLimitLinear(tmplimit);
}
void ScriptCD6Joint::Internal_getLimitTwist(ScriptCD6Joint* thisPtr, __LimitAngularRangeInterop* __output)
{
LimitAngularRange tmp__output;
tmp__output = thisPtr->getHandle()->getLimitTwist();
__LimitAngularRangeInterop interop__output;
interop__output = ScriptLimitAngularRange::toInterop(tmp__output);
MonoUtil::valueCopy(__output, &interop__output, ScriptLimitAngularRange::getMetaData()->scriptClass->_getInternalClass());
}
void ScriptCD6Joint::Internal_setLimitTwist(ScriptCD6Joint* thisPtr, __LimitAngularRangeInterop* limit)
{
LimitAngularRange tmplimit;
tmplimit = ScriptLimitAngularRange::fromInterop(*limit);
thisPtr->getHandle()->setLimitTwist(tmplimit);
}
void ScriptCD6Joint::Internal_getLimitSwing(ScriptCD6Joint* thisPtr, __LimitConeRangeInterop* __output)
{
LimitConeRange tmp__output;
tmp__output = thisPtr->getHandle()->getLimitSwing();
__LimitConeRangeInterop interop__output;
interop__output = ScriptLimitConeRange::toInterop(tmp__output);
MonoUtil::valueCopy(__output, &interop__output, ScriptLimitConeRange::getMetaData()->scriptClass->_getInternalClass());
}
void ScriptCD6Joint::Internal_setLimitSwing(ScriptCD6Joint* thisPtr, __LimitConeRangeInterop* limit)
{
LimitConeRange tmplimit;
tmplimit = ScriptLimitConeRange::fromInterop(*limit);
thisPtr->getHandle()->setLimitSwing(tmplimit);
}
void ScriptCD6Joint::Internal_getDrive(ScriptCD6Joint* thisPtr, D6JointDriveType type, D6JointDrive* __output)
{
D6JointDrive tmp__output;
tmp__output = thisPtr->getHandle()->getDrive(type);
*__output = tmp__output;
}
void ScriptCD6Joint::Internal_setDrive(ScriptCD6Joint* thisPtr, D6JointDriveType type, D6JointDrive* drive)
{
thisPtr->getHandle()->setDrive(type, *drive);
}
void ScriptCD6Joint::Internal_getDrivePosition(ScriptCD6Joint* thisPtr, Vector3* __output)
{
Vector3 tmp__output;
tmp__output = thisPtr->getHandle()->getDrivePosition();
*__output = tmp__output;
}
void ScriptCD6Joint::Internal_getDriveRotation(ScriptCD6Joint* thisPtr, Quaternion* __output)
{
Quaternion tmp__output;
tmp__output = thisPtr->getHandle()->getDriveRotation();
*__output = tmp__output;
}
void ScriptCD6Joint::Internal_setDriveTransform(ScriptCD6Joint* thisPtr, Vector3* position, Quaternion* rotation)
{
thisPtr->getHandle()->setDriveTransform(*position, *rotation);
}
void ScriptCD6Joint::Internal_getDriveLinearVelocity(ScriptCD6Joint* thisPtr, Vector3* __output)
{
Vector3 tmp__output;
tmp__output = thisPtr->getHandle()->getDriveLinearVelocity();
*__output = tmp__output;
}
void ScriptCD6Joint::Internal_getDriveAngularVelocity(ScriptCD6Joint* thisPtr, Vector3* __output)
{
Vector3 tmp__output;
tmp__output = thisPtr->getHandle()->getDriveAngularVelocity();
*__output = tmp__output;
}
void ScriptCD6Joint::Internal_setDriveVelocity(ScriptCD6Joint* thisPtr, Vector3* linear, Vector3* angular)
{
thisPtr->getHandle()->setDriveVelocity(*linear, *angular);
}
}
| 40.229167
| 134
| 0.789617
|
bsf2dev
|
8735d28c035eaf68c2f63e7e196b2bfb9f9502ec
| 875
|
cpp
|
C++
|
FindMDL.cpp
|
ReeceJones/csgomeme
|
5c9ffc9372232912e98080359fbca47350fa493f
|
[
"Unlicense"
] | null | null | null |
FindMDL.cpp
|
ReeceJones/csgomeme
|
5c9ffc9372232912e98080359fbca47350fa493f
|
[
"Unlicense"
] | null | null | null |
FindMDL.cpp
|
ReeceJones/csgomeme
|
5c9ffc9372232912e98080359fbca47350fa493f
|
[
"Unlicense"
] | null | null | null |
#include "Hooks.h"
#include "Interfaces.h"
#include "Definitions.h"
#include "Settings.h"
#include "Features.h"
FindMDLFn FindMDL_Original;
MDLHandle_t __fastcall Hooks::FindMDL_Hooked(void* ecx, void* edx, const char* pMDLRelativePath)
{
//if (strstr(pMDLRelativePath, "v_knife_default_ct.mdl")
// || strstr(pMDLRelativePath, "v_knife_default_t.mdl"))
// return FindMDL_Original(ecx, "models/weapons/v_knife_butterfly.mdl");
if (strstr(pMDLRelativePath, "models/player")
&& !strstr(pMDLRelativePath, "w_")
&& Settings.Visuals.CustomPlayers)
return FindMDL_Original(ecx, "models/player/custom_player/kuristaja/ak/batman/batmanv2.mdl");
if (strstr(pMDLRelativePath, "arms")
&& Settings.Visuals.CustomGloves)
return FindMDL_Original(ecx, "models/player/custom_player/kuristaja/ak/batman/batman_arms.mdl");
return FindMDL_Original(ecx, pMDLRelativePath);
}
| 36.458333
| 98
| 0.770286
|
ReeceJones
|
873dec0ac6c2a9eda481ac2d9d51e58a1329a44a
| 7,595
|
cpp
|
C++
|
src/mains/main7.cpp
|
KSaunders98/simpleEngine
|
d2bb6f77606dba04c4289125ca3799cc725cb60f
|
[
"MIT"
] | 1
|
2022-02-17T03:25:14.000Z
|
2022-02-17T03:25:14.000Z
|
src/mains/main7.cpp
|
KSaunders98/simpleEngine
|
d2bb6f77606dba04c4289125ca3799cc725cb60f
|
[
"MIT"
] | null | null | null |
src/mains/main7.cpp
|
KSaunders98/simpleEngine
|
d2bb6f77606dba04c4289125ca3799cc725cb60f
|
[
"MIT"
] | null | null | null |
#include <chrono>
#include <condition_variable>
#include <mutex>
#include <thread>
#include "mains/mains.hpp"
using std::size_t;
using namespace Render3D;
using namespace Math3D;
void main7() {
Window window(WIDTH, HEIGHT, "Render during resize (by multithreading and callback)");
Context3D* context = window.getContext();
Shader defaultShader = Shader::defaultPerspective();
context->addShader(&defaultShader);
Cuboid cube;
cube.setSize(Vector4(1, 1, 1));
cube.setCFrame(Matrix4x4(0, 0, -5));
cube.setColor(Color(0.2, 0.2, 0.85));
cube.setShader(&defaultShader);
context->addObject(&cube);
window.setVSyncEnabled(true);
Camera* cam = context->getCamera();
float x, y, z;
x = y = z = 0.0;
float cX, cY;
cX = cY = 0;
window.setMouseDownCallback([&window](MOUSE_BUTTON button, int x, int y) {
if (button == MOUSE_BUTTON::RIGHT) { // right mouse button
window.setMouseLockEnabled(true);
}
});
window.setMouseUpCallback([&window](MOUSE_BUTTON button, int x, int y) {
if (button == MOUSE_BUTTON::RIGHT) { // right mouse button
window.setMouseLockEnabled(false);
}
});
window.setMouseMoveCallback([&window, &cX, &cY](int x, int y, int dx, int dy) {
if (window.isMouseDown(MOUSE_BUTTON::RIGHT)) {
cX -= dx * MOUSE_SENS;
cY = std::max(std::min(cY - dy * MOUSE_SENS, 90.0f), -90.0f);
}
});
std::mutex mtx; // for the condition variable
std::condition_variable cv; // variable that will be used to indicate when threads have given up context
std::atomic<bool> needSync(false); // bool writes and reads should be atomic already, but just in case we will use std::atomic
std::atomic<bool> goingFullscreen(false);
window.setKeyUpCallback([&window, &mtx, &cv, &goingFullscreen](KEYCODE key) {
if (key == KEYCODE::F11) {
std::unique_lock<std::mutex> lck(mtx);
goingFullscreen.store(true);
cv.wait(lck);
window.toggleFullscreen();
goingFullscreen.store(false);
cv.notify_one();
}
});
// This example makes use of the window resize callback and multithreading combined to allow rendering "while" resizing a window.
// This works by "holding up" the window resize callback until the render thread has had time to process the
// resize and render. Since we don't let the window resize callback finish until a render has happened, the
// flicker experienced in example main6 (multiple threads, but no resize callback) is eliminated. Essentially
// this method syncs up the render and window event threads upon window resize. The only drawback is that
// the rendering speed then becomes dependent on the speed of the window resizing, so if you are on a slow
// system where resizing windows is sluggish, the rendering performance will take a hit during resize. This
// is the price that is paid to have window resizing be synced with the rendering.
// Here is where the magic happens. In our resize callback we make sure to wait until a resize has occured
// before we return, so that the threads can sync.
window.setResizeCallback([&](int width, int height) {
if (!goingFullscreen.load()) {
std::unique_lock<std::mutex> lck(mtx); // acquire lock
needSync.store(true); // indicate to the render thread that it needs to sync up (and apply resize)
// After the render thread has synced a resize successfully, it waits for the next resize event
// with a timeout of 7 milliseconds. This is done because if the render thread were to go on to render
// again before the next resize event was processed, it would slow down resizing; this avoids that.
// So, we must notify the render thread that another resize is happening, which is what the following
// line does. Note, if the render thread is not waiting for a resize, this line does nothing.
cv.notify_one();
cv.wait(lck); // block this function and thread until the render has completed
}
});
window.makeCurrent(false); // release rendering control from this thread
std::thread t([&]() {
window.makeCurrent(); // take rendering control on this thread
while (window.isActive()) {
// handle window going fullscreen as well
if (goingFullscreen.load()) {
cv.notify_one();
std::unique_lock<std::mutex> lck(mtx);
cv.wait(lck);
window.applyResize();
window.updateViewport();
}
bool shouldNotify = needSync.load(); // store value of needSync at start of render step
if (shouldNotify) {
// If the window event thread wants to sync, we know that a resize has occured and therefore
// we must apply the resize and update the viewport. We must explicitly call applyResize when
// we set a resize callback or else the window's size won't be kept track of. This is left up
// to the application programmer when implementing a resize callback so that they can take
// care of thread safety issues, or so they can discard window resizes if they so choose.
// In this example, applying the resize here is thread safe because the main window event
// thread is currently waiting for this render thread to render, so it cannot be modifying or
// reading the window at this point.
window.applyResize();
window.updateViewport();
}
x = x + 0.01;
y = y + 0.01;
z = z + 0.01;
cube.setCFrame(Matrix4x4(cube.getCFrame().position()) * Matrix4x4::fromEuler(x, y, z));
// we no longer need to do updateViewport right here because it is handled above
window.clear();
updateCamera(cam, &window, cX, cY);
context->render();
window.update();
if (shouldNotify) {
needSync.store(false); // reset sync variable
cv.notify_one(); // tell window event thread that this thread has rendered with the updated window size
std::unique_lock<std::mutex> lck(mtx); // acquire lock
cv.wait_for(lck, std::chrono::milliseconds(7)); // try to wait for next resize, timeout if one doesn't come in 7 milliseconds
// 7 is the magic number ;)
}
// notice we don't poll events here, the main window event thread handles that
}
// release rendering control from this thread so that the main thread can clean up resources
// and close the window
window.makeCurrent(false);
});
while (window.isActive()) {
window.waitEvents(); // notice we wait for events here instead of polling. this is much more efficient (avoids a busy loop)
}
t.join();
window.close(); // window must be closed to clean up resources it uses
/* WARNING: closing a window requires the objects it currently uses to still exist,
so do NOT delete an object or let it go out of scope until it has been removed
from all contexts or all windows that use it have been closed. in the future I will
likely implement the Context3D to use shared_ptrs instead of raw c pointers */
SDL_Quit();
}
| 46.310976
| 141
| 0.633706
|
KSaunders98
|
873fae10520db248eedb186f9ad27f739239b5da
| 3,358
|
cpp
|
C++
|
view-transaction/main.cpp
|
jambolo/Equity
|
e9f142aec8c5292406b32633fd714c26cf7fd6cd
|
[
"MIT"
] | null | null | null |
view-transaction/main.cpp
|
jambolo/Equity
|
e9f142aec8c5292406b32633fd714c26cf7fd6cd
|
[
"MIT"
] | null | null | null |
view-transaction/main.cpp
|
jambolo/Equity
|
e9f142aec8c5292406b32633fd714c26cf7fd6cd
|
[
"MIT"
] | null | null | null |
//
// main.cpp
// Equity
//
// Created by John Bolton on 10/16/15.
//
//
#include "equity/Script.h"
#include "equity/Transaction.h"
#include "p2p/Serialize.h"
#include "utility/Utility.h"
#include <cstdio>
#include <memory>
#include <vector>
using namespace Equity;
static void syntax(int argc, char ** argv);
int main(int argc, char ** argv)
{
if (argc < 2)
{
syntax(argc, argv);
return 1;
}
--argc;
++argv;
// 0100000001484d40d45b9ea0d652fca8258ab7caa42541eb52975857f96fb50cd732c8b481000000008a47304402202cb265bf10707bf49346c3515dd3d16fc454618c58ec0a0ff448a676c54ff71302206c6624d762a1fcef4618284ead8f08678ac05b13c84235f1654e6ad168233e8201410414e301b2328f17442c0b8310d787bf3d8a404cfbd0704f135b6ad4b2d3ee751310f981926e53a6e8c39bd7d3fefd576c543cce493cbac06388f2651d1aacbfcdffffffff0162640100000000001976a914c8e90996c7c6080ee06284600c684ed904d14c5c88ac00000000
// 0100000002f327e86da3e66bd20e1129b1fb36d07056f0b9a117199e759396526b8f3a20780000000000fffffffff0ede03d75050f20801d50358829ae02c058e8677d2cc74df51f738285013c260000000000ffffffff02f028d6dc010000001976a914ffb035781c3c69e076d48b60c3d38592e7ce06a788ac00ca9a3b000000001976a914fa5139067622fd7e1e722a05c17c2bb7d5fd6df088ac00000000
// 01000000010c432f4fb3e871a8bda638350b3d5c698cf431db8d6031b53e3fb5159e59d4a9000000006b48304502201123d735229382f75496e84ae5831871796ef78726805adc2c6edd36d23e7210022100faceab822a4943309c4b6b61240ae3a9e18ed90a75117c5dc4bfd8f7e17a21d301210367ce0a1c3b3e84cece6dad1a181d989d8e490b84f5431a1f778a88b284c935e6ffffffff0100f2052a010000001976a9143744841e13b90b4aca16fe793a7f88da3a23cc7188ac00000000
std::vector<uint8_t> data = Utility::fromHex(*argv);
uint8_t const * in = data.data();
size_t size = data.size();
try
{
Transaction transaction(in, size);
// printf("valid: %s\n", transaction.valid() ? "true" : "false");
// printf("version: %u\n", transaction.version());
//
// Transaction::InputList inputs = transaction.inputs();
// printf("inputs:\n");
// for (size_t i = 0; i < inputs.size(); ++i)
// {
// Transaction::Input const & input = inputs[i];
// Script script(input.script);
// printf(" %2zu: txid : %s\n", i, Utility::toHex(input.txid.hash_).c_str());
// printf(" index : %u\n", input.outputIndex);
// printf(" script : %s\n", script.toSource().c_str());
// printf(" sequence : %u\n", input.sequence);
// }
//
// Transaction::OutputList outputs = transaction.outputs();
// printf("outputs:\n");
// for (size_t i = 0; i < outputs.size(); ++i)
// {
// Transaction::Output const & output = outputs[i];
// Script script(output.script);
// printf(" %2zu: value : %llu (%lf BTC)\n", i, output.value, (double)output.value / 100000000.0);
// printf(" script : %s\n", script.toSource().c_str());
// }
//
// printf("lockTime: %u\n", transaction.lockTime());
printf("%s\n", transaction.toJson().dump(4).c_str());
}
catch (P2p::DeserializationError)
{
fprintf(stderr, "Invalid transaction.\n");
return 2;
}
return 0;
}
static void syntax(int argc, char ** argv)
{
fprintf(stderr, "syntax: %s <hash>\n", argv[0]);
}
| 40.95122
| 449
| 0.691483
|
jambolo
|
8749d632bde4167bea14c76e6f80d9a68ef58d32
| 740
|
cpp
|
C++
|
zad1.cpp
|
trt5/practika
|
ea2a1577fce97c98db83f517d8d815566b30dd7f
|
[
"Unlicense"
] | null | null | null |
zad1.cpp
|
trt5/practika
|
ea2a1577fce97c98db83f517d8d815566b30dd7f
|
[
"Unlicense"
] | null | null | null |
zad1.cpp
|
trt5/practika
|
ea2a1577fce97c98db83f517d8d815566b30dd7f
|
[
"Unlicense"
] | null | null | null |
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b, c, D, x1, x2;
cout << "Roots of the equation: \n";
cin >> a >> b >> c;
if (a == 0) {
x1 = -(c / b);
cout << "x1 = x2 = " << x1 << "\n";
}
else {
D = pow(b, 2) - 4 * a * c;
if (D > 0) {
x1 = ((-b) + sqrt(D)) / (2 * a);
x2 = ((-b) - sqrt(D)) / (2 * a);
cout << "x1 = " << x1 << "\n";
cout << "x2 = " << x2 << "\n";
}
if (D == 0) {
x1 = -(b / (2 * a));
cout << "x1 = x2 = " << x1 << "\n";
}
if (D < 0)
cout << "D < 0, No roots\n";
}
return 0;
}
| 23.870968
| 48
| 0.287838
|
trt5
|
874da5a74f54504445850355ea706cc805145276
| 74
|
cpp
|
C++
|
src/examples/11_module/01_ref_pointers/main.cpp
|
acc-cosc-1337-spring-2020-hl/acc-cosc-1337-spring-2020-C0779752
|
884607c753f72e0390a7ea3c374137ce1debd6b3
|
[
"MIT"
] | 2
|
2022-01-26T01:12:05.000Z
|
2022-02-12T04:25:51.000Z
|
src/examples/11_module/01_ref_pointers/main.cpp
|
acc-cosc-1337-spring-2020-hl/acc-cosc-1337-spring-2020-C0779752
|
884607c753f72e0390a7ea3c374137ce1debd6b3
|
[
"MIT"
] | 2
|
2021-09-25T03:34:05.000Z
|
2021-10-02T03:30:43.000Z
|
src/examples/11_module/01_ref_pointers/main.cpp
|
acc-cosc-1337-spring-2020-hl/acc-cosc-1337-spring-2020-C0779752
|
884607c753f72e0390a7ea3c374137ce1debd6b3
|
[
"MIT"
] | 3
|
2020-09-10T03:02:48.000Z
|
2020-12-09T13:23:10.000Z
|
#include "ref_pointers.h"
#include<iostream>
int main()
{
return 0;
}
| 9.25
| 25
| 0.662162
|
acc-cosc-1337-spring-2020-hl
|
8753f08789377e8d3235416a009692618ef686e6
| 1,534
|
cpp
|
C++
|
src/cpp/2016-11-18/__Coding 20 Longest Increasing subsequence.cpp
|
spurscoder/forTest
|
2ab069d6740f9d7636c6988a5a0bd3825518335d
|
[
"MIT"
] | null | null | null |
src/cpp/2016-11-18/__Coding 20 Longest Increasing subsequence.cpp
|
spurscoder/forTest
|
2ab069d6740f9d7636c6988a5a0bd3825518335d
|
[
"MIT"
] | 1
|
2018-10-24T05:48:27.000Z
|
2018-10-24T05:52:14.000Z
|
src/cpp/2016-11-18/__Coding 20 Longest Increasing subsequence.cpp
|
spurscoder/forTest
|
2ab069d6740f9d7636c6988a5a0bd3825518335d
|
[
"MIT"
] | null | null | null |
/*
问题描述:最长上升子序列
给定一个整数序列,找到最长上升子序列(LIS),返回LIS的长度。
最长上升子序列的定义:
最长上升子序列问题是在一个无序的给定序列中找到一个尽可能长的
由低到高排列的子序列,这种子序列不一定是连续的或者唯一的。
挑战 :
要求时间复杂度为O(n^2) 或者 O(nlogn)
标签 :
二分法 LintCode 版权所有 动态规划
思路:
如何把这个问题分解成子问题呢?经过分析,发现 “求以ak(k=1, 2, 3…N)为终点的最长上升子序列的
长度”是个好的子问题――这里把一个上升子序列中最右边的那个数,称为该子序列的“终点”。虽然这个
子问题和原问题形式上并不完全一样,但是只要这N个子问题都解决了,那么这N个子问题的解中,最大的
那个就是整个问题的解。
由上所述的子问题只和一个变量相关,就是数字的位置。因此序列中数的位置k 就是“状态”,
而状态 k 对应的“值”,就是以ak做为“终点”的最长上升子序列的长度。这个问题的状态一共有N个。
状态定义出来后,转移方程就不难想了。假定MaxLen (k)表示以ak做为“终点”的最长上升子序列的长度,
那么:
MaxLen (1) = 1
MaxLen (k) = Max { MaxLen (i):1<i < k 且 ai < ak且 k≠1 } + 1
这个状态转移方程的意思就是,MaxLen(k)的值,就是在ak左边,“终点”数值小于ak,且长度最大的那个
上升子序列的长度再加1。因为ak左边任何“终点”小于ak的子序列,加上ak后就能形成一个更长的上升子序列。
实际实现的时候,可以不必编写递归函数,因为从 MaxLen(1)就能推算出MaxLen(2),有了MaxLen(1)和
MaxLen(2)就能推算出MaxLen(3)……
*/
class Solution {
public:
/**
* @param nums: The integer array
* @return: The length of LIS (longest increasing subsequence)
*/
int longestIncreasingSubsequence(vector<int> nums) {
// write your code here
// write your code here
int size = nums.size();
int *state = new int[size];
int max, maxlen = 0;
for (int i = 0 ; i < size; i++)
{
state[i] = 1;
}
for (int i = 1; i < size; i++)
{
max = 0;
for (int j = 0; j <= i; j++)
{
if (nums[i] > nums[j] && state[j] > max)
max = state[j];
}
state[i] = max + 1;
if (max + 1 > maxlen)
maxlen = max + 1;
}
return maxlen;
}
};
| 23.96875
| 66
| 0.616688
|
spurscoder
|
87562cb4238493db4d590c4ec28c1e0f2795efe2
| 6,478
|
cpp
|
C++
|
lib/fields/cjson_class_field.cpp
|
bouviervj/cjson
|
abc96451f02f1b6fc7dfa0b21cd459593c0b9e1e
|
[
"Apache-2.0"
] | 4
|
2015-10-28T17:12:43.000Z
|
2018-09-11T14:45:11.000Z
|
lib/fields/cjson_class_field.cpp
|
bouviervj/cjson
|
abc96451f02f1b6fc7dfa0b21cd459593c0b9e1e
|
[
"Apache-2.0"
] | null | null | null |
lib/fields/cjson_class_field.cpp
|
bouviervj/cjson
|
abc96451f02f1b6fc7dfa0b21cd459593c0b9e1e
|
[
"Apache-2.0"
] | 2
|
2016-10-21T12:36:56.000Z
|
2020-08-13T11:07:27.000Z
|
/*
* Copyright 2013 BOUVIER-VOLAILLE Julien
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cjson_class_field.h"
#include <stdio.h>
#include <iterator>
#include <typeinfo>
using namespace jsonxx;
namespace cjson {
namespace field {
class_field::~class_field(){
for (int i=0; i<_inherited.size();i++){
delete _inherited[i];
}
std::map<std::string, attached_field* >::iterator iter;
for (iter = _list.begin(); iter != _list.end(); ++iter) {
delete iter->second;
}
};
void class_field::dumpVTable(bool iHideAddress){
std::stringstream ass;
dumpVTable(ass,iHideAddress);
std::cout << ass.str();
}
void class_field::dumpVTable(std::stringstream& iss, bool iHideAddress){
iss << "Entry point table:\n";
for (std::map<std::string,void*>::iterator it=_vtableEntryPoint.begin(); it!=_vtableEntryPoint.end(); ++it){
if (iHideAddress) {
iss << it->first << " => " << "0x****************" << "\n";
} else {
iss << it->first << " => " << std::hex << std::showbase << std::right << std::setw(18) << it->second << '\n';
}
}
iss << "VTable Layout:\n";
for (int i=0; i<_vtablelayout.size(); i++) {
char buffer_name[2048];
demangle(buffer_name, 2048, _vtablelayout[i]._name.c_str());
char buffer[2048];
demangleFunctionPointer(buffer, 2048, (void *) *((long*) _vtablelayout[i]._address));
char buffer_vt[2048];
demangleFunctionPointer(buffer_vt, 2048, (void *) _vtablelayout[i]._address);
if (iHideAddress) {
iss << "[" << "0x****************" << "] ";
} else {
iss << "[" << std::hex << std::showbase << std::right << std::setw(18) << _vtablelayout[i]._address << "] ";
}
iss << buffer_vt << " ";
if (iHideAddress) {
iss << "0x********" << " :";
} else {
iss << std::hex << std::right << std::setw(10) << (unsigned int) *((long*) _vtablelayout[i]._address) << " :";
}
iss << " " << std::setw(20) << _vtablelayout[i]._class.c_str() << " ";
iss << std::setw(30) << buffer_name << " expected ";
iss << buffer << "\n";
/*
printf("%p %s %8x : %20s %30s expected %s\n",_vtablelayout[i]._address,
buffer_vt
,(unsigned int) *((long*) _vtablelayout[i]._address)
,_vtablelayout[i]._class.c_str()
, buffer_name
, buffer);
*/
}
}
void class_field::toJson(std::ostringstream& iStream, const void* iEntryPoint){
std::map<std::string, attached_field* >::iterator iter;
#ifdef __DEBUG__
printf("###########\n");
printf("Class %s \n", getName().c_str());
for (iter = _list.begin(); iter != _list.end(); ++iter) {
printf("Field %s %p\n", iter->first.c_str(),(void*) iter->second->getField());
}
printf("###########\n");
#endif
iStream << "{";
for (iter = _list.begin(); iter != _list.end(); ++iter) {
attached_field* aField = iter->second;
if (aField) {
#ifdef __DEBUG__
printf("Field %s \n", iter->first.c_str());
printf("Offset (%d) \n",(int) aField->getOffset());
if (aField->getField()) {
printf("%s\n", aField->getField()->getName().c_str());
printf("Type: %s\n", typeid(aField->getField()).name());
} else {
printf("no field defined.\n");
}
#endif
iStream << "\"" << iter->first << "\":";
void* aFieldAddress = (void*) ((unsigned long) iEntryPoint+aField->getOffset()/8);
aField->getField()->toJson(iStream, aFieldAddress);
#ifdef __DEBUG__
printf("distance:%d\n",(int) std::distance(iter,_list.end()));
#endif
if (std::distance(iter,_list.end()) > 1) iStream << ",";
}
}
iStream << "}";
}
void* class_field::fromJson(const std::string& iJson){
void* aMem = malloc(_size/8);
#ifdef __DEBUG__
printf("Allocate class size %d\n",_size/8);
#endif
jsonxx::Value aValue;
aValue.parse(iJson);
fromJson(aValue, aMem);
return aMem;
}
void class_field::consolidateVTablePointers(void* iEntryPoint, std::map<std::string, void* >& iEntryPoints) {
// Prepare Vtable pointers
std::map<std::string, void* >::iterator it;
std::map<std::string,long>::iterator it_off;
for (it = iEntryPoints.begin(); it != iEntryPoints.end(); ++it) {
it_off = getVTableOffsets().find(it->first);
if (it_off!=getVTableOffsets().end()) {
long aOffset = it_off->second;
#ifdef __DEBUG__
printf("offset %s %p\n",it->first.c_str(), (void*) aOffset);
#endif
*((long*) ((long) iEntryPoint+aOffset/8)) =(long) it->second;
}
}
for (int i=0;i<_inherited.size(); i++) {
long aOffset = _inherited[i]->getOffset();
#ifdef __DEBUG__
printf("consolidate on %s \n", _inherited[i]->getField()->getName().c_str());
#endif
class_field* aClass = dynamic_cast<class_field*>(_inherited[i]->getField());
aClass->consolidateVTablePointers((void*) ((long) iEntryPoint+aOffset/8),iEntryPoints);
}
}
void class_field::fromJson(const jsonxx::Value& iJson, void* iEntryPoint){
// Set class members values
std::map<std::string, attached_field* >::iterator iter;
for (iter = _list.begin(); iter != _list.end(); ++iter) {
attached_field* aField = iter->second;
if (aField) {
Value aValue = iJson.get<Object>().get<Value>(iter->first);
void* aFieldAddress = (void*) ((unsigned long) iEntryPoint+aField->getOffset()/8);
aField->getField()->fromJson(aValue, aFieldAddress);
}
}
consolidateVTablePointers(iEntryPoint, _vtableEntryPoint);
}
void class_field::toCpp(std::ostringstream& iStream){
std::map<std::string, attached_field* >::iterator iter;
iStream << "class " << _name << " ";
iStream << "{\n";
for (iter = _list.begin(); iter != _list.end(); ++iter) {
attached_field* aField = iter->second;
if (aField) {
aField->getField()->toCpp(iStream);
iStream << " " << iter->first << "(" << aField->getOffset() << ")" <<";\n";
}
}
iStream << "}\n";
}
}
}
| 28.04329
| 115
| 0.60142
|
bouviervj
|
875763dbcf35f5b4793ac596400d7594ededfba6
| 1,614
|
hpp
|
C++
|
library/include/lvgl/MessageBox.hpp
|
StratifyLabs/LvglAPI
|
c869d5b38ad3aa148fa0801d12271f2d9a6043c5
|
[
"MIT"
] | 1
|
2022-01-03T19:16:58.000Z
|
2022-01-03T19:16:58.000Z
|
library/include/lvgl/MessageBox.hpp
|
StratifyLabs/LvglAPI
|
c869d5b38ad3aa148fa0801d12271f2d9a6043c5
|
[
"MIT"
] | null | null | null |
library/include/lvgl/MessageBox.hpp
|
StratifyLabs/LvglAPI
|
c869d5b38ad3aa148fa0801d12271f2d9a6043c5
|
[
"MIT"
] | null | null | null |
#ifndef LVGLAPI_LVGL_MESSAGEBOX_HPP
#define LVGLAPI_LVGL_MESSAGEBOX_HPP
#include "Button.hpp"
#include "ButtonMatrix.hpp"
#include "Label.hpp"
#if defined MessageBox
#undef MessageBox
#endif
namespace lvgl {
class MessageBox : public ObjectAccess<MessageBox> {
public:
struct Construct {
Construct &set_button_list(const char *list[]) {
button_list = list;
return *this;
}
// name is first
API_PUBLIC_MEMBER(Construct, const char *, name, "");
// alphabetical
API_PUBLIC_BOOL(Construct, add_close_button, true);
const char **button_list = nullptr;
API_PUBLIC_BOOL(Construct, modal, false);
API_PUBLIC_MEMBER(Construct, const char *, message, "");
API_PUBLIC_MEMBER(Construct, const char *, title, "");
};
explicit MessageBox(const Construct &options);
explicit MessageBox(lv_obj_t *object) { m_object = object; }
static const lv_obj_class_t *get_class() { return api()->message_box_class; }
API_NO_DISCARD const char *get_active_button_text() const {
return api()->msgbox_get_active_btn_text(m_object);
}
API_NO_DISCARD Label get_title() const { return Label(api()->msgbox_get_title(m_object)); }
API_NO_DISCARD Label get_text() const { return Label(api()->msgbox_get_text(m_object)); }
API_NO_DISCARD Button get_close_button() const {
return Button(api()->msgbox_get_close_btn(m_object));
}
API_NO_DISCARD ButtonMatrix get_buttons() const {
return ButtonMatrix(api()->msgbox_get_btns(m_object));
}
void close() { api()->msgbox_close(object()); }
};
} // namespace lvgl
#endif // LVGLAPI_LVGL_MESSAGEBOX_HPP
| 27.827586
| 93
| 0.724287
|
StratifyLabs
|
8757ab5381e936617ed3e73c6be0c4a7cc548fe7
| 499
|
cc
|
C++
|
kmp-search/prefixfunction.cc
|
dkodar20/String-Matching-using-Fast-Fourier-Transform
|
52c3d092bf9fe59993cf32064678f677957f246a
|
[
"MIT"
] | 1
|
2021-07-27T11:55:52.000Z
|
2021-07-27T11:55:52.000Z
|
kmp-search/prefixfunction.cc
|
dkodar20/String-Matching-using-Fast-Fourier-Transform
|
52c3d092bf9fe59993cf32064678f677957f246a
|
[
"MIT"
] | null | null | null |
kmp-search/prefixfunction.cc
|
dkodar20/String-Matching-using-Fast-Fourier-Transform
|
52c3d092bf9fe59993cf32064678f677957f246a
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
namespace PrefixFunction {
auto __pf = [](string &s, vector<int>& pi) -> void {
int n = (int)s.length();
pi.assign((unsigned)n, 0);
for(int i = 1; i < n; i++){
int j = pi[i-1];
while(j > 0 and s[i] != s[j])
j = pi[j-1];
if(s[i] == s[j])
j++;
pi[i] = j;
}
return;
};
}
| 21.695652
| 60
| 0.346693
|
dkodar20
|
8759186d3f3b6f27ebf6da35633d8ca6909843b1
| 1,151
|
cpp
|
C++
|
Mistiq/src/Graphics/Shaders/Shader.cpp
|
SGAoo7/Mistiq
|
05feb006366bc2ad15b1752f38bbe45f6967cc8c
|
[
"Apache-2.0"
] | 1
|
2020-10-05T15:36:31.000Z
|
2020-10-05T15:36:31.000Z
|
Mistiq/src/Graphics/Shaders/Shader.cpp
|
SGAoo7/Mistiq
|
05feb006366bc2ad15b1752f38bbe45f6967cc8c
|
[
"Apache-2.0"
] | null | null | null |
Mistiq/src/Graphics/Shaders/Shader.cpp
|
SGAoo7/Mistiq
|
05feb006366bc2ad15b1752f38bbe45f6967cc8c
|
[
"Apache-2.0"
] | 1
|
2020-10-05T15:36:15.000Z
|
2020-10-05T15:36:15.000Z
|
#include "Mstqpch.h"
#include "Shader.h"
#include "include/glad/glad.h"
Mistiq::Shader::Shader(const char* a_Path, ESHADER_TYPE a_Type) : m_Type(a_Type)
{
std::string code;
std::ifstream shaderFile;
shaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
shaderFile.open(a_Path);
std::stringstream shaderStream;
shaderStream << shaderFile.rdbuf();
shaderFile.close();
code = shaderStream.str();
}
catch (std::ifstream::failure& e)
{
std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
}
const char* vShaderCode = code.c_str();
switch (m_Type)
{
case SHADER_TYPE_VERTEX:
m_ID = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(m_ID, 1, &vShaderCode, NULL);
glCompileShader(m_ID);
break;
case SHADER_TYPE_FRAGMENT:
m_ID = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(m_ID, 1, &vShaderCode, NULL);
glCompileShader(m_ID);
break;
}
}
const Mistiq::Shader::ESHADER_TYPE Mistiq::Shader::GetType() const
{
return m_Type;
}
const std::string& Mistiq::Shader::GetContent() const
{
return m_Content;
}
const unsigned& Mistiq::Shader::GetId() const
{
return m_ID;
}
| 21.314815
| 80
| 0.719374
|
SGAoo7
|
87595e0c8bda92fe36ce7464910075bb98cf5bb9
| 18,437
|
cpp
|
C++
|
src/Context.cpp
|
pizthewiz/Cinder-Pipeline
|
2125bf034cd7160eeb1d00ec849ea59adabb9eed
|
[
"MIT"
] | 17
|
2015-04-29T22:24:19.000Z
|
2018-12-06T13:18:06.000Z
|
src/Context.cpp
|
pizthewiz/Cinder-Pipeline
|
2125bf034cd7160eeb1d00ec849ea59adabb9eed
|
[
"MIT"
] | null | null | null |
src/Context.cpp
|
pizthewiz/Cinder-Pipeline
|
2125bf034cd7160eeb1d00ec849ea59adabb9eed
|
[
"MIT"
] | 1
|
2021-12-22T12:05:16.000Z
|
2021-12-22T12:05:16.000Z
|
//
// Context.cpp
// Cinder-Pipeline
//
// Created by Jean-Pierre Mouilleseaux on 19 Apr 2014.
// Copyright 2014-2015 Chorded Constructions. All rights reserved.
//
#include "Context.h"
#include "SourceNode.h"
#include "EffectorNode.h"
#include "cinder/Utilities.h"
#include "cinder/Json.h"
#include "cinder/Log.h"
using namespace ci;
namespace Cinder { namespace Pipeline {
ContextRef Context::create() {
return ContextRef(new Context())->shared_from_this();
}
Context::Context() {
}
Context::~Context() {
}
#pragma mark -
void Context::setup(const ivec2& size, GLenum colorFormat, int attachmentCount) {
// bail if size and attachments are unchanged
if (mFBO && size == mFBO->getSize() && colorFormat == mColorFormat && attachmentCount == mAttachmentCount) {
return;
}
// dump capabilities
// CI_LOG_V(std::string(13, '-'));
// const char* renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
// CI_LOG_V("GL_RENDERER: " + toString(renderer));
// const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
// CI_LOG_V("GL_VENDOR: " + toString(vendor));
// const char* version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
// CI_LOG_V("GL_VERSION: " + toString(version));
// const char* shadingLanguageVersion = reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));
// CI_LOG_V("GL_SHADING_LANGUAGE_VERSION: " + toString(shadingLanguageVersion));
//
// CI_LOG_V("GL_EXTENSIONS: ");
// GLint extensionCount = 0;
// glGetIntegerv(GL_NUM_EXTENSIONS, &extensionCount);
// for (GLint idx = 0; idx < extensionCount; idx++) {
// std::string extension(reinterpret_cast<const char*>(glGetStringi(GL_EXTENSIONS, idx)));
// CI_LOG_V(" " + toString(extension));
// }
//
// GLint texSize;
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
// CI_LOG_V("GL_MAX_TEXTURE_SIZE: " + toString(texSize));
// glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &texSize);
// CI_LOG_V("GL_MAX_3D_TEXTURE_SIZE: " + toString(texSize));
// glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &texSize);
// CI_LOG_V("GL_MAX_TEXTURE_IMAGE_UNITS: " + toString(texSize));
// glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &texSize);
// CI_LOG_V("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: " + toString(texSize));
// glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &texSize);
// CI_LOG_V("GL_MAX_COLOR_ATTACHMENTS: " + toString(texSize));
// CI_LOG_V(std::string(13, '-'));
// checks
GLint texSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
CI_ASSERT_MSG(texSize >= size.x, ("width " + toString(size.x) + " exceeds maximum texture size " + toString(texSize)).c_str());
CI_ASSERT_MSG(texSize >= size.y, ("height " + toString(size.y) + " exceeds maximum texture size " + toString(texSize)).c_str());
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &texSize);
CI_ASSERT_MSG(GL_MAX_COLOR_ATTACHMENTS >= attachmentCount, ("attachment count " + toString(attachmentCount) + " exceeds maximum " + toString(texSize)).c_str());
// float attachmentMemorySizeMB = size.x * size.y * 4 / 1024 / 1024;
// float totalSizeMB = attachmentMemorySizeMB * attachmentCount;
//
// if (gl::isExtensionAvailable("GL_NV_texture_barrier")) {
// if (texSize >= 2 * size.x && texSize >= size.y) {
// // TODO: double-wide
// } else if (texSize >= 2 * size.y && texSize >= size.x) {
// // TODO: double-tall
// } else {
// // TODO: tile
// }
// }
gl::Fbo::Format format;
for (unsigned int idx = 0; idx < attachmentCount; idx++) {
format.attachment(GL_COLOR_ATTACHMENT0 + idx, gl::Texture2d::create(size.x, size.y, gl::Texture2d::Format().internalFormat(colorFormat)));
}
mFBO = gl::Fbo::create(size.x, size.y, format);
GLenum buffers[attachmentCount];
for (unsigned int idx = 0; idx < attachmentCount; idx++) {
buffers[idx] = GL_COLOR_ATTACHMENT0 + idx;
}
glDrawBuffers(attachmentCount, buffers);
gl::ScopedMatrices matricies;
gl::ScopedViewport viewport(ivec2(0), mFBO->getSize());
gl::ScopedFramebuffer fbo(mFBO);
gl::clear(ColorAf(0.0, 0.0, 0.0, 0.0));
mColorFormat = colorFormat;
mAttachmentCount = attachmentCount;
}
#pragma mark - CONNECTIONS
void Context::connectNodes(const NodeRef& sourceNode, const NodePortRef& sourcePort, const NodeRef& destinationNode, const NodePortRef& destinationPort) {
// bail if the port types don't match
if (sourcePort->getType() != destinationPort->getType()) {
return;
}
// remove existing connection if destination port is already has one
NodePortConnectionRef connection = mInputConnections[destinationNode][destinationPort->getKey()];
if (connection) {
disconnect(connection);
}
connection = NodePortConnection::create(sourceNode, sourcePort->getKey(), destinationNode, destinationPort->getKey());
mInputConnections[destinationNode][destinationPort->getKey()] = connection;
mOutputConnections[sourceNode][sourcePort->getKey()].push_back(connection);
// wipe render stack to force a rebuild
mRenderStack.clear();
}
void Context::connectNodes(const NodeRef& sourceNode, const std::string& sourceNodePortKey, const NodeRef& destinationNode, const std::string& destinationNodePortKey) {
NodePortRef sourcePort = sourceNode->getOutputPortForKey(sourceNodePortKey);
NodePortRef destinationPort = destinationNode->getInputPortForKey(destinationNodePortKey);
connectNodes(sourceNode, sourcePort, destinationNode, destinationPort);
}
void Context::connectNodes(const NodeRef& sourceNode, const NodeRef& destinationNode) {
connectNodes(sourceNode, NodeOutputPortKeyImage, destinationNode, NodeInputPortKeyImage);
}
void Context::disconnect(const NodePortConnectionRef& connection) {
// NB - erase replaces connection with a nullptr, it does not remove the key
mInputConnections[connection->getDestinationNode()].erase(connection->getDestinationPortKey());
std::vector<NodePortConnectionRef> connections = mOutputConnections[connection->getSourceNode()][connection->getSourcePortKey()];
connections.erase(std::find(connections.begin(), connections.end(), connection));
// wipe render stack to force a rebuild
mRenderStack.clear();
}
void Context::disconnectNodes(const NodeRef& sourceNode, const NodePortRef& sourcePort, const NodeRef& destinationNode, const NodePortRef& destinationPort) {
NodePortConnectionRef connection = mInputConnections[destinationNode][destinationPort->getKey()];
// make sure nodes are connected on the expected ports
if (!connection || connection->getSourceNode() != sourceNode || connection->getSourcePortKey() != sourcePort->getKey()) {
return;
}
disconnect(connection);
}
void Context::disconnectNodes(const NodeRef& sourceNode, const std::string& sourceNodePortKey, const NodeRef& destinationNode, const std::string& destinationNodePortKey) {
NodePortRef sourcePort = sourceNode->getOutputPortForKey(sourceNodePortKey);
NodePortRef destinationPort = destinationNode->getInputPortForKey(destinationNodePortKey);
disconnectNodes(sourceNode, sourcePort, destinationNode, destinationPort);
}
void Context::disconnectNodes(const NodeRef& sourceNode, const NodeRef& destinationNode) {
disconnectNodes(sourceNode, NodeOutputPortKeyImage, destinationNode, NodeInputPortKeyImage);
}
#pragma mark - SERIALIZATION
std::string Context::serialize() {
std::map<NodeRef, std::string> nodeIdentifierMap;
for (size_t idx = 0; idx < mNodes.size(); idx++) {
const NodeRef& n = mNodes.at(idx);
nodeIdentifierMap[n] = n->getName() + "-" + toString(idx);
}
JsonTree rootObject = JsonTree::makeObject();
for (const NodeRef& n : mNodes) {
JsonTree nodeObject = JsonTree::makeObject();
nodeObject.pushBack(JsonTree("identifier", nodeIdentifierMap[n]));
// TODO - ??? need some way to get classname
nodeObject.pushBack(JsonTree("type", "???"));
JsonTree valuesObject = JsonTree::makeObject("values");
for (const NodePortRef& port : n->getInputPorts()) {
if (!n->hasValueForInputPortKey(port->getKey())) {
continue;
}
switch (port->getType()) {
case NodePortType::FBOImage:
case NodePortType::Texture:
// NB - transient values, nothing to serialize
break;
case NodePortType::Bool:
valuesObject.pushBack(JsonTree(port->getKey(), n->getValueForInputPortKey<bool>(port->getKey())));
break;
case NodePortType::Float:
valuesObject.pushBack(JsonTree(port->getKey(), n->getValueForInputPortKey<float>(port->getKey())));
break;
case NodePortType::Int:
case NodePortType::Index:
valuesObject.pushBack(JsonTree(port->getKey(), n->getValueForInputPortKey<int>(port->getKey())));
break;
case NodePortType::Vec2: {
JsonTree valueObject = JsonTree::makeObject(port->getKey());
vec2 val = n->getValueForInputPortKey<vec2>(port->getKey());
valueObject.pushBack(JsonTree("x", val.x));
valueObject.pushBack(JsonTree("y", val.y));
valuesObject.pushBack(valueObject);
break;
}
case NodePortType::Color: {
JsonTree valueObject = JsonTree::makeObject(port->getKey());
ColorAf val = n->getValueForInputPortKey<ColorAf>(port->getKey());
valueObject.pushBack(JsonTree("r", val.r));
valueObject.pushBack(JsonTree("g", val.g));
valueObject.pushBack(JsonTree("b", val.b));
valueObject.pushBack(JsonTree("a", val.a));
valuesObject.pushBack(valueObject);
break;
}
case NodePortType::FilePath: {
fs::path path = n->getValueForInputPortKey<fs::path>(port->getKey());
valuesObject.pushBack(JsonTree(port->getKey(), path.string()));
break;
}
default:
break;
}
}
nodeObject.pushBack(valuesObject);
JsonTree inputConnections = JsonTree::makeArray("inputConnections");
for (const NodePortConnectionRef& c : getInputConnectionsForNodeWithPortType(n, NodePortType::FBOImage)) {
JsonTree connectionObject = JsonTree::makeObject();
connectionObject.pushBack(JsonTree("sourceNode", nodeIdentifierMap[c->getSourceNode()]));
connectionObject.pushBack(JsonTree("sourcePortKey", c->getSourcePortKey()));
connectionObject.pushBack(JsonTree("destinationPortKey", c->getDestinationPortKey()));
inputConnections.pushBack(connectionObject);
}
nodeObject.pushBack(inputConnections);
JsonTree outputConnections = JsonTree::makeArray("outputConnections");
for (const NodePortConnectionRef& c : getOutputConnectionsForNodeWithPortType(n, NodePortType::FBOImage)) {
JsonTree connectionObject = JsonTree::makeObject();
connectionObject.pushBack(JsonTree("sourcePortKey", c->getSourcePortKey()));
connectionObject.pushBack(JsonTree("destinationNode", nodeIdentifierMap[c->getDestinationNode()]));
connectionObject.pushBack(JsonTree("destinationPortKey", c->getDestinationPortKey()));
outputConnections.pushBack(connectionObject);
}
nodeObject.pushBack(outputConnections);
rootObject.pushBack(nodeObject);
}
return rootObject.serialize();
}
bool Context::serialize(const fs::path& path) {
std::ofstream outfile(path.string());
if (!outfile.is_open()) {
return false;
}
outfile << serialize();
outfile.close();
return true;
}
#pragma mark - EVALUATION
std::deque<std::deque<NodeRef>> Context::renderStackForRenderNode(const NodeRef& node) {
// dependency solver via three-pass stratagem:
// [1] find valid connections and leaf nodes required for render node evaluation
// [2] calculate max distance from leaf nodes to render node
// [3] create a render stack from the bottom up, choose cheap first
// [1] generate list of valid connections and leaf nodes
std::vector<NodePortConnectionRef> connections;
std::vector<NodeRef> leafNodes;
std::function<void (NodeRef)> walkUp = [&](NodeRef n) {
auto inputConections = getInputConnectionsForNodeWithPortType(n, NodePortType::FBOImage);
if (inputConections.empty()) {
// avoid duplicates
if (std::find(std::begin(leafNodes), std::end(leafNodes), n) == std::end(leafNodes)) {
leafNodes.push_back(n);
}
return;
}
for (auto connection : inputConections) {
assert(std::find(std::begin(connections), std::end(connections), connection) == std::end(connections));
connections.push_back(connection);
walkUp(connection->getSourceNode());
}
};
walkUp(node);
// [2] calculate max distances from leaf node to render node
std::map<NodePortConnectionRef, int> downEdgeCostMap;
std::function<void (NodeRef)> walkDown = [&](NodeRef n) {
int cost = 0;
for (auto connection : getInputConnectionsForNodeWithPortType(n, NodePortType::FBOImage)) {
if (downEdgeCostMap.count(connection) != 0 && downEdgeCostMap[connection] > cost) {
cost = downEdgeCostMap[connection];
}
}
cost++;
// TODO: use some sort of std::filter
for (auto connection : getOutputConnectionsForNodeWithPortType(n, NodePortType::FBOImage)) {
if (std::find(std::begin(connections), std::end(connections), connection) != std::end(connections)) {
downEdgeCostMap[connection] = cost;
walkDown(connection->getDestinationNode());
}
}
};
for (auto n : leafNodes) {
walkDown(n);
}
// [3] create render stack
std::deque<std::deque<NodeRef>> renderStack = {{}};
std::function<void (NodeRef)> upStack = [&](NodeRef n) {
renderStack.front().push_front(n);
std::vector<NodePortConnectionRef> sortedInputConnections = getInputConnectionsForNodeWithPortType(n, NodePortType::FBOImage);
std::sort(sortedInputConnections.begin(), sortedInputConnections.end(), [&](const NodePortConnectionRef& c1, const NodePortConnectionRef& c2) {
return downEdgeCostMap[c1] < downEdgeCostMap[c2];
});
if (!sortedInputConnections.empty()) {
auto connection = sortedInputConnections.front();
sortedInputConnections.erase(sortedInputConnections.begin());
upStack(connection->getSourceNode());
for (auto connection : sortedInputConnections) {
renderStack.push_front(std::deque<NodeRef> ());
upStack(connection->getSourceNode());
}
}
};
upStack(node);
return renderStack;
}
gl::Texture2dRef Context::evaluate(const NodeRef& node) {
// rebuild render stack (flush cache) if the stack is empty or the node changes (cache key)
if (mRenderStack.size() == 0 || node != mRenderNode) {
// verify there are enough attachments
auto result = std::max_element(mNodes.begin(), mNodes.end(), [](const NodeRef& n1, const NodeRef& n2) {
return n1->getImageInputPortKeys().size() < n2->getImageInputPortKeys().size();
});
unsigned int count = mNodes.at(std::distance(mNodes.begin(), result))->getImageInputPortKeys().size();
// NB: it appears a single node strand with single inputs can technically be evaluated on a single attachment
if (mAttachmentCount < count + 1) {
CI_LOG_E("more attachments (color buffers) required");
return nullptr;
}
mRenderStack = renderStackForRenderNode(node);
mRenderNode = node;
// dump render stack contents
CI_LOG_V(std::string(3, '#'));
for (auto b : mRenderStack) {
for (auto n : b) {
std::string name = n->getName();
name.resize(3, ' ');
CI_LOG_V("[" + name + "]");
}
CI_LOG_V("");
}
CI_LOG_V(std::string(3, '#'));
}
// render branches
gl::ScopedMatrices matricies;
gl::ScopedViewport viewport(ivec2(0), mFBO->getSize());
gl::ScopedFramebuffer fbo(mFBO);
gl::setMatricesWindow(mFBO->getSize());
gl::color(Color::white());
std::deque<GLenum> attachmentsQueue;
for (unsigned int idx = 0; idx < mAttachmentCount; idx++) {
attachmentsQueue.push_back(GL_COLOR_ATTACHMENT0 + idx);
}
std::map<NodeRef, GLenum> attachmentsMap;
for (const std::deque<NodeRef>& b : mRenderStack) {
for (const NodeRef& n : b) {
assert(attachmentsQueue.size() != 0);
GLenum outAttachment = attachmentsQueue.front();
attachmentsQueue.pop_front();
glDrawBuffer(outAttachment);
std::vector<NodePortConnectionRef> connections = getInputConnectionsForNodeWithPortType(n, NodePortType::FBOImage);
for (const NodePortConnectionRef& c : connections) {
assert(attachmentsMap.count(c->getSourceNode()) != 0);
GLenum inAttachment = attachmentsMap[c->getSourceNode()];
// mark attachment for recycle
attachmentsMap.erase(c->getSourceNode());
attachmentsQueue.push_back(inAttachment);
FBOImageRef inputFBOImage = FBOImage::create(mFBO, inAttachment);
n->setValueForInputPortKey(inputFBOImage, c->getDestinationPortKey());
}
FBOImageRef outputFBOImage = FBOImage::create(mFBO, outAttachment);
n->render(outputFBOImage);
attachmentsMap[n] = outAttachment;
}
}
return mFBO->getTexture2d(attachmentsMap[mRenderNode]);
}
}}
| 42.777262
| 171
| 0.648479
|
pizthewiz
|
875e66673f2b5c1e40347f2db8eb3eebb48c2a8f
| 2,265
|
cpp
|
C++
|
aml-vm/src/vm/compiler/lexer/first_pass/dec_number.cpp
|
gear-lang/gear-vm-cpp
|
89a36dcd6cacef27dd7c7fd72763e11b8eb948bd
|
[
"MIT"
] | null | null | null |
aml-vm/src/vm/compiler/lexer/first_pass/dec_number.cpp
|
gear-lang/gear-vm-cpp
|
89a36dcd6cacef27dd7c7fd72763e11b8eb948bd
|
[
"MIT"
] | 1
|
2015-09-07T22:56:07.000Z
|
2015-09-12T23:41:13.000Z
|
aml-vm/src/vm/compiler/lexer/first_pass/dec_number.cpp
|
gear-lang/gear-vm-cpp
|
89a36dcd6cacef27dd7c7fd72763e11b8eb948bd
|
[
"MIT"
] | null | null | null |
#include "../lexer.hpp"
namespace AVM {
Lexer::
FirstPassDecimalNumberState::FirstPassDecimalNumberState(RawLexicalToken rawToken)
: FirstPassState(rawToken) {};
void
Lexer::
FirstPassDecimalNumberState::handle(AVM::Lexer::FirstPassMachine &machine, UChar32 inputChar) {
UChar32 const &lastChar = rawToken.rawValue.back();
if (Lexer::isDigitChar(lastChar)) {
if (Lexer::isDigitChar(inputChar)) {
/* ### */
accept(inputChar);
} else if (inputChar == Underscore) {
/* ###_ */
accept(inputChar);
} else if (Lexer::isIntegerSuffixChar(inputChar)) {
/* ###Z */
accept(inputChar);
machine.changeState(new FirstPassIntegerSuffixState(rawToken, RawLexicalItemIntegerLiteral));
} else if (inputChar == Letter_r) {
/* ###r */
accept(inputChar);
} else if (inputChar == Letter_i) {
/* ###i */
accept(inputChar);
rawToken.item = RawLexicalItemComplexImaginaryLiteral;
machine.appendToOutput(rawToken);
machine.changeState(new FirstPassStartState);
} else if (inputChar == Dot) {
/* ###. */
/* the ffp state might need to back off and cut the dot, if this was a mistake */
accept(inputChar);
machine.changeState(new FirstPassDecimalFloatingOrFixedPointNumberState(rawToken));
} else if (Lexer::isFpSuffixChar(inputChar)) {
/* ###e */
accept(inputChar);
machine.changeState(new FirstPassDecimalFloatingOrFixedPointNumberState(rawToken));
} else {
/* ### */
rawToken.item = RawLexicalItemIntegerLiteral;
machine.appendToOutput(rawToken);
machine.changeState(new FirstPassStartState);
machine.handle(inputChar);
}
} else if (lastChar == Underscore) {
if (Lexer::isDigitChar(inputChar)) {
/* ###_# */
accept(inputChar);
} else {
throw "Unexpected input character";
}
} else if (lastChar == Letter_r) {
if (inputChar == Letter_i) {
/* ###ri */
accept(inputChar);
} else {
/* ###r */
rawToken.item = RawLexicalItemRationalDenominatorLiteral;
machine.appendToOutput(rawToken);
machine.changeState(new FirstPassStartState);
machine.handle(inputChar);
}
} else {
/* only digit chars and underscore may appear in this state */
throw "Illegal state";
}
}
}
| 26.647059
| 97
| 0.664901
|
gear-lang
|
8765699d8583ce31529d58ec3f744529a7545725
| 4,137
|
cpp
|
C++
|
src/Codecs/TemplateRegistry.cpp
|
divyang4481/quickfast
|
339c78e96a1f63b74c139afa1a3c9a07afff7b5f
|
[
"BSD-3-Clause"
] | 198
|
2015-04-26T08:06:18.000Z
|
2022-03-13T01:31:50.000Z
|
src/Codecs/TemplateRegistry.cpp
|
divyang4481/quickfast
|
339c78e96a1f63b74c139afa1a3c9a07afff7b5f
|
[
"BSD-3-Clause"
] | 15
|
2015-07-07T19:47:08.000Z
|
2022-02-04T05:56:51.000Z
|
src/Codecs/TemplateRegistry.cpp
|
divyang4481/quickfast
|
339c78e96a1f63b74c139afa1a3c9a07afff7b5f
|
[
"BSD-3-Clause"
] | 96
|
2015-04-24T15:19:43.000Z
|
2022-03-28T13:15:11.000Z
|
// Copyright (c) 2009, Object Computing, Inc.
// All rights reserved.
// See the file license.txt for licensing information.
#include <Common/QuickFASTPch.h>
#include "TemplateRegistry.h"
#include <Codecs/Template.h>
#include <Codecs/DictionaryIndexer.h>
using namespace ::QuickFAST;
using namespace ::QuickFAST::Codecs;
TemplateRegistry::TemplateRegistry()
: presenceMapBits_(1) // every template requires 1 bit for the template ID
, dictionarySize_(0)
, maxFieldCount_(0)
{
}
TemplateRegistry::TemplateRegistry(
size_t pmapBits,
size_t fieldCount,
size_t dictionarySize)
: presenceMapBits_(pmapBits)
, dictionarySize_(dictionarySize)
, maxFieldCount_(fieldCount)
{
}
void
TemplateRegistry::finalize()
{
// Give every tmplate a chance to finalize itself.
for(MutableTemplates::iterator mit = mutableTemplates_.begin();
mit != mutableTemplates_.end();
++mit)
{
(*mit)->finalize(*this);
}
DictionaryIndexer indexer;
for(MutableTemplates::iterator mit = mutableTemplates_.begin();
mit != mutableTemplates_.end();
++mit)
{
(*mit)->indexDictionaries(
indexer,
dictionaryName_,
"", // typeref n/a at <templates> level
""); // typeNs
}
dictionarySize_ = indexer.size();
presenceMapBits_ = 1;
maxFieldCount_ = 0;
for(TemplateIdMap::const_iterator it = templates_.begin();
it != templates_.end();
++it)
{
size_t bits = it->second->presenceMapBitCount();
if(bits > presenceMapBits_)
{
presenceMapBits_ = bits;
}
size_t fieldCount = it->second->fieldCount();
if(fieldCount > maxFieldCount_)
{
maxFieldCount_ = fieldCount;
}
}
}
void
TemplateRegistry::addTemplate(TemplatePtr value)
{
template_id_t id = value->getId();
if(id != 0)
{
templates_[id] = value;
}
std::string name;
value->qualifyName(name);
if(!name.empty())
{
namedTemplates_[name] = value;
}
mutableTemplates_.push_back(value);
// TODO: resolve templateRefs before calculating presence map bits.
// but that must be deferred to "finalize"
size_t bits = value->presenceMapBitCount();
if(bits > presenceMapBits_)
{
presenceMapBits_ = bits;
}
}
size_t
TemplateRegistry::size()const
{
return templates_.size();
}
bool
TemplateRegistry::getTemplate(template_id_t templateId, TemplateCPtr & valueFound)const
{
TemplateIdMap::const_iterator it = templates_.find(templateId);
if(it == templates_.end())
{
return false;
}
valueFound = it->second;
return bool(valueFound);
}
bool
TemplateRegistry::findNamedTemplate(
const std::string & templateName,
const std::string & templateNamespace,
TemplateCPtr & valueFound)const
{
std::string name;
Template::qualifyName(name, templateName, templateNamespace);
TemplateNameMap::const_iterator it = namedTemplates_.find(name);
if(it == namedTemplates_.end())
{
return false;
}
valueFound = it->second;
return bool(valueFound);
}
bool
TemplateRegistry::findNamedTemplate(
const std::string & templateName,
const std::string & templateNamespace,
TemplatePtr & valueFound)
{
bool found = false;
for(MutableTemplates::iterator mit = mutableTemplates_.begin();
!found && mit != mutableTemplates_.end();
++mit)
{
if(templateName == (*mit)->getTemplateName() && templateNamespace == (*mit)->getTemplateNamespace())
{
valueFound = *mit;
found = true;
}
}
return found;
}
void
TemplateRegistry::display(std::ostream & output, size_t indent) const
{
std::string indentString(indent, ' ');
output << std::endl << indentString << "<templates";
if(!templateNamespace_.empty())
{
output << " templateNs=\"" << templateNamespace_ << "\"";
}
if(!namespace_.empty())
{
output << " ns=\"" << namespace_ << "\"";
}
if(!dictionaryName_.empty())
{
output << " dictionary=\"" << dictionaryName_ << "\"";
}
output << ">";
for(size_t nTemplate = 0; nTemplate < mutableTemplates_.size(); ++nTemplate)
{
mutableTemplates_[nTemplate]->display(output, indent + 2);
}
output << std::endl << indentString << "</templates>" << std::endl;
}
| 22.856354
| 104
| 0.676819
|
divyang4481
|
87664bc86d17a960ca6c1a13f1d7a57b078acfc9
| 423
|
hpp
|
C++
|
src/bork/parse.hpp
|
NaerJeis/bork
|
27fa5e7d4b2fc6e797d46c8266d8736277cd2886
|
[
"MIT"
] | null | null | null |
src/bork/parse.hpp
|
NaerJeis/bork
|
27fa5e7d4b2fc6e797d46c8266d8736277cd2886
|
[
"MIT"
] | null | null | null |
src/bork/parse.hpp
|
NaerJeis/bork
|
27fa5e7d4b2fc6e797d46c8266d8736277cd2886
|
[
"MIT"
] | null | null | null |
/***************************************************************************************************
* *
***************************************************************************************************/
#ifndef _BORK_PARSE_HPP_
#define _BORK_PARSE_HPP_
/* TODO : implement */
#endif /* _BORK_PARSE_HPP_ */
| 42.3
| 101
| 0.184397
|
NaerJeis
|
8766a316d834084a15d81ad95d8ebf567f2aa73f
| 262
|
cpp
|
C++
|
39 using continue statement.cpp
|
pujanmahat/c-oop-programme
|
8f48bf409e27dbf9c03c8b3cb0a7a7dcdbc0ee46
|
[
"Apache-2.0"
] | null | null | null |
39 using continue statement.cpp
|
pujanmahat/c-oop-programme
|
8f48bf409e27dbf9c03c8b3cb0a7a7dcdbc0ee46
|
[
"Apache-2.0"
] | null | null | null |
39 using continue statement.cpp
|
pujanmahat/c-oop-programme
|
8f48bf409e27dbf9c03c8b3cb0a7a7dcdbc0ee46
|
[
"Apache-2.0"
] | null | null | null |
//wap to display the number from 200 to 400 except 207 usin continue statemetn in c++ programming
#include<iostream>
using namespace std;
int main()
{
int i;
for(i=200;i<=400;i++)
{
if (i==207)
{
continue;
}
cout<<i<<"\t";
}
}
| 14.555556
| 98
| 0.580153
|
pujanmahat
|
876a551beff3391ea8ed076552a3a9f36e37e2f4
| 4,892
|
cpp
|
C++
|
io/DirectoryInputStreamArchive.cpp
|
Andrewich/deadjustice
|
48bea56598e79a1a10866ad41aa3517bf7d7c724
|
[
"BSD-3-Clause"
] | 3
|
2019-04-20T10:16:36.000Z
|
2021-03-21T19:51:38.000Z
|
io/DirectoryInputStreamArchive.cpp
|
Andrewich/deadjustice
|
48bea56598e79a1a10866ad41aa3517bf7d7c724
|
[
"BSD-3-Clause"
] | null | null | null |
io/DirectoryInputStreamArchive.cpp
|
Andrewich/deadjustice
|
48bea56598e79a1a10866ad41aa3517bf7d7c724
|
[
"BSD-3-Clause"
] | 2
|
2020-04-18T20:04:24.000Z
|
2021-09-19T05:07:41.000Z
|
#include "DirectoryInputStreamArchive.h"
#include <io/File.h>
#include <io/FileInputStream.h>
#include <io/FileNotFoundException.h>
#include <lang/Array.h>
#include <lang/Debug.h>
#include "config.h"
//-----------------------------------------------------------------------------
using namespace lang;
//-----------------------------------------------------------------------------
namespace io
{
class DirectoryInputStreamArchive::DirectoryInputStreamArchiveImpl :
public Object
{
public:
DirectoryInputStreamArchiveImpl()
{
m_entriesDirty = true;
}
void addPath( const String& path )
{
File dir( path );
m_paths.add( dir.getAbsolutePath() );
m_entriesDirty = true;
}
void addPaths( const String& path )
{
// add root
File dir( path );
m_paths.add( dir.getAbsolutePath() );
// list files in the directory
Array<String,256> files;
files.setSize( 256 );
int count = dir.list( &files[0], files.size() );
files.setSize( count );
if ( count > 256 )
dir.list( &files[0], files.size() );
// recurse subdirectories
for ( int i = 0 ; i < files.size() ; ++i )
{
File file( path, files[i] );
if ( file.isDirectory() )
addPaths( file.getPath() );
}
m_entriesDirty = true;
}
void removePaths()
{
m_paths.clear();
m_entriesDirty = true;
}
void refreshEntriesRecurse( const String& path ) const
{
// get files in the path
Array<String,256> files;
files.setSize( 256 );
File dir( path );
int count = dir.list( &files[0], files.size() );
files.setSize( count );
if ( count > 256 )
dir.list( &files[0], files.size() );
// add entries
for ( int i = 0 ; i < files.size() ; ++i )
{
File file( path, files[i] );
m_entries.add( file );
}
// recurse subdirectories
for ( int i = 0 ; i < files.size() ; ++i )
{
File file( path, files[i] );
if ( file.isDirectory() )
refreshEntriesRecurse( file.getPath() );
}
}
void refreshEntries() const
{
Debug::println( "Listing files from directories {0}", toString() );
m_entries.clear();
for ( int i = 0 ; i < m_paths.size() ; ++i )
{
const String& path = m_paths[i];
refreshEntriesRecurse( path );
}
m_entriesDirty = false;
}
String getEntry( int index )
{
if ( m_entriesDirty )
refreshEntries();
assert( index >= 0 && index < m_entries.size() );
return m_entries[index].getPath();
}
InputStream* getInputStream( const String& name )
{
String path = name;
if ( !File(path).isAbsolute() )
{
// relative path
for ( int k = 0 ; k < m_paths.size() ; ++k )
{
File file( m_paths[k], path );
if ( file.exists() )
{
path = file.getAbsolutePath();
break;
}
}
}
if ( !File(path).exists() )
throw FileNotFoundException( Format("File {0} is not in directories {1}", name, toString() ) );
m_inputStream = new FileInputStream( path );
return m_inputStream;
}
InputStream* getInputStream( int index )
{
if ( m_entriesDirty )
refreshEntries();
assert( index >= 0 && index < m_entries.size() );
m_inputStream = new FileInputStream( m_entries[index].getPath() );
return m_inputStream;
}
int size() const
{
if ( m_entriesDirty )
refreshEntries();
return m_entries.size();
}
String toString() const
{
String str;
for ( int i = 0 ; i < m_paths.size() ; ++i )
{
if ( i > 0 )
str = str + File::pathSeparator + " ";
str = str + m_paths[i];
}
return str;
}
private:
Array<String,1> m_paths;
mutable Array<File,1> m_entries;
mutable bool m_entriesDirty;
P(InputStream) m_inputStream;
};
//-----------------------------------------------------------------------------
DirectoryInputStreamArchive::DirectoryInputStreamArchive()
{
m_this = new DirectoryInputStreamArchiveImpl;
}
DirectoryInputStreamArchive::~DirectoryInputStreamArchive()
{
}
void DirectoryInputStreamArchive::addPath( const String& path )
{
m_this->addPath( path );
}
void DirectoryInputStreamArchive::addPaths( const String& path )
{
m_this->addPaths( path );
}
void DirectoryInputStreamArchive::removePaths()
{
m_this->removePaths();
}
void DirectoryInputStreamArchive::close()
{
}
InputStream* DirectoryInputStreamArchive::getInputStream( const String& name )
{
return m_this->getInputStream( name );
}
InputStream* DirectoryInputStreamArchive::getInputStream( int index )
{
return m_this->getInputStream( index );
}
String DirectoryInputStreamArchive::getEntry( int index ) const
{
return m_this->getEntry( index );
}
int DirectoryInputStreamArchive::size() const
{
return m_this->size();
}
String DirectoryInputStreamArchive::toString() const
{
return m_this->toString();;
}
} // io
| 21.086207
| 99
| 0.593827
|
Andrewich
|
876cfa131dc8c18353813208dc3f611c83e51abe
| 5,322
|
cpp
|
C++
|
srcdll/ftdi.cpp
|
HPC-Factor/232usb
|
aaf0e43e20e7e7ea9d5f8b0a2c0ba37bcf0d1567
|
[
"BSD-3-Clause"
] | null | null | null |
srcdll/ftdi.cpp
|
HPC-Factor/232usb
|
aaf0e43e20e7e7ea9d5f8b0a2c0ba37bcf0d1567
|
[
"BSD-3-Clause"
] | null | null | null |
srcdll/ftdi.cpp
|
HPC-Factor/232usb
|
aaf0e43e20e7e7ea9d5f8b0a2c0ba37bcf0d1567
|
[
"BSD-3-Clause"
] | null | null | null |
// 232usb Copyright (c) 03-04,06 Zoroyoshi, Japan
// See source.txt for detail
#include <windows.h>
#include "usbdi.h"
#include "common.h"
#include "file.h"
#include "device.h"
#include "ftdi.h"
int ftdi_extension::
recvdata(BYTE* src, DWORD len)
{
//ftdi: every packet(64bytes) have two status header bytes
while(len>=2) {
//signal line
DWORD err;
err= src[1]&(CE_OVERRUN|CE_RXPARITY|CE_FRAME|CE_BREAK);
DWORD in;
in= src[0]&(MS_CTS_ON|MS_DSR_ON|MS_RING_ON|MS_RLSD_ON)|src[1]>>4&1;
linestatein(in, err);
//receive data
DWORD sz= len-2;
if(sz>=62) sz= 62;
if(sz>0) device_extension::recvdata(src+2, sz);
len-= (sz+2);
src+= (sz+2);
};
return 1;
};
BOOL ftdi_extension::
init()
{
if(recvendp==0||sendendp==0) return FALSE;
if(device_extension::init()==0) return FALSE;
USB_DEVICE_REQUEST req;
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_VENDOR|USB_REQUEST_FOR_DEVICE;
req.bRequest= 0x0; //SIO_RESET
req.wValue= 0; req.wIndex= 0; req.wLength= 0;
USB_TRANSFER ut;
ut= uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_DEVICE|USB_OUT_TRANSFER
, &req, 0, 0);
if(ut) uf->lpCloseTransfer(ut);
return TRUE;
};
BOOL ft100_extension::
init()
{
if(ftdi_extension::init()==0) return FALSE;
sendpkt= (sendendp->Descriptor.wMaxPacketSize&0x7ff)-2;
return TRUE;
};
USB_TRANSFER ftdi_extension::
issuelinestate(int nandcode, int orcode, HANDLE event)
{
USB_DEVICE_REQUEST req;
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_VENDOR|USB_REQUEST_FOR_DEVICE;
req.bRequest= 0x1; //MODEM_CTRL
req.wValue= (WORD)(nandcode<<8|orcode); req.wIndex= 0; req.wLength= 0;
return uf->lpIssueVendorTransfer(uh, notifyevent, event
, USB_SEND_TO_DEVICE|USB_OUT_TRANSFER
, &req, 0, 0);
};
USB_TRANSFER ftdi_extension::
issuebreak(int code)
{
USB_DEVICE_REQUEST req;
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_VENDOR|USB_REQUEST_FOR_DEVICE;
req.bRequest= 0x4; //SET_DATA
req.wValue= dcb.ByteSize|(WORD)dcb.Parity<<8|(WORD)dcb.StopBits<<11|(code?1<<14:0);
req.wIndex= 0; req.wLength= 0;
return uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_DEVICE|USB_OUT_TRANSFER
, &req, 0, 0);
};
BOOL ftdi_extension::
applydcb()
{
device_extension::applydcb();
USB_TRANSFER ut;
USB_DEVICE_REQUEST req;
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_VENDOR|USB_REQUEST_FOR_DEVICE;
req.bRequest= 0x3; //SET_BAUDRATE
int baud= dcb.BaudRate; if(baud==0) baud= 9600;
int div= (usbmode&MODE_12MHZ)?6000000:24000000;
div= div/baud;
req.wValue= div>>3|(div&4?0x4000:(div&2?0x8000:(div&1?0xc000:0)));
req.wIndex= 0; req.wLength= 0;
ut= uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_DEVICE|USB_OUT_TRANSFER
, &req, 0, 0);
if(ut) uf->lpCloseTransfer(ut);
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_VENDOR|USB_REQUEST_FOR_DEVICE;
req.bRequest= 0x4; //SET_DATA
req.wValue= dcb.ByteSize|(WORD)dcb.Parity<<8|(WORD)dcb.StopBits<<11;
req.wIndex= 0; req.wLength= 0;
ut= uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_DEVICE|USB_OUT_TRANSFER
, &req, 0, 0);
if(ut) uf->lpCloseTransfer(ut);
return TRUE;
};
BOOL ft100_extension::
applydcb()
{
device_extension::applydcb();
USB_TRANSFER ut;
USB_DEVICE_REQUEST req;
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_VENDOR|USB_REQUEST_FOR_DEVICE;
req.bRequest= 0x3; //SET_BAUDRATE
switch(dcb.BaudRate) {
case 300: req.wValue= 0; break;
case 600: req.wValue= 1; break;
case 1200: req.wValue= 2; break;
case 2400: req.wValue= 3; break;
case 4800: req.wValue= 4; break;
case 9600: default: req.wValue= 5; break;
case 19200: req.wValue= 6; break;
case 38400: req.wValue= 7; break;
case 57600: req.wValue= 8; break;
case 115200: req.wValue= 9; break;
};
req.wIndex= 0; req.wLength= 0;
ut= uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_DEVICE|USB_OUT_TRANSFER
, &req, 0, 0);
if(ut) uf->lpCloseTransfer(ut);
req.bmRequestType= USB_REQUEST_HOST_TO_DEVICE|USB_REQUEST_VENDOR|USB_REQUEST_FOR_DEVICE;
req.bRequest= 0x4; //SET_DATA
req.wValue= dcb.ByteSize|(WORD)dcb.Parity<<8|(WORD)dcb.StopBits<<11;
req.wIndex= 0; req.wLength= 0;
ut= uf->lpIssueVendorTransfer(uh, 0, 0
, USB_SEND_TO_DEVICE|USB_OUT_TRANSFER
, &req, 0, 0);
if(ut) uf->lpCloseTransfer(ut);
return TRUE;
};
int ft100_extension::
sentlen(DWORD *lenp)
{
if(!*lenp==0) (*lenp)--;
return 0;
};
USB_TRANSFER ft100_extension::
issuedata(BYTE* buf, BYTE* data, ULONG len, HANDLE ev)
{
buf[0]= (BYTE)(len<<2|1);
memcpy(buf+1, data, len);
return uf->lpIssueBulkTransfer(sendpipe, ev?notifyevent:0, ev
, USB_OUT_TRANSFER, len+1, buf, 0);
};
USB_TRANSFER ft100_extension::
issuesend(BYTE* data, ULONG len)
{
if(len>(DWORD)sendpkt) len= sendpkt;
if(!(usbmode&MODE_NO1132)) if(len%16==14) len--;
return issuedata(sendbuf, data, len, writeevent);
};
USB_TRANSFER ft100_extension::
issuechar(BYTE *p)
{
BYTE buf[2];
return issuedata(buf, p, 1, 0);
};
USB_TRANSFER ft100_extension::
issuexon(BYTE *p)
{
return issuedata(sendxonbuf, p, 1, serialevent);
};
| 28.612903
| 91
| 0.684705
|
HPC-Factor
|
8773cf166155df0f1409b68e3de6be5f5f16d04a
| 1,088
|
cc
|
C++
|
src/fsm2/serial.cc
|
chenxuhao/gardenia
|
01e8601a9ae76c3b58aa91f1c8c88203a6fe11d1
|
[
"Intel",
"MIT"
] | 23
|
2017-08-16T15:14:25.000Z
|
2022-01-05T06:41:08.000Z
|
mining/fsm2/serial.cc
|
chenxuhao/gardinia
|
5894df11cf47f8839945edadff43dc79e260216d
|
[
"MIT"
] | 2
|
2020-12-14T04:51:01.000Z
|
2022-02-02T20:57:28.000Z
|
mining/fsm2/serial.cc
|
chenxuhao/gardinia
|
5894df11cf47f8839945edadff43dc79e260216d
|
[
"MIT"
] | 5
|
2019-01-22T02:09:06.000Z
|
2020-04-02T12:05:42.000Z
|
// Copyright 2016, National University of Defense Technology
// Authors: Xuhao Chen <cxh@illinois.edu>
#include "fsm.h"
#include <timer.h>
#include <types.hpp>
#include <graph_types.hpp>
#include "miner.h"
#define FSM_VARIANT "serial"
void FSMSolver(const Graph &graph, int minsup, size_t &total) {
printf("Launching Serial FSM solver ...\n");
Timer t;
t.Start();
Miner miner(graph, minsup);
EdgeList edges;
Projected_map3 root;
for(unsigned int from = 0; from < graph.size(); ++from) {
if(get_forward_root(graph, graph[from], edges)) { // get the edge list of the node g[from] in graph g
for(EdgeList::iterator it = edges.begin(); it != edges.end(); ++it)
//projected (PDFS vector) entry: graph id (always 0 for single graph), edge pointer and null PDFS
root[graph[from].label][(*it)->elabel][graph[(*it)->to].label].push(0, *it, 0);
} // if
} // for from
miner.grow(root);
t.Stop();
total = miner.get_count();
printf("Number of frequent subgraphs (minsup=%d): %ld\n", minsup, total);
printf("\truntime [%s] = %f ms.\n", FSM_VARIANT, t.Millisecs());
}
| 36.266667
| 105
| 0.671875
|
chenxuhao
|
8775eb0c5318e119aae0cf058ceb6c40666eb5f0
| 333
|
cpp
|
C++
|
emitter.cpp
|
privet56/qRabbifier
|
4289016f9ba40658ad444580818292456574ffb5
|
[
"Apache-2.0"
] | 10
|
2016-04-15T15:31:08.000Z
|
2019-10-02T01:19:48.000Z
|
emitter.cpp
|
privet56/qRabbifier
|
4289016f9ba40658ad444580818292456574ffb5
|
[
"Apache-2.0"
] | null | null | null |
emitter.cpp
|
privet56/qRabbifier
|
4289016f9ba40658ad444580818292456574ffb5
|
[
"Apache-2.0"
] | 5
|
2016-04-15T15:31:10.000Z
|
2022-02-22T02:00:06.000Z
|
#include "emitter.h"
emitter::emitter(QObject* pLogTarget, QObject *parent) : QObject(parent)
{
connect(this,SIGNAL(log(QString,logger::LogLevel)),pLogTarget,SLOT(log(QString,logger::LogLevel)));
}
void emitter::emitlog(QString s, logger::LogLevel level, QObject* pLogTarget)
{
Q_UNUSED(pLogTarget)
emit log(s,level);
}
| 27.75
| 103
| 0.732733
|
privet56
|
877713aa2627033a2cab30753f80feef89d70bd9
| 117
|
hh
|
C++
|
src/rich-log/message.hh
|
project-arcana/rich-logging
|
23998c8c0a2aa008dbc4dd218f3c730a5ab3058a
|
[
"MIT"
] | 1
|
2020-12-09T13:54:48.000Z
|
2020-12-09T13:54:48.000Z
|
src/rich-log/message.hh
|
project-arcana/rich-logging
|
23998c8c0a2aa008dbc4dd218f3c730a5ab3058a
|
[
"MIT"
] | 2
|
2020-04-03T21:00:25.000Z
|
2021-03-25T14:25:05.000Z
|
src/rich-log/message.hh
|
project-arcana/rich-logging
|
23998c8c0a2aa008dbc4dd218f3c730a5ab3058a
|
[
"MIT"
] | null | null | null |
#pragma once
#include <rich-log/fwd.hh>
namespace rlog
{
struct message
{
rlog::location const* location;
};
}
| 9.75
| 35
| 0.683761
|
project-arcana
|
877b7b8681baf414367c859e8c2e0439fc5cdef8
| 5,579
|
cpp
|
C++
|
src/grep.cpp
|
jlangvand/jucipp
|
0a3102f13e62d78a329d488fb1eb8812181e448e
|
[
"MIT"
] | null | null | null |
src/grep.cpp
|
jlangvand/jucipp
|
0a3102f13e62d78a329d488fb1eb8812181e448e
|
[
"MIT"
] | null | null | null |
src/grep.cpp
|
jlangvand/jucipp
|
0a3102f13e62d78a329d488fb1eb8812181e448e
|
[
"MIT"
] | null | null | null |
#include "grep.hpp"
#include "config.hpp"
#include "dialog.hpp"
#include "filesystem.hpp"
#include "project_build.hpp"
#include "terminal.hpp"
#include "utility.hpp"
Grep::Grep(const boost::filesystem::path &path, const std::string &pattern, bool case_sensitive, bool extended_regex) {
if(path.empty())
return;
auto build = Project::Build::create(path);
std::string exclude;
for(auto &exclude_folder : build->get_exclude_folders())
#ifdef JUCI_USE_GREP_EXCLUDE
exclude += " --exclude=\"" + exclude_folder + "/*\" --exclude=\"*/" + exclude_folder + "/*\""; // BSD grep does not support --exclude-dir
#else
exclude += " --exclude-dir=\"" + exclude_folder + '"'; // Need to use --exclude-dir on Linux for some reason (could not get --exclude to work)
#endif
if(!build->project_path.empty())
project_path = build->project_path;
else
project_path = path;
std::string flags;
if(!case_sensitive)
flags += " -i";
if(extended_regex)
flags += " -E";
auto escaped_pattern = " \"" + pattern + '"';
for(size_t i = 2; i < escaped_pattern.size() - 1; ++i) {
if(escaped_pattern[i] == '"') {
escaped_pattern.insert(i, "\\");
++i;
}
}
std::string command = Config::get().project.grep_command + " -RHn --color=always --binary-files=without-match" + flags + exclude + escaped_pattern + " *";
TinyProcessLib::Process process(
command, project_path.string(),
[this](const char *output, size_t length) {
this->output.write(output, length);
},
[](const char *bytes, size_t n) {
Terminal::get().async_print(std::string(bytes, n), true);
});
int exit_status;
size_t count = 0;
while(!process.try_get_exit_status(exit_status)) {
++count;
if(count > 1000)
break;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
if(!process.try_get_exit_status(exit_status)) {
bool canceled = false;
Dialog::Message message("Please wait until grep command completes", [&canceled] {
canceled = true;
});
bool killed = false;
while(!process.try_get_exit_status(exit_status)) {
if(canceled && !killed) {
process.kill();
killed = true;
}
while(Gtk::Main::events_pending())
Gtk::Main::iteration();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
message.hide();
if(killed)
output = std::stringstream();
}
}
Grep::operator bool() {
output.seekg(0, std::ios::end);
if(output.tellg() == 0)
return false;
output.seekg(0, std::ios::beg);
return true;
}
Grep::Location Grep::get_location(std::string line, bool color_codes_to_markup, bool include_offset, const std::string &only_for_file) const {
#ifdef _WIN32
if(!line.empty() && line.back() == '\r')
line.pop_back();
#endif
std::vector<std::pair<size_t, size_t>> positions;
size_t file_end = std::string::npos, line_end = std::string::npos;
if(color_codes_to_markup) {
std::string escaped = Glib::Markup::escape_text(line);
auto decode_escape_sequence = [](const std::string &line, size_t &i) -> bool {
if(!starts_with(line, i, "["))
return false;
i += 7;
for(; i < line.size(); ++i) {
if((line[i] >= '0' && line[i] <= '9') || line[i] == ';')
continue;
return true;
}
return false;
};
bool open = false;
size_t start = 0;
line.clear();
line.reserve(escaped.size());
for(size_t i = 0; i < escaped.size(); ++i) {
if(decode_escape_sequence(escaped, i)) {
if(escaped[i] == 'm') {
if(!open)
start = line.size();
else
positions.emplace_back(start, line.size());
open = !open;
}
continue;
}
if(escaped[i] == ':') {
if(file_end == std::string::npos)
file_end = line.size();
else if(line_end == std::string::npos)
line_end = line.size();
}
line += escaped[i];
}
if(file_end == std::string::npos || line_end == std::string::npos)
return {};
for(auto it = positions.rbegin(); it != positions.rend(); ++it) {
if(it->first > line_end) {
line.insert(it->second, "</b>");
line.insert(it->first, "<b>");
}
}
}
else {
file_end = line.find(':');
if(file_end == std::string::npos)
return {};
line_end = line.find(':', file_end + 1);
if(file_end == std::string::npos)
return {};
}
Location location;
location.markup = std::move(line);
auto file = location.markup.substr(0, file_end);
if(!only_for_file.empty()) {
#ifdef _WIN32
if(boost::filesystem::path(file) != boost::filesystem::path(only_for_file))
return location;
#else
if(file != only_for_file)
return location;
#endif
}
location.file_path = std::move(file);
try {
location.line = std::stoul(location.markup.substr(file_end + 1, line_end - file_end)) - 1;
if(!include_offset) {
location.offset = 0;
return location;
}
// Find line offset by searching for first match marked with <b></b>
Glib::ustring ustr = location.markup.substr(line_end + 1);
size_t offset = 0;
bool escaped = false;
for(auto chr : ustr) {
if(chr == '<')
break;
else if(chr == '&')
escaped = true;
else if(chr == ';') {
escaped = false;
continue;
}
else if(escaped)
continue;
offset++;
}
location.offset = offset;
return location;
}
catch(...) {
return {};
}
}
| 28.464286
| 156
| 0.586306
|
jlangvand
|
877f1723c0d14a29decf0dc64e9c613a41f75e73
| 797
|
cpp
|
C++
|
Libraries/RobsJuceModules/rosic/filters/rosic_BiquadBase.cpp
|
RobinSchmidt/RS-MET-Preliminary
|
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
|
[
"FTL"
] | 34
|
2017-04-19T18:26:02.000Z
|
2022-02-15T17:47:26.000Z
|
Libraries/RobsJuceModules/rosic/filters/rosic_BiquadBase.cpp
|
RobinSchmidt/RS-MET-Preliminary
|
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
|
[
"FTL"
] | 307
|
2017-05-04T21:45:01.000Z
|
2022-02-03T00:59:01.000Z
|
Libraries/RobsJuceModules/rosic/filters/rosic_BiquadBase.cpp
|
RobinSchmidt/RS-MET-Preliminary
|
6c01cbaad7cce3daa3293c444dd9e4b74e5ebfbe
|
[
"FTL"
] | 4
|
2017-09-05T17:04:31.000Z
|
2021-12-15T21:24:28.000Z
|
//#include "rosic_BiquadBase.h"
//using namespace rosic;
//-------------------------------------------------------------------------------------------------
// construction/destruction:
BiquadBase::BiquadBase()
{
initializeCoefficients();
}
BiquadBase::~BiquadBase()
{
}
//-------------------------------------------------------------------------------------------------
// parameter settings:
void BiquadBase::setCoefficients(double newB0, double newB1, double newB2, double newA1, double newA2)
{
b0 = newB0;
b1 = newB1;
b2 = newB2;
a1 = newA1;
a2 = newA2;
}
//-------------------------------------------------------------------------------------------------
// others:
void BiquadBase::initializeCoefficients()
{
setCoefficients(1.0, 0.0, 0.0, 0.0, 0.0);
}
| 20.973684
| 102
| 0.415307
|
RobinSchmidt
|
87857273beb4ed6e219d8f058407d48944f8e98f
| 493
|
cpp
|
C++
|
baekjoon/10950.cpp
|
GihwanKim/Baekjoon
|
52eb2bf80bb1243697858445e5b5e2d50d78be4e
|
[
"MIT"
] | null | null | null |
baekjoon/10950.cpp
|
GihwanKim/Baekjoon
|
52eb2bf80bb1243697858445e5b5e2d50d78be4e
|
[
"MIT"
] | null | null | null |
baekjoon/10950.cpp
|
GihwanKim/Baekjoon
|
52eb2bf80bb1243697858445e5b5e2d50d78be4e
|
[
"MIT"
] | null | null | null |
/*
10950 : A+B - 3
URL : https://www.acmicpc.net/problem/10950
Input :
5
1 1
2 3
3 4
9 8
5 2
Output :
2
5
7
17
7
*/
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
int N;
cin >> N;
for (int i = 0; i < N; i++)
{
int A;
int B;
cin >> A;
cin >> B;
cout << (A + B) << endl;
}
return 0;
}
| 12.02439
| 47
| 0.365112
|
GihwanKim
|
87882e34bbb1f68b4f8f6ad3537ef5ba4f6fb527
| 224
|
cpp
|
C++
|
tests/math.cpp
|
cenomla/oak-engine
|
e0b559497cddc69d5ed840a65e092dab263e24d1
|
[
"MIT"
] | 3
|
2016-09-12T22:30:10.000Z
|
2017-04-20T06:16:24.000Z
|
tests/math.cpp
|
cenomla/oakengine
|
e0b559497cddc69d5ed840a65e092dab263e24d1
|
[
"MIT"
] | null | null | null |
tests/math.cpp
|
cenomla/oakengine
|
e0b559497cddc69d5ed840a65e092dab263e24d1
|
[
"MIT"
] | null | null | null |
#include <oakengine.h>
#include <math/mat.h>
int main(int argc, char **argv) {
oak::math::Mat4 mat{ 2 };
oak::math::Vec4 vec{ 2 };
auto r = mat * vec;
if (r != oak::math::Vec4{ 4 }) {
return -1;
}
return 0;
}
| 11.789474
| 33
| 0.553571
|
cenomla
|
8788661d10ba31ea255bdbfd0aaa0ab6b8a1bcb3
| 3,872
|
cpp
|
C++
|
Week2/heap/heap.cpp
|
aakash-sahu/compsci-cs400
|
eee279bde822784ba18c6f632f31a3e20ff13741
|
[
"MIT"
] | null | null | null |
Week2/heap/heap.cpp
|
aakash-sahu/compsci-cs400
|
eee279bde822784ba18c6f632f31a3e20ff13741
|
[
"MIT"
] | null | null | null |
Week2/heap/heap.cpp
|
aakash-sahu/compsci-cs400
|
eee279bde822784ba18c6f632f31a3e20ff13741
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include "Cube.h"
using uiuc::Cube;
int main() {
// heap has to assigned by new operator
int *numPtr = new int;
std::cout << "*numptr: " << *numPtr << std::endl; // when dereferenced pointer is printed, it can return any random number
std::cout << "numptr: " << numPtr << std::endl; //content of numPtr == address of heap memory -> a low number than stack memory as heap memory starts from low
std::cout << "&numptr: " << &numPtr << std::endl; // high memory as numPtr variable stored in stack memory
*numPtr = 42;
std::cout << "*numptr: " << *numPtr << std::endl; // value assigned
std::cout << "numptr: " << numPtr << std::endl; //remains same
std::cout << "&numptr: " << &numPtr << std::endl; //remains same
delete numPtr; //delete the heap memory and give back to system
std::cout << "*numptr after deleting: " << *numPtr << std::endl; // now pointer points to a memory that doesn't contain any data for us
// so assign the ptr to nullptr after deleting as it's defined to be going nowhere (raises segmentation error when accesses and can't be deleted.
// ) hence avoids the problem of dangling pointer.
numPtr = nullptr;
//std::cout << "*numptr after deleting: " << *numPtr << std::endl; // this prints a Segmenation fault. The program still compiles and runs till this point.
//ex 2
Cube *c = new Cube;
(*c).setLength(4);
std::cout << "c: " << c << std::endl; //heap address for cube
std::cout << "&c: " << &c << std::endl; //stack address of c
//std::cout << "*c: " << *c << std::endl; //won't compile as not char
std::cout << "c volume: " << (*c).getVolume() << std::endl; //call function for pointer
std::cout << "c volume: " << c->getVolume() << std::endl; //another way of calling class functions.
//ex3
Cube *c1 = new Cube;
Cube *c2 = c1; // points to the same data as c1
c2->setLength(10);
delete c2; // delete the data at memory at which c1 is there so error.
// delete c1; // run gives error that double free memory
// puzzle with reference variable
int *x = new int;
int &y = *x; //y is a reference variable. It alias another memory and name a piece of memory. => this heap memory address is called y.
y =4;
std::cout << "Reference variable: "<< std::endl;
std::cout << &x << std::endl; //stack address = large
std::cout << x << std::endl; //ptr value at heap address = low value
std::cout << *x << std::endl; // value = 4
std::cout << &y << std::endl; // same as heap address
std::cout << y << std::endl; // value =4
// std::cout << *y << std::endl; //gives error as non-pointer => error = indirection requires pointer operand
delete x;
x = nullptr;
//puzzle 3
int *p, *q;
p = new int;
q = p;
*q = 8;
std::cout << "Puzzle 3: "<< std::endl;
std::cout << *p << std::endl; //should print 8
q = new int; //q now points to a new memory
*q = 9;
std::cout << *p << std::endl; //should print 8
std::cout << *q << std::endl; //should print 9
//puzzle 4 -- use of array and for loop
std::cout << "Array and for loop: "<< std::endl;
int *z;
int size =3;
z = new int[size]; //x == new integer array of size 3 => allocating a sequence of memory of size 3 total in heap
for (int i =0; i < size; i++) {
z[i] = i +3;
std::cout << z[i] << std::endl;
}
std::cout << *z << std::endl; //only prints the first value as ptr to first memory location
delete[] z; //delete array of memory.
std::cout << *z << std::endl;
//quiz question
int *v = new int;
*v =0;
int &b = *v;
std::cout << "quiz: " << *v << b << std::endl;
b++;
std::cout << "quiz: " << *v << b << std::endl;
return 0;
}
| 39.917526
| 162
| 0.573089
|
aakash-sahu
|
8789167f13ece3323c9814e4c8ad682a2fa879d6
| 1,673
|
hpp
|
C++
|
src/Common/Profiler.hpp
|
nickwn/Stratum
|
3d99193199ef4e20aca9f9203a36f34e225cd896
|
[
"MIT"
] | null | null | null |
src/Common/Profiler.hpp
|
nickwn/Stratum
|
3d99193199ef4e20aca9f9203a36f34e225cd896
|
[
"MIT"
] | null | null | null |
src/Common/Profiler.hpp
|
nickwn/Stratum
|
3d99193199ef4e20aca9f9203a36f34e225cd896
|
[
"MIT"
] | null | null | null |
#pragma once
#include "common.hpp"
namespace stm {
struct ProfilerSample {
ProfilerSample* mParent;
list<unique_ptr<ProfilerSample>> mChildren;
chrono::high_resolution_clock::time_point mStartTime;
chrono::nanoseconds mDuration;
Vector4f mColor;
string mLabel;
};
class Profiler {
private:
STRATUM_API static list<ProfilerSample> mFrameHistory;
STRATUM_API static ProfilerSample* mCurrentSample;
STRATUM_API static size_t mHistoryCount;
STRATUM_API static bool mPaused;
STRATUM_API static unique_ptr<ProfilerSample> mTimelineSample;
public:
static void DrawGui();
inline static void begin_sample(const string& label, const Vector4f& color = Vector4f(.3f, .9f, .3f, 1)) {
ProfilerSample s;
s.mParent = mCurrentSample;
s.mStartTime = chrono::high_resolution_clock::now();
s.mDuration = chrono::nanoseconds::zero();
s.mLabel = label;
s.mColor = color;
if (mCurrentSample)
mCurrentSample = mCurrentSample->mChildren.emplace_back(make_unique<ProfilerSample>(move(s))).get();
else {
mCurrentSample = &mFrameHistory.emplace_front(move(s));
while (mFrameHistory.size() > mHistoryCount)
mFrameHistory.pop_back();
}
}
inline static ProfilerSample& end_sample() {
if (!mCurrentSample) throw logic_error("attempt to end nonexistant profiler sample!");
if (mPaused) return *mCurrentSample;
mCurrentSample->mDuration += chrono::high_resolution_clock::now() - mCurrentSample->mStartTime;
ProfilerSample* tmp = mCurrentSample;
mCurrentSample = mCurrentSample->mParent;
return *tmp;
}
inline static const list<ProfilerSample>& history() { return mFrameHistory; }
inline static void clear() { mFrameHistory.clear(); }
};
}
| 30.418182
| 107
| 0.759115
|
nickwn
|
879aaa9b4605eef551fb06ce3dcf254a176754f6
| 3,070
|
cpp
|
C++
|
codeforces/F - The Number of Subpermutations/Accepted.cpp
|
kzvd4729/Problem-Solving
|
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
|
[
"MIT"
] | 1
|
2022-02-11T16:55:36.000Z
|
2022-02-11T16:55:36.000Z
|
codeforces/F - The Number of Subpermutations/Accepted.cpp
|
kzvd4729/Problem-Solving
|
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
|
[
"MIT"
] | null | null | null |
codeforces/F - The Number of Subpermutations/Accepted.cpp
|
kzvd4729/Problem-Solving
|
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
|
[
"MIT"
] | null | null | null |
/****************************************************************************************
* @author: kzvd4729 created: Jul/14/2020 22:48
* solution_verdict: Accepted language: GNU C++17
* run_time: 514 ms memory_used: 55700 KB
* problem: https://codeforces.com/contest/1175/problem/F
****************************************************************************************/
#include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<bitset>
#include<assert.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<set>
#include<queue>
#include<unordered_map>
#include<random>
#include<chrono>
#include<stack>
#include<deque>
#define endl '\n'
#define long long long
using namespace std;
const int N=3e5;
int a[N+2],fr[N+2],bc[N+2];
vector<int>v[N+2];
int sp[N+2][20+2];
void build(int n)
{
for(int i=1;i<=n;i++)sp[i][0]=a[i];//array
for(int j=1;j<=20;j++)
{
for(int i=1;i<=n;i++)
{
sp[i][j]=sp[i][j-1];
if((i+(1<<(j-1)))<=n)
sp[i][j]=max(sp[i][j-1],sp[i+(1<<(j-1))][j-1]);
}
}
}
int get(int lt,int rt)
{
//if(rt<lt)return 1e9;
int dg=31-__builtin_clz(rt-lt+1);
return max(sp[lt][dg],sp[rt-(1<<dg)+1][dg]);
}
set<pair<int,int> >ans;
void solve(int l,int r,int m)
{
int sz=r-l+1;set<int>st;
for(int i=1;i<=sz+1;i++)st.insert(i);
ans.insert({m,m});int mx=0;
for(int i=m-1;i>=l;i--)
{
if(a[i]>sz)break;
if(st.find(a[i])==st.end())break;
st.erase(a[i]);mx=max(mx,a[i]);
if(fr[i]<mx)continue;
if(mx==(m-i+1)){ans.insert({i,m});continue;}
auto it=st.lower_bound(mx);it--;
if(get(m+1,i+mx-1)==*it)ans.insert({i,i+mx-1});
}
sz=r-l+1;st.clear();
for(int i=1;i<=sz+1;i++)st.insert(i);
ans.insert({m,m});mx=0;
for(int i=m+1;i<=r;i++)
{
if(a[i]>sz)break;
if(st.find(a[i])==st.end())break;
st.erase(a[i]);mx=max(mx,a[i]);
if(bc[i]<mx)continue;
if(mx==(i-m+1)){ans.insert({m,i});continue;}
auto it=st.lower_bound(mx);it--;
if(get(i-mx+1,m-1)==*it)ans.insert({i-mx+1,i});
}
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],v[a[i]].push_back(i);
fr[n]=n;
for(int i=n-1;i>=1;i--)
{
fr[i]=fr[i+1];int x=a[i];
int id=upper_bound(v[x].begin(),v[x].end(),i)-v[x].begin();
if(id<v[x].size())fr[i]=min(fr[i],v[x][id]-1);
}
bc[1]=1;
for(int i=2;i<=n;i++)
{
bc[i]=bc[i-1];int x=a[i];
int id=lower_bound(v[x].begin(),v[x].end(),i)-v[x].begin();
id--;
if(id>=0)bc[i]=max(bc[i],v[x][id]+1);
}
//for(int i=1;i<=n;i++)cout<<bc[i]<<" ";cout<<endl;
build(n);
for(int i=1;i<=n;i++)fr[i]=fr[i]-i+1,bc[i]=i-bc[i]+1;
int l=0;v[1].push_back(n+1);
for(int i=0;i<v[1].size()-1;i++)
{
solve(l+1,v[1][i+1]-1,v[1][i]);
l=v[1][i];
}
//for(auto x:ans)cout<<x.first<<" "<<x.second<<endl;
cout<<ans.size()<<endl;
return 0;
}
| 27.657658
| 111
| 0.485016
|
kzvd4729
|
879c0fe0d105e64e6c80733892fe3b2d81a71b0d
| 8,045
|
cpp
|
C++
|
Qt/4/01_smarthome/01_smarthome/mainwindow.cpp
|
alientek-openedv/Embedded-Qt-Tutorial
|
3c75142235b4d39c22e1ad56a5bd92d08c1a0d42
|
[
"MIT"
] | 1
|
2022-02-21T03:19:36.000Z
|
2022-02-21T03:19:36.000Z
|
Qt/4/01_smarthome/01_smarthome/mainwindow.cpp
|
alientek-openedv/Embedded-Qt-Tutorial
|
3c75142235b4d39c22e1ad56a5bd92d08c1a0d42
|
[
"MIT"
] | null | null | null |
Qt/4/01_smarthome/01_smarthome/mainwindow.cpp
|
alientek-openedv/Embedded-Qt-Tutorial
|
3c75142235b4d39c22e1ad56a5bd92d08c1a0d42
|
[
"MIT"
] | 1
|
2021-10-19T04:03:56.000Z
|
2021-10-19T04:03:56.000Z
|
/******************************************************************
Copyright © Deng Zhimao Co., Ltd. 1990-2021. All rights reserved.
* @projectName 01_smarthome
* @brief mainwindow.cpp
* @author Deng Zhimao
* @email 1252699831@qq.com
* @net www.openedv.com
* @date 2021-05-26
*******************************************************************/
#include "mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
/* 界面布局 */
layoutInit();
/* 原子云服务器接口对象 */
webapi = new Webapi(this);
/* 接收设备状态改变的心跳包,这里只检查在线的心跳包,
* 离线的需要设备方主动发送离线信息 */
connect(webapi, SIGNAL(deviceStateChanged(QString)),
this, SLOT(deviceState(QString)));
for (int i = 0; i < 3; i++)
connect(switchButton[i], SIGNAL(toggled(bool)),
this, SLOT(onToggled(bool)));
}
MainWindow::~MainWindow()
{
}
void MainWindow::layoutInit()
{
/* 主界面背景 */
this->setGeometry(0, 0, 800, 480);
this->setMinimumWidth(700);
this->setMinimumHeight(450);
this->setObjectName("smarthome");
for (int i = 0; i < 11; i++) {
widget[i] = new QWidget();
widget[i]->setObjectName(tr("widget%1")
.arg(QString::number(i)));
}
for (int i = 0; i < 2; i++)
vBoxLayout[i] = new QVBoxLayout();
for (int i = 0; i < 6; i++)
hBoxLayout[i] = new QHBoxLayout();
for (int i = 0; i < 4; i++) {
label[i] = new QLabel();
label[i]->setObjectName(tr("label%1")
.arg(QString::number(i)));
}
QStringList list;
list<<"在家"<<"睡觉"<<"出远门";
for (int i = 0; i < 3; i++) {
pushButton[i] = new QPushButton();
pushButton[i]->setFixedSize(100, 30);
pushButton[i]->setText(list[i]);
pushButton[i]->setCheckable(true);
pushButton[i]->setFocusPolicy(Qt::NoFocus);
}
pushButton[0]->setChecked(true);
widget[1]->setMaximumHeight(50);
widget[2]->setMaximumHeight(25);
widget[3]->setMaximumHeight(120);
widget[4]->setMaximumHeight(30);
widget[5]->setMaximumHeight(150);
/* 主布局 */
vBoxLayout[0]->addWidget(widget[1]);
vBoxLayout[0]->addWidget(widget[2]);
vBoxLayout[0]->addWidget(widget[3]);
vBoxLayout[0]->addWidget(widget[4]);
vBoxLayout[0]->addWidget(widget[5]);
vBoxLayout[0]->setContentsMargins(80, 52, 80, 50);
/* 主界面采用垂直布局 */
widget[0]->setLayout(vBoxLayout[0]);
setCentralWidget(widget[0]);
cloudPushButton = new QPushButton(this);
cloudPushButton->move(15, 10);
cloudPushButton->setMinimumHeight(42);
cloudPushButton->setMinimumWidth(150);
cloudPushButton->setFocusPolicy(Qt::NoFocus);
cloudPushButton->setObjectName("cloudPushButton");
cloudPushButton->setText("原子云物联");
QIcon icon(":/icons/cloud.png");
cloudPushButton->setIcon(icon);
cloudPushButton->setIconSize(QSize(42, 42));
hBoxLayout[0]->addWidget(label[0]);
hBoxLayout[0]->setContentsMargins(0, 0, 0, 0);
label[0]->setText("虫虫的家");
widget[1]->setLayout(hBoxLayout[0]);
hBoxLayout[1]->addWidget(label[1]);
label[1]->setText("欢迎回家,虫虫,已经为您设置在家模式");
hBoxLayout[1]->setContentsMargins(0, 0, 0, 0);
widget[2]->setLayout(hBoxLayout[1]);
hBoxLayout[2]->addWidget(label[2]);
hBoxLayout[2]->setContentsMargins(0, 0, 0, 0);
label[2]->setText("常用控制面板");
widget[4]->setLayout(hBoxLayout[2]);
vBoxLayout[1]->addWidget(widget[6]);
vBoxLayout[1]->addWidget(widget[7]);
vBoxLayout[1]->setContentsMargins(0, 0, 0, 0);
widget[3]->setLayout(vBoxLayout[1]);
hBoxLayout[3]->addWidget(label[3]);
hBoxLayout[3]->setContentsMargins(30, 0, 0, 0);
label[3]->setText("所处场景");
widget[6]->setLayout(hBoxLayout[3]);
hBoxLayout[4]->addWidget(pushButton[0]);
hBoxLayout[4]->addWidget(pushButton[1]);
hBoxLayout[4]->addWidget(pushButton[2]);
hBoxLayout[4]->setAlignment(Qt::AlignLeft);
hBoxLayout[4]->setSpacing(30);
hBoxLayout[4]->setContentsMargins(30, 0, 0, 0);
widget[7]->setLayout(hBoxLayout[4]);
/* 控制列表 */
listWidget = new QListWidget();
listWidget->setFocusPolicy(Qt::NoFocus);
listWidget->setMaximumHeight(150);
listWidget->setVerticalScrollBarPolicy(
Qt::ScrollBarAlwaysOff);
listWidget->setHorizontalScrollBarPolicy(
Qt::ScrollBarAlwaysOff);
/* 横向排布 */
listWidget->setFlow(QListView::LeftToRight);
hBoxLayout[5]->addWidget(listWidget);
hBoxLayout[5]->setContentsMargins(0, 0, 0, 0);
widget[5]->setLayout(hBoxLayout[5]);
QStringList iconList;
iconList<<":/icons/light.png"
<<":/icons/tablelamp.png"
<<":/icons/fan.png";
QStringList localtionList;
localtionList<<"客厅"<<"次卧"<<"主卧";
QStringList nameList;
nameList<<"客厅灯|离线"<<"台灯|离线"<<"空调|离线";
/* 布局在前面章节详细说过,不再一一注释 */
for (int i = 0; i < 3; i++) {
gridLayout[i] = new QGridLayout();
gridLayout[i]->setContentsMargins(0, 0, 0, 0);
}
for (int i = 0; i < 3; i++) {
switchButton[i] = new SwitchButton();
switchButton[i]->setMaximumSize(50, 30);
}
for (int i = 0; i < 9; i++) {
itemLabel[i] = new QLabel();
itemLabel[i]->setMaximumSize(75, 75);
itemLabel[i]->setScaledContents(true);
itemLabel[i]->setAlignment(Qt::AlignCenter);
itemLabel[i]->setObjectName(tr("itemLable%1")
.arg(QString::number(i)));
}
itemLabel[0]->setPixmap(QPixmap(iconList[0]));
itemLabel[1]->setPixmap(QPixmap(iconList[1]));
itemLabel[2]->setPixmap(QPixmap(iconList[2]));
itemLabel[3]->setText(localtionList[0]);
itemLabel[4]->setText(localtionList[1]);
itemLabel[5]->setText(localtionList[2]);
itemLabel[6]->setText(nameList[0]);
itemLabel[7]->setText(nameList[1]);
itemLabel[8]->setText(nameList[2]);
gridLayout[0]->addWidget(itemLabel[0], 0, 0);
gridLayout[0]->addWidget(itemLabel[3], 0, 1);
gridLayout[0]->addWidget(itemLabel[6], 1, 0);
gridLayout[0]->addWidget(switchButton[0], 1, 1);
gridLayout[1]->addWidget(itemLabel[1], 0, 0);
gridLayout[1]->addWidget(itemLabel[4], 0, 1);
gridLayout[1]->addWidget(itemLabel[7], 1, 0);
gridLayout[1]->addWidget(switchButton[1], 1, 1);
gridLayout[2]->addWidget(itemLabel[2], 0, 0);
gridLayout[2]->addWidget(itemLabel[5], 0, 1);
gridLayout[2]->addWidget(itemLabel[8], 1, 0);
gridLayout[2]->addWidget(switchButton[2], 1, 1);
QListWidgetItem *listWidgetItem[3];
for (int i = 0; i < 3; i++) {
listWidgetItem[i] = new QListWidgetItem();
listWidget->addItem(listWidgetItem[i]);
}
widget[8]->setLayout(gridLayout[0]);
widget[9]->setLayout(gridLayout[1]);
widget[10]->setLayout(gridLayout[2]);
listWidget->setItemWidget(listWidget->item(0), widget[8]);
listWidget->setItemWidget(listWidget->item(1), widget[9]);
listWidget->setItemWidget(listWidget->item(2), widget[10]);
}
void MainWindow::onToggled(bool flag) {
SwitchButton *bt = (SwitchButton *)sender();
for (int i = 0; i < 3; i++) {
if (bt == switchButton[i]) {
QStringList list = itemLabel[i + 6]
->text().split("|");
QString message;
if (flag)
message = "开";
else
message = "关";
/* 给原子云服务器发送指令,发送的信息格式为如:"客厅灯","开" */
webapi->whichDeviceNameSendCmd(list[0], message);
break;
}
}
}
void MainWindow::deviceState(QString state)
{
if (state.contains("客厅灯")) {
itemLabel[6]->setText(state);
itemLabel[6]->setStyleSheet("color:#f39800");
} else if (state.contains("台灯")) {
itemLabel[7]->setText(state);
itemLabel[7]->setStyleSheet("color:#f39800");
} else if (state.contains("空调")) {
itemLabel[8]->setText(state);
itemLabel[8]->setStyleSheet("color:#f39800");
}
}
| 31.798419
| 68
| 0.590677
|
alientek-openedv
|
879cad3008564d5850747b22ea5e92478083a174
| 93
|
hpp
|
C++
|
tests/src/utility/ClassInstanceMethod.hpp
|
Ybalrid/jet-live
|
14b909b00b98399d7e046cd8b7500a3fdfe0a0b1
|
[
"MIT"
] | 325
|
2019-01-05T12:40:46.000Z
|
2022-03-26T09:06:40.000Z
|
tests/src/utility/ClassInstanceMethod.hpp
|
Ybalrid/jet-live
|
14b909b00b98399d7e046cd8b7500a3fdfe0a0b1
|
[
"MIT"
] | 23
|
2019-01-05T19:43:47.000Z
|
2022-01-10T20:11:06.000Z
|
tests/src/utility/ClassInstanceMethod.hpp
|
Ybalrid/jet-live
|
14b909b00b98399d7e046cd8b7500a3fdfe0a0b1
|
[
"MIT"
] | 29
|
2019-01-05T18:49:08.000Z
|
2022-03-20T19:14:30.000Z
|
#pragma once
class ClassInstanceMethod
{
public:
int computeResult(int v1, int v2);
};
| 10.333333
| 38
| 0.709677
|
Ybalrid
|
879dbd52d4434ff3e2c2200391de606dbbc18273
| 5,351
|
cpp
|
C++
|
src/cpp/uniform.cpp
|
dlitvak98/webgl-raub
|
3456f387c2598fc4c8280724030ca4676b469be9
|
[
"MIT"
] | 62
|
2018-06-03T13:54:54.000Z
|
2022-03-11T08:27:36.000Z
|
src/cpp/uniform.cpp
|
dlitvak98/webgl-raub
|
3456f387c2598fc4c8280724030ca4676b469be9
|
[
"MIT"
] | 14
|
2018-10-18T21:34:32.000Z
|
2022-02-06T03:34:10.000Z
|
src/cpp/uniform.cpp
|
dlitvak98/webgl-raub
|
3456f387c2598fc4c8280724030ca4676b469be9
|
[
"MIT"
] | 8
|
2018-08-22T03:35:51.000Z
|
2022-02-04T00:34:06.000Z
|
#include "webgl.hpp"
using namespace std;
namespace webgl {
JS_METHOD(getActiveUniform) { NAPI_ENV;
REQ_INT32_ARG(0, program);
REQ_INT32_ARG(1, index);
char name[1024];
GLsizei length = 0;
GLenum type;
GLsizei size;
glGetActiveUniform(program, index, 1024, &length, &size, &type, name);
Napi::Array activeInfo = Napi::Array::New(env);
activeInfo.Set("size", JS_NUM(size));
activeInfo.Set("type", JS_NUM(static_cast<int>(type)));
activeInfo.Set("name", JS_STR(name));
RET_VALUE(activeInfo);
}
JS_METHOD(getUniform) { NAPI_ENV;
REQ_INT32_ARG(0, program);
REQ_INT32_ARG(1, location);
if (location < 0) {
RET_UNDEFINED;
}
float data[16]; // worst case scenario is 16 floats
glGetUniformfv(program, location, data);
Napi::Array arr = Napi::Array::New(env);
for (int i = 0; i < 16; i++) {
arr.Set(i, JS_NUM(data[i]));
}
RET_VALUE(arr);
}
JS_METHOD(getUniformLocation) { NAPI_ENV;
REQ_INT32_ARG(0, program);
REQ_STR_ARG(1, name);
RET_NUM(glGetUniformLocation(program, name.c_str()));
}
JS_METHOD(uniform1f) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_FLOAT_ARG(1, x);
glUniform1f(location, x);
RET_UNDEFINED;
}
JS_METHOD(uniform2f) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_FLOAT_ARG(1, x);
REQ_FLOAT_ARG(2, y);
glUniform2f(location, x, y);
RET_UNDEFINED;
}
JS_METHOD(uniform3f) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_FLOAT_ARG(1, x);
REQ_FLOAT_ARG(2, y);
REQ_FLOAT_ARG(3, z);
glUniform3f(location, x, y, z);
RET_UNDEFINED;
}
JS_METHOD(uniform4f) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_FLOAT_ARG(1, x);
REQ_FLOAT_ARG(2, y);
REQ_FLOAT_ARG(3, z);
REQ_FLOAT_ARG(4, w);
glUniform4f(location, x, y, z, w);
RET_UNDEFINED;
}
JS_METHOD(uniform1i) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_INT32_ARG(1, x);
glUniform1i(location, x);
RET_UNDEFINED;
}
JS_METHOD(uniform2i) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_INT32_ARG(1, x);
REQ_INT32_ARG(2, y);
glUniform2i(location, x, y);
RET_UNDEFINED;
}
JS_METHOD(uniform3i) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_INT32_ARG(1, x);
REQ_INT32_ARG(2, y);
REQ_INT32_ARG(3, z);
glUniform3i(location, x, y, z);
RET_UNDEFINED;
}
JS_METHOD(uniform4i) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_INT32_ARG(1, x);
REQ_INT32_ARG(2, y);
REQ_INT32_ARG(3, z);
REQ_INT32_ARG(4, w);
glUniform4i(location, x, y, z, w);
RET_UNDEFINED;
}
JS_METHOD(uniform1fv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_OBJ_ARG(1, abv);
int num;
GLfloat *ptr = getArrayData<GLfloat>(env, abv, &num);
glUniform1fv(location, num, ptr);
RET_UNDEFINED;
}
JS_METHOD(uniform2fv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_OBJ_ARG(1, abv);
int num;
GLfloat *ptr = getArrayData<GLfloat>(env, abv, &num);
num /= 2;
glUniform2fv(location, num, ptr);
RET_UNDEFINED;
}
JS_METHOD(uniform3fv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_OBJ_ARG(1, abv);
int num;
GLfloat *ptr = getArrayData<GLfloat>(env, abv, &num);
num /= 3;
glUniform3fv(location, num, ptr);
RET_UNDEFINED;
}
JS_METHOD(uniform4fv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_OBJ_ARG(1, abv);
int num;
GLfloat *ptr = getArrayData<GLfloat>(env, abv, &num);
num /= 4;
glUniform4fv(location, num, ptr);
RET_UNDEFINED;
}
JS_METHOD(uniform1iv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_OBJ_ARG(1, abv);
int num;
GLint *ptr = getArrayData<GLint>(env, abv, &num);
glUniform1iv(location, num, ptr);
RET_UNDEFINED;
}
JS_METHOD(uniform2iv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_OBJ_ARG(1, abv);
int num;
GLint *ptr = getArrayData<GLint>(env, abv, &num);
num /= 2;
glUniform2iv(location, num, ptr);
RET_UNDEFINED;
}
JS_METHOD(uniform3iv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_OBJ_ARG(1, abv);
int num;
GLint *ptr = getArrayData<GLint>(env, abv, &num);
num /= 3;
glUniform3iv(location, num, ptr);
RET_UNDEFINED;
}
JS_METHOD(uniform4iv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
REQ_OBJ_ARG(1, abv);
int num;
GLint *ptr = getArrayData<GLint>(env, abv, &num);
num /= 4;
glUniform4iv(location, num, ptr);
RET_UNDEFINED;
}
JS_METHOD(uniformMatrix2fv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
LET_BOOL_ARG(1, transpose);
REQ_OBJ_ARG(2, abv);
GLsizei count = 0;
GLfloat* data = getArrayData<GLfloat>(env, abv, &count);
if (count < 4) {
JS_THROW("Not enough data for UniformMatrix2fv");
} else {
glUniformMatrix2fv(location, count / 4, transpose, data);
}
RET_UNDEFINED;
}
JS_METHOD(uniformMatrix3fv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
LET_BOOL_ARG(1, transpose);
REQ_OBJ_ARG(2, abv);
GLsizei count = 0;
GLfloat* data = getArrayData<GLfloat>(env, abv, &count);
if (count < 9) {
JS_THROW("Not enough data for UniformMatrix3fv");
} else {
glUniformMatrix3fv(location, count / 9, transpose, data);
}
RET_UNDEFINED;
}
JS_METHOD(uniformMatrix4fv) { NAPI_ENV;
REQ_INT32_ARG(0, location);
LET_BOOL_ARG(1, transpose);
REQ_OBJ_ARG(2, abv);
GLsizei count = 0;
GLfloat* data = getArrayData<GLfloat>(env, abv, &count);
if (count < 16) {
JS_THROW("Not enough data for UniformMatrix4fv");
RET_UNDEFINED;
} else {
glUniformMatrix4fv(location, count / 16, transpose, data);
}
RET_UNDEFINED;
}
} // namespace webgl
| 15.600583
| 71
| 0.683237
|
dlitvak98
|
87a2ef0a609e0e297d0543cab7c9e0049da9b7ba
| 1,409
|
cpp
|
C++
|
ianlmk/cs161b/algorithms/bubbleSortArray.cpp
|
ianlmk/cs161
|
7a50740d1642ca0111a6d0d076b600744552a066
|
[
"MIT"
] | null | null | null |
ianlmk/cs161b/algorithms/bubbleSortArray.cpp
|
ianlmk/cs161
|
7a50740d1642ca0111a6d0d076b600744552a066
|
[
"MIT"
] | 1
|
2022-03-25T18:34:47.000Z
|
2022-03-25T18:35:23.000Z
|
ianlmk/cs161b/algorithms/bubbleSortArray.cpp
|
ianlmk/cs161
|
7a50740d1642ca0111a6d0d076b600744552a066
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <cstdlib>
#include <chrono>
#include <thread>
#define MAX 100
using namespace std;
int main(){
using namespace std::this_thread; // sleep_for, sleep_until
using namespace std::chrono; // nanoseconds, system_clock, seconds
int n;
int arr[MAX] = { };
srand(time(0));
cout << "Enter a number: ";
cin >> n;
for (int i = 0; i < n; i++) {
arr[i] = rand() % 1000;
}
// for (int i = 0; i < n; i++) {
// cout << arr[i] << " ";
// }
// cout << endl;
// SORTING AN ARRAY
// using i as the primary index and j as the secondary / moving index
// compare arr[i] to arr[i+1] and if arr [i+1] is smaller,
// swap it to the reference arr[i],
// and then run through the indeces again.
for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++) {
// can sort in descending order by switching the <> comparators.
if (arr[j]<arr[i]) {
// assign a temp into to the value of arr[i]
int temp = arr[i];
// assign arr[i] to arr[j] (j is just i + 1) to start the swap
arr[i] = arr[j];
// assign arr[j] to arr[i] to complete the index swap
arr[j] = temp;
sleep_for(10ns);
sleep_until(system_clock::now() + 10000000ns);
for (int x = 0; x < n; x++) {
cout << arr[x] << " ";
}
cout << endl;
}
}
}
return 0;
}
| 22.015625
| 71
| 0.528034
|
ianlmk
|
87a5f73fef10d407a0d2259d842885912ad30720
| 86
|
cpp
|
C++
|
Daxa/src/Application.cpp
|
Ipotrick/Daxa
|
07f3f9717f43b32cbe60761602fc16b3a2789b5a
|
[
"MIT"
] | 3
|
2021-03-24T21:26:59.000Z
|
2021-12-28T01:54:17.000Z
|
Daxa/src/Application.cpp
|
Ipotrick/Daxa
|
07f3f9717f43b32cbe60761602fc16b3a2789b5a
|
[
"MIT"
] | 1
|
2021-12-10T01:08:15.000Z
|
2021-12-15T23:38:33.000Z
|
Daxa/src/Application.cpp
|
Ipotrick/Daxa
|
07f3f9717f43b32cbe60761602fc16b3a2789b5a
|
[
"MIT"
] | 1
|
2022-02-18T16:07:19.000Z
|
2022-02-18T16:07:19.000Z
|
#include "Application.hpp"
#include <iostream>
#include <iomanip>
namespace daxa {
}
| 12.285714
| 26
| 0.732558
|
Ipotrick
|
87a9f0b9b598b3a203b8d65ae918600bd96163ce
| 998
|
cpp
|
C++
|
Data_Structures/C++/Heapsort_rsathya4802.cpp
|
manasa-rajeshwari/DS_with_hacktoberfest
|
1b09203b2e85a9b95e2cf4b17c5650ef78d33be7
|
[
"Apache-2.0"
] | 16
|
2019-09-30T18:33:03.000Z
|
2020-11-16T10:29:51.000Z
|
Data_Structures/C++/Heapsort_rsathya4802.cpp
|
manasa-rajeshwari/DS_with_hacktoberfest
|
1b09203b2e85a9b95e2cf4b17c5650ef78d33be7
|
[
"Apache-2.0"
] | 43
|
2019-09-30T13:37:57.000Z
|
2020-10-30T06:13:20.000Z
|
Data_Structures/C++/Heapsort_rsathya4802.cpp
|
manasa-rajeshwari/DS_with_hacktoberfest
|
1b09203b2e85a9b95e2cf4b17c5650ef78d33be7
|
[
"Apache-2.0"
] | 142
|
2019-09-30T16:47:07.000Z
|
2021-10-30T16:29:17.000Z
|
// LANGUAGE: c++
// ENV: gcc
// AUTHOR: Sathyanarayanan R
// GITHUB: https://github.com/rsathya4802
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
void swap(ll a[],ll x,ll y)
{
ll temp=a[x];
a[x]=a[y];
a[y]=temp;
}
void heap_arr(ll a[],ll n,ll pos)
{
ll lar=pos;
ll l=2*pos+1,r=2*pos+2;
if(l<n && a[l]>a[lar])
lar=l;
if(r<n && a[r]>a[lar])
lar=r;
if(pos!=lar)
{
swap(a,lar,pos);
heap_arr(a,n,lar);
}
}
void heapsort(ll a[],ll n)
{
for(ll i=n/2-1;i>=0;i--)
heap_arr(a,n,i);
for(ll i=n-1;i>=0;i--)
{
swap(a,0,i);
heap_arr(a,i,0);
}
}
int main()
{
int a[100];
int n;
cout<<"Enter number of elements: ";
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
heapsort(a,n);
cout<<"After Sorting: ";
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<"\n";
}
| 17.508772
| 41
| 0.497996
|
manasa-rajeshwari
|
87ab7838b8408e2a52b1c0afe24a28a238042ae8
| 4,382
|
hpp
|
C++
|
cslibs_ndt/include/cslibs_ndt/common/weighted_occupancy_distribution.hpp
|
doge-of-the-day/cslibs_ndt
|
f326d05d5bde9750ad595790849eb2ac9a747123
|
[
"BSD-3-Clause"
] | 36
|
2018-10-17T07:00:23.000Z
|
2021-12-22T15:41:50.000Z
|
cslibs_ndt/include/cslibs_ndt/common/weighted_occupancy_distribution.hpp
|
doge-of-the-day/cslibs_ndt
|
f326d05d5bde9750ad595790849eb2ac9a747123
|
[
"BSD-3-Clause"
] | 4
|
2018-10-04T14:16:28.000Z
|
2020-11-26T10:03:14.000Z
|
cslibs_ndt/include/cslibs_ndt/common/weighted_occupancy_distribution.hpp
|
doge-of-the-day/cslibs_ndt
|
f326d05d5bde9750ad595790849eb2ac9a747123
|
[
"BSD-3-Clause"
] | 18
|
2018-07-15T14:39:56.000Z
|
2021-05-05T11:12:51.000Z
|
#ifndef CSLIBS_NDT_COMMON_WEIGHTED_OCCUPANCY_DISTRIBUTION_HPP
#define CSLIBS_NDT_COMMON_WEIGHTED_OCCUPANCY_DISTRIBUTION_HPP
#include <mutex>
#include <cslibs_math/statistics/weighted_distribution.hpp>
#include <cslibs_math/statistics/stable_weighted_distribution.hpp>
#include <cslibs_gridmaps/utility/inverse_model.hpp>
#include <cslibs_indexed_storage/storage.hpp>
namespace cslibs_ndt {
template<typename T, std::size_t Dim>
class /*EIGEN_ALIGN16*/ WeightedOccupancyDistribution
{
public:
// EIGEN_MAKE_ALIGNED_OPERATOR_NEW
// using allocator_t = Eigen::aligned_allocator<WeightedOccupancyDistribution<T,Dim>>;
using Ptr = std::shared_ptr<WeightedOccupancyDistribution<T,Dim>>;
using distribution_container_t = WeightedOccupancyDistribution<T,Dim>;
using distribution_t = cslibs_math::statistics::StableWeightedDistribution<T,Dim,3>;
using distribution_ptr_t = typename distribution_t::Ptr;
using point_t = typename distribution_t::sample_t;
using ivm_t = cslibs_gridmaps::utility::InverseModel<T>;
inline WeightedOccupancyDistribution() :
weight_free_(0)
{
}
inline WeightedOccupancyDistribution(const T weight_free) :
weight_free_(weight_free)
{
}
inline WeightedOccupancyDistribution(const T weight_free,
const distribution_t data) :
weight_free_(weight_free),
distribution_(new distribution_t(data))
{
}
inline WeightedOccupancyDistribution(const WeightedOccupancyDistribution &other) :
weight_free_(other.weight_free_),
distribution_(other.distribution_)
{
}
inline WeightedOccupancyDistribution& operator = (const WeightedOccupancyDistribution &other)
{
weight_free_ = other.weight_free_;
distribution_ = other.distribution_;
return *this;
}
inline void updateFree(const T& weight_free = 1.0)
{
weight_free_ += weight_free;
}
inline void updateOccupied(const point_t& p, const T& w = 1.0)
{
if (!distribution_)
distribution_.reset(new distribution_t());
distribution_->add(p, w);
}
inline void updateOccupied(const distribution_t &d)
{
if (!distribution_)
distribution_.reset(new distribution_t(d));
else
*distribution_ += d;
}
inline void updateOccupied(const distribution_ptr_t &d)
{
if (!d)
return;
if (!distribution_)
distribution_.reset(new distribution_t());
*distribution_ += *d;
}
inline T weightFree() const
{
return weight_free_;
}
inline T weightOccupied() const
{
return distribution_ ? distribution_->getWeight() : T();
}
inline T getOccupancy(const typename ivm_t::Ptr &inverse_model) const
{
if (!inverse_model)
throw std::runtime_error("inverse model not set!");
return getOccupancy(*inverse_model);
}
inline T getOccupancy(const ivm_t &inverse_model) const
{
return distribution_ ?
cslibs_math::common::LogOdds<T>::from(
weight_free_ * inverse_model.getLogOddsFree() +
distribution_->getWeight() * inverse_model.getLogOddsOccupied() -
(weight_free_ + distribution_->getWeight() - 1) * inverse_model.getLogOddsPrior())
: T(0.0);
}
inline const distribution_ptr_t &getDistribution() const
{
return distribution_;
}
inline distribution_ptr_t &getDistribution()
{
return distribution_;
}
inline void merge(const WeightedOccupancyDistribution &other)
{
weight_free_ += other.weight_free_;
if (other.distribution_) {
if (distribution_)
*distribution_ += *(other.distribution_);
else
distribution_ = other.distribution_;
}
}
inline std::size_t byte_size() const
{
return distribution_ ? (sizeof(*this) + sizeof(distribution_t)) : sizeof(*this);
}
private:
T weight_free_;
distribution_ptr_t distribution_;
};
}
#endif // CSLIBS_NDT_COMMON_WEIGHTED_OCCUPANCY_DISTRIBUTION_HPP
| 29.213333
| 106
| 0.641716
|
doge-of-the-day
|
87abc35abd6c12c3114f6d2caa091e340435d388
| 1,835
|
cpp
|
C++
|
src/tests/SparseLattice/sparse_lattice_functions.cpp
|
extragoya/LibNT
|
60372bf4e3c5d6665185358c4756da4fe547f093
|
[
"BSD-3-Clause"
] | 1
|
2021-04-26T05:11:32.000Z
|
2021-04-26T05:11:32.000Z
|
src/tests/SparseLattice/sparse_lattice_functions.cpp
|
extragoya/LibNT
|
60372bf4e3c5d6665185358c4756da4fe547f093
|
[
"BSD-3-Clause"
] | null | null | null |
src/tests/SparseLattice/sparse_lattice_functions.cpp
|
extragoya/LibNT
|
60372bf4e3c5d6665185358c4756da4fe547f093
|
[
"BSD-3-Clause"
] | 1
|
2017-09-21T15:38:23.000Z
|
2017-09-21T15:38:23.000Z
|
#define BOOST_TEST_MODULE SparseLatticeFunctionTests
#include "SparseLattice.h"
#include "DenseLattice.h"
#include "MIAConfig.h"
#ifdef MIA_USE_HEADER_ONLY_TESTS
#include <boost/test/included/unit_test.hpp>
#else
#include <boost/test/unit_test.hpp>
#endif
//#include <boost/timer/timer.hpp>
template<typename data_type>
void do_work(size_t m, size_t n, size_t p){
typedef LibMIA::SparseLattice<data_type> sparseType;
typedef LibMIA::DenseLattice<data_type> denseType;
denseType denseLat(m,n,p);
sparseType sparseLat1,sparseLat2;
denseLat.randu(0,10);
for(auto it=denseLat.data_begin();it<denseLat.data_end();++it)
if(*it<7)
*it=0;
sparseLat1=denseLat;
sparseLat2=denseLat;
BOOST_CHECK_MESSAGE(sparseLat1==sparseLat2,std::string("Assignment and comparison test for ")+typeid(data_type).name());
//boost::timer::cpu_timer ltensor;
sparseLat1.sort(LibMIA::RowMajor);
//std::cout << "special sort time " << boost::timer::format(ltensor.elapsed()) << std::endl;
sparseLat2.set_sorted(false);
//ltensor=boost::timer::cpu_timer ();
sparseLat2.sort(LibMIA::RowMajor);
//std::cout << "normal sort time " << boost::timer::format(ltensor.elapsed()) << std::endl;
//sparseLat1.print();
//sparseLat2.print();
//sparseLat1.print();
//sparseLat2.print();
BOOST_CHECK_MESSAGE(sparseLat1==sparseLat2,std::string("Both sorts create identical results ")+typeid(data_type).name());
}
BOOST_AUTO_TEST_CASE( SparseLatticeFunctionTests )
{
//do_work<double>(4,4,4);
do_work<double>(100,100,1000);
//do_work<double>(2000,2000,10);
// do_work<double>(100,100,100);
// do_work<float>(100,100,100);
// do_work<int>(100,100,100);
// do_work<long>(100,100,100);
}
| 24.797297
| 126
| 0.67139
|
extragoya
|
87b47917495c6de525022d7520b8e0066d33592f
| 158
|
cpp
|
C++
|
thirdparty/apriltag/tests/test.cpp
|
catid/xrcap
|
d3c5900c44861e618fd28b4256387725646b85c7
|
[
"BSD-3-Clause"
] | 62
|
2019-12-21T23:48:28.000Z
|
2021-11-25T14:29:28.000Z
|
thirdparty/apriltag/tests/test.cpp
|
catid/xrcap
|
d3c5900c44861e618fd28b4256387725646b85c7
|
[
"BSD-3-Clause"
] | 5
|
2020-01-06T19:55:41.000Z
|
2020-06-19T23:13:24.000Z
|
thirdparty/apriltag/tests/test.cpp
|
catid/xrcap
|
d3c5900c44861e618fd28b4256387725646b85c7
|
[
"BSD-3-Clause"
] | 10
|
2019-12-22T15:53:10.000Z
|
2021-07-18T09:12:06.000Z
|
#include <apriltag.h>
int main()
{
apriltag_detector_t *detector = apriltag_detector_create();
apriltag_detector_destroy(detector);
return 0;
}
| 15.8
| 63
| 0.721519
|
catid
|
87b4796e38fd9cc6081aa124a4eb9ef755825a25
| 3,678
|
cpp
|
C++
|
components/scream/src/physics/shoc/tests/shoc_energy_threshold_fixer_tests.cpp
|
ambrad/scream
|
52da60f65e870b8a3994bdbf4a6022fdcac7cab5
|
[
"BSD-3-Clause"
] | 22
|
2018-12-12T17:44:55.000Z
|
2022-03-11T03:47:38.000Z
|
components/scream/src/physics/shoc/tests/shoc_energy_threshold_fixer_tests.cpp
|
ambrad/scream
|
52da60f65e870b8a3994bdbf4a6022fdcac7cab5
|
[
"BSD-3-Clause"
] | 1,440
|
2018-07-10T16:49:55.000Z
|
2022-03-31T22:41:25.000Z
|
components/scream/src/physics/shoc/tests/shoc_energy_threshold_fixer_tests.cpp
|
ambrad/scream
|
52da60f65e870b8a3994bdbf4a6022fdcac7cab5
|
[
"BSD-3-Clause"
] | 24
|
2018-11-12T15:43:53.000Z
|
2022-03-30T18:10:52.000Z
|
#include "catch2/catch.hpp"
#include "shoc_unit_tests_common.hpp"
#include "physics/shoc/shoc_functions.hpp"
#include "physics/shoc/shoc_functions_f90.hpp"
#include "physics/share/physics_constants.hpp"
#include "share/scream_types.hpp"
#include "ekat/ekat_pack.hpp"
#include "ekat/util/ekat_arch.hpp"
#include "ekat/kokkos/ekat_kokkos_utils.hpp"
#include <algorithm>
#include <array>
#include <random>
#include <thread>
namespace scream {
namespace shoc {
namespace unit_test {
template <typename D>
struct UnitWrap::UnitTest<D>::TestShocEnergyThreshFixer {
static void run_property()
{
static constexpr Real mintke = scream::shoc::Constants<Real>::mintke;
static constexpr Int shcol = 2;
static constexpr Int nlev = 5;
static constexpr auto nlevi = nlev + 1;
// Tests for the SHOC function
// shoc_energy_threshold_fixer
// TEST ONE
// Set up a reasonable profile verify results are as expected
// Host model TKE [m2/s2]
Real tke_input[nlev] = {mintke, mintke, 0.01, 0.4, 0.5};
// Pressure at interface [Pa]
Real pint[nlevi] = {500e2, 600e2, 700e2, 800e2, 900e2, 1000e2};
// Integrated total energy after SHOC.
static constexpr Real te_a = 100;
// Integrated total energy before SHOC
static constexpr Real te_b = 110;
// convert pressure to Pa
for(Int n = 0; n < nlevi; ++n) {
pint[n] = pint[n];
}
// Initialize data structure for bridging to F90
ShocEnergyThresholdFixerData SDS(shcol, nlev, nlevi);
// Test that the inputs are reasonable.
REQUIRE( (SDS.shcol == shcol && SDS.nlev == nlev && SDS.nlevi == nlevi) );
REQUIRE(SDS.shcol > 1);
REQUIRE(nlev+1 == nlevi);
// Fill in test data on zt_grid.
for(Int s = 0; s < shcol; ++s) {
SDS.te_a[s] = te_a;
SDS.te_b[s] = te_b;
for(Int n = 0; n < nlev; ++n) {
const auto offset = n + s * nlev;
SDS.tke[offset] = tke_input[n];
}
for(Int n = 0; n < nlevi; ++n) {
const auto offset = n + s * nlevi;
SDS.pint[offset] = pint[n];
}
}
// Check that the inputs make sense
for(Int s = 0; s < shcol; ++s) {
for (Int n = 0; n < nlev; ++n){
const auto offset = n + s * nlev;
REQUIRE(SDS.tke[offset] >= mintke);
}
}
// Call the fortran implementation
shoc_energy_threshold_fixer(SDS);
// Verify the result
for(Int s = 0; s < shcol; ++s) {
// Make sure value of shoctop is within reasonable range
REQUIRE(SDS.shoctop[s] < nlev);
REQUIRE(SDS.shoctop[s] > 1);
// Verify that shoctop represents what we want it to
// Make sure that thickness that bounds shoctop is positive
const auto offset_stopi = (SDS.shoctop[s]-1) + s * nlevi;
const auto offset_bot = (nlevi-1) + s * nlevi;
REQUIRE(SDS.pint[offset_bot] - SDS.pint[offset_stopi] > 0.0);
if (SDS.shoctop[s] < nlev){
const auto offset_stop = (SDS.shoctop[s]-1) + s * nlev;
REQUIRE(SDS.tke[offset_stop] == mintke);
REQUIRE(SDS.tke[offset_stop+1] > mintke);
}
}
}
static void run_bfb()
{
// TODO
}
};
} // namespace unit_test
} // namespace shoc
} // namespace scream
namespace {
TEST_CASE("shoc_energy_threshold_fixer_property", "shoc")
{
using TestStruct = scream::shoc::unit_test::UnitWrap::UnitTest<scream::DefaultDevice>::TestShocEnergyThreshFixer;
TestStruct::run_property();
}
TEST_CASE("shoc_energy_threshold_fixer_bfb", "shoc")
{
using TestStruct = scream::shoc::unit_test::UnitWrap::UnitTest<scream::DefaultDevice>::TestShocEnergyThreshFixer;
TestStruct::run_bfb();
}
} // namespace
| 26.271429
| 115
| 0.636759
|
ambrad
|
87b58e981229b712d5631df4c94d8263897e23d3
| 604
|
cpp
|
C++
|
vendor/detours/tests/test_image_api.cpp
|
Scaless/corn-cob
|
f8e2169c1c0882fba6047628e87e05e71fd4a676
|
[
"MIT"
] | 1
|
2021-11-09T13:31:07.000Z
|
2021-11-09T13:31:07.000Z
|
vendor/detours/tests/test_image_api.cpp
|
Scaless/corn-cob
|
f8e2169c1c0882fba6047628e87e05e71fd4a676
|
[
"MIT"
] | null | null | null |
vendor/detours/tests/test_image_api.cpp
|
Scaless/corn-cob
|
f8e2169c1c0882fba6047628e87e05e71fd4a676
|
[
"MIT"
] | null | null | null |
//////////////////////////////////////////////////////////////////////////////
//
// Unit Tests for Detours Image API (test_image_api.cpp of unittests.exe)
//
// Microsoft Research Detours Package
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#include "catch.hpp"
#include "windows.h"
#include "detours.h"
TEST_CASE("DetourBinaryOpen", "[image]")
{
SECTION("Passing INVALID_HANDLE, results in error")
{
auto binary = DetourBinaryOpen(INVALID_HANDLE_VALUE);
REQUIRE( GetLastError() == ERROR_INVALID_HANDLE );
REQUIRE( binary == nullptr );
}
}
| 27.454545
| 78
| 0.592715
|
Scaless
|
87bfa6a825f3d18164b52663e29ae20904385c25
| 8,204
|
cpp
|
C++
|
math/volume.cpp
|
Kahemp/C-Plus-Plus
|
638babd61a998d67d9d68be0e67ece2255265d7f
|
[
"MIT"
] | 5
|
2022-01-01T04:32:12.000Z
|
2022-01-01T05:14:44.000Z
|
math/volume.cpp
|
Kahemp/C-Plus-Plus
|
638babd61a998d67d9d68be0e67ece2255265d7f
|
[
"MIT"
] | 1
|
2020-06-30T00:37:59.000Z
|
2020-06-30T00:38:38.000Z
|
math/volume.cpp
|
Kahemp/C-Plus-Plus
|
638babd61a998d67d9d68be0e67ece2255265d7f
|
[
"MIT"
] | 1
|
2022-03-10T11:13:20.000Z
|
2022-03-10T11:13:20.000Z
|
/**
* @file
* @brief Implmentations for the [volume](https://en.wikipedia.org/wiki/Volume)
* of various 3D shapes.
* @details The volume of a 3D shape is the amount of 3D space that the shape
* takes up. All shapes have a formula to get the volume of any given shape.
* These implementations support multiple return types.
*
* @author [Focusucof](https://github.com/Focusucof)
*/
#include <cassert> /// for assert
#include <cmath> /// for std::pow
#include <cstdint> /// for std::uint32_t
#include <iostream> /// for IO operations
/**
* @namespace math
* @brief Mathematical algorithms
*/
namespace math {
/**
* @brief The volume of a [cube](https://en.wikipedia.org/wiki/Cube)
* @param length The length of the cube
* @returns The volume of the cube
*/
template <typename T>
T cube_volume(T length) {
return std::pow(length, 3);
}
/**
* @brief The volume of a
* [rectangular](https://en.wikipedia.org/wiki/Cuboid) prism
* @param length The length of the base rectangle
* @param width The width of the base rectangle
* @param height The height of the rectangular prism
* @returns The volume of the rectangular prism
*/
template <typename T>
T rect_prism_volume(T length, T width, T height) {
return length * width * height;
}
/**
* @brief The volume of a [cone](https://en.wikipedia.org/wiki/Cone)
* @param radius The radius of the base circle
* @param height The height of the cone
* @param PI The definition of the constant PI
* @returns The volume of the cone
*/
template <typename T>
T cone_volume(T radius, T height, double PI = 3.14) {
return std::pow(radius, 2) * PI * height / 3;
}
/**
* @brief The volume of a
* [triangular](https://en.wikipedia.org/wiki/Triangular_prism) prism
* @param base The length of the base triangle
* @param height The height of the base triangles
* @param depth The depth of the triangular prism (the height of the whole
* prism)
* @returns The volume of the triangular prism
*/
template <typename T>
T triangle_prism_volume(T base, T height, T depth) {
return base * height * depth / 2;
}
/**
* @brief The volume of a
* [pyramid](https://en.wikipedia.org/wiki/Pyramid_(geometry))
* @param length The length of the base shape (or base for triangles)
* @param width The width of the base shape (or height for triangles)
* @param height The height of the pyramid
* @returns The volume of the pyramid
*/
template <typename T>
T pyramid_volume(T length, T width, T height) {
return length * width * height / 3;
}
/**
* @brief The volume of a [sphere](https://en.wikipedia.org/wiki/Sphere)
* @param radius The radius of the sphere
* @param PI The definition of the constant PI
* @returns The volume of the sphere
*/
template <typename T>
T sphere_volume(T radius, double PI = 3.14) {
return PI * std::pow(radius, 3) * 4 / 3;
}
/**
* @brief The volume of a [cylinder](https://en.wikipedia.org/wiki/Cylinder)
* @param radius The radius of the base circle
* @param height The height of the cylinder
* @param PI The definition of the constant PI
* @returns The volume of the cylinder
*/
template <typename T>
T cylinder_volume(T radius, T height, double PI = 3.14) {
return PI * std::pow(radius, 2) * height;
}
} // namespace math
/**
* @brief Self-test implementations
* @returns void
*/
static void test() {
// Input variables
uint32_t int_length = 0; // 32 bit integer length input
uint32_t int_width = 0; // 32 bit integer width input
uint32_t int_base = 0; // 32 bit integer base input
uint32_t int_height = 0; // 32 bit integer height input
uint32_t int_depth = 0; // 32 bit integer depth input
double double_radius = NAN; // double radius input
double double_height = NAN; // double height input
// Output variables
uint32_t int_expected = 0; // 32 bit integer expected output
uint32_t int_volume = 0; // 32 bit integer output
double double_expected = NAN; // double expected output
double double_volume = NAN; // double output
// 1st test
int_length = 5;
int_expected = 125;
int_volume = math::cube_volume(int_length);
std::cout << "VOLUME OF A CUBE" << std::endl;
std::cout << "Input Length: " << int_length << std::endl;
std::cout << "Expected Output: " << int_expected << std::endl;
std::cout << "Output: " << int_volume << std::endl;
assert(int_volume == int_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
// 2nd test
int_length = 4;
int_width = 3;
int_height = 5;
int_expected = 60;
int_volume = math::rect_prism_volume(int_length, int_width, int_height);
std::cout << "VOLUME OF A RECTANGULAR PRISM" << std::endl;
std::cout << "Input Length: " << int_length << std::endl;
std::cout << "Input Width: " << int_width << std::endl;
std::cout << "Input Height: " << int_height << std::endl;
std::cout << "Expected Output: " << int_expected << std::endl;
std::cout << "Output: " << int_volume << std::endl;
assert(int_volume == int_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
// 3rd test
double_radius = 5;
double_height = 7;
double_expected = 183.16666666666666; // truncated to 14 decimal places
double_volume = math::cone_volume(double_radius, double_height);
std::cout << "VOLUME OF A CONE" << std::endl;
std::cout << "Input Radius: " << double_radius << std::endl;
std::cout << "Input Height: " << double_height << std::endl;
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_volume << std::endl;
assert(double_volume == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
// 4th test
int_base = 3;
int_height = 4;
int_depth = 5;
int_expected = 30;
int_volume = math::triangle_prism_volume(int_base, int_height, int_depth);
std::cout << "VOLUME OF A TRIANGULAR PRISM" << std::endl;
std::cout << "Input Base: " << int_base << std::endl;
std::cout << "Input Height: " << int_height << std::endl;
std::cout << "Input Depth: " << int_depth << std::endl;
std::cout << "Expected Output: " << int_expected << std::endl;
std::cout << "Output: " << int_volume << std::endl;
assert(int_volume == int_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
// 5th test
int_length = 10;
int_width = 3;
int_height = 5;
int_expected = 50;
int_volume = math::pyramid_volume(int_length, int_width, int_height);
std::cout << "VOLUME OF A PYRAMID" << std::endl;
std::cout << "Input Length: " << int_length << std::endl;
std::cout << "Input Width: " << int_width << std::endl;
std::cout << "Input Height: " << int_height << std::endl;
std::cout << "Expected Output: " << int_expected << std::endl;
std::cout << "Output: " << int_volume << std::endl;
assert(int_volume == int_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
// 6th test
double_radius = 3;
double_expected = 113.04;
double_volume = math::sphere_volume(double_radius);
std::cout << "VOLUME OF A SPHERE" << std::endl;
std::cout << "Input Radius: " << double_radius << std::endl;
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_volume << std::endl;
assert(double_volume == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
// 7th test
double_radius = 5;
double_height = 2;
double_expected = 157;
double_volume = math::cylinder_volume(double_radius, double_height);
std::cout << "VOLUME OF A CYLINDER" << std::endl;
std::cout << "Input Radius: " << double_radius << std::endl;
std::cout << "Input Height: " << double_height << std::endl;
std::cout << "Expected Output: " << double_expected << std::endl;
std::cout << "Output: " << double_volume << std::endl;
assert(double_volume == double_expected);
std::cout << "TEST PASSED" << std::endl << std::endl;
}
/**
* @brief Main function
* @returns 0 on exit
*/
int main() {
test(); // run self-test implementations
return 0;
}
| 34.32636
| 79
| 0.646148
|
Kahemp
|
87c2fe561531cf2ff69403be99aecc1dc5a381e9
| 527
|
cpp
|
C++
|
firmware/robot2015/src-ctrl/modules/control/RobotModel.cpp
|
JNeiger/robocup-firmware
|
c1bfd4ba24070eaa4e012fdc88aa468aafcc2e4e
|
[
"Apache-2.0"
] | null | null | null |
firmware/robot2015/src-ctrl/modules/control/RobotModel.cpp
|
JNeiger/robocup-firmware
|
c1bfd4ba24070eaa4e012fdc88aa468aafcc2e4e
|
[
"Apache-2.0"
] | null | null | null |
firmware/robot2015/src-ctrl/modules/control/RobotModel.cpp
|
JNeiger/robocup-firmware
|
c1bfd4ba24070eaa4e012fdc88aa468aafcc2e4e
|
[
"Apache-2.0"
] | null | null | null |
#include "RobotModel.hpp"
const RobotModel RobotModel2015 = []() {
RobotModel model;
model.WheelRadius = 0.02856;
// note: wheels are numbered clockwise, starting with the top-right
// TODO(ashaw596): Check angles.
model.WheelAngles = {
DegreesToRadians(38), DegreesToRadians(315), DegreesToRadians(225),
DegreesToRadians(142),
};
model.WheelDist = 0.0798576;
model.DutyCycleMultiplier = 9; // TODO: tune this value
model.recalculateBotToWheel();
return model;
}();
| 26.35
| 75
| 0.671727
|
JNeiger
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.