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
0d76375c5e99cc46664370535b6496af9bc108b5
575
cpp
C++
Source/CAPI.cpp
Cos8o/GDCrypto
2d75646475a752e93c8b2a829033e2350ecc862c
[ "MIT" ]
16
2018-08-31T13:16:30.000Z
2021-03-07T15:14:14.000Z
Source/CAPI.cpp
cos8oih/GDCrypto
2d75646475a752e93c8b2a829033e2350ecc862c
[ "MIT" ]
8
2020-01-21T15:05:19.000Z
2020-11-11T20:05:34.000Z
Source/CAPI.cpp
Cos8o/GDCrypto
2d75646475a752e93c8b2a829033e2350ecc862c
[ "MIT" ]
2
2019-01-12T14:37:40.000Z
2020-01-22T03:34:51.000Z
#include "CAPI.hpp" extern "C" { GDCRYPTO_API uint8_t* gdcrypto_allocateBuffer(size_t const size) { return new uint8_t[size]; } GDCRYPTO_API int gdcrypto_freeBuffer(uint8_t* buffer) { if (buffer) { delete[] buffer; return GDCRYPTO_SUCCESS; } return GDCRYPTO_FAIL; } //This is probably broken (null byte missing) GDCRYPTO_API uint8_t* gdcrypto_createBuffer( void const* data, size_t const size) { if (data && size) { auto p = gdcrypto_allocateBuffer(size); if (p) memcpy(p, data, size); return p; } return nullptr; } }
15.131579
65
0.676522
Cos8o
0d772e5baca28303785202be3e76198753acd995
4,282
hpp
C++
library/include/hal/Spi.hpp
StratifyLabs/HalAPI
9707d7c021fa655666796a0a02994f7766d76e81
[ "MIT" ]
1
2021-11-17T05:41:21.000Z
2021-11-17T05:41:21.000Z
library/include/hal/Spi.hpp
StratifyLabs/HalAPI
9707d7c021fa655666796a0a02994f7766d76e81
[ "MIT" ]
null
null
null
library/include/hal/Spi.hpp
StratifyLabs/HalAPI
9707d7c021fa655666796a0a02994f7766d76e81
[ "MIT" ]
null
null
null
// Copyright 2020-2021 Tyler Gilbert and Stratify Labs, Inc; see LICENSE.md #ifndef HALAPI_HAL_SPI_HPP_ #define HALAPI_HAL_SPI_HPP_ #include <sos/dev/spi.h> #include "Device.hpp" namespace hal { struct SpiFlags { enum class Flags { null = 0, is_format_spi = SPI_FLAG_IS_FORMAT_SPI, is_format_ti = SPI_FLAG_IS_FORMAT_TI, is_format_microwire = SPI_FLAG_IS_FORMAT_MICROWIRE, is_mode0 = SPI_FLAG_IS_MODE0, is_mode1 = SPI_FLAG_IS_MODE1, is_mode2 = SPI_FLAG_IS_MODE2, is_mode3 = SPI_FLAG_IS_MODE3, set_master = SPI_FLAG_SET_MASTER, set_slave = SPI_FLAG_SET_SLAVE, set_full_duplex = SPI_FLAG_SET_FULL_DUPLEX, set_half_duplex = SPI_FLAG_SET_HALF_DUPLEX, assert_cs = SPI_FLAG_ASSERT_CS, deassert_cs = SPI_FLAG_DEASSERT_CS, }; }; API_OR_NAMED_FLAGS_OPERATOR(SpiFlags, Flags) class Spi : public DeviceAccess<Spi>, public SpiFlags { public: class Info { public: Info() { m_info = {0}; } Info(const spi_info_t &info) { m_info = info; } bool is_valid() const { return m_info.o_flags != 0; } API_READ_ACCESS_MEMBER_FUNDAMENTAL(Info, u32, info, o_flags) API_READ_ACCESS_MEMBER_FUNDAMENTAL(Info, u32, info, o_events) private: friend class Spi; spi_info_t m_info; }; class Attributes { public: Attributes() { set_flags(Flags::set_master | Flags::is_format_spi | Flags::is_mode0 | Flags::set_half_duplex); set_frequency(1000000); set_width(8); var::View(m_attributes.pin_assignment).fill<u8>(0xff); } Attributes &set_flags(Flags flags) { m_attributes.o_flags = static_cast<u32>(flags); return *this; } Flags flags() const { return Flags(m_attributes.o_flags); } u32 o_flags() const { return m_attributes.o_flags; } API_ACCESS_MEMBER_FUNDAMENTAL(Attributes, u8, attributes, width) API_ACCESS_MEMBER_FUNDAMENTAL_WITH_ALIAS( Attributes, u32, attributes, frequency, freq) API_ACCESS_MEMBER_FUNDAMENTAL( Attributes, mcu_pin_t, attributes.pin_assignment, miso) API_ACCESS_MEMBER_FUNDAMENTAL( Attributes, mcu_pin_t, attributes.pin_assignment, mosi) API_ACCESS_MEMBER_FUNDAMENTAL( Attributes, mcu_pin_t, attributes.pin_assignment, sck) API_ACCESS_MEMBER_FUNDAMENTAL( Attributes, mcu_pin_t, attributes.pin_assignment, cs) spi_attr_t *attributes() { return &m_attributes; } const spi_attr_t *attributes() const { return &m_attributes; } private: friend class Spi; mutable spi_attr_t m_attributes; }; Spi(const var::StringView device, fs::OpenMode open_mode = DEVICE_OPEN_MODE FSAPI_LINK_DECLARE_DRIVER_NULLPTR_LAST) : DeviceAccess(device, open_mode FSAPI_LINK_INHERIT_DRIVER_LAST) {} Spi() {} Spi(const Spi &a) = delete; Spi &operator=(const Spi &a) = delete; Spi(Spi &&a) { DeviceAccess<Spi>::swap(a); } Spi &operator=(Spi &&a) { DeviceAccess<Spi>::swap(a); return *this; } Spi &set_attributes() { return ioctl(I_SPI_SETATTR, nullptr); } const Spi &set_attributes() const { return ioctl(I_SPI_SETATTR, nullptr); } Spi &set_attributes(const Attributes &attributes) { return ioctl(I_SPI_SETATTR, &attributes.m_attributes); } const Spi &set_attributes(const Attributes &attributes) const { return ioctl(I_SPI_SETATTR, &attributes.m_attributes); } Spi &assert_cs() { return set_attributes(Attributes().set_flags(Flags::assert_cs)); } const Spi &assert_cs() const { return set_attributes(Attributes().set_flags(Flags::assert_cs)); } Spi &deassert_cs() { return set_attributes(Attributes().set_flags(Flags::deassert_cs)); } const Spi &deassert_cs() const { return set_attributes(Attributes().set_flags(Flags::deassert_cs)); } Info get_info() { spi_info_t info; ioctl(I_SPI_GETINFO, &info); return Info(info); } Spi &swap(u32 value) { return ioctl(I_SPI_SWAP, MCU_INT_CAST(value)); } private: }; } // namespace hal namespace printer { Printer &operator<<(Printer &printer, const hal::Spi::Attributes &a); Printer &operator<<(Printer &printer, const hal::Spi::Info &a); } // namespace printer #endif /* HALAPI_HAL_SPI_HPP_ */
25.951515
77
0.694302
StratifyLabs
0d7afb10eb5f16c8a9cea82bcf2560f61d0478e1
1,176
cpp
C++
Tile Stacking Problem/code_1.cpp
Jatin-Goyal5/Data-Structures-and-Algorithms
f6bd0f77e5640c2e0568f3fffc4694758e77af96
[ "MIT" ]
27
2019-01-31T10:22:29.000Z
2021-08-29T08:25:12.000Z
Tile Stacking Problem/code_1.cpp
Jatin-Goyal5/Data-Structures-and-Algorithms
f6bd0f77e5640c2e0568f3fffc4694758e77af96
[ "MIT" ]
6
2020-09-30T19:01:49.000Z
2020-12-17T15:10:54.000Z
Tile Stacking Problem/code_1.cpp
Jatin-Goyal5/Data-Structures-and-Algorithms
f6bd0f77e5640c2e0568f3fffc4694758e77af96
[ "MIT" ]
27
2019-09-21T14:19:32.000Z
2021-09-15T03:06:41.000Z
// // code_1.cpp // Algorithm // // Created by Mohd Shoaib Rayeen on 23/11/18. // Copyright © 2018 Shoaib Rayeen. All rights reserved. // #include <iostream> #include <vector> using namespace std; int possibleWays(int n, int m, int k) { int dp[m+1][n+1]; int presum[m+1][n+1]; memset(dp, 0, sizeof dp); memset(presum, 0, sizeof presum); for (int i = 1; i < n + 1; i++) { dp[0][i] = 0; presum[0][i] = 1; } for (int i = 0; i < m + 1; i++) { presum[i][0] = dp[i][0] = 1; } for (int i = 1; i < m + 1; i++) { for (int j = 1; j < n + 1; j++) { dp[i][j] = presum[i - 1][j]; if (j > k) { dp[i][j] -= presum[i - 1][j - k - 1]; } } for (int j = 1; j < n + 1; j++) { presum[i][j] = dp[i][j] + presum[i][j - 1]; } } return dp[m][n]; } int main() { int n; cout << "\nEnter n\t:\t"; cin >> n; int m; cout << "\nEnter m\t:\t"; cin >> m; int k; cout << "\nEnter k\t:\t"; cin >> k; cout << "\nNumber of ways\t:\t" << possibleWays(n, m, k); cout << endl; return 0; }
21
61
0.423469
Jatin-Goyal5
0d7bc7ec08dc8526263a3e5d9996c9e5c5000883
11,781
cpp
C++
src/common/zendnn_blocked_layout.cpp
amd/ZenDNN
2d8e025a05126b7c378d88a990a20e21a4182b20
[ "Apache-2.0" ]
28
2021-08-12T10:38:06.000Z
2022-03-25T08:37:31.000Z
src/common/zendnn_blocked_layout.cpp
amd/ZenDNN
2d8e025a05126b7c378d88a990a20e21a4182b20
[ "Apache-2.0" ]
2
2021-08-17T03:20:10.000Z
2021-09-23T04:15:32.000Z
src/common/zendnn_blocked_layout.cpp
amd/ZenDNN
2d8e025a05126b7c378d88a990a20e21a4182b20
[ "Apache-2.0" ]
5
2021-08-20T05:05:59.000Z
2022-02-25T19:13:07.000Z
/******************************************************************************* * Copyright (c) 2019-2021 Advanced Micro Devices, Inc. All rights reserved. *******************************************************************************/ #include <zendnn_private.hpp> #include <omp.h> #include <sys/sysinfo.h> #include <cblas.h> #include <time.h> #include <sys/time.h> #include "zendnn_logging.hpp" using namespace zendnn; #define ALIGNED_OFFSET 64 // This implementation uses NCHW (C/8) and parallelizes convolution by accumulation at sub channel level void zenConvolution2D_Latency_blocked_layout( //const unsigned char* in_layer, zendnnEnv zenEnvObj, const float *in_layer, // float or char input? const int no_of_images, const int channels, const int height, const int width, const float *filter, const int no_of_filter, //const int channels, //no. of channels is same as no. of channels filters const int kernel_h, const int kernel_w, const float pad_h, const float pad_w, const int stride_h, const int stride_w, const float *bias, float *out_layer, //o/p to this function //unsigned char *out_layer, // float or char? //const int out_no_of_images, //const int out_channels, // same as no. of filters const int out_height, //o/p to this function const int out_width //o/p to this function ) { zendnnInfo(ZENDNN_ALGOLOG, "zenConvolution2D_Latency_blocked_layout [zendnn convolution blocked]"); unsigned int thread_qty = zenEnvObj.omp_num_threads; struct timeval start, end; gettimeofday(&start, 0); int channel_group = 8; // Modified hardcoding of 8 based on thread quantity in future int remainder = channels % channel_group; int out_ch_per_group = (channels-remainder)/(channel_group); int w_offset = kernel_h * kernel_w * no_of_filter; int o_h_w = out_height*out_width; unsigned long data_col_size = ((kernel_h*kernel_w*channels)*(out_height*out_width)*sizeof(float)*no_of_images); data_col_size = (data_col_size%ALIGNED_OFFSET == 0) ? data_col_size : (data_col_size/ALIGNED_OFFSET)*ALIGNED_OFFSET + (ALIGNED_OFFSET); float *data_col = (float *)aligned_alloc(ALIGNED_OFFSET, data_col_size); float *out_col; // out_col is an intermedidate output // out_col requires excess memory allocation depending on channel groups // The outputs of N channel groups are accumulated after sgemm calls out_col = (float *) malloc(o_h_w * no_of_filter * sizeof(float)*(channel_group+1)); for (int i =0 ; i < o_h_w * no_of_filter *(channel_group+1); i++) { out_col[i] = 0.0; } if (data_col == NULL) { zendnnError(ZENDNN_ALGOLOG, "zenConvolution2D_Latency_blocked_layout Memory Error while allocating patch matrix"); return; } im2col_parNCHW(in_layer, channels, height, width, kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w, data_col); for (int itr=0; itr <= channel_group; itr++) { if (itr < channel_group) { int weight_offset = itr * out_ch_per_group * kernel_h * kernel_w * no_of_filter; int data_offset = itr * out_ch_per_group * out_height*out_width * kernel_h*kernel_w; if (out_ch_per_group) cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, no_of_filter, o_h_w,kernel_h*kernel_w*out_ch_per_group, 1.0F, filter + weight_offset, kernel_h*kernel_w*out_ch_per_group, data_col + data_offset,o_h_w, 0.0F, out_col + itr*o_h_w* no_of_filter, o_h_w); } else { int weight_offset = channel_group * out_ch_per_group * w_offset; int data_offset = channel_group * out_ch_per_group * o_h_w * kernel_h*kernel_w; if (remainder) cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, no_of_filter, o_h_w,kernel_h*kernel_w*remainder, 1.0F, filter + weight_offset, kernel_h*kernel_w*remainder, data_col + data_offset,o_h_w, 0.0F, out_col+channel_group*o_h_w* no_of_filter, o_h_w); } } // initialize output array to zero #pragma omp parallel for for (int j = 0 ; j < o_h_w * no_of_filter ; j++) { out_layer[j] = 0.0; } // Accumulates the output of channels to generate out_layer #pragma omp parallel for for (int j = 0 ; j < o_h_w * no_of_filter ; j++) { for (int ch = 0; ch <= channel_group; ch++) { out_layer[j]+= out_col[j+ (ch *o_h_w * no_of_filter)]; } } // free the intermediate result free(out_col); out_col =NULL; #if BIAS_ENABLED for (int r=0; r<no_of_filter; r++) { for (int m=0; m<out_height*out_width; m++) { out_layer[(r*(out_height*out_width)) + m]+= bias[r]; } } #endif } void zenConvolution2D_Filterwise_Latency( zendnnEnv zenEnvObj, const float *in_layer, const int no_of_images, const int channels, const int height, const int width, const float *filter, const int no_of_filter, const int kernel_h, const int kernel_w, const float pad_t, const float pad_l, const float pad_b, const float pad_r, const int stride_h, const int stride_w, const float *bias, float *out_layer, const int out_height, const int out_width, const bool relu ) { zendnnInfo(ZENDNN_ALGOLOG, "zenConvolution2D_Filterwise_Latency [zendnn convolution Filter parallelization]"); unsigned int thread_qty = zenEnvObj.omp_num_threads; unsigned long data_col_size = ((kernel_h*kernel_w*channels)*(out_height*out_width)*sizeof(float)*no_of_images); unsigned long filter_col_size = ((kernel_h*kernel_w*channels*no_of_filter)*sizeof(float)); unsigned long o_layer_size = ((no_of_filter)*(out_height*out_width)*sizeof(float)*no_of_images); data_col_size = (data_col_size%ALIGNED_OFFSET == 0) ? data_col_size : (data_col_size/ALIGNED_OFFSET)*ALIGNED_OFFSET + (ALIGNED_OFFSET); o_layer_size = (o_layer_size%ALIGNED_OFFSET == 0) ? o_layer_size : (o_layer_size/ALIGNED_OFFSET)*ALIGNED_OFFSET + (ALIGNED_OFFSET); filter_col_size = (filter_col_size%ALIGNED_OFFSET == 0) ? filter_col_size : (filter_col_size/ALIGNED_OFFSET)*ALIGNED_OFFSET + (ALIGNED_OFFSET); // Allocate memory for reordering input , output and filters float *data_col = (float *)aligned_alloc(ALIGNED_OFFSET, data_col_size); float *out_col = (float *)aligned_alloc(ALIGNED_OFFSET, o_layer_size); float *filter_col = (float *)aligned_alloc(ALIGNED_OFFSET, filter_col_size); if (data_col == NULL) { zendnnError(ZENDNN_ALGOLOG, "zenConvolution2D_Filterwise_Latency Memory Error while allocating patch matrix"); return; } //Divide filters into channel groups based on the number of threads int channel_group = thread_qty; if (no_of_filter < thread_qty) { channel_group = no_of_filter; } int remainder = no_of_filter % (channel_group); int out_ch_per_group = (no_of_filter-remainder)/(channel_group); int split_index,split_offset,index; // Reorder Filters to HWCN ( N/Split ) // This routine should be implemented outside ZenDNN Library #pragma omp parallel for for (int j=0; j<kernel_h*kernel_w*channels; j++) { for (int i=0; i<no_of_filter; i++) { if (i < out_ch_per_group*channel_group) { int block_index = ((int)floor(i/out_ch_per_group)); int sub_block_index = j*out_ch_per_group; int filter_index = i%out_ch_per_group; int index = kernel_h*kernel_w*channels*out_ch_per_group*block_index + sub_block_index + filter_index; filter_col[index]=filter[j*no_of_filter+i]; } else { int index = kernel_h*kernel_w*channels*out_ch_per_group*channel_group + j*remainder + (i%no_of_filter)%remainder ; filter_col[index]=filter[j*no_of_filter+i]; } } } // GEMM calls to implement parallel filter convolution for (int i=0; i<no_of_images; i++) { unsigned long bufferOffset = ((kernel_h*kernel_w*channels)*(out_height*out_width) * i); unsigned long inputOffset = channels*height*width*i; im2rowNHWC_par(in_layer + inputOffset, channels, height, width, kernel_h, kernel_w, pad_t, pad_l, pad_b, pad_r, stride_h, stride_w, data_col + bufferOffset); int w_offset = kernel_h * kernel_w * channels; int o_h_w = out_height*out_width; int weight_offset = 0,out_offset=0; int offset = i*no_of_filter*o_h_w; #pragma omp parallel for for (int itr=0; itr <= channel_group; itr++) { if (itr < channel_group) { weight_offset = ((itr * out_ch_per_group)) * w_offset; out_offset = (itr*out_ch_per_group)* o_h_w + offset; cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, o_h_w, out_ch_per_group, w_offset, 1.0F, data_col + bufferOffset, w_offset, filter_col + weight_offset, out_ch_per_group, 0.0F, out_col+ out_offset, out_ch_per_group); } else { if (remainder) { int weight_offset = out_ch_per_group * (channel_group) * w_offset; int out_offset = (itr * out_ch_per_group)* o_h_w + offset; cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, o_h_w, remainder, w_offset, 1.0F, data_col + bufferOffset, w_offset, filter_col + weight_offset, remainder, 0.0F, out_col+out_offset, remainder); } } } // Reorder Output to NHWC from ( N/Split ) HWC #pragma omp parallel for for (int j=0; j<o_h_w; j++) { for (int l=0; l<no_of_filter; l++) { if (l < out_ch_per_group*channel_group) { int block_index = ((int)floor(l/out_ch_per_group)); int sub_block_index = j*out_ch_per_group; int filter_index = l%out_ch_per_group; int index = o_h_w*out_ch_per_group*block_index + sub_block_index + filter_index; out_layer[offset + j*no_of_filter + l]=out_col[offset + index]; } else { int index = o_h_w*out_ch_per_group*channel_group + j*remainder + (l%no_of_filter)%remainder ; out_layer[offset + j*no_of_filter + l]=out_col[offset + index]; } } } if (bias && !relu) { #pragma omp parallel for num_threads(thread_qty) for (int m=0; m<out_height*out_width; m++) for (int r=0; r<no_of_filter; r++) { out_layer[i*out_height*out_width*no_of_filter + (m*(no_of_filter)) + r]+= bias[r]; } } if (bias && relu) { #pragma omp parallel for num_threads(thread_qty) for (int m=0; m<out_height*out_width; m++) for (int r=0; r<no_of_filter; r++) { out_layer[i*out_height*out_width*no_of_filter + (m*(no_of_filter)) + r]+=bias[r]; if (out_layer[i*out_height*out_width*no_of_filter + (m*(no_of_filter)) + r] < 0) { out_layer[i*out_height*out_width*no_of_filter + (m*(no_of_filter)) + r] = 0; } } } } free(data_col); free(filter_col); free(out_col); }
42.075
165
0.622019
amd
0d7ca836b0447f7adf9e7e39d903a5f32ca879ed
2,352
hpp
C++
src/cached_position.hpp
eldariont/vg
aa394a8477eb3f27ccfe421457e2e013e7907493
[ "BSL-1.0" ]
null
null
null
src/cached_position.hpp
eldariont/vg
aa394a8477eb3f27ccfe421457e2e013e7907493
[ "BSL-1.0" ]
1
2020-04-27T23:28:51.000Z
2020-04-27T23:28:51.000Z
src/cached_position.hpp
eldariont/vg
aa394a8477eb3f27ccfe421457e2e013e7907493
[ "BSL-1.0" ]
null
null
null
#ifndef VG_CACHED_POS_HPP_INCLUDED #define VG_CACHED_POS_HPP_INCLUDED #include "vg.pb.h" #include "types.hpp" #include "xg.hpp" #include "lru_cache.h" #include "utility.hpp" #include "json2pb.h" #include <gcsa/gcsa.h> #include <iostream> /** \file * Functions for working with cached Positions and `pos_t`s. */ namespace vg { using namespace std; // xg/position traversal helpers with caching // used by the Sampler and by the Mapper string xg_cached_node_sequence(id_t id, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache); /// Get the length of a Node from an xg::XG index, with cacheing of deserialized nodes. size_t xg_cached_node_length(id_t id, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache); /// Get the node start position in the sequence vector int64_t xg_cached_node_start(id_t id, xg::XG* xgidx, LRUCache<id_t, int64_t>& node_start_cache); /// Get the character at a position in an xg::XG index, with cacheing of deserialized nodes. char xg_cached_pos_char(pos_t pos, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache); /// Get the characters at positions after the given position from an xg::XG index, with cacheing of deserialized nodes. map<pos_t, char> xg_cached_next_pos_chars(pos_t pos, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache, LRUCache<id_t, vector<Edge> >& edge_cache); set<pos_t> xg_cached_next_pos(pos_t pos, bool whole_node, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache, LRUCache<id_t, vector<Edge> >& edge_cache); int64_t xg_cached_distance(pos_t pos1, pos_t pos2, int64_t maximum, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache, LRUCache<id_t, vector<Edge> >& edge_cache); set<pos_t> xg_cached_positions_bp_from(pos_t pos, int64_t distance, bool rev, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache, LRUCache<id_t, vector<Edge> >& edge_cache); //void xg_cached_graph_context(VG& graph, const pos_t& pos, int length, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache, LRUCache<id_t, vector<Edge> >& edge_cache); Node xg_cached_node(id_t id, xg::XG* xgidx, LRUCache<id_t, Node>& node_cache); vector<Edge> xg_cached_edges_of(id_t id, xg::XG* xgidx, LRUCache<id_t, vector<Edge> >& edge_cache); vector<Edge> xg_cached_edges_on_start(id_t id, xg::XG* xgidx, LRUCache<id_t, vector<Edge> >& edge_cache); vector<Edge> xg_cached_edges_on_end(id_t id, xg::XG* xgidx, LRUCache<id_t, vector<Edge> >& edge_cache); } #endif
53.454545
170
0.758503
eldariont
0d847117a22097e6b48c5b667a0d423e1491fae9
440
hpp
C++
Game.hpp
cptkidd62/minesweeper
0ac18dc94d4bca0b5e687cbce64c5e47bde58a26
[ "MIT" ]
null
null
null
Game.hpp
cptkidd62/minesweeper
0ac18dc94d4bca0b5e687cbce64c5e47bde58a26
[ "MIT" ]
null
null
null
Game.hpp
cptkidd62/minesweeper
0ac18dc94d4bca0b5e687cbce64c5e47bde58a26
[ "MIT" ]
null
null
null
#ifndef GAME_HPP #define GAME_HPP #include <SFML/Graphics.hpp> #include <fstream> #include "Board.hpp" class Game { public: Game(int level); ~Game(); int runGame(sf::RenderWindow &window); private: sf::Font font; sf::Color fontColor, backColor; Board *board; int bombs, level; enum State { PLAYING, WON, LOST, MENU, REPLAY, EXIT } state; }; #endif
13.75
42
0.572727
cptkidd62
0d981f64dba134e7bc6320af90320fd75c9c4ef9
794
cpp
C++
Main/src/GeomUtils.cpp
DaOnlyOwner/Materializer
80854737d5e923b99b2b34ac339b5f2904152270
[ "MIT" ]
null
null
null
Main/src/GeomUtils.cpp
DaOnlyOwner/Materializer
80854737d5e923b99b2b34ac339b5f2904152270
[ "MIT" ]
null
null
null
Main/src/GeomUtils.cpp
DaOnlyOwner/Materializer
80854737d5e923b99b2b34ac339b5f2904152270
[ "MIT" ]
null
null
null
#include "GeomUtils.h" // Can also be used for bezier_rect intersection because the curves I use are nearly a straight line. // TODO bool IntersectionLine_AABB(const glm::vec2& pos0, const glm::vec2& pos1, const glm::vec2& min, const glm::vec2& max) { return true; // For now until i found a super fast algo } bool IntersectionAABB_AABB(const glm::vec2& min0, const glm::vec2& max0, const glm::vec2& min1, const glm::vec2& max1) { /* * ----------- * |1------ | Here we have to check if max0.y >= min1.y and max1.y <= min0.y, lets check that it doesn't lay on the right: * | | | | min0.x <= max1.x && max0.x >= min1.x * | | 0 | | * | | | | * --|----|--- * ------ */ return max0.y >= min1.y && min0.y <= max1.y && min0.x <= max1.x && max0.x >= min1.x; }
33.083333
126
0.583123
DaOnlyOwner
0d9854724ab56c2907b2517a9c6fca7360bd5d54
2,761
cpp
C++
UvA 571 BFS solution.cpp
MohamedNabil97/ProgrammingExamples
540d5384a9dc7b67b0aa63500f2adcdd11110a86
[ "MIT" ]
null
null
null
UvA 571 BFS solution.cpp
MohamedNabil97/ProgrammingExamples
540d5384a9dc7b67b0aa63500f2adcdd11110a86
[ "MIT" ]
null
null
null
UvA 571 BFS solution.cpp
MohamedNabil97/ProgrammingExamples
540d5384a9dc7b67b0aa63500f2adcdd11110a86
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #define pb push_back #define lp(i,n) for(int i=0;i<n;i++) using namespace std; pair<int,int> visited[1009][1009]; pair<int,int> bfs(int Ca,int Cb, int N){ queue <pair<int,int> > q; q.push({0,0}); while(!q.empty()){ auto fr=q.front(); q.pop(); if(fr.first==N || fr.second==N) { return fr; } if(visited[0][fr.second]==make_pair(-1,-1)){ visited[0][fr.second]={fr.first,fr.second}; q.push({0,fr.second}); } if(visited[fr.first][0]==make_pair(-1,-1)){ visited[fr.first][0]={fr.first,fr.second}; q.push({fr.first,0}); } if(visited[Ca][fr.second]==make_pair(-1,-1)){ visited[Ca][fr.second]={fr.first,fr.second}; q.push({Ca,fr.second}); } if(visited[fr.first][Cb]==make_pair(-1,-1)){ visited[fr.first][Cb]={fr.first,fr.second}; q.push({fr.first,Cb}); } int poura=min(fr.second,Ca-fr.first); int pourb=min(fr.first,Cb-fr.second); if (visited [fr.first+poura][fr.second-poura]==make_pair(-1,-1)){ visited[fr.first+poura][fr.second-poura]={fr.first,fr.second}; q.push({fr.first+poura, fr.second-poura}); } if(visited[fr.first-pourb][fr.second+pourb]==make_pair(-1,-1)){ visited[fr.first-pourb][fr.second+pourb]={fr.first,fr.second}; q.push({fr.first-pourb,fr.second+pourb}); } }/* END OF WHILE */ //return fr; }/*END OF BFS*/ void print_states(int i,int j){ stack<string> str; while(i!=0 || j!=0){ int par1,par2; par1=visited[i][j].first; par2=visited[i][j].second; if((par2==j) && i>par1){ str.push("fill A"); }else if((par2==j) && par1>i){ str.push("empty A"); } else if((par1==i) && j>par2){ str.push("fill B"); }else if((par1==i) && j<par2){ str.push("empty B"); }else if(par1>i && par2<j){ str.push("pour A B"); }else if(par1<i && par2>j){ str.push("pour B A"); } i=par1; j=par2; } while((!str.empty())){ cout<<str.top()<<endl; str.pop(); } cout<<"success"<<endl; } int main () { int Ca,Cb,N; while(cin>>Ca>>Cb>>N){ for(int i=0 ;i<1001; i++){ for(int j=0 ;j<1001; j++){ visited[i][j]={-1,-1}; } } pair<int,int> final_state=bfs(Ca,Cb,N); print_states(final_state.first,final_state.second); } return 0; }
18.406667
75
0.467584
MohamedNabil97
0d9eded6221faa51af38bcf10a74edb5de2157d9
395
cpp
C++
CODECHEF/lkdngolf.cpp
prameetu/CP_codes
41f8cfc188d2e08a8091bc5134247d05ba8a78f5
[ "MIT" ]
null
null
null
CODECHEF/lkdngolf.cpp
prameetu/CP_codes
41f8cfc188d2e08a8091bc5134247d05ba8a78f5
[ "MIT" ]
null
null
null
CODECHEF/lkdngolf.cpp
prameetu/CP_codes
41f8cfc188d2e08a8091bc5134247d05ba8a78f5
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #define ll long long int using namespace std; void ans() { ll n,x,k; cin >> n >> x >> k; if(x%k ==0 || (n+1-x)%k==0) { cout << "YES\n"; } else cout << "NO\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t; cin >> t; while(t--){ ans(); } }
14.62963
38
0.405063
prameetu
d3f8937193cf3d40c94193ee29f80fbe947f9c86
2,118
cpp
C++
Alien Engine/Alien Engine/Time.cpp
PolRecasensSarra/Alien-GameEngine
dac1d9793ddec77186f1f198f395807f010fab96
[ "MIT" ]
null
null
null
Alien Engine/Alien Engine/Time.cpp
PolRecasensSarra/Alien-GameEngine
dac1d9793ddec77186f1f198f395807f010fab96
[ "MIT" ]
null
null
null
Alien Engine/Alien Engine/Time.cpp
PolRecasensSarra/Alien-GameEngine
dac1d9793ddec77186f1f198f395807f010fab96
[ "MIT" ]
null
null
null
#include "Time.h" #include "Timer.h" #include "Application.h" #include "ModuleObjects.h" Time::GameState Time::state = Time::GameState::NONE; float Time::time_since_start = 0.0F; float Time::game_time = 0.0F; float Time::delta_time = 0.0F; float Time::scale_time = 1.0F; Timer* Time::start_timer = new Timer(); Timer* Time::game_timer = new Timer(); void Time::Start() { start_timer->Start(); } void Time::Update() { time_since_start = start_timer->ReadSec(); if (state == GameState::PLAY || state == GameState::PLAY_ONCE) { game_time = game_timer->ReadSec(scale_time); } } void Time::Play() { if (state == GameState::NONE) { App->objects->SaveScene("Library/play_scene.alienScene", false); App->objects->ignore_cntrlZ = true; state = GameState::PLAY; game_time = 0.0F; game_timer->Start(); } else if (state == GameState::PAUSE) { state = GameState::PLAY; game_timer->Resume(); } else if (state == GameState::PLAY) { state = GameState::NONE; game_time = 0.0F; App->objects->LoadScene("Library/play_scene.alienScene", false); App->objects->ignore_cntrlZ = false; remove("Library/play_scene.alienScene"); } } void Time::Pause() { if (state == GameState::PAUSE) { Time::Play(); } else if (state == GameState::PLAY || state == GameState::PLAY_ONCE) { state = GameState::PAUSE; game_timer->Pause(); } } void Time::PlayOnce() { if (state == GameState::PAUSE) { game_timer->Resume(); state = GameState::PLAY_ONCE; } else if (state == GameState::PLAY) { state = GameState::PLAY_ONCE; } } void Time::CleanUp() { if (start_timer != nullptr) delete start_timer; if (game_timer != nullptr) delete game_timer; } void Time::SetScaleTime(const float& scale) { scale_time = scale; } void Time::SetDT(const float& dt) { delta_time = dt; } float Time::GetDT() { return delta_time * scale_time; } bool Time::IsPlaying() { if (state == GameState::PLAY || state == GameState::PLAY_ONCE) return true; else return false; } bool Time::IsInGameState() { return state != GameState::NONE; } void Time::Stop() { game_time = 0.0F; state = GameState::NONE; }
18.578947
70
0.670444
PolRecasensSarra
d3fcd4551fb72f2a7c430feae8429adfb75e7e6e
80,499
cpp
C++
src/game_api/custom_types.cpp
mattlennon3/overlunky
8521cac20e89c4d4fa5daec53ed216f8103930a7
[ "MIT" ]
null
null
null
src/game_api/custom_types.cpp
mattlennon3/overlunky
8521cac20e89c4d4fa5daec53ed216f8103930a7
[ "MIT" ]
null
null
null
src/game_api/custom_types.cpp
mattlennon3/overlunky
8521cac20e89c4d4fa5daec53ed216f8103930a7
[ "MIT" ]
null
null
null
#include "custom_types.hpp" #include "entity.hpp" const std::map<CUSTOM_TYPE, std::string_view> custom_type_names = { {CUSTOM_TYPE::ACIDBUBBLE, "ACIDBUBBLE"}, {CUSTOM_TYPE::ALIEN, "ALIEN"}, {CUSTOM_TYPE::ALTAR, "ALTAR"}, {CUSTOM_TYPE::AMMIT, "AMMIT"}, {CUSTOM_TYPE::ANKHPOWERUP, "ANKHPOWERUP"}, {CUSTOM_TYPE::ANUBIS, "ANUBIS"}, {CUSTOM_TYPE::APEPHEAD, "APEPHEAD"}, {CUSTOM_TYPE::APEPPART, "APEPPART"}, {CUSTOM_TYPE::ARROW, "ARROW"}, {CUSTOM_TYPE::ARROWTRAP, "ARROWTRAP"}, {CUSTOM_TYPE::AXOLOTL, "AXOLOTL"}, {CUSTOM_TYPE::AXOLOTLSHOT, "AXOLOTLSHOT"}, {CUSTOM_TYPE::BACKPACK, "BACKPACK"}, {CUSTOM_TYPE::BAT, "BAT"}, {CUSTOM_TYPE::BEE, "BEE"}, {CUSTOM_TYPE::BEG, "BEG"}, {CUSTOM_TYPE::BGBACKLAYERDOOR, "BGBACKLAYERDOOR"}, {CUSTOM_TYPE::BGEGGSHIPROOM, "BGEGGSHIPROOM"}, {CUSTOM_TYPE::BGFLOATINGDEBRIS, "BGFLOATINGDEBRIS"}, {CUSTOM_TYPE::BGMOVINGSTAR, "BGMOVINGSTAR"}, {CUSTOM_TYPE::BGRELATIVEELEMENT, "BGRELATIVEELEMENT"}, {CUSTOM_TYPE::BGSHOOTINGSTAR, "BGSHOOTINGSTAR"}, {CUSTOM_TYPE::BGSHOPENTRENCE, "BGSHOPENTRENCE"}, {CUSTOM_TYPE::BGSHOPKEEPERPRIME, "BGSHOPKEEPERPRIME"}, {CUSTOM_TYPE::BGSURFACELAYER, "BGSURFACELAYER"}, {CUSTOM_TYPE::BGSURFACESTAR, "BGSURFACESTAR"}, {CUSTOM_TYPE::BGTUTORIALSIGN, "BGTUTORIALSIGN"}, {CUSTOM_TYPE::BIGSPEARTRAP, "BIGSPEARTRAP"}, {CUSTOM_TYPE::BIRDIES, "BIRDIES"}, {CUSTOM_TYPE::BODYGUARD, "BODYGUARD"}, {CUSTOM_TYPE::BOMB, "BOMB"}, {CUSTOM_TYPE::BONEBLOCK, "BONEBLOCK"}, {CUSTOM_TYPE::BOOMBOX, "BOOMBOX"}, {CUSTOM_TYPE::BOOMERANG, "BOOMERANG"}, {CUSTOM_TYPE::BOULDER, "BOULDER"}, {CUSTOM_TYPE::BOULDERSPAWNER, "BOULDERSPAWNER"}, {CUSTOM_TYPE::BULLET, "BULLET"}, {CUSTOM_TYPE::BURNINGROPEEFFECT, "BURNINGROPEEFFECT"}, {CUSTOM_TYPE::BUTTON, "BUTTON"}, {CUSTOM_TYPE::CAMERAFLASH, "CAMERAFLASH"}, {CUSTOM_TYPE::CAPE, "CAPE"}, {CUSTOM_TYPE::CATMUMMY, "CATMUMMY"}, {CUSTOM_TYPE::CAVEMAN, "CAVEMAN"}, {CUSTOM_TYPE::CAVEMANSHOPKEEPER, "CAVEMANSHOPKEEPER"}, {CUSTOM_TYPE::CHAIN, "CHAIN"}, {CUSTOM_TYPE::CHAINEDPUSHBLOCK, "CHAINEDPUSHBLOCK"}, {CUSTOM_TYPE::CHEST, "CHEST"}, {CUSTOM_TYPE::CINEMATICANCHOR, "CINEMATICANCHOR"}, {CUSTOM_TYPE::CITYOFGOLDDOOR, "CITYOFGOLDDOOR"}, {CUSTOM_TYPE::CLAMBASE, "CLAMBASE"}, {CUSTOM_TYPE::CLAW, "CLAW"}, {CUSTOM_TYPE::CLIMBABLEROPE, "CLIMBABLEROPE"}, {CUSTOM_TYPE::CLONEGUNSHOT, "CLONEGUNSHOT"}, {CUSTOM_TYPE::COBRA, "COBRA"}, {CUSTOM_TYPE::COFFIN, "COFFIN"}, {CUSTOM_TYPE::COIN, "COIN"}, {CUSTOM_TYPE::CONTAINER, "CONTAINER"}, {CUSTOM_TYPE::CONVEYORBELT, "CONVEYORBELT"}, {CUSTOM_TYPE::COOKFIRE, "COOKFIRE"}, {CUSTOM_TYPE::CRABMAN, "CRABMAN"}, {CUSTOM_TYPE::CRITTER, "CRITTER"}, {CUSTOM_TYPE::CRITTERBEETLE, "CRITTERBEETLE"}, {CUSTOM_TYPE::CRITTERBUTTERFLY, "CRITTERBUTTERFLY"}, {CUSTOM_TYPE::CRITTERCRAB, "CRITTERCRAB"}, {CUSTOM_TYPE::CRITTERDRONE, "CRITTERDRONE"}, {CUSTOM_TYPE::CRITTERFIREFLY, "CRITTERFIREFLY"}, {CUSTOM_TYPE::CRITTERFISH, "CRITTERFISH"}, {CUSTOM_TYPE::CRITTERLOCUST, "CRITTERLOCUST"}, {CUSTOM_TYPE::CRITTERPENGUIN, "CRITTERPENGUIN"}, {CUSTOM_TYPE::CRITTERSLIME, "CRITTERSLIME"}, {CUSTOM_TYPE::CRITTERSNAIL, "CRITTERSNAIL"}, {CUSTOM_TYPE::CROCMAN, "CROCMAN"}, {CUSTOM_TYPE::CROSSBEAM, "CROSSBEAM"}, {CUSTOM_TYPE::CRUSHTRAP, "CRUSHTRAP"}, {CUSTOM_TYPE::CURSEDEFFECT, "CURSEDEFFECT"}, {CUSTOM_TYPE::CURSEDPOT, "CURSEDPOT"}, {CUSTOM_TYPE::DECORATEDDOOR, "DECORATEDDOOR"}, {CUSTOM_TYPE::DECOREGENERATINGBLOCK, "DECOREGENERATINGBLOCK"}, {CUSTOM_TYPE::DESTRUCTIBLEBG, "DESTRUCTIBLEBG"}, {CUSTOM_TYPE::DMALIENBLAST, "DMALIENBLAST"}, {CUSTOM_TYPE::DMSPAWNING, "DMSPAWNING"}, {CUSTOM_TYPE::DOOR, "DOOR"}, {CUSTOM_TYPE::DRILL, "DRILL"}, {CUSTOM_TYPE::DUSTWALLAPEP, "DUSTWALLAPEP"}, {CUSTOM_TYPE::EGGPLANTMINISTER, "EGGPLANTMINISTER"}, {CUSTOM_TYPE::EGGPLANTTHROWER, "EGGPLANTTHROWER"}, {CUSTOM_TYPE::EGGSAC, "EGGSAC"}, {CUSTOM_TYPE::EGGSHIPCENTERJETFLAME, "EGGSHIPCENTERJETFLAME"}, {CUSTOM_TYPE::EGGSHIPDOOR, "EGGSHIPDOOR"}, {CUSTOM_TYPE::EGGSHIPDOORS, "EGGSHIPDOORS"}, {CUSTOM_TYPE::ELEVATOR, "ELEVATOR"}, {CUSTOM_TYPE::EMPRESSGRAVE, "EMPRESSGRAVE"}, {CUSTOM_TYPE::ENTITY, "ENTITY"}, {CUSTOM_TYPE::EXCALIBUR, "EXCALIBUR"}, {CUSTOM_TYPE::EXITDOOR, "EXITDOOR"}, {CUSTOM_TYPE::EXPLOSION, "EXPLOSION"}, {CUSTOM_TYPE::FALLINGPLATFORM, "FALLINGPLATFORM"}, {CUSTOM_TYPE::FIREBALL, "FIREBALL"}, {CUSTOM_TYPE::FIREBUG, "FIREBUG"}, {CUSTOM_TYPE::FIREBUGUNCHAINED, "FIREBUGUNCHAINED"}, {CUSTOM_TYPE::FIREFROG, "FIREFROG"}, {CUSTOM_TYPE::FISH, "FISH"}, {CUSTOM_TYPE::FLAME, "FLAME"}, {CUSTOM_TYPE::FLAMESIZE, "FLAMESIZE"}, {CUSTOM_TYPE::FLOOR, "FLOOR"}, {CUSTOM_TYPE::FLY, "FLY"}, {CUSTOM_TYPE::FLYHEAD, "FLYHEAD"}, {CUSTOM_TYPE::FORCEFIELD, "FORCEFIELD"}, {CUSTOM_TYPE::FORESTSISTER, "FORESTSISTER"}, {CUSTOM_TYPE::FROG, "FROG"}, {CUSTOM_TYPE::FROSTBREATHEFFECT, "FROSTBREATHEFFECT"}, {CUSTOM_TYPE::FROZENLIQUID, "FROZENLIQUID"}, {CUSTOM_TYPE::FXALIENBLAST, "FXALIENBLAST"}, {CUSTOM_TYPE::FXANKHBROKENPIECE, "FXANKHBROKENPIECE"}, {CUSTOM_TYPE::FXANKHROTATINGSPARK, "FXANKHROTATINGSPARK"}, {CUSTOM_TYPE::FXCOMPASS, "FXCOMPASS"}, {CUSTOM_TYPE::FXEMPRESS, "FXEMPRESS"}, {CUSTOM_TYPE::FXFIREFLYLIGHT, "FXFIREFLYLIGHT"}, {CUSTOM_TYPE::FXHUNDUNNECKPIECE, "FXHUNDUNNECKPIECE"}, {CUSTOM_TYPE::FXJELLYFISHSTAR, "FXJELLYFISHSTAR"}, {CUSTOM_TYPE::FXJETPACKFLAME, "FXJETPACKFLAME"}, {CUSTOM_TYPE::FXKINGUSLIDING, "FXKINGUSLIDING"}, {CUSTOM_TYPE::FXLAMASSUATTACK, "FXLAMASSUATTACK"}, {CUSTOM_TYPE::FXMAINEXITDOOR, "FXMAINEXITDOOR"}, {CUSTOM_TYPE::FXNECROMANCERANKH, "FXNECROMANCERANKH"}, {CUSTOM_TYPE::FXOUROBORODRAGONPART, "FXOUROBORODRAGONPART"}, {CUSTOM_TYPE::FXOUROBOROOCCLUDER, "FXOUROBOROOCCLUDER"}, {CUSTOM_TYPE::FXPICKUPEFFECT, "FXPICKUPEFFECT"}, {CUSTOM_TYPE::FXPLAYERINDICATOR, "FXPLAYERINDICATOR"}, {CUSTOM_TYPE::FXQUICKSAND, "FXQUICKSAND"}, {CUSTOM_TYPE::FXSALECONTAINER, "FXSALECONTAINER"}, {CUSTOM_TYPE::FXSHOTGUNBLAST, "FXSHOTGUNBLAST"}, {CUSTOM_TYPE::FXSORCERESSATTACK, "FXSORCERESSATTACK"}, {CUSTOM_TYPE::FXSPARKSMALL, "FXSPARKSMALL"}, {CUSTOM_TYPE::FXSPRINGTRAPRING, "FXSPRINGTRAPRING"}, {CUSTOM_TYPE::FXTIAMATHEAD, "FXTIAMATHEAD"}, {CUSTOM_TYPE::FXTIAMATTAIL, "FXTIAMATTAIL"}, {CUSTOM_TYPE::FXTIAMATTORSO, "FXTIAMATTORSO"}, {CUSTOM_TYPE::FXTORNJOURNALPAGE, "FXTORNJOURNALPAGE"}, {CUSTOM_TYPE::FXUNDERWATERBUBBLE, "FXUNDERWATERBUBBLE"}, {CUSTOM_TYPE::FXVATBUBBLE, "FXVATBUBBLE"}, {CUSTOM_TYPE::FXWATERDROP, "FXWATERDROP"}, {CUSTOM_TYPE::FXWEBBEDEFFECT, "FXWEBBEDEFFECT"}, {CUSTOM_TYPE::FXWITCHDOCTORHINT, "FXWITCHDOCTORHINT"}, {CUSTOM_TYPE::GENERATOR, "GENERATOR"}, {CUSTOM_TYPE::GHIST, "GHIST"}, {CUSTOM_TYPE::GHOST, "GHOST"}, {CUSTOM_TYPE::GHOSTBREATH, "GHOSTBREATH"}, {CUSTOM_TYPE::GIANTCLAMTOP, "GIANTCLAMTOP"}, {CUSTOM_TYPE::GIANTFISH, "GIANTFISH"}, {CUSTOM_TYPE::GIANTFLY, "GIANTFLY"}, {CUSTOM_TYPE::GIANTFROG, "GIANTFROG"}, {CUSTOM_TYPE::GOLDBAR, "GOLDBAR"}, {CUSTOM_TYPE::GOLDMONKEY, "GOLDMONKEY"}, {CUSTOM_TYPE::GRUB, "GRUB"}, {CUSTOM_TYPE::GUN, "GUN"}, {CUSTOM_TYPE::HANGANCHOR, "HANGANCHOR"}, {CUSTOM_TYPE::HANGSPIDER, "HANGSPIDER"}, {CUSTOM_TYPE::HANGSTRAND, "HANGSTRAND"}, {CUSTOM_TYPE::HERMITCRAB, "HERMITCRAB"}, {CUSTOM_TYPE::HONEY, "HONEY"}, {CUSTOM_TYPE::HORIZONTALFORCEFIELD, "HORIZONTALFORCEFIELD"}, {CUSTOM_TYPE::HORNEDLIZARD, "HORNEDLIZARD"}, {CUSTOM_TYPE::HOVERPACK, "HOVERPACK"}, {CUSTOM_TYPE::HUNDUN, "HUNDUN"}, {CUSTOM_TYPE::HUNDUNCHEST, "HUNDUNCHEST"}, {CUSTOM_TYPE::HUNDUNHEAD, "HUNDUNHEAD"}, {CUSTOM_TYPE::ICESLIDINGSOUND, "ICESLIDINGSOUND"}, {CUSTOM_TYPE::IDOL, "IDOL"}, {CUSTOM_TYPE::IMP, "IMP"}, {CUSTOM_TYPE::JETPACK, "JETPACK"}, {CUSTOM_TYPE::JIANGSHI, "JIANGSHI"}, {CUSTOM_TYPE::JUMPDOG, "JUMPDOG"}, {CUSTOM_TYPE::JUNGLESPEARCOSMETIC, "JUNGLESPEARCOSMETIC"}, {CUSTOM_TYPE::JUNGLETRAPTRIGGER, "JUNGLETRAPTRIGGER"}, {CUSTOM_TYPE::KAPALAPOWERUP, "KAPALAPOWERUP"}, {CUSTOM_TYPE::KINGU, "KINGU"}, {CUSTOM_TYPE::LAHAMU, "LAHAMU"}, {CUSTOM_TYPE::LAMASSU, "LAMASSU"}, {CUSTOM_TYPE::LAMPFLAME, "LAMPFLAME"}, {CUSTOM_TYPE::LANDMINE, "LANDMINE"}, {CUSTOM_TYPE::LASERBEAM, "LASERBEAM"}, {CUSTOM_TYPE::LASERTRAP, "LASERTRAP"}, {CUSTOM_TYPE::LAVA, "LAVA"}, {CUSTOM_TYPE::LAVAMANDER, "LAVAMANDER"}, {CUSTOM_TYPE::LEAF, "LEAF"}, {CUSTOM_TYPE::LEPRECHAUN, "LEPRECHAUN"}, {CUSTOM_TYPE::LIGHTARROW, "LIGHTARROW"}, {CUSTOM_TYPE::LIGHTARROWPLATFORM, "LIGHTARROWPLATFORM"}, {CUSTOM_TYPE::LIGHTEMITTER, "LIGHTEMITTER"}, {CUSTOM_TYPE::LIGHTSHOT, "LIGHTSHOT"}, {CUSTOM_TYPE::LIMBANCHOR, "LIMBANCHOR"}, {CUSTOM_TYPE::LIQUID, "LIQUID"}, {CUSTOM_TYPE::LIQUIDSURFACE, "LIQUIDSURFACE"}, {CUSTOM_TYPE::LOCKEDDOOR, "LOCKEDDOOR"}, {CUSTOM_TYPE::LOGICALANCHOVYFLOCK, "LOGICALANCHOVYFLOCK"}, {CUSTOM_TYPE::LOGICALCONVEYORBELTSOUND, "LOGICALCONVEYORBELTSOUND"}, {CUSTOM_TYPE::LOGICALDOOR, "LOGICALDOOR"}, {CUSTOM_TYPE::LOGICALDRAIN, "LOGICALDRAIN"}, {CUSTOM_TYPE::LOGICALLIQUIDSTREAMSOUND, "LOGICALLIQUIDSTREAMSOUND"}, {CUSTOM_TYPE::LOGICALMINIGAME, "LOGICALMINIGAME"}, {CUSTOM_TYPE::LOGICALREGENERATINGBLOCK, "LOGICALREGENERATINGBLOCK"}, {CUSTOM_TYPE::LOGICALSOUND, "LOGICALSOUND"}, {CUSTOM_TYPE::LOGICALSTATICSOUND, "LOGICALSTATICSOUND"}, {CUSTOM_TYPE::LOGICALTRAPTRIGGER, "LOGICALTRAPTRIGGER"}, {CUSTOM_TYPE::MAGMAMAN, "MAGMAMAN"}, {CUSTOM_TYPE::MAINEXIT, "MAINEXIT"}, {CUSTOM_TYPE::MANTRAP, "MANTRAP"}, {CUSTOM_TYPE::MATTOCK, "MATTOCK"}, {CUSTOM_TYPE::MECH, "MECH"}, {CUSTOM_TYPE::MEGAJELLYFISH, "MEGAJELLYFISH"}, {CUSTOM_TYPE::MINIGAMEASTEROID, "MINIGAMEASTEROID"}, {CUSTOM_TYPE::MINIGAMESHIP, "MINIGAMESHIP"}, {CUSTOM_TYPE::MINIGAMESHIPOFFSET, "MINIGAMESHIPOFFSET"}, {CUSTOM_TYPE::MOLE, "MOLE"}, {CUSTOM_TYPE::MONKEY, "MONKEY"}, {CUSTOM_TYPE::MONSTER, "MONSTER"}, {CUSTOM_TYPE::MOSQUITO, "MOSQUITO"}, {CUSTOM_TYPE::MOTHERSTATUE, "MOTHERSTATUE"}, {CUSTOM_TYPE::MOUNT, "MOUNT"}, {CUSTOM_TYPE::MOVABLE, "MOVABLE"}, {CUSTOM_TYPE::MOVINGICON, "MOVINGICON"}, {CUSTOM_TYPE::MUMMY, "MUMMY"}, {CUSTOM_TYPE::MUMMYFLIESSOUND, "MUMMYFLIESSOUND"}, {CUSTOM_TYPE::NECROMANCER, "NECROMANCER"}, {CUSTOM_TYPE::NPC, "NPC"}, {CUSTOM_TYPE::OCTOPUS, "OCTOPUS"}, {CUSTOM_TYPE::OLMEC, "OLMEC"}, {CUSTOM_TYPE::OLMECCANNON, "OLMECCANNON"}, {CUSTOM_TYPE::OLMECFLOATER, "OLMECFLOATER"}, {CUSTOM_TYPE::OLMITE, "OLMITE"}, {CUSTOM_TYPE::ONFIREEFFECT, "ONFIREEFFECT"}, {CUSTOM_TYPE::ORB, "ORB"}, {CUSTOM_TYPE::OSIRISHAND, "OSIRISHAND"}, {CUSTOM_TYPE::OSIRISHEAD, "OSIRISHEAD"}, {CUSTOM_TYPE::OUROBOROCAMERAANCHOR, "OUROBOROCAMERAANCHOR"}, {CUSTOM_TYPE::OUROBOROCAMERAZOOMIN, "OUROBOROCAMERAZOOMIN"}, {CUSTOM_TYPE::PALACESIGN, "PALACESIGN"}, {CUSTOM_TYPE::PARACHUTEPOWERUP, "PARACHUTEPOWERUP"}, {CUSTOM_TYPE::PET, "PET"}, {CUSTOM_TYPE::PIPE, "PIPE"}, {CUSTOM_TYPE::PIPETRAVELERSOUND, "PIPETRAVELERSOUND"}, {CUSTOM_TYPE::PLAYER, "PLAYER"}, {CUSTOM_TYPE::PLAYERBAG, "PLAYERBAG"}, {CUSTOM_TYPE::PLAYERGHOST, "PLAYERGHOST"}, {CUSTOM_TYPE::POISONEDEFFECT, "POISONEDEFFECT"}, {CUSTOM_TYPE::POLEDECO, "POLEDECO"}, {CUSTOM_TYPE::PORTAL, "PORTAL"}, {CUSTOM_TYPE::POT, "POT"}, {CUSTOM_TYPE::POWERUP, "POWERUP"}, {CUSTOM_TYPE::POWERUPCAPABLE, "POWERUPCAPABLE"}, {CUSTOM_TYPE::PROTOSHOPKEEPER, "PROTOSHOPKEEPER"}, {CUSTOM_TYPE::PUNISHBALL, "PUNISHBALL"}, {CUSTOM_TYPE::PUSHBLOCK, "PUSHBLOCK"}, {CUSTOM_TYPE::QILIN, "QILIN"}, {CUSTOM_TYPE::QUICKSAND, "QUICKSAND"}, {CUSTOM_TYPE::QUICKSANDSOUND, "QUICKSANDSOUND"}, {CUSTOM_TYPE::QUILLBACK, "QUILLBACK"}, {CUSTOM_TYPE::REGENBLOCK, "REGENBLOCK"}, {CUSTOM_TYPE::ROBOT, "ROBOT"}, {CUSTOM_TYPE::ROCKDOG, "ROCKDOG"}, {CUSTOM_TYPE::ROLLINGITEM, "ROLLINGITEM"}, {CUSTOM_TYPE::ROOMLIGHT, "ROOMLIGHT"}, {CUSTOM_TYPE::ROOMOWNER, "ROOMOWNER"}, {CUSTOM_TYPE::RUBBLE, "RUBBLE"}, {CUSTOM_TYPE::SCARAB, "SCARAB"}, {CUSTOM_TYPE::SCEPTERSHOT, "SCEPTERSHOT"}, {CUSTOM_TYPE::SCORPION, "SCORPION"}, {CUSTOM_TYPE::SHIELD, "SHIELD"}, {CUSTOM_TYPE::SHOOTINGSTARSPAWNER, "SHOOTINGSTARSPAWNER"}, {CUSTOM_TYPE::SHOPKEEPER, "SHOPKEEPER"}, {CUSTOM_TYPE::SKELETON, "SKELETON"}, {CUSTOM_TYPE::SKULLDROPTRAP, "SKULLDROPTRAP"}, {CUSTOM_TYPE::SLEEPBUBBLE, "SLEEPBUBBLE"}, {CUSTOM_TYPE::SLIDINGWALLCEILING, "SLIDINGWALLCEILING"}, {CUSTOM_TYPE::SNAPTRAP, "SNAPTRAP"}, {CUSTOM_TYPE::SORCERESS, "SORCERESS"}, {CUSTOM_TYPE::SOUNDSHOT, "SOUNDSHOT"}, {CUSTOM_TYPE::SPARK, "SPARK"}, {CUSTOM_TYPE::SPARKTRAP, "SPARKTRAP"}, {CUSTOM_TYPE::SPEAR, "SPEAR"}, {CUSTOM_TYPE::SPECIALSHOT, "SPECIALSHOT"}, {CUSTOM_TYPE::SPIDER, "SPIDER"}, {CUSTOM_TYPE::SPIKEBALLTRAP, "SPIKEBALLTRAP"}, {CUSTOM_TYPE::SPLASHBUBBLEGENERATOR, "SPLASHBUBBLEGENERATOR"}, {CUSTOM_TYPE::STICKYTRAP, "STICKYTRAP"}, {CUSTOM_TYPE::STRETCHCHAIN, "STRETCHCHAIN"}, {CUSTOM_TYPE::SWITCH, "SWITCH"}, {CUSTOM_TYPE::TADPOLE, "TADPOLE"}, {CUSTOM_TYPE::TELEPORTER, "TELEPORTER"}, {CUSTOM_TYPE::TELEPORTERBACKPACK, "TELEPORTERBACKPACK"}, {CUSTOM_TYPE::TELEPORTINGBORDER, "TELEPORTINGBORDER"}, {CUSTOM_TYPE::TELESCOPE, "TELESCOPE"}, {CUSTOM_TYPE::TENTACLE, "TENTACLE"}, {CUSTOM_TYPE::TENTACLEBOTTOM, "TENTACLEBOTTOM"}, {CUSTOM_TYPE::TERRA, "TERRA"}, {CUSTOM_TYPE::THINICE, "THINICE"}, {CUSTOM_TYPE::TIAMAT, "TIAMAT"}, {CUSTOM_TYPE::TIAMATSHOT, "TIAMATSHOT"}, {CUSTOM_TYPE::TIMEDFORCEFIELD, "TIMEDFORCEFIELD"}, {CUSTOM_TYPE::TIMEDPOWDERKEG, "TIMEDPOWDERKEG"}, {CUSTOM_TYPE::TIMEDSHOT, "TIMEDSHOT"}, {CUSTOM_TYPE::TORCH, "TORCH"}, {CUSTOM_TYPE::TORCHFLAME, "TORCHFLAME"}, {CUSTOM_TYPE::TOTEMTRAP, "TOTEMTRAP"}, {CUSTOM_TYPE::TRANSFERFLOOR, "TRANSFERFLOOR"}, {CUSTOM_TYPE::TRAPPART, "TRAPPART"}, {CUSTOM_TYPE::TREASURE, "TREASURE"}, {CUSTOM_TYPE::TREASUREHOOK, "TREASUREHOOK"}, {CUSTOM_TYPE::TRUECROWNPOWERUP, "TRUECROWNPOWERUP"}, {CUSTOM_TYPE::TUN, "TUN"}, {CUSTOM_TYPE::TV, "TV"}, {CUSTOM_TYPE::UDJATSOCKET, "UDJATSOCKET"}, {CUSTOM_TYPE::UFO, "UFO"}, {CUSTOM_TYPE::UNCHAINEDSPIKEBALL, "UNCHAINEDSPIKEBALL"}, {CUSTOM_TYPE::USHABTI, "USHABTI"}, {CUSTOM_TYPE::VAMPIRE, "VAMPIRE"}, {CUSTOM_TYPE::VANHORSING, "VANHORSING"}, {CUSTOM_TYPE::VLAD, "VLAD"}, {CUSTOM_TYPE::VLADSCAPE, "VLADSCAPE"}, {CUSTOM_TYPE::WADDLER, "WADDLER"}, {CUSTOM_TYPE::WALKINGMONSTER, "WALKINGMONSTER"}, {CUSTOM_TYPE::WALLTORCH, "WALLTORCH"}, {CUSTOM_TYPE::WEBSHOT, "WEBSHOT"}, {CUSTOM_TYPE::WETEFFECT, "WETEFFECT"}, {CUSTOM_TYPE::WITCHDOCTOR, "WITCHDOCTOR"}, {CUSTOM_TYPE::WITCHDOCTORSKULL, "WITCHDOCTORSKULL"}, {CUSTOM_TYPE::WOODENLOGTRAP, "WOODENLOGTRAP"}, {CUSTOM_TYPE::YAMA, "YAMA"}, {CUSTOM_TYPE::YANG, "YANG"}, {CUSTOM_TYPE::YELLOWCAPE, "YELLOWCAPE"}, {CUSTOM_TYPE::YETIKING, "YETIKING"}, {CUSTOM_TYPE::YETIQUEEN, "YETIQUEEN"}, }; template <CUSTOM_TYPE CustomEntityType, class... StrArgs> requires(std::is_same_v<const char*, StrArgs>&&...) std::span<const ENT_TYPE> make_custom_entity_type_list(StrArgs... ent_type_ids) { static const std::array<ENT_TYPE, sizeof...(StrArgs)> s_entity_types{ to_id(ent_type_ids)..., }; return {s_entity_types.begin(), s_entity_types.end()}; } std::span<const ENT_TYPE> get_custom_entity_types(CUSTOM_TYPE type) { if (type < CUSTOM_TYPE::ACIDBUBBLE) return {}; switch (type) { case CUSTOM_TYPE::ACIDBUBBLE: return make_custom_entity_type_list<CUSTOM_TYPE::ACIDBUBBLE>("ENT_TYPE_ITEM_CRABMAN_ACIDBUBBLE"); case CUSTOM_TYPE::ALIEN: return make_custom_entity_type_list<CUSTOM_TYPE::ALIEN>("ENT_TYPE_MONS_ALIEN"); case CUSTOM_TYPE::ALTAR: return make_custom_entity_type_list<CUSTOM_TYPE::ALTAR>( "ENT_TYPE_FLOOR_ALTAR", "ENT_TYPE_FLOOR_DUAT_ALTAR", "ENT_TYPE_FLOOR_EGGPLANT_ALTAR"); case CUSTOM_TYPE::AMMIT: return make_custom_entity_type_list<CUSTOM_TYPE::AMMIT>("ENT_TYPE_MONS_AMMIT"); case CUSTOM_TYPE::ANKHPOWERUP: return make_custom_entity_type_list<CUSTOM_TYPE::ANKHPOWERUP>("ENT_TYPE_ITEM_POWERUP_ANKH"); case CUSTOM_TYPE::ANUBIS: return make_custom_entity_type_list<CUSTOM_TYPE::ANUBIS>( "ENT_TYPE_MONS_ANUBIS", "ENT_TYPE_MONS_ANUBIS2"); case CUSTOM_TYPE::APEPHEAD: return make_custom_entity_type_list<CUSTOM_TYPE::APEPHEAD>("ENT_TYPE_MONS_APEP_HEAD"); case CUSTOM_TYPE::APEPPART: return make_custom_entity_type_list<CUSTOM_TYPE::APEPPART>( "ENT_TYPE_MONS_APEP_HEAD", "ENT_TYPE_MONS_APEP_BODY", "ENT_TYPE_MONS_APEP_TAIL"); case CUSTOM_TYPE::ARROW: return make_custom_entity_type_list<CUSTOM_TYPE::ARROW>( "ENT_TYPE_ITEM_WOODEN_ARROW", "ENT_TYPE_ITEM_METAL_ARROW", "ENT_TYPE_ITEM_LIGHT_ARROW"); case CUSTOM_TYPE::ARROWTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::ARROWTRAP>( "ENT_TYPE_FLOOR_ARROW_TRAP", "ENT_TYPE_FLOOR_POISONED_ARROW_TRAP"); case CUSTOM_TYPE::AXOLOTL: return make_custom_entity_type_list<CUSTOM_TYPE::AXOLOTL>("ENT_TYPE_MOUNT_AXOLOTL"); case CUSTOM_TYPE::AXOLOTLSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::AXOLOTLSHOT>("ENT_TYPE_ITEM_AXOLOTL_BUBBLESHOT"); case CUSTOM_TYPE::BACKPACK: return make_custom_entity_type_list<CUSTOM_TYPE::BACKPACK>( "ENT_TYPE_ITEM_CAPE", "ENT_TYPE_ITEM_VLADS_CAPE", "ENT_TYPE_ITEM_JETPACK", "ENT_TYPE_ITEM_JETPACK_MECH", "ENT_TYPE_ITEM_TELEPORTER_BACKPACK", "ENT_TYPE_ITEM_HOVERPACK", "ENT_TYPE_ITEM_POWERPACK"); case CUSTOM_TYPE::BAT: return make_custom_entity_type_list<CUSTOM_TYPE::BAT>("ENT_TYPE_MONS_BAT"); case CUSTOM_TYPE::BEE: return make_custom_entity_type_list<CUSTOM_TYPE::BEE>( "ENT_TYPE_MONS_BEE", "ENT_TYPE_MONS_QUEENBEE"); case CUSTOM_TYPE::BEG: return make_custom_entity_type_list<CUSTOM_TYPE::BEG>("ENT_TYPE_MONS_HUNDUNS_SERVANT"); case CUSTOM_TYPE::BGBACKLAYERDOOR: return make_custom_entity_type_list<CUSTOM_TYPE::BGBACKLAYERDOOR>("ENT_TYPE_BG_DOOR_BACK_LAYER"); case CUSTOM_TYPE::BGEGGSHIPROOM: return make_custom_entity_type_list<CUSTOM_TYPE::BGEGGSHIPROOM>("ENT_TYPE_BG_EGGSHIP_ROOM"); case CUSTOM_TYPE::BGFLOATINGDEBRIS: return make_custom_entity_type_list<CUSTOM_TYPE::BGFLOATINGDEBRIS>( "ENT_TYPE_BG_DUAT_FLOATINGDEBRIS", "ENT_TYPE_BG_DUAT_FARFLOATINGDEBRIS", "ENT_TYPE_BG_COSMIC_FLOATINGDEBRIS", "ENT_TYPE_BG_COSMIC_FARFLOATINGDEBRIS"); case CUSTOM_TYPE::BGMOVINGSTAR: return make_custom_entity_type_list<CUSTOM_TYPE::BGMOVINGSTAR>("ENT_TYPE_BG_SURFACE_MOVING_STAR"); case CUSTOM_TYPE::BGRELATIVEELEMENT: return make_custom_entity_type_list<CUSTOM_TYPE::BGRELATIVEELEMENT>( "ENT_TYPE_BG_SURFACE_SHOOTING_STAR", "ENT_TYPE_BG_SURFACE_SHOOTING_STAR_TRAIL", "ENT_TYPE_BG_SURFACE_SHOOTING_STAR_TRAIL_PARTICLE", "ENT_TYPE_BG_SURFACE_NEBULA", "ENT_TYPE_BG_SURFACE_LAYER", "ENT_TYPE_BG_SURFACE_ENTITY", "ENT_TYPE_BG_SURFACE_OLMEC_LAYER", "ENT_TYPE_BG_DUAT_LAYER", "ENT_TYPE_BG_DUAT_PYRAMID_LAYER", "ENT_TYPE_BG_DUAT_FLOATINGDEBRIS", "ENT_TYPE_BG_DUAT_FARFLOATINGDEBRIS", "ENT_TYPE_BG_COSMIC_FLOATINGDEBRIS", "ENT_TYPE_BG_COSMIC_FARFLOATINGDEBRIS"); case CUSTOM_TYPE::BGSHOOTINGSTAR: return make_custom_entity_type_list<CUSTOM_TYPE::BGSHOOTINGSTAR>("ENT_TYPE_BG_SURFACE_SHOOTING_STAR"); case CUSTOM_TYPE::BGSHOPENTRENCE: return make_custom_entity_type_list<CUSTOM_TYPE::BGSHOPENTRENCE>("ENT_TYPE_BG_SHOP_ENTRANCEDOOR"); case CUSTOM_TYPE::BGSHOPKEEPERPRIME: return make_custom_entity_type_list<CUSTOM_TYPE::BGSHOPKEEPERPRIME>("ENT_TYPE_BG_VAT_SHOPKEEPER_PRIME"); case CUSTOM_TYPE::BGSURFACELAYER: return make_custom_entity_type_list<CUSTOM_TYPE::BGSURFACELAYER>( "ENT_TYPE_BG_SURFACE_LAYER", "ENT_TYPE_BG_SURFACE_ENTITY", "ENT_TYPE_BG_SURFACE_OLMEC_LAYER", "ENT_TYPE_BG_DUAT_LAYER", "ENT_TYPE_BG_DUAT_PYRAMID_LAYER", "ENT_TYPE_BG_DUAT_FLOATINGDEBRIS", "ENT_TYPE_BG_DUAT_FARFLOATINGDEBRIS", "ENT_TYPE_BG_COSMIC_FLOATINGDEBRIS", "ENT_TYPE_BG_COSMIC_FARFLOATINGDEBRIS"); case CUSTOM_TYPE::BGSURFACESTAR: return make_custom_entity_type_list<CUSTOM_TYPE::BGSURFACESTAR>( "ENT_TYPE_BG_SURFACE_STAR", "ENT_TYPE_BG_SURFACE_MOVING_STAR", "ENT_TYPE_BG_CONSTELLATION_STAR", "ENT_TYPE_BG_CONSTELLATION_CONNECTION"); case CUSTOM_TYPE::BGTUTORIALSIGN: return make_custom_entity_type_list<CUSTOM_TYPE::BGTUTORIALSIGN>( "ENT_TYPE_BG_TUTORIAL_SIGN_BACK", "ENT_TYPE_BG_TUTORIAL_SIGN_FRONT"); case CUSTOM_TYPE::BIGSPEARTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::BIGSPEARTRAP>("ENT_TYPE_FLOOR_BIGSPEAR_TRAP"); case CUSTOM_TYPE::BIRDIES: return make_custom_entity_type_list<CUSTOM_TYPE::BIRDIES>("ENT_TYPE_FX_BIRDIES"); case CUSTOM_TYPE::BODYGUARD: return make_custom_entity_type_list<CUSTOM_TYPE::BODYGUARD>("ENT_TYPE_MONS_BODYGUARD"); case CUSTOM_TYPE::BOMB: return make_custom_entity_type_list<CUSTOM_TYPE::BOMB>( "ENT_TYPE_ITEM_BOMB", "ENT_TYPE_ITEM_PASTEBOMB"); case CUSTOM_TYPE::BONEBLOCK: return make_custom_entity_type_list<CUSTOM_TYPE::BONEBLOCK>("ENT_TYPE_ACTIVEFLOOR_BONEBLOCK"); case CUSTOM_TYPE::BOOMBOX: return make_custom_entity_type_list<CUSTOM_TYPE::BOOMBOX>("ENT_TYPE_ITEM_BOOMBOX"); case CUSTOM_TYPE::BOOMERANG: return make_custom_entity_type_list<CUSTOM_TYPE::BOOMERANG>("ENT_TYPE_ITEM_BOOMERANG"); case CUSTOM_TYPE::BOULDER: return make_custom_entity_type_list<CUSTOM_TYPE::BOULDER>("ENT_TYPE_ACTIVEFLOOR_BOULDER"); case CUSTOM_TYPE::BOULDERSPAWNER: return make_custom_entity_type_list<CUSTOM_TYPE::BOULDERSPAWNER>("ENT_TYPE_LOGICAL_BOULDERSPAWNER"); case CUSTOM_TYPE::BULLET: return make_custom_entity_type_list<CUSTOM_TYPE::BULLET>("ENT_TYPE_ITEM_BULLET"); case CUSTOM_TYPE::BURNINGROPEEFFECT: return make_custom_entity_type_list<CUSTOM_TYPE::BURNINGROPEEFFECT>("ENT_TYPE_LOGICAL_BURNING_ROPE_EFFECT"); case CUSTOM_TYPE::BUTTON: return make_custom_entity_type_list<CUSTOM_TYPE::BUTTON>("ENT_TYPE_FX_BUTTON"); case CUSTOM_TYPE::CAMERAFLASH: return make_custom_entity_type_list<CUSTOM_TYPE::CAMERAFLASH>("ENT_TYPE_LOGICAL_CAMERA_FLASH"); case CUSTOM_TYPE::CAPE: return make_custom_entity_type_list<CUSTOM_TYPE::CAPE>( "ENT_TYPE_ITEM_CAPE", "ENT_TYPE_ITEM_VLADS_CAPE"); case CUSTOM_TYPE::CATMUMMY: return make_custom_entity_type_list<CUSTOM_TYPE::CATMUMMY>("ENT_TYPE_MONS_CATMUMMY"); case CUSTOM_TYPE::CAVEMAN: return make_custom_entity_type_list<CUSTOM_TYPE::CAVEMAN>("ENT_TYPE_MONS_CAVEMAN"); case CUSTOM_TYPE::CAVEMANSHOPKEEPER: return make_custom_entity_type_list<CUSTOM_TYPE::CAVEMANSHOPKEEPER>("ENT_TYPE_MONS_CAVEMAN_SHOPKEEPER"); case CUSTOM_TYPE::CHAIN: return make_custom_entity_type_list<CUSTOM_TYPE::CHAIN>( "ENT_TYPE_ITEM_CHAIN", "ENT_TYPE_ITEM_CHAIN_LASTPIECE", "ENT_TYPE_ITEM_SLIDINGWALL_CHAIN", "ENT_TYPE_ITEM_SLIDINGWALL_CHAIN_LASTPIECE", "ENT_TYPE_ITEM_STICKYTRAP_PIECE", "ENT_TYPE_ITEM_STICKYTRAP_LASTPIECE", "ENT_TYPE_ITEM_TENTACLE", "ENT_TYPE_ITEM_TENTACLE_PIECE", "ENT_TYPE_ITEM_TENTACLE_LAST_PIECE"); case CUSTOM_TYPE::CHAINEDPUSHBLOCK: return make_custom_entity_type_list<CUSTOM_TYPE::CHAINEDPUSHBLOCK>("ENT_TYPE_ACTIVEFLOOR_CHAINEDPUSHBLOCK"); case CUSTOM_TYPE::CHEST: return make_custom_entity_type_list<CUSTOM_TYPE::CHEST>("ENT_TYPE_ITEM_CHEST"); case CUSTOM_TYPE::CINEMATICANCHOR: return make_custom_entity_type_list<CUSTOM_TYPE::CINEMATICANCHOR>("ENT_TYPE_LOGICAL_CINEMATIC_ANCHOR"); case CUSTOM_TYPE::CITYOFGOLDDOOR: return make_custom_entity_type_list<CUSTOM_TYPE::CITYOFGOLDDOOR>("ENT_TYPE_FLOOR_DOOR_COG"); case CUSTOM_TYPE::CLAMBASE: return make_custom_entity_type_list<CUSTOM_TYPE::CLAMBASE>("ENT_TYPE_ACTIVEFLOOR_GIANTCLAM_BASE"); case CUSTOM_TYPE::CLAW: return make_custom_entity_type_list<CUSTOM_TYPE::CLAW>("ENT_TYPE_ITEM_CRABMAN_CLAW"); case CUSTOM_TYPE::CLIMBABLEROPE: return make_custom_entity_type_list<CUSTOM_TYPE::CLIMBABLEROPE>( "ENT_TYPE_ITEM_CLIMBABLE_ROPE", "ENT_TYPE_ITEM_UNROLLED_ROPE"); case CUSTOM_TYPE::CLONEGUNSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::CLONEGUNSHOT>("ENT_TYPE_ITEM_CLONEGUNSHOT"); case CUSTOM_TYPE::COBRA: return make_custom_entity_type_list<CUSTOM_TYPE::COBRA>("ENT_TYPE_MONS_COBRA"); case CUSTOM_TYPE::COFFIN: return make_custom_entity_type_list<CUSTOM_TYPE::COFFIN>( "ENT_TYPE_ITEM_COFFIN", "ENT_TYPE_ITEM_ANUBIS_COFFIN"); case CUSTOM_TYPE::COIN: return make_custom_entity_type_list<CUSTOM_TYPE::COIN>("ENT_TYPE_ITEM_GOLDCOIN"); case CUSTOM_TYPE::CONTAINER: return make_custom_entity_type_list<CUSTOM_TYPE::CONTAINER>( "ENT_TYPE_ITEM_CRATE", "ENT_TYPE_ITEM_DMCRATE", "ENT_TYPE_ITEM_PRESENT", "ENT_TYPE_ITEM_GHIST_PRESENT", "ENT_TYPE_ITEM_ALIVE_EMBEDDED_ON_ICE"); case CUSTOM_TYPE::CONVEYORBELT: return make_custom_entity_type_list<CUSTOM_TYPE::CONVEYORBELT>( "ENT_TYPE_FLOOR_CONVEYORBELT_LEFT", "ENT_TYPE_FLOOR_CONVEYORBELT_RIGHT"); case CUSTOM_TYPE::COOKFIRE: return make_custom_entity_type_list<CUSTOM_TYPE::COOKFIRE>("ENT_TYPE_ITEM_COOKFIRE"); case CUSTOM_TYPE::CRABMAN: return make_custom_entity_type_list<CUSTOM_TYPE::CRABMAN>("ENT_TYPE_MONS_CRABMAN"); case CUSTOM_TYPE::CRITTER: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTER>( "ENT_TYPE_MONS_CRITTERDUNGBEETLE", "ENT_TYPE_MONS_CRITTERBUTTERFLY", "ENT_TYPE_MONS_CRITTERSNAIL", "ENT_TYPE_MONS_CRITTERFISH", "ENT_TYPE_MONS_CRITTERANCHOVY", "ENT_TYPE_MONS_CRITTERCRAB", "ENT_TYPE_MONS_CRITTERLOCUST", "ENT_TYPE_MONS_CRITTERPENGUIN", "ENT_TYPE_MONS_CRITTERFIREFLY", "ENT_TYPE_MONS_CRITTERDRONE", "ENT_TYPE_MONS_CRITTERSLIME"); case CUSTOM_TYPE::CRITTERBEETLE: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERBEETLE>("ENT_TYPE_MONS_CRITTERDUNGBEETLE"); case CUSTOM_TYPE::CRITTERBUTTERFLY: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERBUTTERFLY>("ENT_TYPE_MONS_CRITTERBUTTERFLY"); case CUSTOM_TYPE::CRITTERCRAB: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERCRAB>("ENT_TYPE_MONS_CRITTERCRAB"); case CUSTOM_TYPE::CRITTERDRONE: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERDRONE>("ENT_TYPE_MONS_CRITTERDRONE"); case CUSTOM_TYPE::CRITTERFIREFLY: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERFIREFLY>("ENT_TYPE_MONS_CRITTERFIREFLY"); case CUSTOM_TYPE::CRITTERFISH: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERFISH>("ENT_TYPE_MONS_CRITTERFISH"); case CUSTOM_TYPE::CRITTERLOCUST: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERLOCUST>("ENT_TYPE_MONS_CRITTERLOCUST"); case CUSTOM_TYPE::CRITTERPENGUIN: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERPENGUIN>("ENT_TYPE_MONS_CRITTERPENGUIN"); case CUSTOM_TYPE::CRITTERSLIME: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERSLIME>("ENT_TYPE_MONS_CRITTERSLIME"); case CUSTOM_TYPE::CRITTERSNAIL: return make_custom_entity_type_list<CUSTOM_TYPE::CRITTERSNAIL>("ENT_TYPE_MONS_CRITTERSNAIL"); case CUSTOM_TYPE::CROCMAN: return make_custom_entity_type_list<CUSTOM_TYPE::CROCMAN>("ENT_TYPE_MONS_CROCMAN"); case CUSTOM_TYPE::CROSSBEAM: return make_custom_entity_type_list<CUSTOM_TYPE::CROSSBEAM>("ENT_TYPE_DECORATION_CROSS_BEAM"); case CUSTOM_TYPE::CRUSHTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::CRUSHTRAP>( "ENT_TYPE_ACTIVEFLOOR_CRUSH_TRAP", "ENT_TYPE_ACTIVEFLOOR_CRUSH_TRAP_LARGE"); case CUSTOM_TYPE::CURSEDEFFECT: return make_custom_entity_type_list<CUSTOM_TYPE::CURSEDEFFECT>("ENT_TYPE_LOGICAL_CURSED_EFFECT"); case CUSTOM_TYPE::CURSEDPOT: return make_custom_entity_type_list<CUSTOM_TYPE::CURSEDPOT>("ENT_TYPE_ITEM_CURSEDPOT"); case CUSTOM_TYPE::DECORATEDDOOR: return make_custom_entity_type_list<CUSTOM_TYPE::DECORATEDDOOR>( "ENT_TYPE_FLOOR_DOOR_COG", "ENT_TYPE_FLOOR_DOOR_EGGPLANT_WORLD"); case CUSTOM_TYPE::DECOREGENERATINGBLOCK: return make_custom_entity_type_list<CUSTOM_TYPE::DECOREGENERATINGBLOCK>( "ENT_TYPE_DECORATION_REGENERATING_SMALL_BLOCK", "ENT_TYPE_DECORATION_REGENERATING_BORDER"); case CUSTOM_TYPE::DESTRUCTIBLEBG: return make_custom_entity_type_list<CUSTOM_TYPE::DESTRUCTIBLEBG>("ENT_TYPE_DECORATION_DUAT_DESTRUCTIBLE_BG"); case CUSTOM_TYPE::DMALIENBLAST: return make_custom_entity_type_list<CUSTOM_TYPE::DMALIENBLAST>("ENT_TYPE_LOGICAL_DM_ALIEN_BLAST"); case CUSTOM_TYPE::DMSPAWNING: return make_custom_entity_type_list<CUSTOM_TYPE::DMSPAWNING>( "ENT_TYPE_LOGICAL_DM_CRATE_SPAWNING", "ENT_TYPE_LOGICAL_DM_IDOL_SPAWNING"); case CUSTOM_TYPE::DOOR: return make_custom_entity_type_list<CUSTOM_TYPE::DOOR>( "ENT_TYPE_FLOOR_DOOR_ENTRANCE", "ENT_TYPE_FLOOR_DOOR_EXIT", "ENT_TYPE_FLOOR_DOOR_MAIN_EXIT", "ENT_TYPE_FLOOR_DOOR_STARTING_EXIT", "ENT_TYPE_FLOOR_DOOR_LAYER", "ENT_TYPE_FLOOR_DOOR_LAYER_DROP_HELD", "ENT_TYPE_FLOOR_DOOR_GHISTSHOP", "ENT_TYPE_FLOOR_DOOR_LOCKED", "ENT_TYPE_FLOOR_DOOR_LOCKED_PEN", "ENT_TYPE_FLOOR_DOOR_COG", "ENT_TYPE_FLOOR_DOOR_MOAI_STATUE", "ENT_TYPE_FLOOR_DOOR_EGGSHIP", "ENT_TYPE_FLOOR_DOOR_EGGSHIP_ATREZZO", "ENT_TYPE_FLOOR_DOOR_EGGSHIP_ROOM", "ENT_TYPE_FLOOR_DOOR_EGGPLANT_WORLD"); case CUSTOM_TYPE::DRILL: return make_custom_entity_type_list<CUSTOM_TYPE::DRILL>("ENT_TYPE_ACTIVEFLOOR_DRILL"); case CUSTOM_TYPE::DUSTWALLAPEP: return make_custom_entity_type_list<CUSTOM_TYPE::DUSTWALLAPEP>("ENT_TYPE_LOGICAL_DUSTWALL_APEP"); case CUSTOM_TYPE::EGGPLANTMINISTER: return make_custom_entity_type_list<CUSTOM_TYPE::EGGPLANTMINISTER>("ENT_TYPE_MONS_EGGPLANT_MINISTER"); case CUSTOM_TYPE::EGGPLANTTHROWER: return make_custom_entity_type_list<CUSTOM_TYPE::EGGPLANTTHROWER>("ENT_TYPE_LOGICAL_EGGPLANT_THROWER"); case CUSTOM_TYPE::EGGSAC: return make_custom_entity_type_list<CUSTOM_TYPE::EGGSAC>("ENT_TYPE_ITEM_EGGSAC"); case CUSTOM_TYPE::EGGSHIPCENTERJETFLAME: return make_custom_entity_type_list<CUSTOM_TYPE::EGGSHIPCENTERJETFLAME>("ENT_TYPE_FX_EGGSHIP_CENTERJETFLAME"); case CUSTOM_TYPE::EGGSHIPDOOR: return make_custom_entity_type_list<CUSTOM_TYPE::EGGSHIPDOOR>( "ENT_TYPE_FLOOR_DOOR_EGGSHIP", "ENT_TYPE_FLOOR_DOOR_EGGSHIP_ATREZZO", "ENT_TYPE_FLOOR_DOOR_EGGSHIP_ROOM"); case CUSTOM_TYPE::EGGSHIPDOORS: return make_custom_entity_type_list<CUSTOM_TYPE::EGGSHIPDOORS>("ENT_TYPE_FLOOR_DOOR_EGGSHIP"); case CUSTOM_TYPE::ELEVATOR: return make_custom_entity_type_list<CUSTOM_TYPE::ELEVATOR>("ENT_TYPE_ACTIVEFLOOR_ELEVATOR"); case CUSTOM_TYPE::EMPRESSGRAVE: return make_custom_entity_type_list<CUSTOM_TYPE::EMPRESSGRAVE>("ENT_TYPE_ITEM_EMPRESS_GRAVE"); case CUSTOM_TYPE::ENTITY: return make_custom_entity_type_list<CUSTOM_TYPE::ENTITY>(); case CUSTOM_TYPE::EXCALIBUR: return make_custom_entity_type_list<CUSTOM_TYPE::EXCALIBUR>("ENT_TYPE_ITEM_EXCALIBUR"); case CUSTOM_TYPE::EXITDOOR: return make_custom_entity_type_list<CUSTOM_TYPE::EXITDOOR>( "ENT_TYPE_FLOOR_DOOR_EXIT", "ENT_TYPE_FLOOR_DOOR_MAIN_EXIT", "ENT_TYPE_FLOOR_DOOR_STARTING_EXIT", "ENT_TYPE_FLOOR_DOOR_COG", "ENT_TYPE_FLOOR_DOOR_EGGPLANT_WORLD"); case CUSTOM_TYPE::EXPLOSION: return make_custom_entity_type_list<CUSTOM_TYPE::EXPLOSION>( "ENT_TYPE_FX_EXPLOSION", "ENT_TYPE_FX_POWEREDEXPLOSION", "ENT_TYPE_FX_MODERNEXPLOSION"); case CUSTOM_TYPE::FALLINGPLATFORM: return make_custom_entity_type_list<CUSTOM_TYPE::FALLINGPLATFORM>("ENT_TYPE_ACTIVEFLOOR_FALLING_PLATFORM"); case CUSTOM_TYPE::FIREBALL: return make_custom_entity_type_list<CUSTOM_TYPE::FIREBALL>( "ENT_TYPE_ITEM_FIREBALL", "ENT_TYPE_ITEM_HUNDUN_FIREBALL"); case CUSTOM_TYPE::FIREBUG: return make_custom_entity_type_list<CUSTOM_TYPE::FIREBUG>("ENT_TYPE_MONS_FIREBUG"); case CUSTOM_TYPE::FIREBUGUNCHAINED: return make_custom_entity_type_list<CUSTOM_TYPE::FIREBUGUNCHAINED>("ENT_TYPE_MONS_FIREBUG_UNCHAINED"); case CUSTOM_TYPE::FIREFROG: return make_custom_entity_type_list<CUSTOM_TYPE::FIREFROG>("ENT_TYPE_MONS_FIREFROG"); case CUSTOM_TYPE::FISH: return make_custom_entity_type_list<CUSTOM_TYPE::FISH>("ENT_TYPE_MONS_FISH"); case CUSTOM_TYPE::FLAME: return make_custom_entity_type_list<CUSTOM_TYPE::FLAME>( "ENT_TYPE_ITEM_WHIP_FLAME", "ENT_TYPE_ITEM_SPARK", "ENT_TYPE_ITEM_FLAMETHROWER_FIREBALL", "ENT_TYPE_ITEM_WALLTORCHFLAME", "ENT_TYPE_ITEM_TORCHFLAME", "ENT_TYPE_ITEM_LAMPFLAME", "ENT_TYPE_FX_SMALLFLAME"); case CUSTOM_TYPE::FLAMESIZE: return make_custom_entity_type_list<CUSTOM_TYPE::FLAMESIZE>( "ENT_TYPE_ITEM_WHIP_FLAME", "ENT_TYPE_ITEM_WALLTORCHFLAME"); case CUSTOM_TYPE::FLOOR: { const static std::vector<ENT_TYPE> types = []() { auto idx = to_id("ENT_TYPE_FLOOR_BORDERTILE"); const auto end = to_id("ENT_TYPE_FLOORSTYLED_GUTS") + 1; std::vector<ENT_TYPE> result; result.reserve(end - idx + 2); for (; idx < end; idx++) result.push_back(idx); result.push_back(to_id("ENT_TYPE_EMBED_GOLD")); result.push_back(to_id("ENT_TYPE_EMBED_GOLD_BIG")); return result; }(); return {types.begin(), types.end()}; } case CUSTOM_TYPE::FLY: return make_custom_entity_type_list<CUSTOM_TYPE::FLY>("ENT_TYPE_ITEM_FLY"); case CUSTOM_TYPE::FLYHEAD: return make_custom_entity_type_list<CUSTOM_TYPE::FLYHEAD>("ENT_TYPE_ITEM_GIANTFLY_HEAD"); case CUSTOM_TYPE::FORCEFIELD: return make_custom_entity_type_list<CUSTOM_TYPE::FORCEFIELD>( "ENT_TYPE_FLOOR_FORCEFIELD", "ENT_TYPE_FLOOR_DICE_FORCEFIELD", "ENT_TYPE_FLOOR_CHALLENGE_ENTRANCE", "ENT_TYPE_FLOOR_CHALLENGE_WAITROOM", "ENT_TYPE_FLOOR_TIMED_FORCEFIELD"); case CUSTOM_TYPE::FORESTSISTER: return make_custom_entity_type_list<CUSTOM_TYPE::FORESTSISTER>( "ENT_TYPE_MONS_SISTER_PARSLEY", "ENT_TYPE_MONS_SISTER_PARSNIP", "ENT_TYPE_MONS_SISTER_PARMESAN"); case CUSTOM_TYPE::FROG: return make_custom_entity_type_list<CUSTOM_TYPE::FROG>( "ENT_TYPE_MONS_FROG", "ENT_TYPE_MONS_FIREFROG"); case CUSTOM_TYPE::FROSTBREATHEFFECT: return make_custom_entity_type_list<CUSTOM_TYPE::FROSTBREATHEFFECT>("ENT_TYPE_LOGICAL_FROST_BREATH"); case CUSTOM_TYPE::FROZENLIQUID: return make_custom_entity_type_list<CUSTOM_TYPE::FROZENLIQUID>("ENT_TYPE_ITEM_FROZEN_LIQUID"); case CUSTOM_TYPE::FXALIENBLAST: return make_custom_entity_type_list<CUSTOM_TYPE::FXALIENBLAST>( "ENT_TYPE_FX_ALIENBLAST_RETICULE_INTERNAL", "ENT_TYPE_FX_ALIENBLAST_RETICULE_EXTERNAL", "ENT_TYPE_FX_ALIENBLAST"); case CUSTOM_TYPE::FXANKHBROKENPIECE: return make_custom_entity_type_list<CUSTOM_TYPE::FXANKHBROKENPIECE>("ENT_TYPE_FX_ANKH_BROKENPIECE"); case CUSTOM_TYPE::FXANKHROTATINGSPARK: return make_custom_entity_type_list<CUSTOM_TYPE::FXANKHROTATINGSPARK>("ENT_TYPE_FX_ANKH_ROTATINGSPARK"); case CUSTOM_TYPE::FXCOMPASS: return make_custom_entity_type_list<CUSTOM_TYPE::FXCOMPASS>( "ENT_TYPE_FX_COMPASS", "ENT_TYPE_FX_SPECIALCOMPASS"); case CUSTOM_TYPE::FXEMPRESS: return make_custom_entity_type_list<CUSTOM_TYPE::FXEMPRESS>("ENT_TYPE_FX_EMPRESS"); case CUSTOM_TYPE::FXFIREFLYLIGHT: return make_custom_entity_type_list<CUSTOM_TYPE::FXFIREFLYLIGHT>("ENT_TYPE_FX_CRITTERFIREFLY_LIGHT"); case CUSTOM_TYPE::FXHUNDUNNECKPIECE: return make_custom_entity_type_list<CUSTOM_TYPE::FXHUNDUNNECKPIECE>("ENT_TYPE_FX_HUNDUN_NECK_PIECE"); case CUSTOM_TYPE::FXJELLYFISHSTAR: return make_custom_entity_type_list<CUSTOM_TYPE::FXJELLYFISHSTAR>("ENT_TYPE_FX_MEGAJELLYFISH_STAR"); case CUSTOM_TYPE::FXJETPACKFLAME: return make_custom_entity_type_list<CUSTOM_TYPE::FXJETPACKFLAME>("ENT_TYPE_FX_JETPACKFLAME"); case CUSTOM_TYPE::FXKINGUSLIDING: return make_custom_entity_type_list<CUSTOM_TYPE::FXKINGUSLIDING>("ENT_TYPE_FX_KINGU_SLIDING"); case CUSTOM_TYPE::FXLAMASSUATTACK: return make_custom_entity_type_list<CUSTOM_TYPE::FXLAMASSUATTACK>("ENT_TYPE_FX_LAMASSU_ATTACK"); case CUSTOM_TYPE::FXMAINEXITDOOR: return make_custom_entity_type_list<CUSTOM_TYPE::FXMAINEXITDOOR>("ENT_TYPE_FX_MAIN_EXIT_DOOR"); case CUSTOM_TYPE::FXNECROMANCERANKH: return make_custom_entity_type_list<CUSTOM_TYPE::FXNECROMANCERANKH>("ENT_TYPE_FX_NECROMANCER_ANKH"); case CUSTOM_TYPE::FXOUROBORODRAGONPART: return make_custom_entity_type_list<CUSTOM_TYPE::FXOUROBORODRAGONPART>( "ENT_TYPE_FX_OUROBORO_HEAD", "ENT_TYPE_FX_OUROBORO_TAIL"); case CUSTOM_TYPE::FXOUROBOROOCCLUDER: return make_custom_entity_type_list<CUSTOM_TYPE::FXOUROBOROOCCLUDER>("ENT_TYPE_FX_OUROBORO_OCCLUDER"); case CUSTOM_TYPE::FXPICKUPEFFECT: return make_custom_entity_type_list<CUSTOM_TYPE::FXPICKUPEFFECT>("ENT_TYPE_FX_PICKUPEFFECT"); case CUSTOM_TYPE::FXPLAYERINDICATOR: return make_custom_entity_type_list<CUSTOM_TYPE::FXPLAYERINDICATOR>("ENT_TYPE_FX_PLAYERINDICATOR"); case CUSTOM_TYPE::FXQUICKSAND: return make_custom_entity_type_list<CUSTOM_TYPE::FXQUICKSAND>( "ENT_TYPE_FX_QUICKSAND_DUST", "ENT_TYPE_FX_QUICKSAND_RUBBLE"); case CUSTOM_TYPE::FXSALECONTAINER: return make_custom_entity_type_list<CUSTOM_TYPE::FXSALECONTAINER>("ENT_TYPE_FX_SALEDIALOG_CONTAINER"); case CUSTOM_TYPE::FXSHOTGUNBLAST: return make_custom_entity_type_list<CUSTOM_TYPE::FXSHOTGUNBLAST>("ENT_TYPE_FX_SHOTGUNBLAST"); case CUSTOM_TYPE::FXSORCERESSATTACK: return make_custom_entity_type_list<CUSTOM_TYPE::FXSORCERESSATTACK>("ENT_TYPE_FX_SORCERESS_ATTACK"); case CUSTOM_TYPE::FXSPARKSMALL: return make_custom_entity_type_list<CUSTOM_TYPE::FXSPARKSMALL>("ENT_TYPE_FX_SPARK_SMALL"); case CUSTOM_TYPE::FXSPRINGTRAPRING: return make_custom_entity_type_list<CUSTOM_TYPE::FXSPRINGTRAPRING>("ENT_TYPE_FX_SPRINGTRAP_RING"); case CUSTOM_TYPE::FXTIAMATHEAD: return make_custom_entity_type_list<CUSTOM_TYPE::FXTIAMATHEAD>("ENT_TYPE_FX_TIAMAT_HEAD"); case CUSTOM_TYPE::FXTIAMATTAIL: return make_custom_entity_type_list<CUSTOM_TYPE::FXTIAMATTAIL>( "ENT_TYPE_FX_TIAMAT_TAIL", "ENT_TYPE_FX_TIAMAT_TAIL_DECO1", "ENT_TYPE_FX_TIAMAT_TAIL_DECO2", "ENT_TYPE_FX_TIAMAT_TAIL_DECO3"); case CUSTOM_TYPE::FXTIAMATTORSO: return make_custom_entity_type_list<CUSTOM_TYPE::FXTIAMATTORSO>("ENT_TYPE_FX_TIAMAT_TORSO"); case CUSTOM_TYPE::FXTORNJOURNALPAGE: return make_custom_entity_type_list<CUSTOM_TYPE::FXTORNJOURNALPAGE>("ENT_TYPE_FX_TORNJOURNALPAGE"); case CUSTOM_TYPE::FXUNDERWATERBUBBLE: return make_custom_entity_type_list<CUSTOM_TYPE::FXUNDERWATERBUBBLE>("ENT_TYPE_FX_UNDERWATER_BUBBLE"); case CUSTOM_TYPE::FXVATBUBBLE: return make_custom_entity_type_list<CUSTOM_TYPE::FXVATBUBBLE>("ENT_TYPE_FX_VAT_BUBBLE"); case CUSTOM_TYPE::FXWATERDROP: return make_custom_entity_type_list<CUSTOM_TYPE::FXWATERDROP>("ENT_TYPE_FX_WATER_DROP"); case CUSTOM_TYPE::FXWEBBEDEFFECT: return make_custom_entity_type_list<CUSTOM_TYPE::FXWEBBEDEFFECT>("ENT_TYPE_FX_WEBBEDEFFECT"); case CUSTOM_TYPE::FXWITCHDOCTORHINT: return make_custom_entity_type_list<CUSTOM_TYPE::FXWITCHDOCTORHINT>("ENT_TYPE_FX_WITCHDOCTOR_HINT"); case CUSTOM_TYPE::GENERATOR: return make_custom_entity_type_list<CUSTOM_TYPE::GENERATOR>( "ENT_TYPE_FLOOR_FACTORY_GENERATOR", "ENT_TYPE_FLOOR_SHOPKEEPER_GENERATOR", "ENT_TYPE_FLOOR_SUNCHALLENGE_GENERATOR"); case CUSTOM_TYPE::GHIST: return make_custom_entity_type_list<CUSTOM_TYPE::GHIST>( "ENT_TYPE_MONS_GHIST", "ENT_TYPE_MONS_GHIST_SHOPKEEPER"); case CUSTOM_TYPE::GHOST: return make_custom_entity_type_list<CUSTOM_TYPE::GHOST>( "ENT_TYPE_MONS_GHOST", "ENT_TYPE_MONS_GHOST_MEDIUM_SAD", "ENT_TYPE_MONS_GHOST_MEDIUM_HAPPY", "ENT_TYPE_MONS_GHOST_SMALL_ANGRY", "ENT_TYPE_MONS_GHOST_SMALL_SAD", "ENT_TYPE_MONS_GHOST_SMALL_SURPRISED", "ENT_TYPE_MONS_GHOST_SMALL_HAPPY"); case CUSTOM_TYPE::GHOSTBREATH: return make_custom_entity_type_list<CUSTOM_TYPE::GHOSTBREATH>("ENT_TYPE_ITEM_PLAYERGHOST_BREATH"); case CUSTOM_TYPE::GIANTCLAMTOP: return make_custom_entity_type_list<CUSTOM_TYPE::GIANTCLAMTOP>("ENT_TYPE_ITEM_GIANTCLAM_TOP"); case CUSTOM_TYPE::GIANTFISH: return make_custom_entity_type_list<CUSTOM_TYPE::GIANTFISH>("ENT_TYPE_MONS_GIANTFISH"); case CUSTOM_TYPE::GIANTFLY: return make_custom_entity_type_list<CUSTOM_TYPE::GIANTFLY>("ENT_TYPE_MONS_GIANTFLY"); case CUSTOM_TYPE::GIANTFROG: return make_custom_entity_type_list<CUSTOM_TYPE::GIANTFROG>("ENT_TYPE_MONS_GIANTFROG"); case CUSTOM_TYPE::GOLDBAR: return make_custom_entity_type_list<CUSTOM_TYPE::GOLDBAR>( "ENT_TYPE_ITEM_GOLDBAR", "ENT_TYPE_ITEM_GOLDBARS"); case CUSTOM_TYPE::GOLDMONKEY: return make_custom_entity_type_list<CUSTOM_TYPE::GOLDMONKEY>("ENT_TYPE_MONS_GOLDMONKEY"); case CUSTOM_TYPE::GRUB: return make_custom_entity_type_list<CUSTOM_TYPE::GRUB>("ENT_TYPE_MONS_GRUB"); case CUSTOM_TYPE::GUN: return make_custom_entity_type_list<CUSTOM_TYPE::GUN>( "ENT_TYPE_ITEM_WEBGUN", "ENT_TYPE_ITEM_SHOTGUN", "ENT_TYPE_ITEM_FREEZERAY", "ENT_TYPE_ITEM_CAMERA", "ENT_TYPE_ITEM_PLASMACANNON", "ENT_TYPE_ITEM_SCEPTER", "ENT_TYPE_ITEM_CLONEGUN"); case CUSTOM_TYPE::HANGANCHOR: return make_custom_entity_type_list<CUSTOM_TYPE::HANGANCHOR>("ENT_TYPE_ITEM_HANGANCHOR"); case CUSTOM_TYPE::HANGSPIDER: return make_custom_entity_type_list<CUSTOM_TYPE::HANGSPIDER>("ENT_TYPE_MONS_HANGSPIDER"); case CUSTOM_TYPE::HANGSTRAND: return make_custom_entity_type_list<CUSTOM_TYPE::HANGSTRAND>("ENT_TYPE_ITEM_HANGSTRAND"); case CUSTOM_TYPE::HERMITCRAB: return make_custom_entity_type_list<CUSTOM_TYPE::HERMITCRAB>("ENT_TYPE_MONS_HERMITCRAB"); case CUSTOM_TYPE::HONEY: return make_custom_entity_type_list<CUSTOM_TYPE::HONEY>("ENT_TYPE_ITEM_HONEY"); case CUSTOM_TYPE::HORIZONTALFORCEFIELD: return make_custom_entity_type_list<CUSTOM_TYPE::HORIZONTALFORCEFIELD>("ENT_TYPE_FLOOR_HORIZONTAL_FORCEFIELD"); case CUSTOM_TYPE::HORNEDLIZARD: return make_custom_entity_type_list<CUSTOM_TYPE::HORNEDLIZARD>("ENT_TYPE_MONS_HORNEDLIZARD"); case CUSTOM_TYPE::HOVERPACK: return make_custom_entity_type_list<CUSTOM_TYPE::HOVERPACK>("ENT_TYPE_ITEM_HOVERPACK"); case CUSTOM_TYPE::HUNDUN: return make_custom_entity_type_list<CUSTOM_TYPE::HUNDUN>("ENT_TYPE_MONS_HUNDUN"); case CUSTOM_TYPE::HUNDUNCHEST: return make_custom_entity_type_list<CUSTOM_TYPE::HUNDUNCHEST>("ENT_TYPE_ITEM_ENDINGTREASURE_HUNDUN"); case CUSTOM_TYPE::HUNDUNHEAD: return make_custom_entity_type_list<CUSTOM_TYPE::HUNDUNHEAD>( "ENT_TYPE_MONS_HUNDUN_BIRDHEAD", "ENT_TYPE_MONS_HUNDUN_SNAKEHEAD"); case CUSTOM_TYPE::ICESLIDINGSOUND: return make_custom_entity_type_list<CUSTOM_TYPE::ICESLIDINGSOUND>("ENT_TYPE_LOGICAL_ICESLIDING_SOUND_SOURCE"); case CUSTOM_TYPE::IDOL: return make_custom_entity_type_list<CUSTOM_TYPE::IDOL>( "ENT_TYPE_ITEM_IDOL", "ENT_TYPE_ITEM_MADAMETUSK_IDOL"); case CUSTOM_TYPE::IMP: return make_custom_entity_type_list<CUSTOM_TYPE::IMP>("ENT_TYPE_MONS_IMP"); case CUSTOM_TYPE::JETPACK: return make_custom_entity_type_list<CUSTOM_TYPE::JETPACK>( "ENT_TYPE_ITEM_JETPACK", "ENT_TYPE_ITEM_JETPACK_MECH"); case CUSTOM_TYPE::JIANGSHI: return make_custom_entity_type_list<CUSTOM_TYPE::JIANGSHI>( "ENT_TYPE_MONS_JIANGSHI", "ENT_TYPE_MONS_FEMALE_JIANGSHI"); case CUSTOM_TYPE::JUMPDOG: return make_custom_entity_type_list<CUSTOM_TYPE::JUMPDOG>("ENT_TYPE_MONS_JUMPDOG"); case CUSTOM_TYPE::JUNGLESPEARCOSMETIC: return make_custom_entity_type_list<CUSTOM_TYPE::JUNGLESPEARCOSMETIC>("ENT_TYPE_ITEM_JUNGLE_SPEAR_COSMETIC"); case CUSTOM_TYPE::JUNGLETRAPTRIGGER: return make_custom_entity_type_list<CUSTOM_TYPE::JUNGLETRAPTRIGGER>("ENT_TYPE_LOGICAL_JUNGLESPEAR_TRAP_TRIGGER"); case CUSTOM_TYPE::KAPALAPOWERUP: return make_custom_entity_type_list<CUSTOM_TYPE::KAPALAPOWERUP>("ENT_TYPE_ITEM_POWERUP_KAPALA"); case CUSTOM_TYPE::KINGU: return make_custom_entity_type_list<CUSTOM_TYPE::KINGU>("ENT_TYPE_MONS_KINGU"); case CUSTOM_TYPE::LAHAMU: return make_custom_entity_type_list<CUSTOM_TYPE::LAHAMU>("ENT_TYPE_MONS_ALIENQUEEN"); case CUSTOM_TYPE::LAMASSU: return make_custom_entity_type_list<CUSTOM_TYPE::LAMASSU>("ENT_TYPE_MONS_LAMASSU"); case CUSTOM_TYPE::LAMPFLAME: return make_custom_entity_type_list<CUSTOM_TYPE::LAMPFLAME>("ENT_TYPE_ITEM_LAMPFLAME"); case CUSTOM_TYPE::LANDMINE: return make_custom_entity_type_list<CUSTOM_TYPE::LANDMINE>("ENT_TYPE_ITEM_LANDMINE"); case CUSTOM_TYPE::LASERBEAM: return make_custom_entity_type_list<CUSTOM_TYPE::LASERBEAM>( "ENT_TYPE_ITEM_LASERBEAM", "ENT_TYPE_ITEM_HORIZONTALLASERBEAM"); case CUSTOM_TYPE::LASERTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::LASERTRAP>("ENT_TYPE_FLOOR_LASER_TRAP"); case CUSTOM_TYPE::LAVA: return make_custom_entity_type_list<CUSTOM_TYPE::LAVA>( "ENT_TYPE_LIQUID_LAVA", "ENT_TYPE_LIQUID_STAGNANT_LAVA", "ENT_TYPE_LIQUID_COARSE_LAVA"); case CUSTOM_TYPE::LAVAMANDER: return make_custom_entity_type_list<CUSTOM_TYPE::LAVAMANDER>("ENT_TYPE_MONS_LAVAMANDER"); case CUSTOM_TYPE::LEAF: return make_custom_entity_type_list<CUSTOM_TYPE::LEAF>("ENT_TYPE_ITEM_LEAF"); case CUSTOM_TYPE::LEPRECHAUN: return make_custom_entity_type_list<CUSTOM_TYPE::LEPRECHAUN>("ENT_TYPE_MONS_LEPRECHAUN"); case CUSTOM_TYPE::LIGHTARROW: return make_custom_entity_type_list<CUSTOM_TYPE::LIGHTARROW>("ENT_TYPE_ITEM_LIGHT_ARROW"); case CUSTOM_TYPE::LIGHTARROWPLATFORM: return make_custom_entity_type_list<CUSTOM_TYPE::LIGHTARROWPLATFORM>("ENT_TYPE_ACTIVEFLOOR_LIGHTARROWPLATFORM"); case CUSTOM_TYPE::LIGHTEMITTER: return make_custom_entity_type_list<CUSTOM_TYPE::LIGHTEMITTER>( "ENT_TYPE_ITEM_SCEPTER_ANUBISSHOT", "ENT_TYPE_ITEM_SCEPTER_ANUBISSPECIALSHOT", "ENT_TYPE_ITEM_SCEPTER_PLAYERSHOT", "ENT_TYPE_ITEM_TIAMAT_SHOT", "ENT_TYPE_ITEM_REDLANTERNFLAME", "ENT_TYPE_ITEM_LANDMINE", "ENT_TYPE_ITEM_PLAYERGHOST", "ENT_TYPE_ITEM_PALACE_CANDLE_FLAME", "ENT_TYPE_ITEM_LAVAPOT", "ENT_TYPE_FX_TELEPORTSHADOW"); case CUSTOM_TYPE::LIGHTSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::LIGHTSHOT>( "ENT_TYPE_ITEM_PLASMACANNON_SHOT", "ENT_TYPE_ITEM_UFO_LASER_SHOT", "ENT_TYPE_ITEM_LAMASSU_LASER_SHOT", "ENT_TYPE_ITEM_SORCERESS_DAGGER_SHOT", "ENT_TYPE_ITEM_LASERTRAP_SHOT", "ENT_TYPE_ITEM_FIREBALL", "ENT_TYPE_ITEM_HUNDUN_FIREBALL", "ENT_TYPE_ITEM_FREEZERAYSHOT", "ENT_TYPE_ITEM_CLONEGUNSHOT"); case CUSTOM_TYPE::LIMBANCHOR: return make_custom_entity_type_list<CUSTOM_TYPE::LIMBANCHOR>("ENT_TYPE_LOGICAL_LIMB_ANCHOR"); case CUSTOM_TYPE::LIQUID: return make_custom_entity_type_list<CUSTOM_TYPE::LIQUID>( "ENT_TYPE_LIQUID_WATER", "ENT_TYPE_LIQUID_COARSE_WATER", "ENT_TYPE_LIQUID_LAVA", "ENT_TYPE_LIQUID_STAGNANT_LAVA", "ENT_TYPE_LIQUID_COARSE_LAVA"); case CUSTOM_TYPE::LIQUIDSURFACE: return make_custom_entity_type_list<CUSTOM_TYPE::LIQUIDSURFACE>( "ENT_TYPE_FX_LAVA_GLOW", "ENT_TYPE_FX_WATER_SURFACE"); case CUSTOM_TYPE::LOCKEDDOOR: return make_custom_entity_type_list<CUSTOM_TYPE::LOCKEDDOOR>( "ENT_TYPE_FLOOR_DOOR_LOCKED", "ENT_TYPE_FLOOR_DOOR_LOCKED_PEN"); case CUSTOM_TYPE::LOGICALANCHOVYFLOCK: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALANCHOVYFLOCK>("ENT_TYPE_LOGICAL_ANCHOVY_FLOCK"); case CUSTOM_TYPE::LOGICALCONVEYORBELTSOUND: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALCONVEYORBELTSOUND>("ENT_TYPE_LOGICAL_CONVEYORBELT_SOUND_SOURCE"); case CUSTOM_TYPE::LOGICALDOOR: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALDOOR>( "ENT_TYPE_LOGICAL_DOOR", "ENT_TYPE_LOGICAL_BLACKMARKET_DOOR"); case CUSTOM_TYPE::LOGICALDRAIN: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALDRAIN>( "ENT_TYPE_LOGICAL_WATER_DRAIN", "ENT_TYPE_LOGICAL_LAVA_DRAIN"); case CUSTOM_TYPE::LOGICALLIQUIDSTREAMSOUND: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALLIQUIDSTREAMSOUND>( "ENT_TYPE_LOGICAL_STREAMLAVA_SOUND_SOURCE", "ENT_TYPE_LOGICAL_STREAMWATER_SOUND_SOURCE"); case CUSTOM_TYPE::LOGICALMINIGAME: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALMINIGAME>("ENT_TYPE_LOGICAL_MINIGAME"); case CUSTOM_TYPE::LOGICALREGENERATINGBLOCK: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALREGENERATINGBLOCK>("ENT_TYPE_LOGICAL_REGENERATING_BLOCK"); case CUSTOM_TYPE::LOGICALSOUND: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALSOUND>( "ENT_TYPE_LOGICAL_DOOR_AMBIENT_SOUND", "ENT_TYPE_LOGICAL_STATICLAVA_SOUND_SOURCE", "ENT_TYPE_LOGICAL_STREAMLAVA_SOUND_SOURCE", "ENT_TYPE_LOGICAL_STREAMWATER_SOUND_SOURCE", "ENT_TYPE_LOGICAL_CONVEYORBELT_SOUND_SOURCE", "ENT_TYPE_LOGICAL_MUMMYFLIES_SOUND_SOURCE", "ENT_TYPE_LOGICAL_QUICKSAND_AMBIENT_SOUND_SOURCE", "ENT_TYPE_LOGICAL_QUICKSAND_SOUND_SOURCE", "ENT_TYPE_LOGICAL_DUSTWALL_SOUND_SOURCE", "ENT_TYPE_LOGICAL_ICESLIDING_SOUND_SOURCE", "ENT_TYPE_LOGICAL_PIPE_TRAVELER_SOUND_SOURCE"); case CUSTOM_TYPE::LOGICALSTATICSOUND: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALSTATICSOUND>( "ENT_TYPE_LOGICAL_STATICLAVA_SOUND_SOURCE", "ENT_TYPE_LOGICAL_STREAMLAVA_SOUND_SOURCE", "ENT_TYPE_LOGICAL_STREAMWATER_SOUND_SOURCE", "ENT_TYPE_LOGICAL_QUICKSAND_AMBIENT_SOUND_SOURCE"); case CUSTOM_TYPE::LOGICALTRAPTRIGGER: return make_custom_entity_type_list<CUSTOM_TYPE::LOGICALTRAPTRIGGER>( "ENT_TYPE_LOGICAL_ARROW_TRAP_TRIGGER", "ENT_TYPE_LOGICAL_TOTEM_TRAP_TRIGGER", "ENT_TYPE_LOGICAL_JUNGLESPEAR_TRAP_TRIGGER", "ENT_TYPE_LOGICAL_SPIKEBALL_TRIGGER", "ENT_TYPE_LOGICAL_TENTACLE_TRIGGER", "ENT_TYPE_LOGICAL_BIGSPEAR_TRAP_TRIGGER"); case CUSTOM_TYPE::MAGMAMAN: return make_custom_entity_type_list<CUSTOM_TYPE::MAGMAMAN>("ENT_TYPE_MONS_MAGMAMAN"); case CUSTOM_TYPE::MAINEXIT: return make_custom_entity_type_list<CUSTOM_TYPE::MAINEXIT>("ENT_TYPE_FLOOR_DOOR_MAIN_EXIT"); case CUSTOM_TYPE::MANTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::MANTRAP>("ENT_TYPE_MONS_MANTRAP"); case CUSTOM_TYPE::MATTOCK: return make_custom_entity_type_list<CUSTOM_TYPE::MATTOCK>("ENT_TYPE_ITEM_MATTOCK"); case CUSTOM_TYPE::MECH: return make_custom_entity_type_list<CUSTOM_TYPE::MECH>("ENT_TYPE_MOUNT_MECH"); case CUSTOM_TYPE::MEGAJELLYFISH: return make_custom_entity_type_list<CUSTOM_TYPE::MEGAJELLYFISH>( "ENT_TYPE_MONS_MEGAJELLYFISH", "ENT_TYPE_MONS_MEGAJELLYFISH_BACKGROUND"); case CUSTOM_TYPE::MINIGAMEASTEROID: return make_custom_entity_type_list<CUSTOM_TYPE::MINIGAMEASTEROID>( "ENT_TYPE_ITEM_MINIGAME_ASTEROID_BG", "ENT_TYPE_ITEM_MINIGAME_ASTEROID", "ENT_TYPE_ITEM_MINIGAME_BROKEN_ASTEROID"); case CUSTOM_TYPE::MINIGAMESHIP: return make_custom_entity_type_list<CUSTOM_TYPE::MINIGAMESHIP>("ENT_TYPE_ITEM_MINIGAME_SHIP"); case CUSTOM_TYPE::MINIGAMESHIPOFFSET: return make_custom_entity_type_list<CUSTOM_TYPE::MINIGAMESHIPOFFSET>( "ENT_TYPE_FX_MINIGAME_SHIP_DOOR", "ENT_TYPE_FX_MINIGAME_SHIP_CENTERJETFLAME", "ENT_TYPE_FX_MINIGAME_SHIP_JETFLAME"); case CUSTOM_TYPE::MOLE: return make_custom_entity_type_list<CUSTOM_TYPE::MOLE>("ENT_TYPE_MONS_MOLE"); case CUSTOM_TYPE::MONKEY: return make_custom_entity_type_list<CUSTOM_TYPE::MONKEY>("ENT_TYPE_MONS_MONKEY"); case CUSTOM_TYPE::MONSTER: { const static std::vector<ENT_TYPE> types = []() { auto idx = to_id("ENT_TYPE_MONS_PET_TUTORIAL"); const auto end = to_id("ENT_TYPE_MONS_GHOST_SMALL_HAPPY") + 1; std::vector<ENT_TYPE> result; result.reserve(end - idx + 14); for (; idx < end; idx++) { if (idx == to_id("ENT_TYPE_MONS_GHIST_SHOPKEEPER") + 1) // skip no id continue; result.push_back(idx); } result.insert(result.end(), { to_id("ENT_TYPE_MONS_PET_DOG"), to_id("ENT_TYPE_MONS_PET_CAT"), to_id("ENT_TYPE_MONS_PET_HAMSTER"), to_id("ENT_TYPE_MONS_CRITTERDUNGBEETLE"), to_id("ENT_TYPE_MONS_CRITTERBUTTERFLY"), to_id("ENT_TYPE_MONS_CRITTERSNAIL"), to_id("ENT_TYPE_MONS_CRITTERFISH"), to_id("ENT_TYPE_MONS_CRITTERANCHOVY"), to_id("ENT_TYPE_MONS_CRITTERCRAB"), to_id("ENT_TYPE_MONS_CRITTERLOCUST"), to_id("ENT_TYPE_MONS_CRITTERPENGUIN"), to_id("ENT_TYPE_MONS_CRITTERFIREFLY"), to_id("ENT_TYPE_MONS_CRITTERDRONE"), to_id("ENT_TYPE_MONS_CRITTERSLIME"), }); return result; }(); return {types.begin(), types.end()}; } case CUSTOM_TYPE::MOSQUITO: return make_custom_entity_type_list<CUSTOM_TYPE::MOSQUITO>("ENT_TYPE_MONS_MOSQUITO"); case CUSTOM_TYPE::MOTHERSTATUE: return make_custom_entity_type_list<CUSTOM_TYPE::MOTHERSTATUE>("ENT_TYPE_FLOOR_MOTHER_STATUE"); case CUSTOM_TYPE::MOUNT: return make_custom_entity_type_list<CUSTOM_TYPE::MOUNT>( "ENT_TYPE_MOUNT_TURKEY", "ENT_TYPE_MOUNT_ROCKDOG", "ENT_TYPE_MOUNT_AXOLOTL", "ENT_TYPE_MOUNT_MECH", "ENT_TYPE_MOUNT_QILIN", "ENT_TYPE_MOUNT_BASECAMP_CHAIR", "ENT_TYPE_MOUNT_BASECAMP_COUCH"); case CUSTOM_TYPE::MOVABLE: { const static std::vector<ENT_TYPE> types = []() { auto idx = to_id("ENT_TYPE_CHAR_ANA_SPELUNKY"); const auto end = to_id("ENT_TYPE_FX_ANKH_BROKENPIECE") + 1; const std::array gaps = { to_id("ENT_TYPE_CHAR_HIREDHAND") - 1, to_id("ENT_TYPE_MONS_PET_TUTORIAL") - 1, to_id("ENT_TYPE_MONS_PET_TUTORIAL") - 2, to_id("ENT_TYPE_MONS_GHOST") - 1, to_id("ENT_TYPE_MONS_PET_DOG") - 1, to_id("ENT_TYPE_MONS_PET_DOG") - 2, to_id("ENT_TYPE_MONS_CRITTERDUNGBEETLE") - 1, to_id("ENT_TYPE_MONS_CRITTERDUNGBEETLE") - 2, to_id("ENT_TYPE_ITEM_WHIP") - 1, to_id("ENT_TYPE_ITEM_WHIP") - 2, to_id("ENT_TYPE_ITEM_WHIP") - 3, to_id("ENT_TYPE_ITEM_POT") - 1, to_id("ENT_TYPE_ITEM_GOLDBAR") - 1, to_id("ENT_TYPE_ITEM_GOLDBAR") - 2, to_id("ENT_TYPE_ITEM_PICKUP_TORNJOURNALPAGE") - 1, to_id("ENT_TYPE_ITEM_PICKUP_TORNJOURNALPAGE") - 2, to_id("ENT_TYPE_ITEM_PICKUP_SPECTACLES") - 1, to_id("ENT_TYPE_ITEM_PICKUP_PLAYERBAG") - 1, to_id("ENT_TYPE_ITEM_POWERUP_PASTE") - 1, to_id("ENT_TYPE_ITEM_CAPE") - 1, to_id("ENT_TYPE_ACTIVEFLOOR_EGGSHIPPLATFORM") - 1, to_id("ENT_TYPE_ACTIVEFLOOR_EGGSHIPPLATFORM") - 2, to_id("ENT_TYPE_ACTIVEFLOOR_EGGSHIPPLATFORM") - 3, to_id("ENT_TYPE_FX_EGGSHIP_SHELL") - 1, to_id("ENT_TYPE_FX_EGGSHIP_SHELL") - 2, to_id("ENT_TYPE_FX_ANKH_ROTATINGSPARK") - 1, }; std::vector<ENT_TYPE> result; result.reserve(550); // more or less for (; idx < end; idx++) { if (std::find(gaps.begin(), gaps.end(), idx) != gaps.end()) continue; result.push_back(idx); } return result; }(); return {types.begin(), types.end()}; } case CUSTOM_TYPE::MOVINGICON: return make_custom_entity_type_list<CUSTOM_TYPE::MOVINGICON>( "ENT_TYPE_FX_SALEICON", "ENT_TYPE_FX_DIEINDICATOR", "ENT_TYPE_FX_STORAGE_INDICATOR"); case CUSTOM_TYPE::MUMMY: return make_custom_entity_type_list<CUSTOM_TYPE::MUMMY>("ENT_TYPE_MONS_MUMMY"); case CUSTOM_TYPE::MUMMYFLIESSOUND: return make_custom_entity_type_list<CUSTOM_TYPE::MUMMYFLIESSOUND>("ENT_TYPE_LOGICAL_MUMMYFLIES_SOUND_SOURCE"); case CUSTOM_TYPE::NECROMANCER: return make_custom_entity_type_list<CUSTOM_TYPE::NECROMANCER>("ENT_TYPE_MONS_NECROMANCER"); case CUSTOM_TYPE::NPC: return make_custom_entity_type_list<CUSTOM_TYPE::NPC>( "ENT_TYPE_MONS_SHOPKEEPERCLONE", "ENT_TYPE_MONS_SISTER_PARSLEY", "ENT_TYPE_MONS_SISTER_PARSNIP", "ENT_TYPE_MONS_SISTER_PARMESAN", "ENT_TYPE_MONS_OLD_HUNTER", "ENT_TYPE_MONS_THIEF", "ENT_TYPE_MONS_BODYGUARD", "ENT_TYPE_MONS_HUNDUNS_SERVANT"); case CUSTOM_TYPE::OCTOPUS: return make_custom_entity_type_list<CUSTOM_TYPE::OCTOPUS>("ENT_TYPE_MONS_OCTOPUS"); case CUSTOM_TYPE::OLMEC: return make_custom_entity_type_list<CUSTOM_TYPE::OLMEC>("ENT_TYPE_ACTIVEFLOOR_OLMEC"); case CUSTOM_TYPE::OLMECCANNON: return make_custom_entity_type_list<CUSTOM_TYPE::OLMECCANNON>( "ENT_TYPE_ITEM_OLMECCANNON_BOMBS", "ENT_TYPE_ITEM_OLMECCANNON_UFO"); case CUSTOM_TYPE::OLMECFLOATER: return make_custom_entity_type_list<CUSTOM_TYPE::OLMECFLOATER>("ENT_TYPE_FX_OLMECPART_FLOATER"); case CUSTOM_TYPE::OLMITE: return make_custom_entity_type_list<CUSTOM_TYPE::OLMITE>( "ENT_TYPE_MONS_OLMITE_HELMET", "ENT_TYPE_MONS_OLMITE_BODYARMORED", "ENT_TYPE_MONS_OLMITE_NAKED"); case CUSTOM_TYPE::ONFIREEFFECT: return make_custom_entity_type_list<CUSTOM_TYPE::ONFIREEFFECT>("ENT_TYPE_LOGICAL_ONFIRE_EFFECT"); case CUSTOM_TYPE::ORB: return make_custom_entity_type_list<CUSTOM_TYPE::ORB>("ENT_TYPE_ITEM_FLOATING_ORB"); case CUSTOM_TYPE::OSIRISHAND: return make_custom_entity_type_list<CUSTOM_TYPE::OSIRISHAND>("ENT_TYPE_MONS_OSIRIS_HAND"); case CUSTOM_TYPE::OSIRISHEAD: return make_custom_entity_type_list<CUSTOM_TYPE::OSIRISHEAD>("ENT_TYPE_MONS_OSIRIS_HEAD"); case CUSTOM_TYPE::OUROBOROCAMERAANCHOR: return make_custom_entity_type_list<CUSTOM_TYPE::OUROBOROCAMERAANCHOR>("ENT_TYPE_LOGICAL_OUROBORO_CAMERA_ANCHOR"); case CUSTOM_TYPE::OUROBOROCAMERAZOOMIN: return make_custom_entity_type_list<CUSTOM_TYPE::OUROBOROCAMERAZOOMIN>("ENT_TYPE_LOGICAL_OUROBORO_CAMERA_ANCHOR_ZOOMIN"); case CUSTOM_TYPE::PALACESIGN: return make_custom_entity_type_list<CUSTOM_TYPE::PALACESIGN>("ENT_TYPE_DECORATION_PALACE_SIGN"); case CUSTOM_TYPE::PARACHUTEPOWERUP: return make_custom_entity_type_list<CUSTOM_TYPE::PARACHUTEPOWERUP>("ENT_TYPE_ITEM_POWERUP_PARACHUTE"); case CUSTOM_TYPE::PET: return make_custom_entity_type_list<CUSTOM_TYPE::PET>( "ENT_TYPE_MONS_PET_TUTORIAL", "ENT_TYPE_MONS_PET_DOG", "ENT_TYPE_MONS_PET_CAT", "ENT_TYPE_MONS_PET_HAMSTER"); case CUSTOM_TYPE::PIPE: return make_custom_entity_type_list<CUSTOM_TYPE::PIPE>("ENT_TYPE_FLOOR_PIPE"); case CUSTOM_TYPE::PIPETRAVELERSOUND: return make_custom_entity_type_list<CUSTOM_TYPE::PIPETRAVELERSOUND>("ENT_TYPE_LOGICAL_PIPE_TRAVELER_SOUND_SOURCE"); case CUSTOM_TYPE::PLAYER: { const static std::vector<ENT_TYPE> types = []() { auto idx = to_id("ENT_TYPE_CHAR_ANA_SPELUNKY"); const auto end = to_id("ENT_TYPE_CHAR_EGGPLANT_CHILD") + 1; const auto gap = to_id("ENT_TYPE_CHAR_HIREDHAND") - 1; std::vector<ENT_TYPE> result; result.reserve(end - idx); for (; idx < end; idx++) { if (idx == gap) continue; result.push_back(idx); } return result; }(); return {types.begin(), types.end()}; } case CUSTOM_TYPE::PLAYERBAG: return make_custom_entity_type_list<CUSTOM_TYPE::PLAYERBAG>("ENT_TYPE_ITEM_PICKUP_PLAYERBAG"); case CUSTOM_TYPE::PLAYERGHOST: return make_custom_entity_type_list<CUSTOM_TYPE::PLAYERGHOST>("ENT_TYPE_ITEM_PLAYERGHOST"); case CUSTOM_TYPE::POISONEDEFFECT: return make_custom_entity_type_list<CUSTOM_TYPE::POISONEDEFFECT>("ENT_TYPE_LOGICAL_POISONED_EFFECT"); case CUSTOM_TYPE::POLEDECO: return make_custom_entity_type_list<CUSTOM_TYPE::POLEDECO>( "ENT_TYPE_FLOORSTYLED_MINEWOOD", "ENT_TYPE_FLOORSTYLED_PAGODA"); case CUSTOM_TYPE::PORTAL: return make_custom_entity_type_list<CUSTOM_TYPE::PORTAL>("ENT_TYPE_LOGICAL_PORTAL"); case CUSTOM_TYPE::POT: return make_custom_entity_type_list<CUSTOM_TYPE::POT>("ENT_TYPE_ITEM_POT"); case CUSTOM_TYPE::POWERUP: { const static std::vector<ENT_TYPE> types = []() { auto idx = to_id("ENT_TYPE_ITEM_POWERUP_PASTE"); const auto end = to_id("ENT_TYPE_ITEM_POWERUP_SKELETON_KEY") + 1; std::vector<ENT_TYPE> result; result.reserve(end - idx); for (; idx < end; idx++) result.push_back(idx); return result; }(); return {types.begin(), types.end()}; } case CUSTOM_TYPE::POWERUPCAPABLE: { const static std::vector<ENT_TYPE> types = []() { std::vector<ENT_TYPE> result; auto idx = to_id("ENT_TYPE_CHAR_ANA_SPELUNKY"); const auto end = to_id("ENT_TYPE_MONS_CRITTERSLIME") + 1; const std::array missing_ids = { to_id("ENT_TYPE_CHAR_HIREDHAND") - 1, to_id("ENT_TYPE_MONS_PET_TUTORIAL") - 1, to_id("ENT_TYPE_MONS_PET_TUTORIAL") - 2, to_id("ENT_TYPE_MONS_GHOST") - 1, to_id("ENT_TYPE_MONS_PET_DOG") - 1, to_id("ENT_TYPE_MONS_PET_DOG") - 2, to_id("ENT_TYPE_MONS_CRITTERDUNGBEETLE") - 1, to_id("ENT_TYPE_MONS_CRITTERDUNGBEETLE") - 2, }; result.reserve(end - idx); for (; idx < end; idx++) { if (std::find(missing_ids.begin(), missing_ids.end(), idx) != missing_ids.end()) continue; result.push_back(idx); } return result; }(); return {types.begin(), types.end()}; } case CUSTOM_TYPE::PROTOSHOPKEEPER: return make_custom_entity_type_list<CUSTOM_TYPE::PROTOSHOPKEEPER>("ENT_TYPE_MONS_PROTOSHOPKEEPER"); case CUSTOM_TYPE::PUNISHBALL: return make_custom_entity_type_list<CUSTOM_TYPE::PUNISHBALL>("ENT_TYPE_ITEM_PUNISHBALL"); case CUSTOM_TYPE::PUSHBLOCK: return make_custom_entity_type_list<CUSTOM_TYPE::PUSHBLOCK>( "ENT_TYPE_ACTIVEFLOOR_PUSHBLOCK", "ENT_TYPE_ACTIVEFLOOR_POWDERKEG", "ENT_TYPE_ACTIVEFLOOR_CHAINEDPUSHBLOCK", "ENT_TYPE_ACTIVEFLOOR_TIMEDPOWDERKEG"); case CUSTOM_TYPE::QILIN: return make_custom_entity_type_list<CUSTOM_TYPE::QILIN>("ENT_TYPE_MOUNT_QILIN"); case CUSTOM_TYPE::QUICKSAND: return make_custom_entity_type_list<CUSTOM_TYPE::QUICKSAND>("ENT_TYPE_FLOOR_QUICKSAND"); case CUSTOM_TYPE::QUICKSANDSOUND: return make_custom_entity_type_list<CUSTOM_TYPE::QUICKSANDSOUND>("ENT_TYPE_LOGICAL_QUICKSAND_SOUND_SOURCE"); case CUSTOM_TYPE::QUILLBACK: return make_custom_entity_type_list<CUSTOM_TYPE::QUILLBACK>("ENT_TYPE_MONS_CAVEMAN_BOSS"); case CUSTOM_TYPE::REGENBLOCK: return make_custom_entity_type_list<CUSTOM_TYPE::REGENBLOCK>("ENT_TYPE_ACTIVEFLOOR_REGENERATINGBLOCK"); case CUSTOM_TYPE::ROBOT: return make_custom_entity_type_list<CUSTOM_TYPE::ROBOT>("ENT_TYPE_MONS_ROBOT"); case CUSTOM_TYPE::ROCKDOG: return make_custom_entity_type_list<CUSTOM_TYPE::ROCKDOG>("ENT_TYPE_MOUNT_ROCKDOG"); case CUSTOM_TYPE::ROLLINGITEM: { const static std::vector<ENT_TYPE> types = []() { auto idx = to_id("ENT_TYPE_ITEM_PICKUP_TORNJOURNALPAGE"); const auto end = to_id("ENT_TYPE_ITEM_PICKUP_SKELETON_KEY") + 1; const auto gap = to_id("ENT_TYPE_ITEM_PICKUP_SPECTACLES") - 1; std::vector<ENT_TYPE> result; result.reserve(end - idx); for (; idx < end; idx++) { if (idx == gap) continue; result.push_back(idx); } return result; }(); return {types.begin(), types.end()}; } case CUSTOM_TYPE::ROOMLIGHT: return make_custom_entity_type_list<CUSTOM_TYPE::ROOMLIGHT>("ENT_TYPE_LOGICAL_ROOM_LIGHT"); case CUSTOM_TYPE::ROOMOWNER: return make_custom_entity_type_list<CUSTOM_TYPE::ROOMOWNER>( "ENT_TYPE_MONS_SHOPKEEPER", "ENT_TYPE_MONS_MERCHANT", "ENT_TYPE_MONS_YANG", "ENT_TYPE_MONS_MADAMETUSK", "ENT_TYPE_MONS_STORAGEGUY"); case CUSTOM_TYPE::RUBBLE: return make_custom_entity_type_list<CUSTOM_TYPE::RUBBLE>("ENT_TYPE_ITEM_RUBBLE"); case CUSTOM_TYPE::SCARAB: return make_custom_entity_type_list<CUSTOM_TYPE::SCARAB>("ENT_TYPE_MONS_SCARAB"); case CUSTOM_TYPE::SCEPTERSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::SCEPTERSHOT>( "ENT_TYPE_ITEM_SCEPTER_ANUBISSHOT", "ENT_TYPE_ITEM_SCEPTER_PLAYERSHOT"); case CUSTOM_TYPE::SCORPION: return make_custom_entity_type_list<CUSTOM_TYPE::SCORPION>("ENT_TYPE_MONS_SCORPION"); case CUSTOM_TYPE::SHIELD: return make_custom_entity_type_list<CUSTOM_TYPE::SHIELD>( "ENT_TYPE_ITEM_WOODEN_SHIELD", "ENT_TYPE_ITEM_METAL_SHIELD"); case CUSTOM_TYPE::SHOOTINGSTARSPAWNER: return make_custom_entity_type_list<CUSTOM_TYPE::SHOOTINGSTARSPAWNER>("ENT_TYPE_LOGICAL_SHOOTING_STARS_SPAWNER"); case CUSTOM_TYPE::SHOPKEEPER: return make_custom_entity_type_list<CUSTOM_TYPE::SHOPKEEPER>("ENT_TYPE_MONS_SHOPKEEPER"); case CUSTOM_TYPE::SKELETON: return make_custom_entity_type_list<CUSTOM_TYPE::SKELETON>( "ENT_TYPE_MONS_SKELETON", "ENT_TYPE_MONS_REDSKELETON"); case CUSTOM_TYPE::SKULLDROPTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::SKULLDROPTRAP>("ENT_TYPE_ITEM_SKULLDROPTRAP"); case CUSTOM_TYPE::SLEEPBUBBLE: return make_custom_entity_type_list<CUSTOM_TYPE::SLEEPBUBBLE>("ENT_TYPE_FX_SLEEP_BUBBLE"); case CUSTOM_TYPE::SLIDINGWALLCEILING: return make_custom_entity_type_list<CUSTOM_TYPE::SLIDINGWALLCEILING>("ENT_TYPE_FLOOR_SLIDINGWALL_CEILING"); case CUSTOM_TYPE::SNAPTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::SNAPTRAP>("ENT_TYPE_ITEM_SNAP_TRAP"); case CUSTOM_TYPE::SORCERESS: return make_custom_entity_type_list<CUSTOM_TYPE::SORCERESS>("ENT_TYPE_MONS_SORCERESS"); case CUSTOM_TYPE::SOUNDSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::SOUNDSHOT>( "ENT_TYPE_ITEM_UFO_LASER_SHOT", "ENT_TYPE_ITEM_LAMASSU_LASER_SHOT", "ENT_TYPE_ITEM_FIREBALL", "ENT_TYPE_ITEM_HUNDUN_FIREBALL"); case CUSTOM_TYPE::SPARK: return make_custom_entity_type_list<CUSTOM_TYPE::SPARK>("ENT_TYPE_ITEM_SPARK"); case CUSTOM_TYPE::SPARKTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::SPARKTRAP>("ENT_TYPE_FLOOR_SPARK_TRAP"); case CUSTOM_TYPE::SPEAR: return make_custom_entity_type_list<CUSTOM_TYPE::SPEAR>( "ENT_TYPE_ITEM_TOTEM_SPEAR", "ENT_TYPE_ITEM_LION_SPEAR", "ENT_TYPE_ITEM_BIG_SPEAR"); case CUSTOM_TYPE::SPECIALSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::SPECIALSHOT>("ENT_TYPE_ITEM_SCEPTER_ANUBISSPECIALSHOT"); case CUSTOM_TYPE::SPIDER: return make_custom_entity_type_list<CUSTOM_TYPE::SPIDER>( "ENT_TYPE_MONS_SPIDER", "ENT_TYPE_MONS_GIANTSPIDER"); case CUSTOM_TYPE::SPIKEBALLTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::SPIKEBALLTRAP>("ENT_TYPE_FLOOR_SPIKEBALL_CEILING"); case CUSTOM_TYPE::SPLASHBUBBLEGENERATOR: return make_custom_entity_type_list<CUSTOM_TYPE::SPLASHBUBBLEGENERATOR>("ENT_TYPE_LOGICAL_SPLASH_BUBBLE_GENERATOR"); case CUSTOM_TYPE::STICKYTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::STICKYTRAP>("ENT_TYPE_FLOOR_STICKYTRAP_CEILING"); case CUSTOM_TYPE::STRETCHCHAIN: return make_custom_entity_type_list<CUSTOM_TYPE::STRETCHCHAIN>( "ENT_TYPE_ITEM_CRABMAN_CLAWCHAIN", "ENT_TYPE_ITEM_PUNISHCHAIN"); case CUSTOM_TYPE::SWITCH: return make_custom_entity_type_list<CUSTOM_TYPE::SWITCH>( "ENT_TYPE_ITEM_SLIDINGWALL_SWITCH", "ENT_TYPE_ITEM_SLIDINGWALL_SWITCH_REWARD"); case CUSTOM_TYPE::TADPOLE: return make_custom_entity_type_list<CUSTOM_TYPE::TADPOLE>("ENT_TYPE_MONS_TADPOLE"); case CUSTOM_TYPE::TELEPORTER: return make_custom_entity_type_list<CUSTOM_TYPE::TELEPORTER>("ENT_TYPE_ITEM_TELEPORTER"); case CUSTOM_TYPE::TELEPORTERBACKPACK: return make_custom_entity_type_list<CUSTOM_TYPE::TELEPORTERBACKPACK>("ENT_TYPE_ITEM_TELEPORTER_BACKPACK"); case CUSTOM_TYPE::TELEPORTINGBORDER: return make_custom_entity_type_list<CUSTOM_TYPE::TELEPORTINGBORDER>("ENT_TYPE_FLOOR_TELEPORTINGBORDER"); case CUSTOM_TYPE::TELESCOPE: return make_custom_entity_type_list<CUSTOM_TYPE::TELESCOPE>("ENT_TYPE_ITEM_TELESCOPE"); case CUSTOM_TYPE::TENTACLE: return make_custom_entity_type_list<CUSTOM_TYPE::TENTACLE>("ENT_TYPE_ITEM_TENTACLE"); case CUSTOM_TYPE::TENTACLEBOTTOM: return make_custom_entity_type_list<CUSTOM_TYPE::TENTACLEBOTTOM>("ENT_TYPE_FLOOR_TENTACLE_BOTTOM"); case CUSTOM_TYPE::TERRA: return make_custom_entity_type_list<CUSTOM_TYPE::TERRA>("ENT_TYPE_MONS_MARLA_TUNNEL"); case CUSTOM_TYPE::THINICE: return make_custom_entity_type_list<CUSTOM_TYPE::THINICE>("ENT_TYPE_ACTIVEFLOOR_THINICE"); case CUSTOM_TYPE::TIAMAT: return make_custom_entity_type_list<CUSTOM_TYPE::TIAMAT>("ENT_TYPE_MONS_TIAMAT"); case CUSTOM_TYPE::TIAMATSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::TIAMATSHOT>("ENT_TYPE_ITEM_TIAMAT_SHOT"); case CUSTOM_TYPE::TIMEDFORCEFIELD: return make_custom_entity_type_list<CUSTOM_TYPE::TIMEDFORCEFIELD>("ENT_TYPE_FLOOR_TIMED_FORCEFIELD"); case CUSTOM_TYPE::TIMEDPOWDERKEG: return make_custom_entity_type_list<CUSTOM_TYPE::TIMEDPOWDERKEG>("ENT_TYPE_ACTIVEFLOOR_TIMEDPOWDERKEG"); case CUSTOM_TYPE::TIMEDSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::TIMEDSHOT>("ENT_TYPE_ITEM_FREEZERAYSHOT"); case CUSTOM_TYPE::TORCH: return make_custom_entity_type_list<CUSTOM_TYPE::TORCH>( "ENT_TYPE_ITEM_WALLTORCH", "ENT_TYPE_ITEM_LITWALLTORCH", "ENT_TYPE_ITEM_AUTOWALLTORCH", "ENT_TYPE_ITEM_TORCH", "ENT_TYPE_ITEM_LAMP", "ENT_TYPE_ITEM_REDLANTERN"); case CUSTOM_TYPE::TORCHFLAME: return make_custom_entity_type_list<CUSTOM_TYPE::TORCHFLAME>("ENT_TYPE_ITEM_TORCHFLAME"); case CUSTOM_TYPE::TOTEMTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::TOTEMTRAP>( "ENT_TYPE_FLOOR_TOTEM_TRAP", "ENT_TYPE_FLOOR_LION_TRAP"); case CUSTOM_TYPE::TRANSFERFLOOR: return make_custom_entity_type_list<CUSTOM_TYPE::TRANSFERFLOOR>( "ENT_TYPE_FLOOR_CONVEYORBELT_LEFT", "ENT_TYPE_FLOOR_CONVEYORBELT_RIGHT"); case CUSTOM_TYPE::TRAPPART: return make_custom_entity_type_list<CUSTOM_TYPE::TRAPPART>( "ENT_TYPE_ITEM_STICKYTRAP_BALL", "ENT_TYPE_ACTIVEFLOOR_CHAINED_SPIKEBALL", "ENT_TYPE_ACTIVEFLOOR_SLIDINGWALL"); case CUSTOM_TYPE::TREASURE: return make_custom_entity_type_list<CUSTOM_TYPE::TREASURE>( "ENT_TYPE_ITEM_ENDINGTREASURE_TIAMAT", "ENT_TYPE_ITEM_ENDINGTREASURE_HUNDUN"); case CUSTOM_TYPE::TREASUREHOOK: return make_custom_entity_type_list<CUSTOM_TYPE::TREASUREHOOK>("ENT_TYPE_ITEM_EGGSHIP_HOOK"); case CUSTOM_TYPE::TRUECROWNPOWERUP: return make_custom_entity_type_list<CUSTOM_TYPE::TRUECROWNPOWERUP>("ENT_TYPE_ITEM_POWERUP_TRUECROWN"); case CUSTOM_TYPE::TUN: return make_custom_entity_type_list<CUSTOM_TYPE::TUN>("ENT_TYPE_MONS_MERCHANT"); case CUSTOM_TYPE::TV: return make_custom_entity_type_list<CUSTOM_TYPE::TV>("ENT_TYPE_ITEM_TV"); case CUSTOM_TYPE::UDJATSOCKET: return make_custom_entity_type_list<CUSTOM_TYPE::UDJATSOCKET>("ENT_TYPE_ITEM_UDJAT_SOCKET"); case CUSTOM_TYPE::UFO: return make_custom_entity_type_list<CUSTOM_TYPE::UFO>("ENT_TYPE_MONS_UFO"); case CUSTOM_TYPE::UNCHAINEDSPIKEBALL: return make_custom_entity_type_list<CUSTOM_TYPE::UNCHAINEDSPIKEBALL>("ENT_TYPE_ACTIVEFLOOR_UNCHAINED_SPIKEBALL"); case CUSTOM_TYPE::USHABTI: return make_custom_entity_type_list<CUSTOM_TYPE::USHABTI>("ENT_TYPE_ITEM_USHABTI"); case CUSTOM_TYPE::VAMPIRE: return make_custom_entity_type_list<CUSTOM_TYPE::VAMPIRE>( "ENT_TYPE_MONS_VAMPIRE", "ENT_TYPE_MONS_VLAD"); case CUSTOM_TYPE::VANHORSING: return make_custom_entity_type_list<CUSTOM_TYPE::VANHORSING>("ENT_TYPE_MONS_OLD_HUNTER"); case CUSTOM_TYPE::VLAD: return make_custom_entity_type_list<CUSTOM_TYPE::VLAD>("ENT_TYPE_MONS_VLAD"); case CUSTOM_TYPE::VLADSCAPE: return make_custom_entity_type_list<CUSTOM_TYPE::VLADSCAPE>("ENT_TYPE_ITEM_VLADS_CAPE"); case CUSTOM_TYPE::WADDLER: return make_custom_entity_type_list<CUSTOM_TYPE::WADDLER>("ENT_TYPE_MONS_STORAGEGUY"); case CUSTOM_TYPE::WALKINGMONSTER: return make_custom_entity_type_list<CUSTOM_TYPE::WALKINGMONSTER>( "ENT_TYPE_MONS_CAVEMAN", "ENT_TYPE_MONS_CAVEMAN_SHOPKEEPER", "ENT_TYPE_MONS_CAVEMAN_BOSS", "ENT_TYPE_MONS_TIKIMAN", "ENT_TYPE_MONS_WITCHDOCTOR", "ENT_TYPE_MONS_ROBOT", "ENT_TYPE_MONS_CROCMAN", "ENT_TYPE_MONS_SORCERESS", "ENT_TYPE_MONS_NECROMANCER", "ENT_TYPE_MONS_OCTOPUS", "ENT_TYPE_MONS_YETI", "ENT_TYPE_MONS_OLMITE_HELMET", "ENT_TYPE_MONS_OLMITE_BODYARMORED", "ENT_TYPE_MONS_OLMITE_NAKED", "ENT_TYPE_MONS_LEPRECHAUN"); case CUSTOM_TYPE::WALLTORCH: return make_custom_entity_type_list<CUSTOM_TYPE::WALLTORCH>( "ENT_TYPE_ITEM_WALLTORCH", "ENT_TYPE_ITEM_LITWALLTORCH", "ENT_TYPE_ITEM_AUTOWALLTORCH"); case CUSTOM_TYPE::WEBSHOT: return make_custom_entity_type_list<CUSTOM_TYPE::WEBSHOT>("ENT_TYPE_ITEM_WEBSHOT"); case CUSTOM_TYPE::WETEFFECT: return make_custom_entity_type_list<CUSTOM_TYPE::WETEFFECT>("ENT_TYPE_LOGICAL_WET_EFFECT"); case CUSTOM_TYPE::WITCHDOCTOR: return make_custom_entity_type_list<CUSTOM_TYPE::WITCHDOCTOR>("ENT_TYPE_MONS_WITCHDOCTOR"); case CUSTOM_TYPE::WITCHDOCTORSKULL: return make_custom_entity_type_list<CUSTOM_TYPE::WITCHDOCTORSKULL>("ENT_TYPE_MONS_WITCHDOCTORSKULL"); case CUSTOM_TYPE::WOODENLOGTRAP: return make_custom_entity_type_list<CUSTOM_TYPE::WOODENLOGTRAP>("ENT_TYPE_ACTIVEFLOOR_WOODENLOG_TRAP"); case CUSTOM_TYPE::YAMA: return make_custom_entity_type_list<CUSTOM_TYPE::YAMA>("ENT_TYPE_MONS_YAMA"); case CUSTOM_TYPE::YANG: return make_custom_entity_type_list<CUSTOM_TYPE::YANG>("ENT_TYPE_MONS_YANG"); case CUSTOM_TYPE::YELLOWCAPE: return make_custom_entity_type_list<CUSTOM_TYPE::YELLOWCAPE>("ENT_TYPE_ITEM_CAPE"); case CUSTOM_TYPE::YETIKING: return make_custom_entity_type_list<CUSTOM_TYPE::YETIKING>("ENT_TYPE_MONS_YETIKING"); case CUSTOM_TYPE::YETIQUEEN: return make_custom_entity_type_list<CUSTOM_TYPE::YETIQUEEN>("ENT_TYPE_MONS_YETIQUEEN"); } return {}; } bool is_type_movable(ENT_TYPE type) { auto movable_types = get_custom_entity_types(CUSTOM_TYPE::MOVABLE); if (std::find(movable_types.begin(), movable_types.end(), type) != movable_types.end()) return true; return false; } const std::map<CUSTOM_TYPE, std::string_view>& get_custom_types_map() { return custom_type_names; }
51.469949
129
0.711301
mattlennon3
31041e4f324324d2e426166ca783a81a6accce4e
794
cpp
C++
ChnCities.cpp
lydiau/GISGraphics
54818dcbeb01c4801a877fb465898e2a32d13616
[ "MIT" ]
null
null
null
ChnCities.cpp
lydiau/GISGraphics
54818dcbeb01c4801a877fb465898e2a32d13616
[ "MIT" ]
null
null
null
ChnCities.cpp
lydiau/GISGraphics
54818dcbeb01c4801a877fb465898e2a32d13616
[ "MIT" ]
2
2018-09-21T20:58:50.000Z
2018-11-20T10:13:32.000Z
// ChnCities.cpp: implementation of the CChnCities class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "CGExe.h" #include "ChnCities.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CChnCities::CChnCities() { } CChnCities::~CChnCities() { } void CChnCities::addCity(CITY city) { cities.Add(city); } void CChnCities::Draw(CDC *pDC) { int size=cities.GetSize(); CITY ocity; int r=100000; for(int i=0;i<size;i++) { ocity=cities.GetAt(i); pDC->Ellipse(ocity.lon,ocity.lat,ocity.lon+r,ocity.lat+r); } }
17.644444
70
0.513854
lydiau
31052fad0884ae5266fe1bd129a94d65e06ee917
391
cpp
C++
potato/libeditor/source/imgui_fonts.cpp
potatoengine/potato
001b08371cf3dca26406c0f207a87bf784322e82
[ "MIT" ]
38
2019-05-25T17:32:26.000Z
2022-02-27T22:25:05.000Z
potato/libeditor/source/imgui_fonts.cpp
potatoengine/potato
001b08371cf3dca26406c0f207a87bf784322e82
[ "MIT" ]
35
2019-05-26T17:52:39.000Z
2022-02-12T19:54:14.000Z
potato/libeditor/source/imgui_fonts.cpp
potatoengine/potato
001b08371cf3dca26406c0f207a87bf784322e82
[ "MIT" ]
2
2019-06-09T16:06:27.000Z
2019-08-16T14:17:20.000Z
// Copyright by Potato Engine contributors. See accompanying License.txt for copyright details. #include "potato/editor/imgui_fonts.h" #include "potato/editor/imgui_backend.h" #include <imgui.h> void ImGui::Potato::PushFont(UpFont font) { auto const& backend = *static_cast<up::ImguiBackend const*>(GetIO().UserData); ImGui::PushFont(backend.getFont(static_cast<int>(font))); }
27.928571
95
0.749361
potatoengine
311508528d8b378cd1b76a62ca79f1ba37d79bc7
3,101
cpp
C++
GeoFenix/Graphics/Camera/camera.cpp
TheNachoBIT/GeoFenix-Engine
9167edb4c44d70204e03f9551a7184184ec659c1
[ "MIT" ]
8
2020-08-17T22:35:53.000Z
2021-11-08T09:41:55.000Z
GeoFenix/Graphics/Camera/camera.cpp
TheNachoBIT/GeoFenix-Engine
9167edb4c44d70204e03f9551a7184184ec659c1
[ "MIT" ]
null
null
null
GeoFenix/Graphics/Camera/camera.cpp
TheNachoBIT/GeoFenix-Engine
9167edb4c44d70204e03f9551a7184184ec659c1
[ "MIT" ]
null
null
null
#include "camera.h" namespace geofenix { namespace graphics { Camera::Camera(glm::vec3 position, glm::vec3 direction, glm::vec3 worldUp) : worldUp(worldUp), up(worldUp), position(position) { right = glm::vec3(0.f); ViewMatrix = glm::mat4(1.f); movementSpeed = 3.f; sensitivity = 5.f; pitch = 0.f; yaw = -90.f; roll = 0.f; UpdateCameraVectors(); } Camera::~Camera() { } void Camera::CreateFrustumFromMatrix(const glm::mat4 matrix) { //left planes[0].x = matrix[0][3] + matrix[0][0]; planes[0].y = matrix[1][3] + matrix[1][0]; planes[0].z = matrix[2][3] + matrix[2][0]; planes[0].w = matrix[3][3] + matrix[3][0]; // right planes[1].x = matrix[0][3] - matrix[0][0]; planes[1].y = matrix[1][3] - matrix[1][0]; planes[1].z = matrix[2][3] - matrix[2][0]; planes[1].w = matrix[3][3] - matrix[3][0]; // bottom planes[2].x = matrix[0][3] + matrix[0][1]; planes[2].y = matrix[1][3] + matrix[1][1]; planes[2].z = matrix[2][3] + matrix[2][1]; planes[2].w = matrix[3][3] + matrix[3][1]; // top planes[3].x = matrix[0][3] - matrix[0][1]; planes[3].y = matrix[1][3] - matrix[1][1]; planes[3].z = matrix[2][3] - matrix[2][1]; planes[3].w = matrix[3][3] - matrix[3][1]; // near planes[4].x = matrix[0][3] + matrix[0][2]; planes[4].y = matrix[1][3] + matrix[1][2]; planes[4].z = matrix[2][3] + matrix[2][2]; planes[4].w = matrix[3][3] + matrix[3][2]; // far planes[5].x = matrix[0][3] - matrix[0][2]; planes[5].y = matrix[1][3] - matrix[1][2]; planes[5].z = matrix[2][3] - matrix[2][2]; planes[5].w = matrix[3][3] - matrix[3][2]; for (int i = 0; i < 6; i++) { float length = planes[i].length(); planes[i] /= length; } } void Camera::UpdateCameraVectors() { front.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch)); front.y = sin(glm::radians(pitch)); front.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch)); front = glm::normalize(front); right = glm::normalize(glm::cross(front, worldUp)); up = glm::normalize(glm::cross(right, front)); } glm::mat4 Camera::UpdateViewMatrix() { ViewMatrix = glm::lookAt(position, position + front, up); UpdateCameraVectors(); return ViewMatrix; } void Camera::MoveCamera(const float& deltaTime, const int direction) { switch (direction) { case FORWARD: position += front * movementSpeed * deltaTime; break; case BACKWARD: position -= front * movementSpeed * deltaTime; break; case LEFT: position -= right * movementSpeed * deltaTime; break; case RIGHT: position += right * movementSpeed * deltaTime; break; default: break; } } void Camera::Mouse(const float& deltaTime, const double& speedX, const double& speedY) { pitch -= static_cast<GLfloat>(speedY) * sensitivity * deltaTime; yaw += static_cast<GLfloat>(speedX) * sensitivity * deltaTime; if (pitch > 80.f) pitch = 80.f; else if (pitch < -80.f) pitch = -80.f; if (yaw > 360.f || yaw < -360.f) yaw = 0.f; } } }
24.417323
88
0.578201
TheNachoBIT
3118bb8c3bb79b9207f4c2c365a2ca6ecb58ded7
3,278
hpp
C++
email/include/email/log.hpp
christophebedard/rmw_email
c0110b6fc6a61f389ec58f54496c39f6026a4a13
[ "Apache-2.0" ]
14
2021-09-19T02:04:37.000Z
2022-02-24T08:15:50.000Z
email/include/email/log.hpp
christophebedard/rmw_email
c0110b6fc6a61f389ec58f54496c39f6026a4a13
[ "Apache-2.0" ]
5
2021-09-18T23:50:02.000Z
2022-02-21T14:44:49.000Z
email/include/email/log.hpp
christophebedard/rmw_email
c0110b6fc6a61f389ec58f54496c39f6026a4a13
[ "Apache-2.0" ]
2
2021-09-20T13:56:38.000Z
2021-12-10T09:00:24.000Z
// Copyright 2020-2021 Christophe Bedard // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef EMAIL__LOG_HPP_ #define EMAIL__LOG_HPP_ #include <memory> #include <stdexcept> #include <string> #include "rcpputils/filesystem_helper.hpp" #include "spdlog/spdlog.h" #include "spdlog/fmt/ostr.h" #include "yaml-cpp/yaml.h" #include "email/utils.hpp" namespace email { /// Abstract away the logger implementation. using Logger = spdlog::logger; namespace log { /// Generic logging error. class LoggingError : public std::runtime_error { public: explicit LoggingError(const std::string & msg) : std::runtime_error(msg) {} }; /// Error when logging is not initialized. class LoggingNotInitializedError : public LoggingError { public: LoggingNotInitializedError() : LoggingError("logging not initialized") {} }; /// Logging level. enum Level { debug, info, warn, error, fatal, off }; /// Initialize logging. /** * \param level the console logging level * \throw LoggingAlreadyInitializedError if logging is already intialized */ void init(const Level & level); /// Initialize logging using environment variable value for the logging level. /** * \throw LoggingAlreadyInitializedError if logging is already intialized */ void init_from_env(); /// Create logger from the root logger. /** * Uses sink(s) and log level from the root logger. * * Will initialize logging from environment if not initialized. * * \param name the name of the logger * \return the logger */ std::shared_ptr<Logger> create(const std::string & name); /// Get an existing logger or create it from the root logger. /** * Useful for sharing a logger. * * Will initialize logging from environment if not initialized. * * \param name the name of the logger * \return the logger */ std::shared_ptr<Logger> get_or_create(const std::string & name); /// Remove an existing logger. /** * \param logger the logger * \throw LoggingNotInitializedError if logging is not intialized */ void remove(const std::shared_ptr<Logger> & logger); /// Shutdown and finalize. void shutdown(); } // namespace log } // namespace email /// Formatting for rcpputils::fs::path objects. template<> struct fmt::formatter<rcpputils::fs::path>: formatter<string_view> { template<typename FormatContext> auto format(const rcpputils::fs::path & p, FormatContext & ctx) { return formatter<string_view>::format(p.string(), ctx); } }; /// Formatting for YAML::Node objects. template<> struct fmt::formatter<YAML::Node>: formatter<string_view> { template<typename FormatContext> auto format(const YAML::Node & node, FormatContext & ctx) { return formatter<string_view>::format(email::utils::yaml_to_string(node), ctx); } }; #endif // EMAIL__LOG_HPP_
22.763889
83
0.727883
christophebedard
312605a5cdc8c9cdd8bc09d0c68d3737585ee481
15,101
cpp
C++
modules/standard.lib.amf/src/main.cpp
Devronium/ConceptApplicationServer
c1fcb8de8d752f352485840aab13511dd1aa6a15
[ "BSD-2-Clause" ]
11
2016-01-24T18:53:36.000Z
2021-01-21T08:59:01.000Z
modules/standard.lib.amf/src/main.cpp
Devronium/ConceptApplicationServer
c1fcb8de8d752f352485840aab13511dd1aa6a15
[ "BSD-2-Clause" ]
1
2016-01-22T21:38:38.000Z
2016-01-30T17:25:01.000Z
modules/standard.lib.amf/src/main.cpp
Devronium/ConceptApplicationServer
c1fcb8de8d752f352485840aab13511dd1aa6a15
[ "BSD-2-Clause" ]
null
null
null
//------------ standard header -----------------------------------// #include "stdlibrary.h" //------------ end of standard header ----------------------------// #include "library.h" #include "AnsiString.h" #include <string> #include "amf.h" typedef amf::amf_strict_array * am_ptr; amf::amf_data_ptr amf_rec(void *arr); amf::amf_object *do_object(void *pData); void process_array(void *RESULT, amf::amf_strict_array *obj); void process_object(void *RESULT, amf::amf_object *obj); void process_ecma(void *RESULT, amf::amf_ecma_array *obj); void ecma(void *RESULT, amf::ecma_array_t *e_arr); //-------------------------// // Local variables // //-------------------------// INVOKE_CALL InvokePtr = 0; //-----------------------------------------------------// CONCEPT_DLL_API ON_CREATE_CONTEXT MANAGEMENT_PARAMETERS { InvokePtr = Invoke; return 0; } //-----------------------------------------------------// CONCEPT_DLL_API ON_DESTROY_CONTEXT MANAGEMENT_PARAMETERS { return 0; } //-----------------------------------------------------// void set_object(amf::amf_object *obj, char *key, void *newpData) { char *szData; INTEGER type; NUMBER nData; InvokePtr(INVOKE_GET_VARIABLE, newpData, &type, &szData, &nData); switch (type) { case VARIABLE_STRING: { std::string str; str.assign(szData, (int)nData); if (/*nData>0xFF*/ 0) { amf::amf_long_string *s = new amf::amf_long_string(str); obj->add_properity(amf::amf_string(key), amf::amf_data_ptr(s)); } else { amf::amf_string *s = new amf::amf_string(str); obj->add_properity(amf::amf_string(key), amf::amf_data_ptr(s)); } } break; case VARIABLE_NUMBER: { amf::amf_numeric *s = new amf::amf_numeric(nData); obj->add_properity(amf::amf_string(key), amf::amf_data_ptr(s)); } break; case VARIABLE_ARRAY: { amf::amf_data_ptr o = amf_rec(newpData); obj->add_properity(amf::amf_string(key), o); } break; case VARIABLE_CLASS: obj->add_properity(amf::amf_string(key), amf::amf_data_ptr(do_object(szData))); break; default: break; } } //-----------------------------------------------------// void set_list(amf::amf_strict_array *obj, void *newpData) { char *szData; INTEGER type; NUMBER nData; InvokePtr(INVOKE_GET_VARIABLE, newpData, &type, &szData, &nData); std::list<amf::amf_data_ptr> *lst = (std::list<amf::amf_data_ptr> *) & (obj->get_value()); switch (type) { case VARIABLE_STRING: { std::string str; str.assign(szData, (int)nData); if (/*nData>0xFF*/ 0) { amf::amf_long_string *s = new amf::amf_long_string(str); lst->push_back(amf::amf_data_ptr(s)); } else { amf::amf_string *s = new amf::amf_string(str); lst->push_back(amf::amf_data_ptr(s)); } } break; case VARIABLE_NUMBER: { amf::amf_numeric *s = new amf::amf_numeric(nData); lst->push_back(amf::amf_data_ptr(s)); } break; case VARIABLE_ARRAY: { amf::amf_data_ptr o = amf_rec(newpData); lst->push_back(o); } //obj->add(amf::amf_data_ptr(amf_rec(newpData))); break; case VARIABLE_CLASS: lst->push_back(amf::amf_data_ptr(do_object(szData))); break; default: break; } } //-----------------------------------------------------// amf::amf_object *do_object(void *pData) { amf::amf_object *obj = new amf::amf_object(); char *class_name = 0; int members_count = InvokePtr(INVOKE_GET_SERIAL_CLASS, pData, (int)0, &class_name, (char **)0, (char *)0, (char *)0, (char *)0, (char **)0, (NUMBER *)0, (char *)0, (char *)0); if (members_count > 0) { char **members = new char * [members_count]; char *flags = new char[members_count]; char *access = new char[members_count]; char *types = new char[members_count]; char **szValues = new char * [members_count]; NUMBER *nValues = new NUMBER[members_count]; void **class_data = new void * [members_count]; void **variable_data = new void * [members_count]; int result = InvokePtr(INVOKE_GET_SERIAL_CLASS, pData, members_count, &class_name, members, flags, access, types, (const char **)szValues, nValues, class_data, variable_data); if (IS_OK(result)) { for (int i = 0; i < members_count; i++) { if (flags[i] == 0) { char *key = members[i]; if (key) { set_object(obj, key, variable_data[i]); } } } } delete[] members; delete[] flags; delete[] access; delete[] types; delete[] szValues; delete[] nValues; delete[] class_data; delete[] variable_data; } return obj; } //----------------------------------------- amf::amf_data_ptr amf_rec(void *arr) { int count = InvokePtr(INVOKE_GET_ARRAY_COUNT, arr); INTEGER len = 0; void *newpData = 0; char *key = 0; char is_array = 0; if (count > 0) { InvokePtr(INVOKE_ARRAY_VARIABLE, arr, (INTEGER)0, &newpData); InvokePtr(INVOKE_GET_ARRAY_KEY, arr, (INTEGER)0, &key); } amf::amf_object *obj = 0; amf::amf_strict_array *obj3 = 0; if (key) obj = new amf::amf_object(); else { is_array = 1; obj3 = new amf::amf_strict_array(); } for (int i = 0; i < count; i++) { void *newpData = 0; char *key = 0; InvokePtr(INVOKE_ARRAY_VARIABLE, arr, i, &newpData); if (is_array) { set_list(obj3, newpData); } else { InvokePtr(INVOKE_GET_ARRAY_KEY, arr, i, &key); if ((newpData) && (key)) set_object(obj, key, newpData); } } if (obj) return amf::amf_data_ptr(obj); return amf::amf_data_ptr(obj3); } //-----------------------------------------------------// CONCEPT_FUNCTION_IMPL(AMF, 1) __INTERNAL_PARAMETER_DECL(char *, bind, 0); __INTERNAL_PARAMETER_DECL(NUMBER, bind_len, 0); char *dclass = 0; GetVariable(LOCAL_CONTEXT[PARAMETERS->PARAM_INDEX[0] - 1], &TYPE, &dclass, &nDUMMY_FILL); if ((TYPE != VARIABLE_CLASS) && (TYPE != VARIABLE_ARRAY)) return (void *)"AMF: parameter 1 should be an object or array"; void *arr = PARAMETER(0); amf::amf_data_ptr obj; if (TYPE == VARIABLE_ARRAY) obj = amf_rec(arr); else obj = amf::amf_data_ptr(do_object(dclass)); int size = 0; if (obj) size = obj->get_size(); if (size > 0) { char *buf = new char[size + 1]; buf[size] = 0; if (obj) obj->encode(buf); RETURN_BUFFER(buf, size); delete[] buf; } else RETURN_STRING(""); END_IMPL //-----------------------------------------------------// void process_array(void *RESULT, amf::amf_strict_array *obj) { InvokePtr(INVOKE_CREATE_ARRAY, RESULT); NUMBER nVal; std::string sVal; void *new_var; std::list<amf::amf_data_ptr> *lst = (std::list<amf::amf_data_ptr> *) & (obj->get_value()); std::list<amf::amf_data_ptr>::iterator it; INTEGER index = 0; for (it = lst->begin(); it != lst->end(); it++) { amf::amf_data_ptr val = *it; if (val) { void *val_ptr = val.get(); switch (val->get_type()) { case amf::AMF_TYPE_NUMERIC: nVal = ((amf::amf_numeric *)val_ptr)->get_value(); InvokePtr(INVOKE_SET_ARRAY_ELEMENT, RESULT, index, (INTEGER)VARIABLE_NUMBER, "", (NUMBER)nVal); break; case amf::AMF_TYPE_NULL_VALUE: case amf::AMF_TYPE_UNDEFINED: case amf::AMF_TYPE_OBJECT_END: nVal = 0; InvokePtr(INVOKE_SET_ARRAY_ELEMENT, RESULT, index, (INTEGER)VARIABLE_NUMBER, "", (NUMBER)nVal); break; case amf::AMF_TYPE_STRING: sVal = ((amf::amf_string *)val_ptr)->get_value(); InvokePtr(INVOKE_SET_ARRAY_ELEMENT, RESULT, index, (INTEGER)VARIABLE_STRING, sVal.length() ? sVal.c_str() : "", (NUMBER)sVal.length()); break; case amf::AMF_TYPE_LONG_STRING: sVal = ((amf::amf_long_string *)val_ptr)->get_value(); InvokePtr(INVOKE_SET_ARRAY_ELEMENT, RESULT, index, (INTEGER)VARIABLE_STRING, sVal.length() ? sVal.c_str() : "", (NUMBER)sVal.length()); break; case amf::AMF_TYPE_OBJECT: InvokePtr(INVOKE_ARRAY_VARIABLE, RESULT, index, &new_var); process_object(new_var, (amf::amf_object *)val_ptr); break; case amf::AMF_TYPE_STRICT_ARRAY: InvokePtr(INVOKE_ARRAY_VARIABLE, RESULT, index, &new_var); process_array(new_var, (amf::amf_strict_array *)val_ptr); break; case amf::AMF_TYPE_DATE: sVal = ((amf::amf_date *)val_ptr)->to_string(); InvokePtr(INVOKE_SET_ARRAY_ELEMENT, RESULT, index, (INTEGER)VARIABLE_STRING, sVal.length() ? sVal.c_str() : "", (NUMBER)sVal.length()); break; case amf::AMF_TYPE_ECMA_ARRAY: InvokePtr(INVOKE_ARRAY_VARIABLE, RESULT, index, &new_var); process_ecma(new_var, (amf::amf_ecma_array *)val_ptr); break; case amf::AMF_TYPE_REFERENCE: case amf::AMF_TYPE_UNSUPPORTED: case amf::AMF_TYPE_RECORD_SET: case amf::AMF_TYPE_XML_OBJECT: case amf::AMF_TYPE_MOVIECLIP: case amf::AMF_TYPE_TYPED_OBJECT: sVal = "Unsupported"; InvokePtr(INVOKE_SET_ARRAY_ELEMENT, RESULT, index, (INTEGER)VARIABLE_STRING, sVal.length() ? sVal.c_str() : "", (NUMBER)sVal.length()); break; } } index++; } } //-----------------------------------------------------// void process_ecma(void *RESULT, amf::amf_ecma_array *obj) { InvokePtr(INVOKE_CREATE_ARRAY, RESULT); amf::ecma_array_t arr = obj->get_value(); ecma(RESULT, &arr); } //-----------------------------------------------------// void ecma(void *RESULT, amf::ecma_array_t *e_arr) { amf::ecma_array_t::iterator it; InvokePtr(INVOKE_CREATE_ARRAY, RESULT); NUMBER nVal; std::string sVal; void *new_var; for (it = e_arr->begin(); it != e_arr->end(); it++) { const char *key = (*it).first.to_string().c_str(); amf::amf_data_ptr val = (*it).second; if ((key) && (val)) { void *val_ptr = val.get(); switch (val->get_type()) { case amf::AMF_TYPE_NUMERIC: nVal = ((amf::amf_numeric *)val_ptr)->get_value(); InvokePtr(INVOKE_SET_ARRAY_ELEMENT_BY_KEY, RESULT, key, (INTEGER)VARIABLE_NUMBER, "", (NUMBER)nVal); break; case amf::AMF_TYPE_NULL_VALUE: case amf::AMF_TYPE_UNDEFINED: case amf::AMF_TYPE_OBJECT_END: nVal = 0; InvokePtr(INVOKE_SET_ARRAY_ELEMENT_BY_KEY, RESULT, key, (INTEGER)VARIABLE_NUMBER, "", (NUMBER)nVal); break; case amf::AMF_TYPE_STRING: sVal = ((amf::amf_string *)val_ptr)->get_value(); InvokePtr(INVOKE_SET_ARRAY_ELEMENT_BY_KEY, RESULT, key, (INTEGER)VARIABLE_STRING, sVal.length() ? sVal.c_str() : "", (NUMBER)sVal.length()); break; case amf::AMF_TYPE_LONG_STRING: sVal = ((amf::amf_long_string *)val_ptr)->get_value(); InvokePtr(INVOKE_SET_ARRAY_ELEMENT_BY_KEY, RESULT, key, (INTEGER)VARIABLE_STRING, sVal.length() ? sVal.c_str() : "", (NUMBER)sVal.length()); break; case amf::AMF_TYPE_OBJECT: InvokePtr(INVOKE_ARRAY_VARIABLE_BY_KEY, RESULT, (char *)key, &new_var); process_object(new_var, (amf::amf_object *)val_ptr); break; case amf::AMF_TYPE_STRICT_ARRAY: InvokePtr(INVOKE_ARRAY_VARIABLE_BY_KEY, RESULT, (char *)key, &new_var); process_array(new_var, (amf::amf_strict_array *)val_ptr); break; case amf::AMF_TYPE_DATE: sVal = ((amf::amf_date *)val_ptr)->to_string(); InvokePtr(INVOKE_SET_ARRAY_ELEMENT_BY_KEY, RESULT, key, (INTEGER)VARIABLE_STRING, sVal.length() ? sVal.c_str() : "", (NUMBER)sVal.length()); break; case amf::AMF_TYPE_ECMA_ARRAY: InvokePtr(INVOKE_SET_ARRAY_ELEMENT_BY_KEY, RESULT, key, &new_var); process_ecma(new_var, (amf::amf_ecma_array *)val_ptr); break; case amf::AMF_TYPE_REFERENCE: case amf::AMF_TYPE_UNSUPPORTED: case amf::AMF_TYPE_RECORD_SET: case amf::AMF_TYPE_XML_OBJECT: case amf::AMF_TYPE_MOVIECLIP: case amf::AMF_TYPE_TYPED_OBJECT: sVal = "Unsupported"; InvokePtr(INVOKE_SET_ARRAY_ELEMENT_BY_KEY, RESULT, key, (INTEGER)VARIABLE_STRING, sVal.length() ? sVal.c_str() : "", (NUMBER)sVal.length()); break; } } } } //-----------------------------------------------------// void process_object(void *RESULT, amf::amf_object *obj) { amf::ecma_array_t e_arr = obj->get_value(); ecma(RESULT, &e_arr); } //-----------------------------------------------------// CONCEPT_FUNCTION_IMPL(UnAMF, 1) T_STRING(UnAMF, 0) amf::amf_object * obj = new amf::amf_object(); int ret = obj->decode(PARAM(0), PARAM_LEN(0)); if (ret < 0) { amf::amf_strict_array *arr = new amf::amf_strict_array(); ret = arr->decode(PARAM(0), PARAM_LEN(0)); if (ret < 0) { RETURN_NUMBER(0); } else process_array(RESULT, arr); } else process_object(RESULT, obj); END_IMPL
36.300481
183
0.512615
Devronium
312cf9235009d4990327e012463a2040fd42c085
2,052
cpp
C++
2016/Day24/Packaging.cpp
marcuskrahl/AdventOfCode
0148d9a01a565aac1a6104a6001478fab3b6d4f8
[ "MIT" ]
null
null
null
2016/Day24/Packaging.cpp
marcuskrahl/AdventOfCode
0148d9a01a565aac1a6104a6001478fab3b6d4f8
[ "MIT" ]
null
null
null
2016/Day24/Packaging.cpp
marcuskrahl/AdventOfCode
0148d9a01a565aac1a6104a6001478fab3b6d4f8
[ "MIT" ]
null
null
null
#include "Packaging.hpp" #include <cmath> #include <array> #include <limits> unsigned int get_target_weight(const std::vector<unsigned int>& packages,unsigned int package_groups) { unsigned int sum = 0; for(auto package:packages) { sum += package; } return sum/package_groups; } struct package_values { unsigned long quantum_entanglement; unsigned int packages_in_front; unsigned int weight; }; void iterate (const std::vector<unsigned int>& packages, std::vector<unsigned int>::const_iterator start, package_values& best_values, package_values current_values, unsigned int target_weight) { for (auto it = start; it != packages.end(); it++) { package_values new_values = current_values; new_values.weight += *it; new_values.packages_in_front++; new_values.quantum_entanglement *= *it; if (new_values.weight < target_weight) { iterate(packages,it+1,best_values,new_values,target_weight); } else if (new_values.weight == target_weight) { if ((new_values.packages_in_front < best_values.packages_in_front) || (new_values.packages_in_front == best_values.packages_in_front && new_values.quantum_entanglement < best_values.quantum_entanglement)) { best_values = new_values; } } } } unsigned long get_minimum_entaglement(const std::vector<unsigned int>& packages, unsigned int group_size) { unsigned int target_weight = get_target_weight(packages,group_size); package_values best_values; best_values.packages_in_front = std::numeric_limits<unsigned int>::max(); best_values.quantum_entanglement = std::numeric_limits<unsigned long>::max(); best_values.weight = 0; package_values current_values; current_values.packages_in_front = 0; current_values.quantum_entanglement = 1; current_values.weight = 0; iterate(packages,packages.begin(),best_values,current_values,target_weight); return best_values.quantum_entanglement; }
36.642857
195
0.710039
marcuskrahl
312d08da2f83f624d1370106192a7c9f5b0f71b5
2,717
cpp
C++
Tests/container/any.test.cpp
gpdaniels/gtl
cd495343c5e89395be063a3dff6dfc41492c9677
[ "MIT" ]
28
2018-07-23T06:52:19.000Z
2021-09-07T22:15:52.000Z
Tests/container/any.test.cpp
gpdaniels/gtl
cd495343c5e89395be063a3dff6dfc41492c9677
[ "MIT" ]
17
2018-09-13T13:29:05.000Z
2021-01-04T09:23:31.000Z
Tests/container/any.test.cpp
gpdaniels/gtl
cd495343c5e89395be063a3dff6dfc41492c9677
[ "MIT" ]
4
2019-02-27T13:33:16.000Z
2019-12-27T14:14:55.000Z
/* The MIT License Copyright (c) 2018 Geoffrey Daniels. http://gpdaniels.com/ 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 <main.tests.hpp> #include <optimise.tests.hpp> #include <comparison.tests.hpp> #include <data.tests.hpp> #include <require.tests.hpp> #include <template.tests.hpp> #include <container/any> #if defined(_MSC_VER) # pragma warning(push, 0) #endif #include <type_traits> #if defined(_MSC_VER) # pragma warning(pop) #endif TEST(any, traits, standard) { REQUIRE(std::is_pod<gtl::any>::value == false, "Expected std::is_pod to be false."); REQUIRE(std::is_trivial<gtl::any>::value == false, "Expected std::is_trivial to be false."); REQUIRE(std::is_trivially_copyable<gtl::any>::value == false, "Expected std::is_trivially_copyable to be false."); REQUIRE(std::is_standard_layout<gtl::any>::value == true, "Expected std::is_standard_layout to be true."); } TEST(any, constructor, empty) { gtl::any any; testbench::do_not_optimise_away(any); } TEST(any, constructor, value) { gtl::any any(1); testbench::do_not_optimise_away(any); } TEST(any, evaluation, any) { gtl::any any(1); REQUIRE(static_cast<int>(any) == 1, "Unexpected value '%d' in any, expected %d.", static_cast<int>(any), 1); any = 1.0; REQUIRE(static_cast<int>(any) != 1, "Unexpected value '%d' in any, expected %f.", static_cast<int>(any), 1.0); REQUIRE(static_cast<double>(any) == 1.0, "Unexpected value '%f' in any, expected %f.", static_cast<double>(any), 1.0); const char* string = "Hello world!"; any = string; REQUIRE(testbench::is_string_same(static_cast<const char*>(any), string) == true, "gtl::any = '%s', expected '%s'", static_cast<char*>(any), string); }
37.736111
153
0.725801
gpdaniels
31367ebdf364ab93c56378453239e8db4f165daa
845
hh
C++
src/services/IAudioSystem.hh
Jamiras/RAIntegration
ccf3dea24d81aefdcf51535f073889d03272b259
[ "MIT" ]
71
2018-04-15T13:02:43.000Z
2022-03-26T11:19:18.000Z
src/services/IAudioSystem.hh
Jamiras/RAIntegration
ccf3dea24d81aefdcf51535f073889d03272b259
[ "MIT" ]
309
2018-04-15T12:10:59.000Z
2022-01-22T20:13:04.000Z
src/services/IAudioSystem.hh
Jamiras/RAIntegration
ccf3dea24d81aefdcf51535f073889d03272b259
[ "MIT" ]
17
2018-04-17T16:09:31.000Z
2022-03-04T08:49:03.000Z
#ifndef RA_SERVICES_IAUDIOSYSTEM_HH #define RA_SERVICES_IAUDIOSYSTEM_HH #pragma once #include <string> namespace ra { namespace services { class IAudioSystem { public: virtual ~IAudioSystem() noexcept = default; IAudioSystem(const IAudioSystem&) noexcept = delete; IAudioSystem& operator=(const IAudioSystem&) noexcept = delete; IAudioSystem(IAudioSystem&&) noexcept = delete; IAudioSystem& operator=(IAudioSystem&&) noexcept = delete; /// <summary> /// Plays the specified audio file. /// </summary> virtual void PlayAudioFile(const std::wstring& sPath) const = 0; /// <summary> /// Plays a simple beep. /// </summary> virtual void Beep() const = 0; protected: IAudioSystem() noexcept = default; }; } // namespace services } // namespace ra #endif // !RA_SERVICES_IAUDIOSYSTEM_HH
22.837838
68
0.697041
Jamiras
313af1a68f5f9e84dd822f1c5e48101be4c2ae39
2,760
hpp
C++
client_project/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_websocket_server.hpp
pertgame/battleframe
ffba8a7b4f7f45f1eed2c56060d9a2205fb1fdc9
[ "MIT" ]
1
2020-10-28T15:19:15.000Z
2020-10-28T15:19:15.000Z
client_project/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_websocket_server.hpp
pertgame/battleframe
ffba8a7b4f7f45f1eed2c56060d9a2205fb1fdc9
[ "MIT" ]
null
null
null
client_project/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_websocket_server.hpp
pertgame/battleframe
ffba8a7b4f7f45f1eed2c56060d9a2205fb1fdc9
[ "MIT" ]
1
2020-10-28T15:19:40.000Z
2020-10-28T15:19:40.000Z
/**************************************************************************** Copyright (c) 2019 Xiamen Yaji Software Co., Ltd. http://www.cocos.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall not use Cocos Creator software for developing other software or tools that's used for developing games. You are not granted to publish, distribute, sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. 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. ****************************************************************************/ #pragma once #include "base/ccConfig.h" #if (USE_SOCKET > 0) && (USE_WEBSOCKET_SERVER > 0) #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" namespace se { class Object; class Value; } SE_DECLARE_FINALIZE_FUNC(WebSocketServer_finalize); SE_DECLARE_FUNC(WebSocketServer_constructor); SE_DECLARE_FUNC(WebSocketServer_listen); SE_DECLARE_FUNC(WebSocketServer_close); SE_DECLARE_FUNC(WebSocketServer_onconnection); SE_DECLARE_FUNC(WebSocketServer_onclose); SE_DECLARE_FUNC(WebSocketServer_connections); SE_DECLARE_FUNC(WebSocketServer_Connection_constructor); SE_DECLARE_FUNC(WebSocketServer_Connection_finalize); SE_DECLARE_FUNC(WebSocketServer_Connection_close); SE_DECLARE_FUNC(WebSocketServer_Connection_send); SE_DECLARE_FUNC(WebSocketServer_Connection_ontext); SE_DECLARE_FUNC(WebSocketServer_Connection_onbinary); SE_DECLARE_FUNC(WebSocketServer_Connection_onconnect); SE_DECLARE_FUNC(WebSocketServer_Connection_onerror); SE_DECLARE_FUNC(WebSocketServer_Connection_onclose); SE_DECLARE_FUNC(WebSocketServer_Connection_ondata); SE_DECLARE_FUNC(WebSocketServer_Connection_headers); SE_DECLARE_FUNC(WebSocketServer_Connection_protocols); SE_DECLARE_FUNC(WebSocketServer_Connection_protocol); SE_DECLARE_FUNC(WebSocketServer_Connection_readyState); bool register_all_websocket_server(se::Object *obj); #endif //#if (USE_SOCKET > 0) && (USE_WEBSOCKET_SERVER > 0)
43.125
81
0.784058
pertgame
313c1df57682d95205aecc183739179d7eb3e32d
2,750
cpp
C++
src/sofq.cpp
Cetus-K/corder
cd635c3bf49f578952d65393270a9a980841299e
[ "MIT" ]
null
null
null
src/sofq.cpp
Cetus-K/corder
cd635c3bf49f578952d65393270a9a980841299e
[ "MIT" ]
null
null
null
src/sofq.cpp
Cetus-K/corder
cd635c3bf49f578952d65393270a9a980841299e
[ "MIT" ]
null
null
null
#include "corder.h" void sofq::init ( void ) { // temporary variable nq = (int)((co->q1-co->q0)/co->dq); } void sofq::write ( string filename, gofr *gf ) { // temporary variable int iab,isab; double r,q,sincqr; double *sq,**sabq,**ssabq; ofstream ofs,ofsab,ofssab; // memory allocation sq = alloc1d < double > (nq); sabq = alloc2d < double > (co->ntypes*co->ntypes,nq); ssabq = alloc2d < double > (co->nstypes*co->nstypes,nq); // calc [s(q)-1]/(4*pi)/(dr/2) for ( int iq=0; iq<nq; iq++ ) { q = (double)iq*co->dq + co->q0; sq[iq] = 0; for ( iab=0; iab<(co->ntypes*co->ntypes); iab++ ) sabq[iab][iq] = 0; for ( isab=0; isab<(co->nstypes*co->nstypes); isab++ ) ssabq[isab][iq] = 0; for ( int ir=0; ir<(gf->nr); ir++ ) { r = (double)ir*co->dr + co->r0; // sinc function if ( q*r == 0 ) sincqr = 1.0; else sincqr = sin(q*r)/q*r; // trapezoidal integrate g(r) if ( ir == 0 || ir == gf->nr-1 ) { sq[iq] += (gf->rhor[ir]-gf->rho)*sincqr*r*r; for ( int a=0; a<(co->ntypes); a++ ) { for ( int b=0; b<(co->ntypes); b++ ) { iab = a*co->ntypes+b; sabq[iab][iq] += (gf->rhoabr[iab][ir]-gf->rhob[b])*sincqr*r*r; } } for ( int spa=0; spa<(co->nstypes); spa++ ) { for ( int spb=0; spb<(co->nstypes); spb++ ) { isab = spa*co->nstypes+spb; ssabq[isab][iq] += (gf->rhosabr[isab][ir]-gf->rhosb[spb])*sincqr*r*r; } } } else { sq[iq] += 2.0*(gf->rhor[ir]-gf->rho)*sincqr*r*r; for ( int a=0; a<co->ntypes; a++ ) { for ( int b=0; b<co->ntypes; b++ ) { iab = a*co->ntypes+b; sabq[iab][iq] += 2.0*(gf->rhoabr[iab][ir]-gf->rhob[b])*sincqr*r*r; } } for ( int spa=0; spa<(co->nstypes); spa++ ) { for ( int spb=0; spb<(co->nstypes); spb++ ) { isab = spa*co->nstypes+spb; ssabq[isab][iq] += 2.0*(gf->rhosabr[isab][ir]-gf->rhosb[spb])*sincqr*r*r; } } } } } // write out ofs.open((filename+"-tot.dat").c_str(),ios::out); ofsab.open((filename+".dat").c_str(),ios::out); ofssab.open((filename+"-spec.dat").c_str(),ios::out); ofs << scientific << setprecision(5); ofsab << scientific << setprecision(5); ofssab << scientific << setprecision(5); for ( int iq=0; iq<nq; iq++ ) { q = (double)iq*co->dq + co->q0; ofs << q << "\t" << 1.0+4.0*pi*sq[iq]*(0.5*co->dr) << endl; ofsab << q; ofssab << q; for ( iab=0; iab<(co->ntypes*co->ntypes); iab++ ) ofsab << "\t" << 1.0+4.0*pi*sabq[iab][iq]*(0.5*co->dr); for ( isab=0; isab<(co->nstypes*co->nstypes); isab++ ) ofssab << "\t" << 1.0+4.0*pi*ssabq[isab][iq]*(0.5*co->dr); ofsab << endl; ofssab << endl; } ofs.close(); ofsab.close(); ofssab.close(); // free free1d < double > (sq); free2d < double > (sabq); free2d < double > (ssabq); }
28.350515
78
0.532727
Cetus-K
313ee682299decc46e27a354cbf0daf7a41268c1
458
hpp
C++
modules/engine/include/randar/Render/Palette/Palette.hpp
litty-studios/randar
95daae57b1ec7d87194cdbcf6e3946b4ed9fc79b
[ "MIT" ]
1
2016-11-12T02:43:29.000Z
2016-11-12T02:43:29.000Z
modules/engine/include/randar/Render/Palette/Palette.hpp
litty-studios/randar
95daae57b1ec7d87194cdbcf6e3946b4ed9fc79b
[ "MIT" ]
null
null
null
modules/engine/include/randar/Render/Palette/Palette.hpp
litty-studios/randar
95daae57b1ec7d87194cdbcf6e3946b4ed9fc79b
[ "MIT" ]
null
null
null
#ifndef RANDAR_RENDER_PALETTE_HPP #define RANDAR_RENDER_PALETTE_HPP #include <randar/Render/Color.hpp> namespace randar { /** * A color palette. * * Used to sample specifically random colors. */ struct Palette { /** * Destructor. */ virtual ~Palette(); /** * Samples a color randomly from the palette. */ virtual Color color() const = 0; }; } #endif
16.357143
53
0.552402
litty-studios
314166729c3e1e02d10cda4472f0f89d98974f7a
1,124
cpp
C++
client/client.cpp
scholzf98/usermode-and-kernel-source-r6-
e786efcf1ba8d519b2bf18823f4c067ecf5ab739
[ "MIT" ]
null
null
null
client/client.cpp
scholzf98/usermode-and-kernel-source-r6-
e786efcf1ba8d519b2bf18823f4c067ecf5ab739
[ "MIT" ]
null
null
null
client/client.cpp
scholzf98/usermode-and-kernel-source-r6-
e786efcf1ba8d519b2bf18823f4c067ecf5ab739
[ "MIT" ]
1
2021-05-05T00:29:11.000Z
2021-05-05T00:29:11.000Z
#include "client.h" int main( ) { SetConsoleTitle( "" ); // ** get function that is hooked by driver ** void* fn = kernel_control_function( ); unsigned long pid = GetCurrentProcessId( ); uint64_t loaded_check = call_driver_control( fn, ID_CONFIRM_DRIVER_LOADED ); if ( loaded_check != 0 ) printf( "[!] driver communication not set up\n" ); // ** basic memory ** uint64_t process_base = call_driver_control( fn, ID_GET_PROCESS_BASE, pid ); printf( "[-] process_base: %llx\n", process_base ); uint32_t read_result = read_virtual_memory<uint32_t>( fn, pid, process_base ); printf( "[-] read_result: %lx\n", read_result ); // ** module ** const wchar_t module_name[] = L"kernel32.dll"; uint64_t module_base = call_driver_control( fn, ID_GET_PROCESS_MODULE, pid, module_name ); // hardcoded for kernel32.dll printf( "[-] kernel32.dll: %llx\n", module_base ); // ** unhook ** printf( "[-] unhook result: %llx\n", call_driver_control( fn, ID_REMOVE_HOOK ) ); while ( ( GetAsyncKeyState( VK_F12 ) & 1 ) == 0 ) Sleep( 100 ); return 0; }
22.938776
122
0.644128
scholzf98
3143f5367a05102a7bc4bd0765bc25afd1f783ca
1,559
cpp
C++
main.cpp
amungo/SdMerge
24f95bbe4e5246eb99416c10a6937b0187bc26fa
[ "BSD-2-Clause" ]
null
null
null
main.cpp
amungo/SdMerge
24f95bbe4e5246eb99416c10a6937b0187bc26fa
[ "BSD-2-Clause" ]
null
null
null
main.cpp
amungo/SdMerge
24f95bbe4e5246eb99416c10a6937b0187bc26fa
[ "BSD-2-Clause" ]
1
2022-03-09T18:35:38.000Z
2022-03-09T18:35:38.000Z
#include <cstdio> #include <vector> #include "utils.h" using namespace std; int main(int argc, char *argv[]) { if ( argc != 5 ) { fprintf( stderr, "Usage:\n" ); fprintf( stderr, "SdMerge BLOCK_SIZE srcfileA srcfileB outfile\n\n" ); return 0; } const char* f0name = argv[2]; const char* f1name = argv[3]; int block_size = atoi(argv[1]); FILE* f0 = fopen( f0name, "rb" ); FILE* f1 = fopen( f1name, "rb" ); FILE* fout = fopen( argv[4], "wb" ); if ( !f0 || !f1 || !fout ) { fprintf(stderr, "File open error\n"); return 1; } size_t f0size = get_file_size( f0name ); size_t f1size = get_file_size( f1name ); if ( f0size != f1size ) { fprintf( stderr, "Sizes of input files are not equal\n" ); return 2; } size_t bcnt = f0size / block_size; if ( bcnt == 0 ) { fprintf( stderr, "Block size = %zu, file_size = %zu ==> blocks count is %zu.\n Too small files or block size is incorrect\n", block_size, f0size, bcnt ); } vector<uint8_t> buf0( block_size ); vector<uint8_t> buf1( block_size ); for ( int i = 0; i < bcnt; i++ ) { fread( buf0.data(), 1, block_size, f0 ); fread( buf1.data(), 1, block_size, f1 ); fwrite( buf0.data(), 1, block_size, fout ); fwrite( buf1.data(), 1, block_size, fout ); } fprintf( stderr, "Closing files now...\n" ); fclose( f0 ); fclose( f1 ); fclose( fout ); fprintf( stderr, "Done.\n" ); return 0; }
24.746032
133
0.547146
amungo
3147097f983502bb136fc40efd98dddaf2c8ed2f
1,316
cpp
C++
src/internal_lexer_builder.cpp
mohitmv/aparse
34a6811f9a3d4f1c5dd21ed874b14e59e6725746
[ "MIT" ]
2
2021-04-15T20:02:37.000Z
2021-04-17T18:18:50.000Z
src/internal_lexer_builder.cpp
mohitmv/aparse
34a6811f9a3d4f1c5dd21ed874b14e59e6725746
[ "MIT" ]
1
2019-10-07T10:41:52.000Z
2019-10-07T10:41:52.000Z
src/internal_lexer_builder.cpp
mohitmv/aparse
34a6811f9a3d4f1c5dd21ed874b14e59e6725746
[ "MIT" ]
1
2020-05-05T16:52:20.000Z
2020-05-05T16:52:20.000Z
// Copyright: 2015 Mohit Saini // Author: Mohit Saini (mohitsaini1196@gmail.com) #include "src/internal_lexer_builder.hpp" #include <memory> #include <unordered_map> #include "src/lexer_machine_builder.hpp" namespace aparse { // sttaic bool InternalLexerBuilder::Build(const InternalLexerGrammar& lexer_grammar, Lexer* output) { if (lexer_grammar.rules.size() == 0) { throw Error(Error::LEXER_BUILDER_ERROR_MUST_HAVE_NON_ZERO_RULES)(); } int index_counter = 1; unordered_map<int, LexerMachine::DFA> dfa_map; vector<int> section_id_list; for (auto& section : lexer_grammar.rules) { Regex regex_union(Regex::UNION); for (auto& rule : section.second) { auto regex = rule.regex; regex.label = index_counter++; output->pattern_actions[regex.label] = rule.action; regex_union.children.emplace_back(regex); } auto nfa = LexerMachineBuilder::BuildNFA(regex_union); LexerMachineBuilder::BuildDFA(nfa, &dfa_map[section.first]); } output->main_section = lexer_grammar.main_section; LexerMachineBuilder::MergeDFA( dfa_map, lexer_grammar.main_section, &output->machine.dfa, &output->section_to_start_state_mapping); output->machine.initialized = true; return output->Finalize(); } } // namespace aparse
29.909091
75
0.711246
mohitmv
314af6cb0e21853b5b087ab99237bbeeae33b960
2,211
cpp
C++
component/edriver/colorled.cpp
eboxmaker/eboxFramework-rtt
9718678422f56faec1cf21a6a8fd3f72441bea33
[ "MIT" ]
115
2018-08-12T08:41:17.000Z
2022-03-08T07:43:48.000Z
component/edriver/colorled.cpp
eboxmaker/eboxFramework-rtt
9718678422f56faec1cf21a6a8fd3f72441bea33
[ "MIT" ]
4
2018-08-13T10:14:55.000Z
2019-07-03T06:54:10.000Z
component/edriver/colorled.cpp
eboxmaker/eboxFramework-rtt
9718678422f56faec1cf21a6a8fd3f72441bea33
[ "MIT" ]
59
2018-09-02T21:54:25.000Z
2022-01-13T02:28:28.000Z
/** ****************************************************************************** * @file colorled.cpp * @author shentq * @version V2.1 * @date 2016/08/14 * @brief ****************************************************************************** * @attention * * No part of this software may be used for any commercial activities by any form * or means, without the prior written consent of shentq. This specification is * preliminary and is subject to change at any time without notice. shentq assumes * no responsibility for any errors contained herein. * <h2><center>&copy; Copyright 2015 shentq. All Rights Reserved.</center></h2> ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "colorled.h" void ColorLed::begin() { r = new Pwm(r_pin); g = new Pwm(g_pin); b = new Pwm(b_pin); r->begin(1000, 0); g->begin(1000, 0); b->begin(1000, 0); r->set_oc_polarity(0); g->set_oc_polarity(0); b->set_oc_polarity(0); } void ColorLed::color_rgb(uint8_t r, uint8_t g, uint8_t b) { this->r->set_duty(r * 3); this->g->set_duty(g * 3); this->b->set_duty(b * 3); } void ColorLed::color_hsl(int h, float s, float l) { COLOR_HSL hsl; COLOR_RGB rgb; hsl.h = h; hsl.s = s; hsl.l = l; HSL_to_RGB(hsl, rgb); this->r->set_duty(rgb.r * 1.9); this->g->set_duty(rgb.g * 3.9); this->b->set_duty(rgb.b * 0.6); } void ColorLed::color_hsl(COLOR_HSL &hsl) { COLOR_RGB rgb; HSL_to_RGB(hsl, rgb); this->r->set_duty(rgb.r * 1.9); this->g->set_duty(rgb.g * 3.9); this->b->set_duty(rgb.b * 0.6); } void ColorLed::color_hsv(int h, float s, float v) { COLOR_HSV hsv; COLOR_RGB rgb; hsv.h = h; hsv.s = s; hsv.v = v; HSV_to_RGB(hsv, rgb); this->r->set_duty(rgb.r * 1.9); this->g->set_duty(rgb.g * 3.9); this->b->set_duty(rgb.b * 0.6); } void ColorLed::color_hsv(COLOR_HSV &hsv) { COLOR_RGB rgb; HSV_to_RGB(hsv, rgb); this->r->set_duty(rgb.r * 1.9); this->g->set_duty(rgb.g * 3.9); this->b->set_duty(rgb.b * 0.6); }
23.774194
83
0.515604
eboxmaker
31509082a623dc8c5ea0cc5e3725db58c7e1b42b
3,083
hpp
C++
source/modules/problem/hierarchical/hierarchical.hpp
JonathanLehner/korali
90f97d8e2fed2311f988f39cfe014f23ba7dd6cf
[ "MIT" ]
43
2018-07-26T07:20:42.000Z
2022-03-02T10:23:12.000Z
source/modules/problem/hierarchical/hierarchical.hpp
JonathanLehner/korali
90f97d8e2fed2311f988f39cfe014f23ba7dd6cf
[ "MIT" ]
212
2018-09-21T10:44:07.000Z
2022-03-22T14:33:05.000Z
source/modules/problem/hierarchical/hierarchical.hpp
JonathanLehner/korali
90f97d8e2fed2311f988f39cfe014f23ba7dd6cf
[ "MIT" ]
16
2018-07-25T15:00:36.000Z
2022-03-22T14:19:46.000Z
/** \namespace problem * @brief Namespace declaration for modules of type: problem. */ /** \file * @brief Header file for module: Hierarchical. */ /** \dir problem/hierarchical * @brief Contains code, documentation, and scripts for module: Hierarchical. */ #pragma once #include "modules/problem/problem.hpp" namespace korali { namespace problem { ; /** * @brief Class declaration for module: Hierarchical. */ class Hierarchical : public Problem { private: public: /** * @brief Obtains the entire current state and configuration of the module. * @param js JSON object onto which to save the serialized state of the module. */ void getConfiguration(knlohmann::json& js) override; /** * @brief Sets the entire state and configuration of the module, given a JSON object. * @param js JSON object from which to deserialize the state of the module. */ void setConfiguration(knlohmann::json& js) override; /** * @brief Applies the module's default configuration upon its creation. * @param js JSON object containing user configuration. The defaults will not override any currently defined settings. */ void applyModuleDefaults(knlohmann::json& js) override; /** * @brief Applies the module's default variable configuration to each variable in the Experiment upon creation. */ void applyVariableDefaults() override; /** * @brief Runs the operation specified on the given sample. It checks recursively whether the function was found by the current module or its parents. * @param sample Sample to operate on. Should contain in the 'Operation' field an operation accepted by this module or its parents. * @param operation Should specify an operation type accepted by this module or its parents. * @return True, if operation found and executed; false, otherwise. */ bool runOperation(std::string operation, korali::Sample& sample) override; void initialize() override; /** * @brief Checks whether the proposed sample fits within the range of the prior distribution. * @param sample A Korali Sample * @return True, if feasible; false, otherwise. */ bool isSampleFeasible(korali::Sample &sample); /** * @brief Produces a generic evaluation from the Posterior distribution of the sample, for optimization with CMAES, DEA, storing it in and stores it in sample["F(x)"]. * @param sample A Korali Sample */ virtual void evaluate(korali::Sample &sample); /** * @brief Evaluates the log prior of the given sample, and stores it in sample["Log Prior"] * @param sample A Korali Sample */ void evaluateLogPrior(korali::Sample &sample); /** * @brief Evaluates the log likelihood of the given sample, and stores it in sample["Log Likelihood"] * @param sample A Korali Sample */ virtual void evaluateLogLikelihood(korali::Sample &sample) = 0; /** * @brief Evaluates the log posterior of the given sample, and stores it in sample["Log Posterior"] * @param sample A Korali Sample */ void evaluateLogPosterior(korali::Sample &sample); }; } //problem } //korali ;
31.783505
169
0.722997
JonathanLehner
3158b5500d579054f45836f9a28d233d0f7792be
343
cpp
C++
solutions/1015.smallest-integer-divisible-by-k.378784762.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
78
2020-10-22T11:31:53.000Z
2022-02-22T13:27:49.000Z
solutions/1015.smallest-integer-divisible-by-k.378784762.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
null
null
null
solutions/1015.smallest-integer-divisible-by-k.378784762.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
26
2020-10-23T15:10:44.000Z
2021-11-07T16:13:50.000Z
class Solution { public: int smallestRepunitDivByK(int K) { vector<bool> visited(K); int candidate = 1; int ans = 1; while (candidate % K) { if (visited[candidate]) return -1; visited[candidate] = true; candidate = candidate * 10 + 1; candidate %= K; ans++; } return ans; } };
19.055556
37
0.548105
satu0king
315908274535fba099818d9f93f0a7d9b4b3556c
1,845
hpp
C++
include/chopper/build/read_chopper_pack_file.hpp
Felix-Droop/Chopper
5cc214103b2d088ae400bec0fde8973e03dd3095
[ "BSD-3-Clause" ]
null
null
null
include/chopper/build/read_chopper_pack_file.hpp
Felix-Droop/Chopper
5cc214103b2d088ae400bec0fde8973e03dd3095
[ "BSD-3-Clause" ]
null
null
null
include/chopper/build/read_chopper_pack_file.hpp
Felix-Droop/Chopper
5cc214103b2d088ae400bec0fde8973e03dd3095
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include <cstdlib> #include <fstream> #include <set> #include <string> #include <tuple> #include <vector> #include <seqan3/std/ranges> #include <chopper/build/build_data.hpp> #include <chopper/detail_parse_chopper_pack_header_line.hpp> #include <chopper/detail_parse_chopper_pack_line.hpp> auto read_chopper_pack_file(std::string const & chopper_pack_filename) { build_data data; std::vector<std::vector<chopper_pack_record>> records_per_hibf_bin{}; std::ifstream chopper_pack_file{chopper_pack_filename}; if (!chopper_pack_file.good() || !chopper_pack_file.is_open()) throw std::logic_error{"Could not open file " + chopper_pack_filename + " for reading"}; // parse header // ------------------------------------------------------------------------- std::string current_line; while (std::getline(chopper_pack_file, current_line) && current_line[0] == '#') parse_chopper_pack_header_line(current_line, data); // pack and split header are the same // parse lines // ------------------------------------------------------------------------- do { chopper_pack_record const && record = parse_chopper_pack_line(current_line); data.num_libfs += (record.lidx != -1); if (records_per_hibf_bin.size() <= record.hidx) records_per_hibf_bin.resize(record.hidx + ((record.lidx == -1) ? record.bins : 1)); records_per_hibf_bin[record.hidx].push_back(record); } while (std::getline(chopper_pack_file, current_line)); for (auto & records : records_per_hibf_bin) std::ranges::sort(records, [] (auto const & rec1, auto const & rec2) { return rec1.lidx < rec2.lidx; }); data.hibf_num_technical_bins = records_per_hibf_bin.size(); return std::make_pair(std::move(data), std::move(records_per_hibf_bin)); };
35.480769
112
0.645528
Felix-Droop
3179b309e18662e1943eab749b76932a952504dc
1,931
cpp
C++
lib/srvidentity.cpp
timmyw/ofsystem
6f955d53dc3025148763333bea0a11d0bce28c06
[ "MIT" ]
null
null
null
lib/srvidentity.cpp
timmyw/ofsystem
6f955d53dc3025148763333bea0a11d0bce28c06
[ "MIT" ]
null
null
null
lib/srvidentity.cpp
timmyw/ofsystem
6f955d53dc3025148763333bea0a11d0bce28c06
[ "MIT" ]
null
null
null
/* Copyright (C) 1997-2011 by Suntail.com AS, Tim Whelan 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 <ofsys.h> #include <srvidentity.h> const SRVIDENTITY SRVIDENTITY::NullSrvID( "0000000000000000" ); ostream & operator << ( ostream &s, const SRVIDENTITY &id ) { return s << hex << setfill('0') << setw(16) << id.m_id << dec; } bool SRVIDENTITY::isNull() const { return m_id == NullSrvID.m_id; } void readFromBlob( SRVIDENTITYLIST* list, StorageBlob* b ) { ofuint32 c = b->readInt32 (); list->reserve (c); for(; c; c--) { SRVIDENTITY* i = new SRVIDENTITY; b->readServerIdentity (i); list->push_back (i); } } void dumpToBlob(SRVIDENTITYLIST* list, StorageBlob* b) { assert(list); b->writeInt32( list->size() ); for ( SRVIDENTITYLIST::iterator i = list->begin(); i != list->end(); i++ ) b->writeServerIdentity( *i ); }
31.145161
78
0.702745
timmyw
317bd2e12c90ddaa1af2927b76ba7d14320eadb3
2,363
cpp
C++
A-Array/Reversingofarray.cpp
riyasingh240601/LearnCPP
5dc75a4d7cd1a1c4519018bc4ef1f54151c0a8ed
[ "MIT" ]
2
2022-03-10T12:28:22.000Z
2022-03-10T12:28:32.000Z
A-Array/Reversingofarray.cpp
riyasingh240601/LearnCPP
5dc75a4d7cd1a1c4519018bc4ef1f54151c0a8ed
[ "MIT" ]
null
null
null
A-Array/Reversingofarray.cpp
riyasingh240601/LearnCPP
5dc75a4d7cd1a1c4519018bc4ef1f54151c0a8ed
[ "MIT" ]
1
2022-03-26T08:23:30.000Z
2022-03-26T08:23:30.000Z
#include <iostream> using namespace std; // Utility function to print elements of an array void print(int arr[], int n) { for (int i = 0; i < n; i++) { cout << arr[i] << " "; } } /* 1. Using Auxiliary Array we can create an auxiliary array of the same type and size as the input array, fill it with elements from the original array in reverse order, and then copy the contents of the auxiliary array into the original one.*/ void reverse1(int arr[], int n) { int aux[n]; //Initializing the auxilliary array for (int i = 0; i < n; i++) { aux[n - 1 - i] = arr[i]; //copying elements from main array(arr) to auxilliary array(aux) in reverse order } for (int i = 0; i < n; i++) { arr[i] = aux[i]; //again copying elements from auxilliary array(aux) to main array(arr) } //Time-Complexity-->O(n) where n is the total number of elements in array //space-complexity-->O(n) -->as we are using auxilliary array for reversing the main array } /* 1. Using high and low pointers we can initialize two poinetrs high and low and swapping arr[low] with arr[high] with reverse our main array(arr) without using any auxuliaary array*/ void reverse2(int arr[], int n) { for (int low = 0, high = n - 1; low < high; low++, high--) { swap(arr[low], arr[high]); //swapping the elements from wiht the help of high and low pointers } //Time-Complexity-->O(n) where n is the total number of elements in array //space-complexity-->O(1) -->Constant } int main() { cout<<"Enter size of array"<<endl; int n; cin>>n; //taking n (size of array) as input int arr[n]; cout<<"Enter "<<n<<" elements of array"<<endl; for(int i=0;i<n;i++) { //taking array as input cin>>arr[i]; } //calling the utility function reverse1 with passing two arguments array and size of array for reversing the array with the help of auxulliary array reverse1(arr, n); //calling the utility function reverse2 with passing two arguments array and size of array for reversing the array with method 2 (with the help of swapping reverse2(arr,n); //calling another utility function with same arguments for printing the result print(arr, n); return 0; }
32.819444
159
0.628015
riyasingh240601
317debe52d7987ec63075a1503d1009f0ff75b43
4,931
cpp
C++
source/mono/MonoLibLoader.cpp
SuiMachine/Ultimate-ASI-Loader
b3ec0950df5ac7fa057bc9af8298bcfb6241f107
[ "MIT" ]
null
null
null
source/mono/MonoLibLoader.cpp
SuiMachine/Ultimate-ASI-Loader
b3ec0950df5ac7fa057bc9af8298bcfb6241f107
[ "MIT" ]
null
null
null
source/mono/MonoLibLoader.cpp
SuiMachine/Ultimate-ASI-Loader
b3ec0950df5ac7fa057bc9af8298bcfb6241f107
[ "MIT" ]
null
null
null
#pragma once #include "MonoLibLoader.h" #include <string> //For base reference see https://www.unknowncheats.me/forum/rust/114627-loader-titanium-alternative.html intptr_t dwReturn; void DoTheHighLevelMonoThing() { auto instance = MonoLibLoader::GetInstance(); instance->monoDll.mono_security_set_mode(NULL); auto domain = instance->monoDll.mono_domain_get(); try { for (int i = 0; i < instance->LibsToLoad.size(); i++) { auto domainAssemblyOpen = instance->monoDll.mono_domain_assembly_open(domain, instance->LibsToLoad.at(i).library.c_str()); if (domainAssemblyOpen != NULL) { auto assemblyImage = instance->monoDll.mono_assembly_get_image(domainAssemblyOpen); if (assemblyImage != NULL) { auto klass = instance->monoDll.mono_class_from_name(assemblyImage, instance->LibsToLoad.at(i).className.c_str(), instance->LibsToLoad.at(i).className.c_str()); if (klass != NULL) { auto methodFromName = instance->monoDll.mono_class_get_method_from_name(klass, instance->LibsToLoad.at(i).initializerMethodName.c_str(), 0); if (methodFromName != NULL) { auto result = instance->monoDll.mono_runtime_invoke(methodFromName, NULL, NULL, NULL); if (result == NULL) { OutputDebugString(L"Fuck!"); } } else OutputDebugString(L"Method name ended up being null!"); } else OutputDebugString(L"Class name ended up being null!"); } else OutputDebugString(L"Assembly Image ended up being null!"); } else OutputDebugString(L"Domain Assembly Open returned null!"); } } catch (const std::exception e) { } } __declspec(naked) int MonoInject() { __asm { push dwReturn; pushfd; pushad; }; DoTheHighLevelMonoThing(); __asm { // restore the execution state popad; popfd; // go about original game 'bidness ret; } } MonoLibLoader* MonoLibLoader::instance = NULL; MonoLibLoader* MonoLibLoader::GetInstance() { if (!instance) { instance = new MonoLibLoader(); return instance; } else return instance; } void MonoLibLoader::StartThread() { loaderThread = std::thread(&MonoLibLoader::DoThreadWork, this, this); } void MonoLibLoader::Deinject(const WCHAR* text) { if (text) { MessageBox(NULL, text, L"Error", MB_OK | MB_ICONERROR | MB_TOPMOST); } } void MonoLibLoader::Inject() { FILETIME CreationTime, ExitTime, KernelTime, UserTime; CONTEXT context = { CONTEXT_CONTROL }; // poll for mono while ((this->monoDll.dll = GetModuleHandle(L"mono.dll")) == NULL) Sleep(10); // acquire functions auto test = GetProcAddress(this->monoDll.dll, "mono_security_get_mode"); //monoDll.mono_security_get_mode = (LP_mono_security_get_mode)(void))GetProcAddress(monoDll.dll, "mono_security_get_mode"); monoDll.mono_security_set_mode = (LP_mono_security_set_mode)GetProcAddress(monoDll.dll, "mono_security_set_mode"); monoDll.mono_domain_get = (LP_mono_domain_get)GetProcAddress(monoDll.dll, "mono_domain_get"); monoDll.mono_domain_assembly_open = (LP_mono_domain_assembly_open)GetProcAddress(monoDll.dll, "mono_domain_assembly_open"); monoDll.mono_assembly_get_image = (LP_mono_assembly_get_image)GetProcAddress(monoDll.dll, "mono_assembly_get_image"); monoDll.mono_class_from_name = (LP_mono_class_from_name)GetProcAddress(monoDll.dll, "mono_class_from_name"); monoDll.mono_class_get_method_from_name = (LP_mono_class_get_method_from_name)GetProcAddress(monoDll.dll, "mono_class_get_method_from_name"); monoDll.mono_runtime_invoke = (LP_mono_runtime_invoke)GetProcAddress(monoDll.dll, "mono_runtime_invoke"); DWORD id = NULL; DWORD pID = GetCurrentProcessId(); HANDLE hSs = CreateToolhelp32Snapshot(TH32CS_SNAPALL, pID); THREADENTRY32 t; t.dwSize = sizeof(THREADENTRY32); if (hSs) { unsigned long time = 0xFFFFFFFFFFFFFFFF; if (Thread32First(hSs, &t)) { do { if (t.th32OwnerProcessID == pID) { HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION, FALSE, t.th32ThreadID); if (hThread) { if (GetThreadTimes(hThread, &CreationTime, &ExitTime, &KernelTime, &UserTime)) { // nasty casting lol if (time > (unsigned long)&CreationTime) { time = (unsigned long)&CreationTime; id = t.th32ThreadID; } } CloseHandle(hThread); } } } while (Thread32Next(hSs, &t)); } else { Deinject(L"Couldn't acquire the main thread."); return; } } if (id) { Sleep(2000); HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION | THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | THREAD_SET_CONTEXT, FALSE, id); if (hThread) { SuspendThread(hThread); if (GetThreadContext(hThread, &context)) { dwReturn = context.Eip; context.Eip = (intptr_t)MonoInject; SetThreadContext(hThread, &context); } else { Deinject(L"Couldn't hijack the main thread!"); return; } ResumeThread(hThread); } } }
26.654054
164
0.709187
SuiMachine
3184cb7b1e9af5dd038c94dc75ad6d4f37b429ac
1,248
hpp
C++
lib/isa/include/isa/alu.hpp
richhorvath/QtPieISA
ebbb8aafd84521571456c337897be704e1dba1d8
[ "MIT" ]
null
null
null
lib/isa/include/isa/alu.hpp
richhorvath/QtPieISA
ebbb8aafd84521571456c337897be704e1dba1d8
[ "MIT" ]
null
null
null
lib/isa/include/isa/alu.hpp
richhorvath/QtPieISA
ebbb8aafd84521571456c337897be704e1dba1d8
[ "MIT" ]
null
null
null
#ifndef LIB_ISA_ALU_HPP_ #define LIB_ISA_ALU_HPP_ class ALU { public: /** * The following functors are classes used to pass in template types to * corresponding r type instruction. */ template <typename T> struct subtract { T operator()(T x, T y) { return x - y; } }; /**********************************************************************/ template <typename T> struct modulus { T operator()(T x, T y) { return x % y; } }; /**********************************************************************/ template <typename T> struct bitwiseAnd { T operator()(T x, T y) { return x | y; } }; /**********************************************************************/ template <typename T> struct add { T operator()(T x, T y) { return x + y; } }; /**********************************************************************/ template <typename T> struct divide { T operator()(T x, T y) { return x / y; } }; /**********************************************************************/ template <typename T> struct multiply { T operator()(T x, T y) { return x * y; } }; /**********************************************************************/ }; #endif // LIB_ISA_ALU_HPP_
23.111111
74
0.377404
richhorvath
3185fe0a22dced73b823cbaaf6aae2920fcc0689
433
cpp
C++
src/host.cpp
marc-despland/httpd
da3258b5c84eacbd662245e49bbe81822537c548
[ "Apache-2.0" ]
null
null
null
src/host.cpp
marc-despland/httpd
da3258b5c84eacbd662245e49bbe81822537c548
[ "Apache-2.0" ]
null
null
null
src/host.cpp
marc-despland/httpd
da3258b5c84eacbd662245e49bbe81822537c548
[ "Apache-2.0" ]
null
null
null
#include "host.h" Host::Host(string name, unsigned int port) { this->myname=name; this->myport=port; } Host::~Host() { } unsigned int Host::port() { return this->myport; } string Host::name() { return this->myname; } std::ostream & operator<<(std::ostream &os, const Host& h) { return os << h.myname<<":"<<h.myport; } std::ostream & operator<<(std::ostream &os, const Host * h) { return os << h->myname<<":"<<h->myport; }
17.32
61
0.623557
marc-despland
3187af7b610eb2226732ce58fbd7f05c61569371
2,485
hpp
C++
src/xalanc/Utils/MsgCreator/IndexFileData.hpp
rherardi/xml-xalan-c-src_1_10_0
24e6653a617a244e4def60d67b57e70a192a5d4d
[ "Apache-2.0" ]
null
null
null
src/xalanc/Utils/MsgCreator/IndexFileData.hpp
rherardi/xml-xalan-c-src_1_10_0
24e6653a617a244e4def60d67b57e70a192a5d4d
[ "Apache-2.0" ]
null
null
null
src/xalanc/Utils/MsgCreator/IndexFileData.hpp
rherardi/xml-xalan-c-src_1_10_0
24e6653a617a244e4def60d67b57e70a192a5d4d
[ "Apache-2.0" ]
null
null
null
/* * Copyright 1999-2004 The Apache Software Foundation. * * 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. */ #if !defined(INDEX_FILE_DATA_1357924680) #define INDEX_FILE_DATA_1357924680 #include <xercesc/util/XercesDefs.hpp> const char* szApacheLicense[]={ "/*\n", "* Copyright 1999-2004 The Apache Software Foundation.\n", "*\n", "* Licensed under the Apache License, Version 2.0 (the \"License\");\n", "* you may not use this file except in compliance with the License.\n", "* You may obtain a copy of the License at\n", "*\n", "* http://www.apache.org/licenses/LICENSE-2.0\n", "*\n", "* Unless required by applicable law or agreed to in writing, software\n", "* distributed under the License is distributed on an \"AS IS\" BASIS,\n", "* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", "* See the License for the specific language governing permissions and\n", "* limitations under the License.\n", "*/\n", "\n", "\n", "// ----------------------------------------------------------------\n", "// This file was generated from the XalanC error message source.\n", "// so do not edit this file directly!!\n", "// ----------------------------------------------------------------\n", 0}; static const char* szStartIndexFile[]= { "\n", "\n", "\n", "\n", "#if !defined(XALAN_MSG_LOADER_INDEX_GUARD_1357924680) \n", "#define XALAN_MSG_LOADER_INDEX_GUARD_1357924680 \n", "\n", "\n", "\n", "XALAN_CPP_NAMESPACE_BEGIN\n", "\n", "\n", "class XalanMessages", "{ \n", "public : \n", " enum Codes \n", " { \n", " ", 0 }; static const char* szEndIndexFile[]= { " };\n", "\n", "\n", "};\n", "\n", "\n", "XALAN_CPP_NAMESPACE_END \n", "\n", "\n", "#endif //XALAN_MSG_LOADER_INDEX_GUARD_1357924680 \n", "\n", "\n", 0 }; static const char* szBeginIndexLine[]= { " ,", 0 }; #endif //INDEX_FILE_DATA_1357924680
24.85
81
0.608853
rherardi
3188856eaf34d47e0ca7c25e4774318809d508da
796
hpp
C++
Sources/AGEngine/Graphic/DRBLightElementManager.hpp
Another-Game-Engine/AGE
d5d9e98235198fe580a43007914f515437635830
[ "MIT" ]
47
2015-03-29T09:44:25.000Z
2020-11-30T10:05:56.000Z
Sources/AGEngine/Graphic/DRBLightElementManager.hpp
Another-Game-Engine/AGE
d5d9e98235198fe580a43007914f515437635830
[ "MIT" ]
313
2015-01-01T18:16:30.000Z
2015-11-30T07:54:07.000Z
Sources/AGEngine/Graphic/DRBLightElementManager.hpp
Another-Game-Engine/AGE
d5d9e98235198fe580a43007914f515437635830
[ "MIT" ]
9
2015-06-07T13:21:54.000Z
2020-08-25T09:50:07.000Z
#pragma once #include <memory> #include "Utils/ObjectPool.hpp" #include "Utils/Dependency.hpp" #include "DRBPointLight.hpp" #include "DRBSpotLight.hpp" namespace AGE { class BFCCullableHandle; class BFCBlockManagerFactory; class IProperty; // That's a SCENE dependency, and not a global one, set on per scene class DRBLightElementManager : public Dependency<DRBLightElementManager> { public: DRBLightElementManager(BFCBlockManagerFactory *factory); BFCCullableHandle addPointLight(); BFCCullableHandle addSpotLight(); void removePointLight(BFCCullableHandle &handle); void removeSpotLight(BFCCullableHandle &handle); private: BFCBlockManagerFactory *_bfcBlockManager = nullptr; ObjectPool<DRBPointLight> _pointLightPool; ObjectPool<DRBSpotLight> _spotLightPool; }; }
25.677419
73
0.797739
Another-Game-Engine
318a3e5e0bc44630ff492f82d258df199f57b1d8
1,944
cpp
C++
urutils.cpp
PavelNajman/QURScanner
d0990f4a84c40425dfa6a3d55020bb2ca5bf012b
[ "MIT" ]
null
null
null
urutils.cpp
PavelNajman/QURScanner
d0990f4a84c40425dfa6a3d55020bb2ca5bf012b
[ "MIT" ]
null
null
null
urutils.cpp
PavelNajman/QURScanner
d0990f4a84c40425dfa6a3d55020bb2ca5bf012b
[ "MIT" ]
null
null
null
/* * Copyright (c) 2021 Pavel Najman * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to dea 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 "urutils.h" #include <regex> namespace qurscanner { bool IsMultiPartUr(const std::string& str) { const auto multiPartUrRegex = std::regex("[uU][rR]:[a-zA-Z0-9-]+/[1-9][0-9]*-[1-9][0-9]*/[a-zA-Z]+"); return std::regex_match(str, multiPartUrRegex); } bool IsSinglePartUr(const std::string& str) { const auto singlePartUrRegex = std::regex("[uU][rR]:[a-zA-Z0-9-]+/[a-zA-Z]+"); return std::regex_match(str, singlePartUrRegex); } int GetMultipartUrSeqNum(const std::string& str) { const auto multiPartUrRegexWithSeqNumCapture = std::regex("[uU][rR]:[a-zA-Z0-9-]+/([1-9][0-9]*)-[1-9][0-9]*/[a-zA-Z]+"); std::smatch match; if (std::regex_match(str, match, multiPartUrRegexWithSeqNumCapture)) { return std::stoi(match.str(1)); } return -1; } } // namespace qurscanner
38.117647
124
0.708848
PavelNajman
318b8e214b6735179ee21dacd6d769510d38cee5
1,386
cpp
C++
unittest/Rail_connect_Test.cpp
romadidukh/trains
57200efbb079cdc3844d4626ec38197ad863b9bb
[ "Apache-2.0" ]
null
null
null
unittest/Rail_connect_Test.cpp
romadidukh/trains
57200efbb079cdc3844d4626ec38197ad863b9bb
[ "Apache-2.0" ]
null
null
null
unittest/Rail_connect_Test.cpp
romadidukh/trains
57200efbb079cdc3844d4626ec38197ad863b9bb
[ "Apache-2.0" ]
null
null
null
#include "RdTest.h" #include "Rail.h" TEST(Rail, connectRR) { Rail railA(0, 0, 3, 4); Rail railB(3, 4, 7, 7); bool ret = Rail::connect(&railA, &railB); ASSERT_TRUE(ret); ASSERT_NULL(railA.next(0)); ASSERT_NOTNULL(railA.next(1)); ASSERT_NOTNULL(railB.next(0)); ASSERT_NULL(railB.next(1)); ASSERT_EQ(railA.next(1), &railB); ASSERT_EQ(railB.next(0), &railA); } TEST(Rail, connectNeg) { Rail railA(0, 0, 3, 4); Rail railB(4, 3, 7, 7); bool ret = Rail::connect(&railA, &railB); ASSERT_FALSE(ret); ASSERT_NULL(railA.next(0)); ASSERT_NULL(railA.next(1)); ASSERT_NULL(railB.next(0)); ASSERT_NULL(railB.next(1)); } TEST(Rail, connectFloat) { float e = 0.2*Point::error(); Rail railA(0, 0, 3+e, 4-e); Rail railB(3-e, 4+e, 7, 7); bool ret = Rail::connect(&railA, &railB); ASSERT_TRUE(ret); ASSERT_NULL(railA.next(0)); ASSERT_NOTNULL(railA.next(1)); ASSERT_NOTNULL(railB.next(0)); ASSERT_NULL(railB.next(1)); } TEST(Rail, connectFloatNeg) { float e = 0.5*Point::error(); Rail railA(0, 0, 3+e, 4-e); Rail railB(3-e, 4+e, 7, 7); bool ret = Rail::connect(&railA, &railB); ASSERT_FALSE(ret); ASSERT_NULL(railA.next(0)); ASSERT_NULL(railA.next(1)); ASSERT_NULL(railB.next(0)); ASSERT_NULL(railB.next(1)); } /* * TODO: * - Middle rail test */
20.086957
45
0.603175
romadidukh
318bca5bda583e1a8f357a8c82f83aea52f2054b
725
cpp
C++
problems/71.simplify-path.cpp
bigfishi/leetcode
3e512f2822a742349384a0bdd7954696f5867683
[ "MIT" ]
null
null
null
problems/71.simplify-path.cpp
bigfishi/leetcode
3e512f2822a742349384a0bdd7954696f5867683
[ "MIT" ]
null
null
null
problems/71.simplify-path.cpp
bigfishi/leetcode
3e512f2822a742349384a0bdd7954696f5867683
[ "MIT" ]
null
null
null
class Solution { public: string simplifyPath(string path) { stack<string> st; int pos = 0; while (pos<path.size()) { string::size_type tPos = path.find('/', pos); if (tPos == string::npos) { tPos = path.size(); } if (tPos > pos) { string sub = path.substr(pos, tPos - pos); if (sub == ".") { } else if (sub == "..") { if (st.size()) st.pop(); } else { st.push(sub); } } pos = tPos+1; } vector<string> list; while (st.size()) { list.push_back(st.top()); st.pop(); } string res = ""; for (auto iter = list.rbegin(); iter != list.rend(); iter++) { res += "/" + *iter; } if (res.size() == 0) res = "/"; return res; } };
17.261905
64
0.485517
bigfishi
318ca2a2adc45256b83eff72b74f8c68366878a4
771
cpp
C++
ares/sfc/coprocessor/armdsp/io.cpp
CasualPokePlayer/ares
58690cd5fc7bb6566c22935c5b80504a158cca29
[ "BSD-3-Clause" ]
153
2020-07-25T17:55:29.000Z
2021-10-01T23:45:01.000Z
ares/sfc/coprocessor/armdsp/io.cpp
CasualPokePlayer/ares
58690cd5fc7bb6566c22935c5b80504a158cca29
[ "BSD-3-Clause" ]
245
2021-10-08T09:14:46.000Z
2022-03-31T08:53:13.000Z
ares/sfc/coprocessor/armdsp/io.cpp
CasualPokePlayer/ares
58690cd5fc7bb6566c22935c5b80504a158cca29
[ "BSD-3-Clause" ]
44
2020-07-25T08:51:55.000Z
2021-09-25T16:09:01.000Z
//MMIO: 00-3f,80-bf:3800-38ff //3800-3807 mirrored throughout //a0 ignored auto ARMDSP::read(n24 address, n8) -> n8 { cpu.synchronize(*this); n8 data = 0x00; address &= 0xff06; if(address == 0x3800) { if(bridge.armtocpu.ready) { bridge.armtocpu.ready = false; data = bridge.armtocpu.data; } } if(address == 0x3802) { bridge.signal = false; } if(address == 0x3804) { data = bridge.status(); } return data; } auto ARMDSP::write(n24 address, n8 data) -> void { cpu.synchronize(*this); address &= 0xff06; if(address == 0x3802) { bridge.cputoarm.ready = true; bridge.cputoarm.data = data; } if(address == 0x3804) { data &= 1; if(!bridge.reset && data) reset(); bridge.reset = data; } }
17.133333
50
0.599222
CasualPokePlayer
31a1e9f0f754a52ef0e8792175ae192bd4096967
506
hpp
C++
libsnes/bsnes/gameboy/apu/master/master.hpp
ircluzar/BizhawkLegacy-Vanguard
cd8b6dfe881f3c9d322b73c29f0d71df2ce3178e
[ "MIT" ]
null
null
null
libsnes/bsnes/gameboy/apu/master/master.hpp
ircluzar/BizhawkLegacy-Vanguard
cd8b6dfe881f3c9d322b73c29f0d71df2ce3178e
[ "MIT" ]
null
null
null
libsnes/bsnes/gameboy/apu/master/master.hpp
ircluzar/BizhawkLegacy-Vanguard
cd8b6dfe881f3c9d322b73c29f0d71df2ce3178e
[ "MIT" ]
null
null
null
struct Master { bool left_in_enable; uint3 left_volume; bool right_in_enable; uint3 right_volume; bool channel4_left_enable; bool channel3_left_enable; bool channel2_left_enable; bool channel1_left_enable; bool channel4_right_enable; bool channel3_right_enable; bool channel2_right_enable; bool channel1_right_enable; bool enable; int16 center; int16 left; int16 right; void run(); void write(unsigned r, uint8 data); void power(); void serialize(serializer&); };
20.24
37
0.758893
ircluzar
31a72719143e5c49942d0853094fdeef5cc5191f
2,426
cc
C++
test.cc
thinkoid/stca-ukkonen
eb0a0cc306a6d76141f0052cb50099dbf2faf831
[ "MIT" ]
null
null
null
test.cc
thinkoid/stca-ukkonen
eb0a0cc306a6d76141f0052cb50099dbf2faf831
[ "MIT" ]
null
null
null
test.cc
thinkoid/stca-ukkonen
eb0a0cc306a6d76141f0052cb50099dbf2faf831
[ "MIT" ]
null
null
null
#include <cassert> #include <cstring> #include <algorithm> #include <iostream> #include <iterator> #include <sstream> #include <string> #include <vector> using namespace std; #include "st.hh" const vector< string > test_data { "A", "AA", "AAA", "AAAAAAA", "AAAAAAAAAAAA", "ABCABC", "ABCABCABCABC", "ABCABCABCABCABCABCABCABC", "ABCATBC", "ABCABCABTCABC", "ABCABCABCABCABCABTCABCABC", "ABCABDABXYABCABDABXZABCABDABXWSABCABDABXYABCABD" "ABXZABCABDABXWTABCABDABXYABCABDABXZABCABDABXWU" }; #if 0 #include <benchmark/benchmark.h> static string make_label (const string& s) { stringstream ss; if (s.size () > 6) { ss << s.substr (0, 6) << "..."; ss << "(" << s.size () << ")"; } else ss << s; return ss.str (); } static void BM_tree_construction (benchmark::State& state) { const string s = test_data [state.range (0)] + "$"; state.SetLabel (make_label (s)); while (state.KeepRunning ()) benchmark::DoNotOptimize (make_suffix_tree< > (s)); } BENCHMARK (BM_tree_construction)->DenseRange (0, test_data.size () - 1); BENCHMARK_MAIN (); #else struct dot_graph_t { template< typename T, typename U > explicit dot_graph_t (const ukkonen::suffix_tree_t< T, U >& t) : value_ (make_dot (t)) { } const string& value () const { return value_; } private: template< typename T, typename U > static string make_dot (const ukkonen::suffix_tree_t< T, U >& t) { stringstream ss; ss << "#+BEGIN_SRC dot :file t.png :cmdline -Kdot -Tpng\n"; ss << "digraph g {\n"; auto first = t.nodes.size (), last = first; for (const auto& e : t.edges) { size_t s, s_; int k, p; tie (s, k, p, s_) = e; if (0 == s) continue; ss << " " << s << " -> " << (0 == s_ ? last++ : s_) << " [label=\"" << t.text.substr (k, p - k + 1) << "\"];\n"; } for (; first != last; ++first) ss << " " << first << " [shape=point];\n"; ss << "}\n"; ss << "#+END_SRC\n\n"; return ss.str (); } private: string value_; }; int main (int, char** argv) { const auto t = ukkonen::make_suffix_tree< > (argv [1]); cout << dot_graph_t (t).value () << endl; return 0; } #endif
20.049587
82
0.535862
thinkoid
b3c422f0e3c15d95ca22969a9d844030b790e359
4,475
cpp
C++
src/Misc/SWTypes/EMPulse.cpp
Otamaa/Antares
7241a5ff20f4dbf7153cc77e16edca5c9db473d4
[ "BSD-4-Clause" ]
4
2021-04-24T04:34:06.000Z
2021-09-19T13:55:33.000Z
src/Misc/SWTypes/EMPulse.cpp
Otamaa/Antares
7241a5ff20f4dbf7153cc77e16edca5c9db473d4
[ "BSD-4-Clause" ]
null
null
null
src/Misc/SWTypes/EMPulse.cpp
Otamaa/Antares
7241a5ff20f4dbf7153cc77e16edca5c9db473d4
[ "BSD-4-Clause" ]
2
2021-08-17T14:44:45.000Z
2021-09-19T11:02:04.000Z
#include "EMPulse.h" #include "../../Ext/Building/Body.h" #include "../../Ext/BulletType/Body.h" #include "../../Ext/Techno/Body.h" #include "../../Ext/TechnoType/Body.h" #include "../../Utilities/Helpers.Alex.h" #include "../../Utilities/INIParser.h" #include "../../Utilities/TemplateDef.h" #include <BulletClass.h> #include <BulletTypeClass.h> #include <HouseClass.h> void SW_EMPulse::Initialize(SWTypeExt::ExtData* pData, SuperWeaponTypeClass* pSW) { pData->SW_RangeMaximum = -1.0; pData->SW_RangeMinimum = 0.0; pData->SW_MaxCount = 1; pData->EMPulse_Linked = false; pData->EMPulse_TargetSelf = false; pData->SW_AITargetingType = SuperWeaponAITargetingMode::None; pData->SW_Cursor = MouseCursor::GetCursor(MouseCursorType::Attack); pData->SW_NoCursor = MouseCursor::GetCursor(MouseCursorType::AttackOutOfRange); } void SW_EMPulse::LoadFromINI(SWTypeExt::ExtData* pData, SuperWeaponTypeClass* pSW, CCINIClass* pINI) { const char* section = pSW->get_ID(); if(!pINI->GetSection(section)) { return; } INI_EX exINI(pINI); pData->EMPulse_Linked.Read(exINI, section, "EMPulse.Linked"); pData->EMPulse_TargetSelf.Read(exINI, section, "EMPulse.TargetSelf"); pData->EMPulse_PulseDelay.Read(exINI, section, "EMPulse.PulseDelay"); pData->EMPulse_PulseBall.Read(exINI, section, "EMPulse.PulseBall"); pData->EMPulse_Cannons.Read(exINI, section, "EMPulse.Cannons"); pSW->Action = pData->EMPulse_TargetSelf ? Action::None : Actions::SuperWeaponAllowed; } bool SW_EMPulse::Activate(SuperClass* pThis, const CellStruct &Coords, bool IsPlayer) { auto pType = pThis->Type; auto pData = SWTypeExt::ExtMap.Find(pType); if(!pData) { return false; } auto pOwner = pThis->Owner; pOwner->EMPTarget = Coords; // the maximum number of buildings to fire. negative means all. const auto Count = (pData->SW_MaxCount >= 0) ? static_cast<size_t>(pData->SW_MaxCount) : std::numeric_limits<size_t>::max(); // if linked, only one needs to be in range (and CanFireAt checked that already). const bool ignoreRange = pData->EMPulse_Linked || pData->EMPulse_TargetSelf; auto IsEligible = [=](BuildingClass* pBld) { return IsLaunchSiteEligible(pData, Coords, pBld, ignoreRange); }; // only call on up to Count buildings that suffice IsEligible Helpers::Alex::for_each_if_n(pOwner->Buildings.begin(), pOwner->Buildings.end(), Count, IsEligible, [=](BuildingClass* pBld) { if(!pData->EMPulse_TargetSelf) { // set extended properties auto pExt = TechnoExt::ExtMap.Find(pBld); pExt->SuperWeapon = pThis; pExt->SuperTarget = MapClass::Instance->TryGetCellAt(Coords); // setup the cannon and start the fire mission pBld->FiringSWType = pType->ArrayIndex; pBld->QueueMission(Mission::Missile, false); pBld->NextMission(); } else { // create a bullet and detonate immediately if(auto pWeapon = pBld->GetWeapon(0)->WeaponType) { auto pExt = BulletTypeExt::ExtMap.Find(pWeapon->Projectile); if(auto pBullet = pExt->CreateBullet(pBld, pBld, pWeapon)) { pBullet->SetWeaponType(pWeapon); pBullet->Remove(); pBullet->Detonate(BuildingExt::GetCenterCoords(pBld)); pBullet->Release(); } } } }); return true; } bool SW_EMPulse::IsLaunchSite(SWTypeExt::ExtData* pSWType, BuildingClass* pBuilding) const { // don't further question the types in this list if(!pSWType->EMPulse_Cannons.empty()) { return pSWType->EMPulse_Cannons.Contains(pBuilding->Type) && pBuilding->IsAlive && pBuilding->Health && !pBuilding->InLimbo && pBuilding->IsPowerOnline(); } return pBuilding->Type->EMPulseCannon && NewSWType::IsLaunchSite(pSWType, pBuilding); } std::pair<double, double> SW_EMPulse::GetLaunchSiteRange(SWTypeExt::ExtData* pSWType, BuildingClass* pBuilding) const { if(pSWType->EMPulse_TargetSelf) { // no need for any range check return std::make_pair(-1.0, -1.0); } if(!pBuilding) { // for EMP negative ranges mean default value, so this forces // to do the check regardless of the actual value return std::make_pair(0.0, 0.0); } if(auto pWeap = pBuilding->GetWeapon(0)->WeaponType) { // get maximum range double maxRange = pSWType->SW_RangeMaximum; if(maxRange < 0.0) { maxRange = pWeap->Range / 256.0; } // get minimum range double minRange = pSWType->SW_RangeMinimum; if(minRange < 0.0) { minRange = pWeap->MinimumRange / 256.0; } return std::make_pair(minRange, maxRange); } return NewSWType::GetLaunchSiteRange(pSWType, pBuilding); }
30.650685
117
0.718212
Otamaa
b3c750b19169b008dbd1a336d84bd9c5d82513c2
8,267
cpp
C++
aperta-compiler/aperta-compiler/Lexer.cpp
ApertaTeam/aperta-compiler
116bb104e267ff8682ecb7c83086bad2027ef1eb
[ "MIT" ]
null
null
null
aperta-compiler/aperta-compiler/Lexer.cpp
ApertaTeam/aperta-compiler
116bb104e267ff8682ecb7c83086bad2027ef1eb
[ "MIT" ]
null
null
null
aperta-compiler/aperta-compiler/Lexer.cpp
ApertaTeam/aperta-compiler
116bb104e267ff8682ecb7c83086bad2027ef1eb
[ "MIT" ]
null
null
null
#include "Lexer.h" namespace aperta_compiler { namespace lexer { char* ErrorMessage = ""; inline bool DetectToken(std::string& input, int& pos, char c) { if (input[pos] == c) { pos++; return true; } else { return false; } } inline bool DetectToken(std::string& input, int& pos, char c1, char c2) { if (input[pos] == c1) { pos++; if (input[pos] == c2) { pos++; return true; } else { pos--; return false; } } else { return false; } } inline bool DetectToken(std::string& input, int& pos, char c1, char c2, char c3) { if (input[pos] == c1) { pos++; if (input[pos] == c2) { pos++; if (input[pos] == c3) { pos++; return true; } else { pos -= 2; return false; } } else { pos--; return false; } } else { return false; } } std::vector<Token> GetTokensFromString(std::string& input) { std::vector<Token> tokens = std::vector<Token>(); int line = 1; // For safety and ease in detecting unenclosed things. input += "\n "; int pos = 0; while (pos < (int)input.length()) { // Detect newlines if (input[pos] == '\n') { line++; } // Skip whitespace while (pos < (int)input.length() && iswspace(input[pos])) { pos++; } // Single line comment if (DetectToken(input, pos, '/', '/')) { while (pos < (int)input.length() && input[pos] != '\n') { pos++; } } // Multi line comment else if (DetectToken(input, pos, '/', '*')) { while (pos < (int)input.length() && !DetectToken(input, pos, '*', '/')) { if (input[pos] == '\n') line++; pos++; } } // String else if (DetectToken(input, pos, '"')) { std::string contents = ""; while (pos < (int)input.length() && !DetectToken(input, pos, '"')) { if (input[pos] == '\\') { pos++; if (input[pos] == '"') { contents += '"'; } else if (input[pos] == 'n') { contents += 0x0A; } else if (input[pos] == 'r') { contents += 0x0D; } pos++; } else { contents += input[pos]; if (input[pos] == '\n') line++; pos++; } } if (pos >= (int)input.length()) { ErrorMessage = "Unenclosed string literal detected."; return std::vector<Token>(); } else { tokens.push_back({ line, String, contents }); } } // Character else if (DetectToken(input, pos, '\'')) { std::string content = ""; if (input[pos] == '\\') { pos++; if (input[pos] == '\'') { content += '\''; } else if (input[pos] == 'n') { content += 0x0A; } else if (input[pos] == 'r') { content += 0x0D; } pos++; } else { content += input[pos]; if (input[pos] == '\n') line++; pos++; } if (pos >= (int)input.length() || !DetectToken(input, pos, '\'')) { ErrorMessage = "Unenclosed/too large character literal detected."; return std::vector<Token>(); } else { tokens.push_back({ line, Character, content }); } } // Number else if (isdigit(input[pos])) { bool usedDot = false; std::string contents = ""; contents += input[pos]; pos++; while (pos < (int)input.length() && (isdigit(input[pos]) || (!usedDot && input[pos] == '.'))) { if (input[pos] == '.') { if (!usedDot) { usedDot = true; } else { ErrorMessage = "Malformed number."; return std::vector<Token>(); } } contents += input[pos]; pos++; } tokens.push_back({ line, Number, contents }); } // Identifier else if (isalpha(input[pos]) || input[pos] == '_') { std::string contents = ""; contents += input[pos]; pos++; while (pos < (int)input.length() && (isalpha(input[pos]) || isdigit(input[pos]) || input[pos] == '_')) { contents += input[pos]; pos++; } tokens.push_back({ line, Identifier, contents }); } // Semicolon else if (DetectToken(input, pos, ';'))\ { tokens.push_back({ line, Semicolon, ";" }); } // Conditional Operators else if (DetectToken(input, pos, '=', '=')) { tokens.push_back({ line, ConditonalOp, "==" }); } else if (DetectToken(input, pos, '!', '=')) { tokens.push_back({ line, ConditonalOp, "!=" }); } else if (DetectToken(input, pos, '>', '=')) { tokens.push_back({ line, ConditonalOp, ">=" }); } else if (DetectToken(input, pos, '<', '=')) { tokens.push_back({ line, ConditonalOp, "<=" }); } else if (DetectToken(input, pos, '|', '|')) { tokens.push_back({ line, ConditonalOp, "||" }); } else if (DetectToken(input, pos, '&', '&')) { tokens.push_back({ line, ConditonalOp, "&&" }); } else if (DetectToken(input, pos, '>')) { tokens.push_back({ line, ConditonalOp, ">" }); } else if (DetectToken(input, pos, '<')) { tokens.push_back({ line, ConditonalOp, "<" }); } // BinOp Equals else if (DetectToken(input, pos, '+', '+')) { // "++" becomes "+= 1" at compile time. tokens.push_back({ line, BinOpEquals, "+=" }); tokens.push_back({ line, Number, "1" }); } else if (DetectToken(input, pos, '-', '-')) { // "++" becomes "+= 1" at compile time. tokens.push_back({ line, BinOpEquals, "-=" }); tokens.push_back({ line, Number, "1" }); } else if (DetectToken(input, pos, '+', '=')) { tokens.push_back({ line, BinOpEquals, "+=" }); } else if (DetectToken(input, pos, '-', '=')) { tokens.push_back({ line, BinOpEquals, "-=" }); } else if (DetectToken(input, pos, '*', '=')) { tokens.push_back({ line, BinOpEquals, "*=" }); } else if (DetectToken(input, pos, '/', '=')) { tokens.push_back({ line, BinOpEquals, "/=" }); } // BinOp else if (DetectToken(input, pos, '+')) { tokens.push_back({ line, BinOp, "+" }); } else if (DetectToken(input, pos, '-')) { tokens.push_back({ line, BinOp, "-" }); } else if (DetectToken(input, pos, '*')) { tokens.push_back({ line, BinOp, "*" }); } else if (DetectToken(input, pos, '/')) { tokens.push_back({ line, BinOp, "/" }); } // Equals else if (DetectToken(input, pos, '=')) { tokens.push_back({ line, Equals, "=" }); } // OpenParen else if (DetectToken(input, pos, '(')) { tokens.push_back({ line, OpenParen, "(" }); } // CloseParen else if (DetectToken(input, pos, ')')) { tokens.push_back({ line, CloseParen, ")" }); } // OpenBrack else if (DetectToken(input, pos, '[')) { tokens.push_back({ line, OpenBrack, "[" }); } // CloseBrack else if (DetectToken(input, pos, ']')) { tokens.push_back({ line, CloseBrack, "]" }); } // OpenBrace else if (DetectToken(input, pos, '{')) { tokens.push_back({ line, OpenBrace, "{" }); } // CloseBrace else if (DetectToken(input, pos, '}')) { tokens.push_back({ line, CloseBrace, "}" }); } // Dot else if (DetectToken(input, pos, '.')) { tokens.push_back({ line, Dot, "." }); } // Colon else if (DetectToken(input, pos, ':')) { tokens.push_back({ line, Colon, ":" }); } // Comma else if (DetectToken(input, pos, ',')) { tokens.push_back({ line, Comma, "," }); } // Not else if (DetectToken(input, pos, '!')) { tokens.push_back({ line, Not, "!" }); } // Ampersand else if (DetectToken(input, pos, '&')) { tokens.push_back({ line, Ampersand, "&" }); } // Tilde else if (DetectToken(input, pos, '~')) { tokens.push_back({ line, Tilde, "~" }); } else pos++; } return tokens; } } }
21.528646
107
0.474658
ApertaTeam
b3cf72e45d8dabd9a01bcfbdc6d019fd7474070f
4,358
cpp
C++
mrsl_mobile_object/src/mobile_object.cpp
ackoc23/mrsl_quadrotor
fb68c16a5895c1c7281c048a75e1841b5964d3ee
[ "BSD-3-Clause" ]
70
2017-12-15T10:52:04.000Z
2022-03-30T19:46:56.000Z
mrsl_mobile_object/src/mobile_object.cpp
ackoc23/mrsl_quadrotor
fb68c16a5895c1c7281c048a75e1841b5964d3ee
[ "BSD-3-Clause" ]
11
2018-08-14T11:47:21.000Z
2021-12-02T16:30:01.000Z
mrsl_mobile_object/src/mobile_object.cpp
ackoc23/mrsl_quadrotor
fb68c16a5895c1c7281c048a75e1841b5964d3ee
[ "BSD-3-Clause" ]
33
2018-03-18T18:34:20.000Z
2022-03-29T12:13:16.000Z
#include <boost/bind.hpp> #include <gazebo/physics/physics.hh> #include <gazebo/common/common.hh> #include <gazebo/gazebo.hh> #include <ros/ros.h> #include <geometry_msgs/PoseStamped.h> #include <tf/transform_broadcaster.h> namespace mrsl_quadrotor_simulator { class MobileObject : public gazebo::ModelPlugin { public: MobileObject(): initialzed_(false), lower_bound_(-1.0), upper_bound_(1.0), vx_(0.0), vy_(0.0) { } ~MobileObject() { } void Load(gazebo::physics::ModelPtr _parent, sdf::ElementPtr _sdf) { ns_ = ""; if (_sdf->HasElement("robotNamespace")) ns_ = _sdf->GetElement("robotNamespace")->Get<std::string>(); if (!_sdf->HasElement("updateRate")) update_rate_ = 10.0; else update_rate_ = _sdf->GetElement("updateRate")->Get<double>(); if (!_sdf->HasElement("topicName")) topic_name_ = "pose"; else topic_name_ = _sdf->Get<std::string>("topicName"); node_handle_ = new ros::NodeHandle(ns_); if (topic_name_ != "") pub_ = node_handle_->advertise<geometry_msgs::PoseStamped>(topic_name_, 1); if(_sdf->HasElement("vx")) vx_ = _sdf->GetElement("vx")->Get<double>(); else vx_ = 0; if(_sdf->HasElement("vy")) vy_ = _sdf->GetElement("vy")->Get<double>(); else vy_ = 0; if (_sdf->HasElement("w")) w_ = _sdf->GetElement("w")->Get<double>(); else w_ = 0; link = _parent->GetLink(); updateConnection = gazebo::event::Events::ConnectWorldUpdateBegin( boost::bind(&MobileObject::OnUpdate, this, _1)); } void OnUpdate(const gazebo::common::UpdateInfo &_info) { #if GAZEBO_MAJOR_VERSION >= 8 ignition::math::Pose3d pose = link->WorldPose(); #else ignition::math::Pose3d pose = link->GetWorldPose().Ign(); #endif if(!initialzed_){ initialzed_ = true; init_pose_ = pose; } if((fabs(pose.Pos().X() - (init_pose_.Pos().X() + lower_bound_)) < 1e-1 && vx_ < 0) || (fabs(pose.Pos().X() - (init_pose_.Pos().X() + upper_bound_)) < 1e-1 && vx_ > 0)) vx_ = -vx_; if((fabs(pose.Pos().Y() - (init_pose_.Pos().Y() + lower_bound_)) < 1e-1 && vy_ < 0) || (fabs(pose.Pos().Y() - (init_pose_.Pos().Y() + upper_bound_)) < 1e-1 && vy_ > 0)) vy_ = -vy_; link->SetLinearVel(ignition::math::Vector3d(vx_, vy_, 0)); link->SetAngularVel(ignition::math::Vector3d(0, 0, w_)); //if (pub_.getNumSubscribers() > 0 && topic_name_ != "" && update_rate_ > 0) if (topic_name_ != "" && update_rate_ > 0) { static tf::TransformBroadcaster br; static ros::Time prev_time = ros::Time::now(); if((ros::Time::now() - prev_time).toSec() >= 1./update_rate_) { geometry_msgs::PoseStamped msg; msg.header.stamp = ros::Time::now(); msg.header.frame_id = "map"; msg.pose.position.x = pose.Pos().X(); msg.pose.position.y = pose.Pos().Y(); msg.pose.position.z = pose.Pos().Z(); msg.pose.orientation.w = pose.Rot().W(); msg.pose.orientation.x = pose.Rot().X(); msg.pose.orientation.y = pose.Rot().Y(); msg.pose.orientation.z = pose.Rot().Z(); pub_.publish(msg); tf::Transform bt(tf::Quaternion(msg.pose.orientation.x, msg.pose.orientation.y, msg.pose.orientation.z, msg.pose.orientation.w), tf::Vector3(msg.pose.position.x, msg.pose.position.y, msg.pose.position.z)); br.sendTransform(tf::StampedTransform(bt, msg.header.stamp, msg.header.frame_id, ns_ + "base_link")); prev_time = msg.header.stamp; } } } private: // Pointer to the model ignition::math::Pose3d init_pose_; gazebo::event::ConnectionPtr updateConnection; gazebo::physics::LinkPtr link; // Link for robot bool initialzed_; double lower_bound_; double upper_bound_; double vx_, vy_, w_; // Ros interface ros::NodeHandle *node_handle_; ros::Publisher pub_; std::string ns_; std::string topic_name_; double update_rate_; }; // Register this plugin with the simulator GZ_REGISTER_MODEL_PLUGIN(MobileObject) }
29.445946
111
0.582836
ackoc23
b3d39d4d2d975e03b2c5eccdfc3331ad61f54bbe
1,144
cpp
C++
Poly/src/Platform/Vulkan/PVKShader.cpp
Ceanze/Poly
0bd1ec060ec7e785fa3b7ad1744b8488220ca8d3
[ "MIT" ]
1
2022-01-25T20:19:23.000Z
2022-01-25T20:19:23.000Z
Poly/src/Platform/Vulkan/PVKShader.cpp
Ceanze/Poly
0bd1ec060ec7e785fa3b7ad1744b8488220ca8d3
[ "MIT" ]
33
2020-01-29T21:19:54.000Z
2022-03-29T17:31:36.000Z
Poly/src/Platform/Vulkan/PVKShader.cpp
Ceanze/Poly
0bd1ec060ec7e785fa3b7ad1744b8488220ca8d3
[ "MIT" ]
null
null
null
#include "polypch.h" #include "PVKShader.h" #include "PVKInstance.h" #include "VulkanCommon.h" #include "Poly/Resources/ResourceLoader.h" namespace Poly { PVKShader::~PVKShader() { vkDestroyShaderModule(PVKInstance::GetDevice(), m_ShaderModule, nullptr); } void PVKShader::Init(const ShaderDesc* pDesc) { m_ShaderStage = pDesc->ShaderStage; m_EntryPoint = pDesc->EntryPoint; // Create shader module VkShaderModuleCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; createInfo.codeSize = pDesc->ShaderCode.size(); createInfo.pCode = reinterpret_cast<const uint32_t*>(pDesc->ShaderCode.data()); createInfo.flags = 0; createInfo.pNext = nullptr; PVK_CHECK(vkCreateShaderModule(PVKInstance::GetDevice(), &createInfo, nullptr, &m_ShaderModule), "Failed to create shader module!"); // Save the pipeline info for easier use later on m_PipelineInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; m_PipelineInfo.stage = ConvertShaderStageBitsVK(pDesc->ShaderStage); m_PipelineInfo.module = m_ShaderModule; m_PipelineInfo.pName = m_EntryPoint.c_str(); } }
30.918919
134
0.771853
Ceanze
b3d483eb1529360a581604ac74346cfbf00d2c0a
3,259
hpp
C++
src/iFPGA/include/algorithms/ref_deref.hpp
nlwmode/ifpga-mapper
cd4193bfe1e41fe71f8a01754b71cb92137a76db
[ "MIT" ]
null
null
null
src/iFPGA/include/algorithms/ref_deref.hpp
nlwmode/ifpga-mapper
cd4193bfe1e41fe71f8a01754b71cb92137a76db
[ "MIT" ]
null
null
null
src/iFPGA/include/algorithms/ref_deref.hpp
nlwmode/ifpga-mapper
cd4193bfe1e41fe71f8a01754b71cb92137a76db
[ "MIT" ]
null
null
null
/** * @file ref_deref.hpp * @author liwei ni (nilw@pcl.ac.cn) * @brief the ref and deref function of a node * * @version 0.1 * @date 2021-07-26 * @copyright Copyright (c) 2021 */ #pragma once #include "misc/common_properties.hpp" #include "misc/cost_function.hpp" #include <stdint.h> #include <tuple> iFPGA_NAMESPACE_HEADER_START template<typename Ntk, typename NodeCostFn, typename TermConditionFn> uint32_t deref_node_recursive_cond(Ntk const& ntk, node<Ntk> const& n, TermConditionFn const& term_fn) { if ( term_fn( n ) ) return 0u; uint32_t value = NodeCostFn{}( ntk, n ); ntk.foreach_fanin( n, [&]( auto const& s ) { if ( ntk.decr_value( ntk.get_node( s ) ) == 0 ) { value += deref_node_recursive_cond<Ntk, NodeCostFn, TermConditionFn>( ntk, ntk.get_node( s ), term_fn ); } } ); return value; } template<typename Ntk, typename NodeCostFn, typename TermConditionFn> uint32_t ref_node_recursive_cond(Ntk const& ntk, node<Ntk> const& n, TermConditionFn const& term_fn) { if ( term_fn( n ) ) return 0u; uint32_t value = NodeCostFn{}( ntk, n ); ntk.foreach_fanin( n, [&]( auto const& s ) { if ( ntk.incr_value( ntk.get_node( s ) ) == 0 ) { value += ref_node_recursive_cond<Ntk, NodeCostFn, TermConditionFn>( ntk, ntk.get_node( s ), term_fn ); } } ); return value; } template<typename Ntk, typename NodeCostFn> uint32_t deref_node_recursive(Ntk const& ntk, node<Ntk> const& n) { const auto term_fn = [&](const auto& n){ return ntk.is_constant(n) || ntk.is_pi(n); }; return deref_node_recursive_cond<Ntk, NodeCostFn, decltype(term_fn)>(ntk, n, term_fn); } template<typename Ntk, typename NodeCostFn> uint32_t ref_node_recursive(Ntk const& ntk, node<Ntk> const& n) { const auto term_fn = [&](const auto& n){ return ntk.is_constant(n) || ntk.is_pi(n); }; return ref_node_recursive_cond<Ntk, NodeCostFn, decltype(term_fn)>(ntk, n, term_fn); } /** * @brief ref the node ,and check if the mffc contains the repalced_node */ template<typename Ntk> std::tuple<int, bool> ref_node_recursive_contained(Ntk& ntk, node<Ntk> const& n, node<Ntk> const& replaced_node) { if( ntk.is_constant(n) || ntk.is_pi(n) ) return {0, false}; int value = 0; bool contains = ( n == replaced_node); ntk.foreach_fanin(n, [&](auto const& s){ contains = contains || (ntk.get_node(s) == replaced_node); if(ntk.decr_value( ntk.get_node(s)) == 0 ) { const auto tmp_res = ref_node_recursive_contained(ntk, ntk.get_node(s), replaced_node); value += std::get<0>(tmp_res); contains = contains || std::get<1>(tmp_res); } }); return std::make_tuple(value, contains); } template<typename Ntk, typename NodeCostFn = unit_cost<Ntk>> uint32_t derefed_size(Ntk const& ntk, node<Ntk> const& n) { uint32_t s1 = deref_node_recursive<Ntk, NodeCostFn>(ntk, n); uint32_t s2 = ref_node_recursive<Ntk, NodeCostFn>(ntk, n); assert(s1 == s2); return s1; } template<typename Ntk, typename NodeCostFn = unit_cost<Ntk>> uint32_t refed_size(Ntk const& ntk, node<Ntk> const& n) { uint32_t s1 = ref_node_recursive<Ntk, NodeCostFn>(ntk, n); uint32_t s2 = deref_node_recursive<Ntk, NodeCostFn>(ntk, n); assert(s1 == s2); return s1; } iFPGA_NAMESPACE_HEADER_END
30.745283
112
0.689168
nlwmode
b3dd42d01ebf64a8b945abee78a0c5954f0c4945
2,628
cpp
C++
source/components/unit-test-c++/src/DeferredTestReporter.cpp
renebarto/gstreamerpp
846981ee50cfc11ed9bde0c8e898d722cc2a57c5
[ "Apache-2.0" ]
null
null
null
source/components/unit-test-c++/src/DeferredTestReporter.cpp
renebarto/gstreamerpp
846981ee50cfc11ed9bde0c8e898d722cc2a57c5
[ "Apache-2.0" ]
null
null
null
source/components/unit-test-c++/src/DeferredTestReporter.cpp
renebarto/gstreamerpp
846981ee50cfc11ed9bde0c8e898d722cc2a57c5
[ "Apache-2.0" ]
null
null
null
#include <unit-test-c++/DeferredTestReporter.h> #include <unit-test-c++/TestDetails.h> #include <osal/unused.h> using namespace std; namespace UnitTestCpp { void DeferredTestReporter::ReportTestRunStart(int UNUSED(numberOfTestSuites), int UNUSED(numberOfTestFixtures), int UNUSED(numberOfTests)) { } void DeferredTestReporter::ReportTestRunFinish(int UNUSED(numberOfTestSuites), int UNUSED(numberOfTestFixtures), int UNUSED(numberOfTests), int UNUSED(milliSecondsElapsed)) { } void DeferredTestReporter::ReportTestRunSummary(const TestResults * UNUSED(_results), int UNUSED(milliSecondsElapsed)) { } void DeferredTestReporter::ReportTestRunOverview(const TestResults * UNUSED(_results)) { } void DeferredTestReporter::ReportTestSuiteStart(const string & UNUSED(suiteName), int UNUSED(numberOfTestFixtures)) { } void DeferredTestReporter::ReportTestSuiteFinish(const string & UNUSED(suiteName), int UNUSED(numberOfTests), int UNUSED(milliSecondsElapsed)) { } void DeferredTestReporter::ReportTestFixtureStart(const string & UNUSED(fixtureName), int UNUSED(numberOfTests)) { } void DeferredTestReporter::ReportTestFixtureFinish(const string & UNUSED(fixtureName), int UNUSED(numberOfTests), int UNUSED(milliSecondsElapsed)) { } void DeferredTestReporter::ReportTestStart(const TestDetails & details) { _results.push_back(TestDetailedResult(details)); } void DeferredTestReporter::ReportTestFinish(const TestDetails & UNUSED(details), bool UNUSED(success), int milliSecondsElapsed) { TestDetailedResult & result = _results.back(); result.MilliSecondsElapsed(milliSecondsElapsed); } void DeferredTestReporter::ReportTestFailure(const TestDetails & details, const string & failure) { TestDetailedResult & result = _results.back(); result.AddFailure(TestDetailedResult::Failure(details.lineNumber, failure)); } DeferredTestReporter::ResultList & DeferredTestReporter::Results() { return _results; } } // namespace UnitTestCpp
32.444444
97
0.598554
renebarto
b3df3144e29dbee35819308a7a5645a04324a73d
970
cpp
C++
c/interface/SPUserInterface.cpp
e-foto/e-foto
cf143a1076c03c7bdf5a2f41efad2c98e9272722
[ "FTL" ]
3
2021-06-28T21:07:58.000Z
2021-07-02T11:21:49.000Z
c/interface/SPUserInterface.cpp
e-foto/e-foto
cf143a1076c03c7bdf5a2f41efad2c98e9272722
[ "FTL" ]
null
null
null
c/interface/SPUserInterface.cpp
e-foto/e-foto
cf143a1076c03c7bdf5a2f41efad2c98e9272722
[ "FTL" ]
null
null
null
/*Copyright 2002-2014 e-foto team (UERJ) This file is part of e-foto. e-foto is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. e-foto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with e-foto. If not, see <http://www.gnu.org/licenses/>. */ #include "SPUserInterface.h" // Other Methods // namespace br { namespace uerj { namespace eng { namespace efoto { SPManager* SPUserInterface::getManager() { return manager; } } // namespace efoto } // namespace eng } // namespace uerj } // namespace br
26.216216
72
0.72268
e-foto
b3e25f5accb670a7dbe6f09dba4837d17e1a675f
6,612
cpp
C++
ui/qqboardinfo.cpp
ototu/quteqoin
8b4f74de819442451201c5e4eae9e2374c0024ea
[ "WTFPL" ]
2
2015-03-21T09:20:35.000Z
2015-08-06T12:50:57.000Z
ui/qqboardinfo.cpp
dguihal/quteqoin
8b4f74de819442451201c5e4eae9e2374c0024ea
[ "WTFPL" ]
23
2016-08-01T09:43:51.000Z
2021-04-02T13:49:55.000Z
ui/qqboardinfo.cpp
dguihal/quteqoin
8b4f74de819442451201c5e4eae9e2374c0024ea
[ "WTFPL" ]
1
2018-10-25T21:17:51.000Z
2018-10-25T21:17:51.000Z
#include "qqboardinfo.h" #include "ui_qqboardinfo.h" #include "core/qqbouchot.h" #include "core/qqboardstatechangeevent.h" #include "core/qutetools.h" #include "ui/qqmusselinfo.h" #include <QtDebug> #include <QFontMetrics> ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::QQBoardInfo /// \param board /// \param parent /// QQBoardInfo::QQBoardInfo(QQBouchot *board, QWidget *parent) : QWidget(parent), m_ui(new Ui::QQBoardInfo), m_board(board) { if(m_board == nullptr) return; m_ui->setupUi(this); m_ui->usrDspSA->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); m_ui->usrDspSA->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); m_ui->bodyWidget->hide(); m_ui->showBtn->setText("+"); connect(m_ui->showBtn, &QToolButton::clicked, this, &QQBoardInfo::toggleExpandedView); m_ui->refreshPB->setTextVisible(true); m_ui->refreshPB->setBoardColor(m_board->settings().color()); m_ui->refreshPB->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); m_ui->refreshPB->setBoardName(board->name()); connect(m_ui->refreshPB, &QQBoardInfoProgressBar::bouchotSelected, this, &QQBoardInfo::toggleBoardVisibility); QFontInfo fi = m_ui->refreshPB->fontInfo(); int size = fi.pixelSize() + 2; m_ui->refreshPB->setFixedHeight(size); m_ui->showBtn->setFixedHeight(size); m_ui->showBtn->setFixedWidth(size); m_pctPollAnimation.setStartValue(100); m_pctPollAnimation.setEndValue(0); m_pctPollAnimation.setEasingCurve(QEasingCurve::Linear); m_pctPollAnimation.setTargetObject(m_ui->refreshPB); m_pctPollAnimation.setPropertyName("value"); rearmRefreshPB(); connect(m_board, &QQBouchot::lastPostersUpdated, this, &QQBoardInfo::updateUserList); connect(m_board, &QQBouchot::refreshStarted, this, &QQBoardInfo::rearmRefreshPB); connect(m_board, &QQBouchot::refreshOK, this, &QQBoardInfo::resetFromErrorState); connect(m_board, &QQBouchot::refreshError, this, &QQBoardInfo::showRefreshError); connect(m_board, &QQBouchot::visibilitychanged, this, &QQBoardInfo::updateNameWithStatus); board->registerForEventNotification(this, QQBouchot::StateChanged); } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::~QQBoardInfo /// QQBoardInfo::~QQBoardInfo() { delete m_ui; } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::sizeHint /// \return /// QSize QQBoardInfo::sizeHint() const { QFontMetrics fm = m_ui->usrDspSA->fontMetrics(); int minWidth = fm.boundingRect("moules").width(); return QSize(minWidth + m_ui->labelUsers->minimumWidth(), m_ui->labelUsers->minimumHeight()); } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::musselSelected /// \param mussel /// void QQBoardInfo::musselSelected(QQMussel mussel) { Q_UNUSED(mussel) } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::rearmRefreshPB /// void QQBoardInfo::rearmRefreshPB() { disconnect(m_board, SIGNAL(refreshOK()), this, SLOT(rearmRefreshPB())); m_pctPollAnimation.stop(); m_ui->refreshPB->setValue(0); m_pctPollAnimation.setDuration(m_board->currentRefreshInterval()); m_pctPollAnimation.start(); } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::resetFromErrorState /// void QQBoardInfo::resetFromErrorState() { m_ui->refreshPB->setOnError(false); m_ui->refreshPB->setToolTip(""); updateNameWithStatus(); } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::showRefreshError /// \param errMsg /// void QQBoardInfo::showRefreshError(QString &errMsg) { m_ui->refreshPB->setOnError(true); m_ui->refreshPB->setToolTip(errMsg); connect(m_board, SIGNAL(refreshOK()), this, SLOT(rearmRefreshPB())); updateNameWithStatus(); } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::toggleBoardVisibility /// void QQBoardInfo::toggleBoardVisibility() { m_board->toggleVisibility(); updateNameWithStatus(); } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::toggleExpandedView /// void QQBoardInfo::toggleExpandedView() { if(m_ui->bodyWidget->isVisible()) { m_ui->bodyWidget->hide(); m_ui->showBtn->setText("+"); } else { m_ui->bodyWidget->show(); m_ui->showBtn->setText("-"); } } #define MAX_ITEMS 10 ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::updateUserList /// void QQBoardInfo::updateUserList() { QList<QQMussel> lastPosters = m_board->lastPosters(); QWidget *boardInfoWidget = new QWidget(m_ui->usrDspSA); QHash<QQMussel, QQMusselInfo *> newMusselInfoHash; QVBoxLayout *lastPostersWidgetLayout = new QVBoxLayout(boardInfoWidget); lastPostersWidgetLayout->setSpacing(1); lastPostersWidgetLayout->setContentsMargins(0, 0, 0, 0); QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Preferred); policy.setHorizontalStretch(0); policy.setVerticalStretch(0); // TODO Keep all datas, but mark them as hidden to // 1/ keep tracks of slow posting mussels // 2/ Avoid mem leaks int vSpace = 0; for(int i = 0; i < lastPosters.size(); i++) { QQMussel mussel = lastPosters.at(i); QQMusselInfo *mi = nullptr; if(m_musselInfoHash.contains(mussel)) { mi = m_musselInfoHash.take(mussel); mi->setParent(boardInfoWidget); } else { mi = new QQMusselInfo(mussel, boardInfoWidget); connect(mi, SIGNAL(selected(QQMussel)), this, SLOT(musselSelected(QQMussel))); mi->setSizePolicy(policy); } newMusselInfoHash.insert(mussel, mi); lastPostersWidgetLayout->addWidget(mi); if(i < MAX_ITEMS) vSpace += mi->sizeHint().height() + 1; } QWidget *old = m_ui->usrDspSA->takeWidget(); if(old != nullptr) delete old; m_ui->usrDspSA->setWidget(boardInfoWidget); if(! lastPosters.isEmpty()) { m_ui->usrDspSA->setMaximumHeight(vSpace); m_ui->usrDspSA->setMinimumHeight(vSpace); m_ui->usrDspSA->show(); } else m_ui->usrDspSA->hide(); m_musselInfoHash = newMusselInfoHash; } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::event /// \param e /// \return /// bool QQBoardInfo::event(QEvent *e) { if(e->type() == QQBoardStateChangeEvent::BOARD_STATE_CHANGED) updateNameWithStatus(); else QWidget::event(e); return true; } ////////////////////////////////////////////////////////////// /// \brief QQBoardInfo::updateNameWithStatus /// void QQBoardInfo::updateNameWithStatus() { QString flags = QuteTools::statusStringFromState(m_board->boardState()); m_ui->refreshPB->setBoardStatusFlags(flags); }
27.098361
94
0.652753
ototu
b3e517bc58c4f8212bf970569d416424b637eb33
6,985
cpp
C++
Meduza/Source/Platform/General/Graphics/RenderLayerGL.cpp
NWagter/Meduza
d1df99061381fa1c7665d09e275ddc0060a6ac8d
[ "MIT" ]
6
2020-10-17T10:50:13.000Z
2022-02-25T20:14:23.000Z
Meduza/Source/Platform/General/Graphics/RenderLayerGL.cpp
NWagter/Meduza
d1df99061381fa1c7665d09e275ddc0060a6ac8d
[ "MIT" ]
null
null
null
Meduza/Source/Platform/General/Graphics/RenderLayerGL.cpp
NWagter/Meduza
d1df99061381fa1c7665d09e275ddc0060a6ac8d
[ "MIT" ]
1
2020-05-06T12:02:47.000Z
2020-05-06T12:02:47.000Z
#include "MePCH.h" #include "Platform/General/Graphics/RenderLayerGL.h" #include "Platform/General/Window.h" #ifdef PLATFORM_LINUX #include "Platform/Linux/Graphics/Context.h" #elif PLATFORM_WINDOWS #include "Platform/Windows/Graphics/ContextGL.h" #endif #include "Platform/General/Resources/Mesh.h" #include "Platform/General/Resources/Shader.h" #include "Platform/General/Resources/Texture.h" #include "Platform/General/MeshLibrary.h" #include "Platform/General/ShaderLibrary.h" #include "Platform/General/TextureLibrary.h" #include "Core/Components/RenderComponent.h" #include "Core/Components/CameraComponent.h" #include "Core/Components/TransformComponent.h" Me::Renderer::GL::RenderLayerGL::RenderLayerGL(Window* a_window) { if(a_window== nullptr) { printf("No Window! \n"); return; } m_window = a_window; m_context = new Context(*m_window); m_activeShader = nullptr; m_camera = new Camera(); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glAlphaFunc(GL_GREATER, 0.6f); glCullFace(GL_FRONT); } Me::Renderer::GL::RenderLayerGL::~RenderLayerGL() { for(auto r : m_renderables) { delete r; } m_renderables.clear(); for(auto r : m_debugRenderables) { delete r; } m_debugRenderables.clear(); delete m_context; delete m_camera; } void Me::Renderer::GL::RenderLayerGL::Clear(Colour a_colour) { for(auto r : m_renderables) { delete r; } m_renderables.clear(); for(auto r : m_debugRenderables) { delete r; } m_debugRenderables.clear(); glViewport(0,0, m_context->m_width, m_context->m_height); glClearColor(a_colour.m_colour[0], a_colour.m_colour[1], a_colour.m_colour[2], a_colour.m_colour[3]); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_activeShader = nullptr; } void Me::Renderer::GL::RenderLayerGL::Present() { m_context->SwapBuffer(); } void Me::Renderer::GL::RenderLayerGL::Populate() { glEnable(GL_DEPTH_TEST); glEnable(GL_ALPHA_TEST); for (auto r : m_renderables) { glEnable(GL_CULL_FACE); auto renderComp = r->m_renderComponent; auto s = static_cast<Resources::GL::Shader*>(Resources::ShaderLibrary::GetShader(renderComp->m_shader)); auto m = static_cast<Resources::GL::Mesh*>(Resources::MeshLibrary::GetMesh(renderComp->m_mesh)); auto t = static_cast<Resources::GL::Texture*>(Resources::TextureLibrary::GetTexture(renderComp->m_texture)); if(m_activeShader == nullptr || m_activeShader != s) // only change when shader / pso changes { if(s != nullptr) { m_activeShader = s; m_activeShader->Bind(); } else { continue; } } m_activeShader->SetMat4("u_model", r->m_modelMatrix, false); m_activeShader->SetMat4("u_projectionView", m_camera->m_cameraMatrix, false); m_activeShader->SetVec4("u_colour", Math::Vec4(renderComp->m_colour.m_colour)); m_activeShader->SetVec4("u_uv", Math::Vec4(renderComp->m_textureCoords.m_xyzw)); if(t != nullptr) { if(renderComp->m_mesh == (Mesh)Primitives::Quad) { glDisable(GL_CULL_FACE); } t->Bind(); } glBindVertexArray(m->GetVAO()); glDrawElementsInstanced(GL_TRIANGLES, m->GetIndices().size(), GL_UNSIGNED_SHORT, 0, 1); glBindVertexArray(0); t->UnBind(); } glDisable(GL_ALPHA_TEST); for(auto r : m_debugRenderables) { glDisable(GL_DEPTH_TEST); auto renderComp = r->m_debugRenderComponent; auto s = static_cast<Resources::GL::Shader*>(Resources::ShaderLibrary::GetShader(renderComp->m_shader)); auto m = static_cast<Resources::GL::Mesh*>(Resources::MeshLibrary::GetMesh(renderComp->m_mesh)); if(m_activeShader == nullptr || m_activeShader != s) // only change when shader / pso changes { if(s != nullptr) { m_activeShader = s; m_activeShader->Bind(); } else { continue; } } m_activeShader->SetMat4("u_model", r->m_modelMatrix, false); m_activeShader->SetMat4("u_projectionView", m_camera->m_cameraMatrix, false); m_activeShader->SetVec4("u_colour", Math::Vec4(renderComp->m_debugColour.m_colour)); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindVertexArray(m->GetVAO()); glDrawElementsInstanced(GL_TRIANGLES, m->GetIndices().size(), GL_UNSIGNED_SHORT, 0, 1); glBindVertexArray(0); } } void Me::Renderer::GL::RenderLayerGL::Submit(RenderComponent& a_renderable, TransformComponent& a_trans) { Renderable* r = new Renderable(); r->m_renderComponent = &a_renderable; //r->m_modelMatrix = Math::Transpose(a_trans.GetTransform()); r->m_modelMatrix = Math::Transpose(a_trans.GetTransform()); m_renderables.push_back(r); } void Me::Renderer::GL::RenderLayerGL::DebugSubmit(DebugRenderComponent& a_renderable, TransformComponent& a_trans) { DebugRenderable* r = new DebugRenderable(); r->m_debugRenderComponent = &a_renderable; //r->m_modelMatrix = Math::Transpose(a_trans.GetTransform()); r->m_modelMatrix = Math::Transpose(a_trans.GetTransform()); m_debugRenderables.push_back(r); } void Me::Renderer::GL::RenderLayerGL::SetCamera(CameraComponent& a_cameraComp, TransformComponent& a_transComp) { Math::Mat4 camMat = Math::Mat4::Identity(); if(a_cameraComp.m_cameraType == Me::CameraType::Orthographic) { Me::Math::Vec2 size = m_window->GetSize(); float aspect = size.m_x / size.m_y; camMat = Math::GetOrthographicMatrix(-a_cameraComp.m_orthoScale, a_cameraComp.m_orthoScale, -a_cameraComp.m_orthoScale * aspect , a_cameraComp.m_orthoScale * aspect, a_cameraComp.m_near, a_cameraComp.m_far); } else { camMat = Math::GetProjectionMatrix(45.0f, a_cameraComp.m_size.m_x / a_cameraComp.m_size.m_y, a_cameraComp.m_near, a_cameraComp.m_far); } Math::Mat4 rMat = Math::Mat4::Identity(); rMat.Rotation(a_transComp.m_rotation); Math::Mat4 pMat = Math::Mat4::Identity(); pMat.SetPosition(a_transComp.m_translation); Math::Mat4 view = rMat * pMat.Inverse(); Math::Mat4 camViewProjection = camMat * view; m_camera->m_cameraMatrix = Math::Transpose(camViewProjection); } Me::Resources::GL::Mesh* Me::Renderer::GL::RenderLayerGL::CreateMesh(std::string a_path, std::vector<Vertex> a_vertices, std::vector<uint16_t> a_indices) { return new Resources::GL::Mesh(a_path, a_vertices, a_indices); }
28.983402
153
0.651253
NWagter
b3e764b9dc0f1cba40e5677a22d2abde4585ee5e
2,665
cpp
C++
src/Server.cpp
dawidd6/qtictactoe
c893331271b7aada0b099f362b052f8e2f0cd75c
[ "MIT" ]
2
2017-07-10T14:23:53.000Z
2017-12-18T09:55:12.000Z
src/Server.cpp
dawidd6/qtictactoe
c893331271b7aada0b099f362b052f8e2f0cd75c
[ "MIT" ]
null
null
null
src/Server.cpp
dawidd6/qtictactoe
c893331271b7aada0b099f362b052f8e2f0cd75c
[ "MIT" ]
1
2018-07-26T15:24:48.000Z
2018-07-26T15:24:48.000Z
#include <QtNetwork> #include "Game.h" #include "Server.h" void Server::handleNewConnection() { if(connection_a == nullptr) { connection_a = nextPendingConnection(); connect(connection_a, &QTcpSocket::disconnected, this, &Server::handleDisconnection); Game::logger("Connected a"); } else if(connection_b == nullptr) { connection_b = nextPendingConnection(); connect(connection_b, &QTcpSocket::disconnected, this, &Server::handleDisconnection); Game::logger("Connected b"); } else Game::logger("two clients connected, ignoring"); if(connection_a != nullptr && connection_b != nullptr) { randomTurnAndSymbol(); connect(connection_a, &QTcpSocket::readyRead, this, &Server::handleRead); connect(connection_b, &QTcpSocket::readyRead, this, &Server::handleRead); } } void Server::randomTurnAndSymbol() { QByteArray request_a = "r-"; QByteArray request_b = "r-"; if(qrand() % 2) { request_a.append("1"); request_b.append("0"); } else { request_a.append("0"); request_b.append("1"); } if(qrand() % 2) { request_a.append("x"); request_b.append("o"); } else { request_a.append("o"); request_b.append("x"); } connection_a->write(request_a); connection_b->write(request_b); } void Server::handleRead() { if(sender() == connection_a) { response = connection_a->readAll().data(); if(connection_b != nullptr) { if(response == "ry") randomTurnAndSymbol(); else connection_b->write(response.toUtf8()); Game::logger("Message from a to b redirected"); } else connection_a->write("dis"); } if(sender() == connection_b) { response = connection_b->readAll().data(); if(connection_a != nullptr) { if(response == "ry") randomTurnAndSymbol(); else connection_a->write(response.toUtf8()); Game::logger("Message from b to a redirected"); } else connection_b->write("dis"); } } void Server::handleDisconnection() { if(sender() == connection_a) { Game::logger("Disconnected a"); if(connection_b != nullptr) connection_b->write("dis"); connection_a = nullptr; } if(sender() == connection_b) { Game::logger("Disconnected b"); if(connection_a != nullptr) connection_a->write("dis"); connection_b = nullptr; } } void Server::startListening() { if(listen(QHostAddress::Any, 60000)) Game::logger("Listening..."); else { Game::logger("Could not start server"); Game::logger("Exiting..."); exit(1); } } Server::Server() { setMaxPendingConnections(2); qsrand(QTime::currentTime().msec()); connection_a = nullptr; connection_b = nullptr; connect(this, &Server::newConnection, this, &Server::handleNewConnection); startListening(); }
20.820313
87
0.675797
dawidd6
b3eb32ab8021dd48734a32302c0d1338282ab924
89,150
cpp
C++
src/StoneCutter/SCParser.cpp
opensocsysarch/CoreGen
204e03b8b4a0d23cf8f955ed99af5de7fa07569e
[ "Apache-2.0" ]
6
2019-08-15T23:11:49.000Z
2021-12-17T18:28:37.000Z
src/StoneCutter/SCParser.cpp
rkabrick/CoreGen
e456763d6b669370b9a17d92552516ebc2887ddf
[ "Apache-2.0" ]
245
2018-10-23T12:52:09.000Z
2022-03-31T20:16:04.000Z
src/StoneCutter/SCParser.cpp
rkabrick/CoreGen
e456763d6b669370b9a17d92552516ebc2887ddf
[ "Apache-2.0" ]
5
2019-10-15T15:01:04.000Z
2022-02-18T17:09:12.000Z
// // _SCParser_cpp_ // // Copyright (C) 2017-2020 Tactical Computing Laboratories, LLC // All Rights Reserved // contact@tactcomplabs.com // // See LICENSE in the top level directory for licensing details // #include "CoreGen/StoneCutter/SCParser.h" LLVMContext SCParser::TheContext; IRBuilder<> SCParser::Builder(TheContext); std::unique_ptr<Module> SCParser::TheModule; std::unique_ptr<legacy::FunctionPassManager> SCParser::TheFPM; std::map<std::string, std::unique_ptr<PrototypeAST>> SCParser::FunctionProtos; std::map<std::string, AllocaInst*> SCParser::NamedValues; std::map<std::string, GlobalVariable*> SCParser::GlobalNamedValues; std::map<std::string, unsigned> SCParser::PipeInstances; unsigned SCParser::LabelIncr; bool SCParser::IsOpt = false; bool SCParser::IsPipe = false; SCMsg *SCParser::GMsgs = nullptr; MDNode *SCParser::NameMDNode = nullptr; MDNode *SCParser::InstanceMDNode = nullptr; MDNode *SCParser::PipelineMDNode = nullptr; SCParser::SCParser(std::string B, std::string F, SCOpts *O, SCMsg *M) : CurTok(-1), InBuf(B), FileName(F), Opts(O), Msgs(M), Lex(new SCLexer()), InFunc(false), Rtn(true) { TheModule = llvm::make_unique<Module>(StringRef(FileName), TheContext); GMsgs = M; InitBinopPrecedence(); LabelIncr = 0; InitPassMap(); InitIntrinsics(); } SCParser::SCParser(SCMsg *M) : CurTok(-1), Msgs(M), Lex(nullptr), InFunc(false) { GMsgs = M; InitBinopPrecedence(); LabelIncr = 0; InitPassMap(); InitIntrinsics(); } SCParser::~SCParser(){ TheModule.reset(); TheFPM.reset(); NamedValues.clear(); Intrins.clear(); delete Lex; SCParser::NamedValues.clear(); SCParser::GlobalNamedValues.clear(); SCParser::FunctionProtos.clear(); SCParser::PipeInstances.clear(); } void SCParser::InitIntrinsics(){ Intrins.push_back(static_cast<SCIntrin *>(new SCMax())); Intrins.push_back(static_cast<SCIntrin *>(new SCMin())); Intrins.push_back(static_cast<SCIntrin *>(new SCLoad())); Intrins.push_back(static_cast<SCIntrin *>(new SCStore())); Intrins.push_back(static_cast<SCIntrin *>(new SCLoadElem())); Intrins.push_back(static_cast<SCIntrin *>(new SCStoreElem())); Intrins.push_back(static_cast<SCIntrin *>(new SCNot())); Intrins.push_back(static_cast<SCIntrin *>(new SCNeg())); Intrins.push_back(static_cast<SCIntrin *>(new SCReverse())); Intrins.push_back(static_cast<SCIntrin *>(new SCPopcount())); Intrins.push_back(static_cast<SCIntrin *>(new SCClz())); Intrins.push_back(static_cast<SCIntrin *>(new SCCtz())); Intrins.push_back(static_cast<SCIntrin *>(new SCSext())); Intrins.push_back(static_cast<SCIntrin *>(new SCZext())); Intrins.push_back(static_cast<SCIntrin *>(new SCRotateL())); Intrins.push_back(static_cast<SCIntrin *>(new SCRotateR())); Intrins.push_back(static_cast<SCIntrin *>(new SCMaj())); Intrins.push_back(static_cast<SCIntrin *>(new SCDoz())); Intrins.push_back(static_cast<SCIntrin *>(new SCCompress())); Intrins.push_back(static_cast<SCIntrin *>(new SCCompressM())); Intrins.push_back(static_cast<SCIntrin *>(new SCInsertS())); Intrins.push_back(static_cast<SCIntrin *>(new SCInsertZ())); Intrins.push_back(static_cast<SCIntrin *>(new SCExtractS())); Intrins.push_back(static_cast<SCIntrin *>(new SCExtractZ())); Intrins.push_back(static_cast<SCIntrin *>(new SCMerge())); Intrins.push_back(static_cast<SCIntrin *>(new SCConcat())); Intrins.push_back(static_cast<SCIntrin *>(new SCLss())); Intrins.push_back(static_cast<SCIntrin *>(new SCFence())); Intrins.push_back(static_cast<SCIntrin *>(new SCBsel())); Intrins.push_back(static_cast<SCIntrin *>(new SCNop())); } void SCParser::InitPassMap(){ //#if 0 EPasses.insert(std::pair<std::string,bool>("PromoteMemoryToRegisterPass",true)); EPasses.insert(std::pair<std::string,bool>("InstructionCombiningPass",true)); EPasses.insert(std::pair<std::string,bool>("ReassociatePass",true)); //#endif EPasses.insert(std::pair<std::string,bool>("GVNPass",true)); EPasses.insert(std::pair<std::string,bool>("CFGSimplificationPass",true)); EPasses.insert(std::pair<std::string,bool>("ConstantPropagationPass",true)); EPasses.insert(std::pair<std::string,bool>("IndVarSimplifyPass",true)); EPasses.insert(std::pair<std::string,bool>("LICMPass",true)); EPasses.insert(std::pair<std::string,bool>("LoopDeletionPass",true)); EPasses.insert(std::pair<std::string,bool>("LoopIdiomPass",true)); EPasses.insert(std::pair<std::string,bool>("LoopRerollPass",true)); EPasses.insert(std::pair<std::string,bool>("LoopRotatePass",true)); EPasses.insert(std::pair<std::string,bool>("LoopUnswitchPass",true)); } bool SCParser::SetInputs( std::string B, std::string F ){ InBuf = B; FileName = F; if( Lex ){ delete Lex; } Lex = new SCLexer(); TheModule = llvm::make_unique<Module>(StringRef(FileName), TheContext); return true; } //===----------------------------------------------------------------------===// // Optimizer //===----------------------------------------------------------------------===// std::vector<std::string> SCParser::GetPassList(){ std::vector<std::string> P; for( auto it = EPasses.begin(); it != EPasses.end(); ++it ){ P.push_back(it->first); } return P; } // Utilizes Levenshtein Edit Distance algorithm from: // https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C++ // Based upon the original common Lisp implementation whereby only two of the columns // in the matrix are utilized unsigned SCParser::EditDistance( std::string &s1, std::string &s2 ){ const std::size_t len1 = s1.size(), len2 = s2.size(); std::vector<unsigned int> col(len2+1), prevCol(len2+1); for (unsigned int i = 0; i < prevCol.size(); i++){ prevCol[i] = i; } for (unsigned int i = 0; i < len1; i++) { col[0] = i+1; for (unsigned int j = 0; j < len2; j++){ // note that std::min({arg1, arg2, arg3}) works only in C++11, // for C++98 use std::min(std::min(arg1, arg2), arg3) col[j+1] = std::min({ prevCol[1 + j] + 1, col[j] + 1, prevCol[j] + (s1[i]==s2[j] ? 0 : 1) }); } col.swap(prevCol); } return prevCol[len2]; } std::string SCParser::GetNearbyString(std::string &Input){ // build a vector of the known pass names std::vector<std::string> Passes; for( auto it = EPasses.begin(); it != EPasses.end(); ++it ){ Passes.push_back(it->first); } // search the vector std::string RtnStr; unsigned LowVal; // walk all the pass values and find their edit distance from the input LowVal = EditDistance(Input,Passes[0]); RtnStr = Passes[0]; for( unsigned i=1; i<Passes.size(); i++ ){ unsigned tmp = EditDistance(Input,Passes[i]); if( tmp < LowVal ){ LowVal = tmp; RtnStr = Passes[i]; } } return RtnStr; } bool SCParser::CheckPassNames(std::vector<std::string> P){ bool rtn = true; for( unsigned i=0; i<P.size(); i++ ){ auto Search = EPasses.find(P[i]); if( Search == EPasses.end() ){ // misspelled pass name Msgs->PrintMsg( L_ERROR, "Unknown pass name: \"" + P[i] + "\". Did you mean " + GetNearbyString(P[i]) + "?"); rtn = false; } } return rtn; } bool SCParser::DisablePasses(std::vector<std::string> P){ if( !CheckPassNames(P) ){ // something is misspelled return false; } // enable everything, just to be pedantic for( auto it=EPasses.begin(); it != EPasses.end(); ++it){ it->second = true; } // disable individual passes for( unsigned i=0; i<P.size(); i++ ){ for( auto it=EPasses.begin(); it != EPasses.end(); ++it){ if( it->first == P[i] ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Disabling LLVM Pass: " + it->first ); it->second = false; } } } return true; } void SCParser::EnableAllPasses(){ for( auto it=EPasses.begin(); it != EPasses.end(); ++it){ it->second = true; } } bool SCParser::EnablePasses(std::vector<std::string> P){ if( !CheckPassNames(P) ){ // something is misspelled return false; } // disable everything, just to be pedantic for( auto it=EPasses.begin(); it != EPasses.end(); ++it){ it->second = false; } // disable individual passes for( unsigned i=0; i<P.size(); i++ ){ for( auto it=EPasses.begin(); it != EPasses.end(); ++it){ if( it->first == P[i] ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Enabling LLVM Pass: " + it->first ); it->second = true; } } } return true; } bool SCParser::IsPassEnabled(std::string P){ if( P.length() == 0 ){ return false; } std::map<std::string,bool>::iterator it; for( it = EPasses.begin(); it != EPasses.end(); ++it ){ if( it->first == P ){ return it->second; } } return false; } void SCParser::InitModuleandPassManager(){ // create a new pass manager TheFPM = llvm::make_unique<legacy::FunctionPassManager>(TheModule.get()); // promote allocas to registers if( IsPassEnabled("PromoteMemoryToRegisterPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: PromoteMemoryToRegisterPass"); TheFPM->add(createPromoteMemoryToRegisterPass()); } // enable simple peephole opts and bit-twiddling opts if( IsPassEnabled("InstructionCombiningPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: InstructionCombiningPass"); TheFPM->add(createInstructionCombiningPass()); } // enable reassociation of epxressions if( IsPassEnabled("ReassociatePass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: ReassociatePass"); TheFPM->add(createReassociatePass()); } // eliminate common subexpressions if( IsPassEnabled("GVNPass" ) ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: GVNPass"); TheFPM->add(createGVNPass()); } // simplify the control flow graph if( IsPassEnabled("CFGSimplificationPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: CFGSimplificationPass"); TheFPM->add(createCFGSimplificationPass()); } // constant propogations if( IsPassEnabled("ConstantPropagationPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: ConstantPropagationPass"); TheFPM->add(createConstantPropagationPass()); } // induction variable simplification pass if( IsPassEnabled("IndVarSimplifyPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: IndVarSimplifyPass"); TheFPM->add(createIndVarSimplifyPass()); } // loop invariant code motion if( IsPassEnabled("LICMPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: LICMPass"); TheFPM->add(createLICMPass()); } // loop deletion if( IsPassEnabled( "LoopDeletionPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: LoopDeletionPass"); TheFPM->add(createLoopDeletionPass()); } // loop idiom if( IsPassEnabled( "LoopIdiomPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: LoopIdiomPass"); TheFPM->add(createLoopIdiomPass()); } // loop re-roller if( IsPassEnabled( "LoopRerollPass") ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: LoopRerollPass"); TheFPM->add(createLoopRerollPass()); } // loop rotation if( IsPassEnabled( "LoopRotatePass" ) ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: LoopRotatePass"); TheFPM->add(createLoopRotatePass()); } // loop unswitching if( IsPassEnabled( "LoopUnswitchPass" ) ){ if( Opts->IsVerbose() ) Msgs->PrintRawMsg( "Executing LLVM Pass: LoopUnswitchPass"); TheFPM->add(createLoopUnswitchPass()); } // Init it! TheFPM->doInitialization(); } bool SCParser::Optimize(){ InitModuleandPassManager(); SCParser::IsOpt = true; return true; } //===----------------------------------------------------------------------===// // Parser //===----------------------------------------------------------------------===// bool SCParser::CheckIntrinName( std::string Name ){ if( Name.length() == 0 ){ return false; } for( unsigned i=0; i<Intrins.size(); i++ ){ if( Name == Intrins[i]->GetKeyword() ){ return true; } } return false; } unsigned SCParser::GetNumIntrinArgs( std::string Name ){ if( Name.length() == 0 ){ return 0; } for( unsigned i=0; i<Intrins.size(); i++ ){ if( Name == Intrins[i]->GetKeyword() ){ return Intrins[i]->GetNumInputs(); } } return 0; } bool SCParser::InsertExternIntrin(){ for( unsigned i=0; i<Intrins.size(); i++ ){ // insert the intrinsic definition std::string TmpStr = "extern " + Intrins[i]->GetKeyword() + "("; for( unsigned j=0; j<Intrins[i]->GetNumInputs(); j++ ){ TmpStr += "a"; TmpStr += std::to_string(j); if( j != (Intrins[i]->GetNumInputs()-1) ){ TmpStr += " "; } } TmpStr += ");\n"; InBuf.insert(0,TmpStr); } return true; } void SCParser::InitBinopPrecedence(){ BinopPrecedence['='] = 10; BinopPrecedence['<'] = 11; BinopPrecedence['>'] = 11; BinopPrecedence['|'] = 15; BinopPrecedence['^'] = 16; BinopPrecedence['&'] = 17; //BinopPrecedence['!'] = 18; BinopPrecedence['+'] = 20; BinopPrecedence['-'] = 20; BinopPrecedence['*'] = 40; BinopPrecedence['/'] = 40; BinopPrecedence['%'] = 40; // dyadic operators BinopPrecedence[dyad_shfl] = 13; BinopPrecedence[dyad_shfr] = 13; BinopPrecedence[dyad_shfr] = 13; BinopPrecedence[dyad_eqeq] = 12; BinopPrecedence[dyad_noteq] = 12; BinopPrecedence[dyad_logand] = 11; BinopPrecedence[dyad_logor] = 11; } bool SCParser::Parse(){ if( InBuf.length() == 0 ){ Msgs->PrintMsg( L_ERROR, "No StoneCutter input defined"); return false; } // insert all the necessary intrinsic externs if( !InsertExternIntrin() ){ Msgs->PrintMsg( L_ERROR, "Could not adjust input buffer to include intrinsic definitions" ); return false; } // set the input buffer for the lexer if( !Lex ){ Msgs->PrintMsg( L_ERROR, "The StoneCutter lexer is not initialized" ); return false; }else if( !Lex->SetInput(InBuf) ){ Msgs->PrintMsg( L_ERROR, "Failed to initialize the input buffer for the lexer" ); return false; } // reset the character entry point to the beginning Lex->Reset(); // pull the first token GetNextToken(); while(true){ switch(CurTok){ case tok_eof: if( InFunc ){ // no close bracket found return false; } return Rtn; case ';': GetNextToken(); break; case tok_def: HandleDefinition(); break; case tok_extern: HandleExtern(); break; case tok_regclass: HandleRegClass(); break; case tok_pipeline: HandlePipeline(); break; case tok_instf: HandleInstFormat(); break; case '}': HandleFuncClose(); break; default: HandleTopLevelExpression(); break; } } return Rtn; } bool SCParser::GetFieldAttr( std::string Str, SCInstField &F ){ // parse the incoming string and determine if it matches // an existing instruction format field type if( (Str == "enc") || (Str == "ENC") ){ F = field_enc; return true; }else if( (Str == "reg") || (Str == "REG") ){ F = field_reg; return true; }else if( (Str == "imm") || (Str == "IMM") ){ F = field_imm; return true; } F = field_unk; return false; } bool SCParser::GetVarAttr( std::string Str, VarAttrs &V ){ // parse the variable attribute string // and determine what type of variable it is // common types for speed int Idx = 0; while( VarAttrEntryTable[Idx].Name != "." ){ if( Str == VarAttrEntryTable[Idx].Name ){ V.width = VarAttrEntryTable[Idx].width; V.elems = VarAttrEntryTable[Idx].elems; V.defSign = VarAttrEntryTable[Idx].IsDefSign; V.defVector = VarAttrEntryTable[Idx].IsDefVector; V.defFloat = VarAttrEntryTable[Idx].IsDefFloat; V.defRegClass = false; return true; } Idx++; } if( Str[0] == 'u' ){ // unsigned variable V.elems = 1; V.defSign = false; V.defVector = false; V.defFloat = false; V.defRegClass = false; V.width = std::stoi( Str.substr(1,Str.length()-1) ); return true; }else if( Str[0] == 's' ){ // signed variable V.elems = 1; V.defSign = true; V.defVector = false; V.defFloat = false; V.defRegClass = false; V.width = std::stoi( Str.substr(1,Str.length()-1) ); return true; } return false; } int SCParser::GetNextToken(){ CurTok = Lex->GetTok(); return CurTok; } int SCParser::GetTokPrecedence(){ if( CurTok == tok_dyad ){ return BinopPrecedence[StrToDyad()]; } if (!isascii(CurTok)) return -1; // Make sure it's a declared binop. int TokPrec = BinopPrecedence[CurTok]; if (TokPrec <= 0) return -1; return TokPrec; } int SCParser::StrToDyad(){ std::string TStr = Lex->GetIdentifierStr(); if( TStr == "<<" ){ return dyad_shfl; }else if( TStr == ">>" ){ return dyad_shfr; }else if( TStr == "==" ){ return dyad_eqeq; }else if( TStr == "!=" ){ return dyad_noteq; }else if( TStr == "&&" ){ return dyad_logand; }else if( TStr == "||" ){ return dyad_logor; }else if( TStr == ">=" ){ return dyad_gte; }else if( TStr == "<=" ){ return dyad_lte; }else{ return '.'; // this will induce an error } } std::unique_ptr<ExprAST> SCParser::ParseNumberExpr() { auto Result = llvm::make_unique<NumberExprAST>(Lex->GetNumVal()); GetNextToken(); // consume the number return std::move(Result); } std::unique_ptr<ExprAST> SCParser::ParseParenExpr() { GetNextToken(); // eat (. auto V = ParseExpression(); if (!V) return nullptr; if (CurTok != ')') return LogError("expected ')'"); GetNextToken(); // eat ). return V; } std::unique_ptr<ExprAST> SCParser::ParseIdentifierExpr() { std::string IdName = Lex->GetIdentifierStr(); GetNextToken(); // eat identifier. if (CurTok != '(') // Simple variable ref. return llvm::make_unique<VariableExprAST>(IdName); // Call. GetNextToken(); // eat ( std::vector<std::unique_ptr<ExprAST>> Args; if (CurTok != ')') { while (true) { if (auto Arg = ParseExpression()) Args.push_back(std::move(Arg)); else return nullptr; if (CurTok == ')') break; if (CurTok != ',') return LogError("Expected ')' or ',' in argument list"); GetNextToken(); } } // Eat the ')'. GetNextToken(); if( CurTok == ';' ){ GetNextToken(); // eat ';' } // Check to see if the call is an intrinsic bool Intrin = false; if( CheckIntrinName(IdName) ){ // we have an intrinsic, check the argument list Intrin = true; if( GetNumIntrinArgs(IdName) != Args.size() ){ // argument mismatch return LogError( IdName + " intrinsic requires " + std::to_string(GetNumIntrinArgs(IdName)) + " arguments." ); } } return llvm::make_unique<CallExprAST>(IdName, std::move(Args), Intrin); } std::unique_ptr<ExprAST> SCParser::ParseIfExpr() { GetNextToken(); // eat the if. if( CurTok != '(' ) return LogError("expected '(' for conditional statement"); GetNextToken(); // eat the '(' // condition. auto Cond = ParseExpression(); if (!Cond){ return nullptr; } if( CurTok != ')' ) return LogError("expected ')' for conditional statement"); GetNextToken(); // eat the ')' if( CurTok != '{' ) return LogError("expected '{' for conditional expression body"); GetNextToken(); // eat the '{' std::vector<std::unique_ptr<ExprAST>> ThenExpr; while( CurTok != '}' ){ auto Body = ParseExpression(); if( !Body ) return nullptr; ThenExpr.push_back(std::move(Body)); } if( CurTok != '}' ) return LogError("expected '}' for conditional expression body"); GetNextToken(); // eat the '}' // parse the optional else block std::unique_ptr<ExprAST> Else = nullptr; std::vector<std::unique_ptr<ExprAST>> ElseExpr; if( CurTok == tok_else ){ // parse else{ <Expression> } GetNextToken(); // eat the else if( CurTok != '{' ){ LogError("expected '{' for conditional else statement"); } GetNextToken(); // eat the '{' while( CurTok != '}' ){ auto Body = ParseExpression(); if( !Body ) return nullptr; ElseExpr.push_back(std::move(Body)); } if( CurTok != '}' ){ LogError("expected '}' for conditional else statement"); } GetNextToken(); // eat the '}' } return llvm::make_unique<IfExprAST>(std::move(Cond), std::move(ThenExpr), std::move(ElseExpr)); } std::unique_ptr<ExprAST> SCParser::ParsePrimary() { switch (CurTok) { default: return LogError("unknown token when expecting an expression" ); case tok_identifier: return ParseIdentifierExpr(); case tok_number: return ParseNumberExpr(); case '(': return ParseParenExpr(); case tok_if: return ParseIfExpr(); case tok_for: return ParseForExpr(); case tok_while: return ParseWhileExpr(); case tok_do: return ParseDoWhileExpr(); case tok_var: return ParseVarExpr(); case tok_pipe: return ParsePipeExpr(); } } std::unique_ptr<ExprAST> SCParser::ParseBinOpRHS(int ExprPrec, std::unique_ptr<ExprAST> LHS) { // If this is a binop, find its precedence. while (true) { int TokPrec = GetTokPrecedence(); // If this is a binop that binds at least as tightly as the current binop, // consume it, otherwise we are done. if (TokPrec < ExprPrec) return LHS; // Okay, we know this is a binop. int BinOp = CurTok; // handle dyadic binary operators if( BinOp == tok_dyad ){ // convert BinOp to dyadic operator BinOp = StrToDyad(); } GetNextToken(); // eat binop; must be done after dyadic operator conversion // Parse the primary expression after the binary operator. auto RHS = ParsePrimary(); if (!RHS) return nullptr; // If BinOp binds less tightly with RHS than the operator after RHS, let // the pending operator take RHS as its LHS. int NextPrec = GetTokPrecedence(); if (TokPrec < NextPrec) { RHS = ParseBinOpRHS(TokPrec + 1, std::move(RHS)); if (!RHS) return nullptr; } // Merge LHS/RHS. LHS = llvm::make_unique<BinaryExprAST>(BinOp, std::move(LHS), std::move(RHS)); } } // parse the variable definition lists // this can be one of the following permutations: // - DATATYPE VARNAME // - DATATYPE VARNAME = INITIALIZER // - DATATYPE VARNAME, VARNAME, VARNAME, VARNAME // - DATATYPE VARNAME = INITIALIZER, VARNAME, VARNAME std::unique_ptr<ExprAST> SCParser::ParseVarExpr(){ GetNextToken(); // eat the datatype std::vector<std::pair<std::string,std::unique_ptr<ExprAST>>> VarNames; std::vector<VarAttrs> Attrs; // variable attributes if( CurTok != tok_identifier ) return LogError("expected identifier after variable datatype"); while(true){ std::string Name = Lex->GetIdentifierStr(); GetNextToken(); // eat identifier. // Read the optional initializer. std::unique_ptr<ExprAST> Init = nullptr; if (CurTok == '=') { GetNextToken(); // eat the '='. Init = ParseExpression(); if (!Init) return nullptr; } // add the new variable to our vector VarNames.push_back(std::make_pair(Name, std::move(Init))); Attrs.push_back(Lex->GetVarAttrs()); // check for the end of the variable list if( CurTok != ',' ){ break; } GetNextToken(); // eat the ',' if( CurTok != tok_identifier ) LogError("expected identifier list in variable definition"); }// end parsing the variable list auto Body = ParseExpression(); if (!Body) return nullptr; return llvm::make_unique<VarExprAST>(std::move(VarNames), std::move(Attrs), std::move(Body) ); } std::unique_ptr<ExprAST> SCParser::ParseDoWhileExpr(){ GetNextToken(); // eat the do if (CurTok != '{') return LogError("expected '{' for do while loop control statement"); GetNextToken(); // eat the '{' std::vector<std::unique_ptr<ExprAST>> BodyExpr; while( CurTok != '}' ){ auto Body = ParseExpression(); if( !Body ) return nullptr; BodyExpr.push_back(std::move(Body)); } // handle close bracket if( CurTok != '}' ) return LogError("expected '}' for do while loop control body"); GetNextToken(); // eat the '}' if( CurTok != tok_while ) return LogError("expected 'while' for do while loop control"); GetNextToken(); // eat the 'do' if( CurTok != '(' ) return LogError("expected '(' after 'do' token in do while loop control"); GetNextToken(); // eat the '(' // parse the while conditional expression auto Cond = ParseExpression(); if (!Cond) return nullptr; if (CurTok != ')') return LogError("expected ')' for do while loop control statement"); GetNextToken(); // eat the ')' return llvm::make_unique<DoWhileExprAST>(std::move(Cond),std::move(BodyExpr)); } std::unique_ptr<ExprAST> SCParser::ParseWhileExpr(){ GetNextToken(); // eat the while if (CurTok != '(' ) return LogError("expected '(' for while loop control statement"); GetNextToken(); // eat the '(' // parse the while conditional expression auto Cond = ParseExpression(); if (!Cond) return nullptr; if (CurTok != ')') return LogError("expected ')' for while loop control statement"); GetNextToken(); // eat ')' // check for open bracket if (CurTok != '{'){ return LogError("expected '{' for while loop control body"); } GetNextToken(); // eat '{' std::vector<std::unique_ptr<ExprAST>> BodyExpr; while( CurTok != '}' ){ auto Body = ParseExpression(); if( !Body ) return nullptr; BodyExpr.push_back(std::move(Body)); } // handle close bracket if( CurTok != '}' ){ return LogError("expected '}' for while loop control body"); } GetNextToken(); // eat the '}' return llvm::make_unique<WhileExprAST>(std::move(Cond),std::move(BodyExpr)); } std::unique_ptr<ExprAST> SCParser::ParsePipeExpr() { if( IsPipe ) return LogError("Nested pipes are not supported"); GetNextToken(); // eat the 'pipe' if (CurTok != tok_identifier) return LogError("expected identifier after pipe"); std::string PipeName = Lex->GetIdentifierStr(); GetNextToken(); // eat identifier. std::string PipeLine; if( CurTok == ':' ){ GetNextToken(); if( CurTok != tok_identifier) return LogError("expected pipeline identifier after 'pipe:'"); PipeLine = Lex->GetIdentifierStr(); GetNextToken(); std::map<std::string, GlobalVariable*>::iterator it; it = SCParser::GlobalNamedValues.find(PipeLine); if( it == SCParser::GlobalNamedValues.end() ){ return LogError("Pipeline=" + PipeLine + " was not previously defined"); } } if (CurTok != '{' ) return LogError("expected '{' for while loop control statement"); GetNextToken(); // eat the '{' IsPipe = true; // mark the fact that we're inside a pipe expression // get the instance of the current pipe unsigned Instance = 0; std::map<std::string,unsigned>::iterator it = PipeInstances.find(PipeName); if( it != PipeInstances.end() ){ // increment the instance count it->second++; Instance = it->second; }else{ // first instance of the pipe PipeInstances.insert(std::make_pair(PipeName,0)); } std::vector<std::unique_ptr<ExprAST>> BodyExpr; while( CurTok != '}' ){ auto Body = ParseExpression(); if( !Body ) return nullptr; BodyExpr.push_back(std::move(Body)); } if( BodyExpr.size() == 0 ){ return LogError("Pipeline=" + PipeLine + " has no body"); } // handle close bracket if( CurTok != '}' ) return LogError("expected '}' for do while loop control body"); GetNextToken(); // eat the '}' IsPipe = false; return llvm::make_unique<PipeExprAST>(PipeName,PipeLine,Instance,std::move(BodyExpr)); } std::unique_ptr<ExprAST> SCParser::ParseForExpr() { GetNextToken(); // eat the for. if (CurTok != '(' ) return LogError("expected '(' for loop control statement"); GetNextToken(); // eat the '(' if (CurTok != tok_identifier) return LogError("expected identifier after for"); std::string IdName = Lex->GetIdentifierStr(); GetNextToken(); // eat identifier. if (CurTok != '=') return LogError("expected '=' after for"); GetNextToken(); // eat '='. auto Start = ParseExpression(); if (!Start) return nullptr; if (CurTok != ';') return LogError("expected ',' after for start value"); GetNextToken(); auto End = ParseExpression(); if (!End) return nullptr; // The step value is optional. std::unique_ptr<ExprAST> Step; if (CurTok == ';') { GetNextToken(); Step = ParseExpression(); if (!Step) return nullptr; }else{ return LogError("expected ';' for loop control step statement"); } if (CurTok != ')') return LogError("expected ')' for loop control statement"); GetNextToken(); // eat ')' // check for open bracket if (CurTok != '{'){ return LogError("expected '{' for loop control body"); } GetNextToken(); // eat '{' std::vector<std::unique_ptr<ExprAST>> BodyExpr; while( CurTok != '}' ){ auto Body = ParseExpression(); if( !Body ) return nullptr; BodyExpr.push_back(std::move(Body)); } // handle close bracket if( CurTok != '}' ){ return LogError("expected '}' for loop control body"); } GetNextToken(); // eat the '}' return llvm::make_unique<ForExprAST>(IdName, std::move(Start), std::move(End), std::move(Step), std::move(BodyExpr)); } std::unique_ptr<ExprAST> SCParser::ParseExpression() { auto LHS = ParsePrimary(); if (!LHS) return nullptr; return ParseBinOpRHS(0, std::move(LHS)); } std::unique_ptr<PrototypeAST> SCParser::ParsePrototype() { if (CurTok != tok_identifier) return LogErrorP("Expected function name in prototype"); std::string FnName = Lex->GetIdentifierStr(); GetNextToken(); // parse the optional inst format std::string InstFormat; if(CurTok == ':'){ GetNextToken(); if( CurTok != tok_identifier ) return LogErrorP("Expected identifier in instruction prototype instruction format: 'name:format'"); InstFormat = Lex->GetIdentifierStr(); GetNextToken(); // eat the identifier } if (CurTok != '(') return LogErrorP("Expected '(' in prototype"); std::vector<std::string> ArgNames; while (GetNextToken() == tok_identifier){ std::string LVar = Lex->GetIdentifierStr(); Value *V = SCParser::GlobalNamedValues[LVar]; if( !V ){ // not a global variable ArgNames.push_back(LVar); } } #if 0 while (GetNextToken() == tok_identifier) ArgNames.push_back(Lex->GetIdentifierStr()); #endif if (CurTok != ')') return LogErrorP("Expected ')' in prototype"); // success. GetNextToken(); // eat ')'. return llvm::make_unique<PrototypeAST>(FnName, InstFormat, std::move(ArgNames)); } VarAttrs SCParser::GetMaxVarAttr(std::vector<VarAttrs> ArgAttrs){ VarAttrs Attr; Attr.elems = 1; Attr.defSign = false; Attr.defVector = false; Attr.defFloat = false; unsigned Max = 0; for( unsigned i=0; i<ArgAttrs.size(); i++ ){ if( ArgAttrs[i].width > Max ){ Max = ArgAttrs[i].width; } } Attr.width = Max; return Attr; } std::unique_ptr<InstFormatAST> SCParser::ParseInstFormatDef(){ if(CurTok != tok_identifier) return LogErrorIF("Expected instruction format name in prototype"); std::string FName = Lex->GetIdentifierStr(); GetNextToken(); if(CurTok != '(' ) return LogErrorIF("Expected '(' in instruction format prototype= " + FName); std::vector<std::tuple<std::string, SCInstField, std::string, unsigned>> Fields; // vector of field tuples // try to pull the next identifier GetNextToken(); // parse all the field names while( CurTok == tok_identifier ){ std::string TypeStr = Lex->GetIdentifierStr(); SCInstField FieldType = field_unk; if( !GetFieldAttr( TypeStr, FieldType) ){ return LogErrorIF("Unknown field type: " + TypeStr ); } // if the field type is a register, read the register class type std::string RegType = "."; if( FieldType == field_reg ){ GetNextToken(); if( CurTok != '[' ) return LogErrorIF("Expected '[' in register field definition: " + FName ); GetNextToken(); if( CurTok != tok_identifier ) return LogErrorIF("Expected register class type in register field definition: instruction format=" + FName ); RegType = Lex->GetIdentifierStr(); GetNextToken(); if( CurTok != ']' ) return LogErrorIF("Expected ']' in register field definition: " + FName ); } // eat the previous token GetNextToken(); if( CurTok != tok_identifier ) return LogErrorIF("Expected field name in field definition: " + FName ); std::string FieldName = Lex->GetIdentifierStr(); // look for the optional width specifier unsigned Width = 0; GetNextToken(); if( CurTok == ':' ){ // eat the colon GetNextToken(); // parse a numeric value if( CurTok != tok_number ){ return LogErrorIF("Expected numeric identifier in field width defintition: " + FName ); } Width = (unsigned)(Lex->GetNumVal()); GetNextToken(); } // add it to the vector Fields.push_back(std::tuple<std::string,SCInstField,std::string,unsigned> (FieldName,FieldType,RegType,Width)); // look for commas and the end of the definition if( CurTok == ',' ){ // eat the comma GetNextToken(); } } if (CurTok != ')') return LogErrorIF("Expected ')' in instruction format"); // success GetNextToken(); // eat ')'. return llvm::make_unique<InstFormatAST>(FName, std::move(Fields)); } std::unique_ptr<PipelineAST> SCParser::ParsePipeline(){ GetNextToken(); //eat pipeline return ParsePipelineDef(); } std::unique_ptr<PipelineAST> SCParser::ParsePipelineDef(){ if( CurTok != tok_identifier ) return LogErrorPI("Expected pipeline name in prototype"); std::string PName = Lex->GetIdentifierStr(); GetNextToken(); std::map<std::string, GlobalVariable*>::iterator it; it = SCParser::GlobalNamedValues.find(PName); if( it != SCParser::GlobalNamedValues.end() ){ return LogErrorPI("Found duplicate pipeline name: " + PName ); } if (CurTok != '(') return LogErrorPI("Expected '(' in pipeline prototype"); std::vector<std::string> Attrs; // vector of pipeline attributes // pull the next identifier GetNextToken(); // eat the '(' while (CurTok == tok_pipeattr){ Attrs.push_back(Lex->GetIdentifierStr()); GetNextToken(); // -- // Parse a comma, if a comma exist, move to the next attribute // -- if( CurTok == ',' ){ // eat the comma GetNextToken(); }else{ break; // probably the end of the attribute list } }// end while loop if (CurTok != ')') return LogErrorPI("Expected ')' in pipeline prototype"); // success. GetNextToken(); // eat ')'. return llvm::make_unique<PipelineAST>(PName, std::move(Attrs)); } std::unique_ptr<RegClassAST> SCParser::ParseRegClassDef(){ if (CurTok != tok_identifier) return LogErrorR("Expected regclass name in prototype"); std::string RName = Lex->GetIdentifierStr(); GetNextToken(); if (CurTok != '(') return LogErrorR("Expected '(' in regclass prototype"); std::string PCName; // name of the PC register std::vector<std::string> ArgNames; // vector of register names std::vector<VarAttrs> ArgAttrs; // vector of register attributes std::vector<std::tuple<std::string, std::string, VarAttrs>> SubRegs; // vector of subregister tuples // try to pull the next identifier GetNextToken(); while (CurTok == tok_var){ std::string Type = Lex->GetIdentifierStr(); VarAttrs VAttr; if( !GetVarAttr( Type, VAttr ) ){ return LogErrorR("Unknown variable type: " + Type ); } if( GetNextToken() != tok_identifier ){ return LogErrorR("Expected register name"); } std::string RegName = Lex->GetIdentifierStr(); // init the register attrs VAttr.defReadOnly = false; VAttr.defReadWrite = true; // default to true VAttr.defCSR = false; VAttr.defAMS = false; VAttr.defTUS = false; VAttr.defShared = false; // add them to our vector ArgAttrs.push_back(VAttr); ArgNames.push_back(RegName); // Look for the an attribute list, subregister list or comma GetNextToken(); // -- // Parse a brace, if a brace exists, parse an attribute list // -- if( CurTok == '[' ){ // attempt to parse the attribute field // eat the [ GetNextToken(); unsigned L_VAttr = ArgAttrs.size()-1; if( CurTok != tok_identifier ){ return LogErrorR("Expected register attribute in [..]"); } while( CurTok == tok_identifier ){ std::string LA = Lex->GetIdentifierStr(); if( LA == "PC" ){ PCName = RegName; }else if( LA == "RO" ){ ArgAttrs[L_VAttr].defReadOnly = true; ArgAttrs[L_VAttr].defReadWrite = false; }else if( LA == "RW" ){ ArgAttrs[L_VAttr].defReadWrite = true; ArgAttrs[L_VAttr].defReadOnly = false; }else if( LA == "CSR" ){ ArgAttrs[L_VAttr].defCSR = true; }else if( LA == "AMS" ){ ArgAttrs[L_VAttr].defAMS = true; }else if( LA == "TUS" ){ ArgAttrs[L_VAttr].defTUS = true; }else if( (LA == "Shared") || (LA == "SHARED") ){ ArgAttrs[L_VAttr].defShared = true; }else{ return LogErrorR("Unknown register attribute type: " + LA); } if( ArgAttrs[L_VAttr].defReadOnly && ArgAttrs[L_VAttr].defReadWrite ){ return LogErrorR("Cannot set Read-Only and Read-Write attributes on register=" + RegName ); } // eat the identifier GetNextToken(); if( CurTok == ',' ){ // eat the comma GetNextToken(); }else if( CurTok == ']' ){ // eat the closing brace GetNextToken(); break; }else{ return LogErrorR("Expected ',' or closing brace ']' in register attribute list for register=" + RegName); } } } // -- // Parse an open paren, if an open paren exists, parse a subregister list // -- if( CurTok == '(' ){ // attempt to parse the sub registers // eat the ( GetNextToken(); // walk all the subregisters while( CurTok == tok_var ){ std::string SType = Lex->GetIdentifierStr(); VarAttrs SAttr; if( !GetVarAttr( SType, SAttr ) ){ return LogErrorR("Unknown subregister type: " + SType ); } if( GetNextToken() != tok_identifier ){ return LogErrorR("Expected subregister name" ); } std::string SubReg = Lex->GetIdentifierStr(); // insert into the vector SubRegs.push_back(std::tuple<std::string,std::string,VarAttrs> (RegName,SubReg,SAttr)); // eat the identifier GetNextToken(); if( CurTok == ')' ){ // eat the ) GetNextToken(); break; }else if( CurTok == ',' ){ // eat the comma but continue reading sub registers GetNextToken(); }else{ // flag an error return LogErrorR("Expected ',' or ')' in subregister list"); } } } // -- // Parse a comma, if a comma exist, move to the next register // -- if( CurTok == ',' ){ // eat the comma GetNextToken(); }else{ break; } } //while (CurTok == tok_var) if (CurTok != ')') return LogErrorR("Expected ')' in regclass prototype"); // success. GetNextToken(); // eat ')'. // push back the register class name as a unique global // this will allow us to use this variable in the function prototype VarAttrs RVAttr = GetMaxVarAttr(ArgAttrs); RVAttr.defRegClass = true; ArgAttrs.push_back(RVAttr); ArgNames.push_back(RName); return llvm::make_unique<RegClassAST>(RName, PCName, std::move(ArgNames), std::move(ArgAttrs), std::move(SubRegs)); } std::unique_ptr<FunctionAST> SCParser::ParseDefinition() { GetNextToken(); // eat def. auto Proto = ParsePrototype(); if (!Proto) return nullptr; // check the prototype name against the list of existing intrinics if( CheckIntrinName(Proto->getName()) ){ return LogErrorF("Instruction definition collides with existing StoneCutter intrinsic: " + Proto->getName() ); } // check for open instruction body if( CurTok != '{' ) return LogErrorF("Expected '{' to open instruction body"); if( InFunc ){ return LogErrorF("Found mismatch '{'"); } GetNextToken(); // eat the '{' InFunc = true; std::vector<std::unique_ptr<ExprAST>> Exprs; while( CurTok != '}' ){ auto Body = ParseExpression(); if( !Body ) return nullptr; Exprs.push_back(std::move(Body)); } if( CurTok != '}' ) return LogErrorF("Expected '}' to close instruction body"); if( Exprs.size() == 0 ){ return LogErrorF("Empty instruction definition: " + Proto->getName() ); } GetNextToken(); // eat '}' InFunc = false; return llvm::make_unique<FunctionAST>(std::move(Proto), std::move(Exprs)); } bool SCParser::ParseCloseBracket(){ if( !InFunc ){ LogErrorF("Found mismatched '}'"); return false; } InFunc = false; GetNextToken(); // get the next token return true; } std::unique_ptr<RegClassAST> SCParser::ParseRegClass(){ GetNextToken(); //eat regclass return ParseRegClassDef(); } std::unique_ptr<InstFormatAST> SCParser::ParseInstFormat(){ GetNextToken(); //eat instformat return ParseInstFormatDef(); } std::unique_ptr<FunctionAST> SCParser::ParseTopLevelExpr() { if (auto E = ParseExpression()) { // Make an anonymous proto. auto Proto = llvm::make_unique<PrototypeAST>("__anon_expr", "", std::vector<std::string>()); std::vector<std::unique_ptr<ExprAST>> Exprs; Exprs.push_back(std::move(E)); //return llvm::make_unique<FunctionAST>(std::move(Proto), std::move(E)); return llvm::make_unique<FunctionAST>(std::move(Proto), std::move(Exprs)); } return nullptr; } std::unique_ptr<PrototypeAST> SCParser::ParseExtern(){ GetNextToken(); // eat extern. return ParsePrototype(); } void SCParser::HandleDefinition() { if (auto FnAST = ParseDefinition()) { if (auto *FnIR = FnAST->codegen()) { //fprintf(stderr, "Read function definition:"); //FnIR->print(errs()); //fprintf(stderr, "\n"); } } else { // Skip token for error recovery. Rtn = false; GetNextToken(); } } void SCParser::HandleExtern() { if (auto ProtoAST = ParseExtern()) { if (auto *FnIR = ProtoAST->codegen()) { //fprintf(stderr, "Read extern: "); //FnIR->print(errs()); //fprintf(stderr, "\n"); SCParser::FunctionProtos[ProtoAST->getName()] = std::move(ProtoAST); } } else { // Skip token for error recovery. Rtn = false; GetNextToken(); } } void SCParser::HandlePipeline(){ // evaluate the pipeline definition if( auto PipelineAST = ParsePipeline()){ if( auto *FnIR = PipelineAST->codegen()){ } }else{ Rtn = false; GetNextToken(); } } void SCParser::HandleRegClass() { // evaluate a register class definition if(auto RegClassAST = ParseRegClass()){ if( auto *FnIR = RegClassAST->codegen()){ //fprintf(stderr, "Read register class definition"); //FnIR->print(errs()); //fprintf(stderr, "\n"); } }else{ Rtn = false; GetNextToken(); } } void SCParser::HandleInstFormat() { // evaluate an instruction definition if(auto InstFormatAST = ParseInstFormat()){ if( auto *FnIR = InstFormatAST->codegen()){ } }else{ Rtn = false; GetNextToken(); } } void SCParser::HandleTopLevelExpression() { // Evaluate a top-level expression into an anonymous function. if (auto FnAST = ParseTopLevelExpr()) { if (auto *FnIR = FnAST->codegen()) { //fprintf(stderr, "Read top-level expression:"); //FnIR->print(errs()); //fprintf(stderr, "\n"); } } else { // Skip token for error recovery. Rtn = false; GetNextToken(); } } void SCParser::HandleFuncClose(){ if(!ParseCloseBracket()){ Rtn = false; GetNextToken(); } } //===----------------------------------------------------------------------===// // Code Generation //===----------------------------------------------------------------------===// static unsigned GetLocalLabel(){ unsigned LocalLabel = SCParser::LabelIncr; SCParser::LabelIncr++; return LocalLabel; } static AllocaInst *CreateEntryBlockAllocaAttr(Function *TheFunction, const std::string &VarName, VarAttrs Attr) { IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); if( Attr.defFloat ){ AllocaInst *AI = TmpB.CreateAlloca(Type::getDoubleTy(SCParser::TheContext), 0, VarName.c_str()); if( SCParser::NameMDNode ){ AI->setMetadata("pipe.pipeName",SCParser::NameMDNode); AI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); AI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } return AI; }else{ AllocaInst *AI = TmpB.CreateAlloca(Type::getIntNTy(SCParser::TheContext,Attr.width), 0, VarName.c_str()); if( SCParser::NameMDNode ){ AI->setMetadata("pipe.pipeName",SCParser::NameMDNode); AI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); AI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } return AI; } } static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, const std::string &VarName) { // if variable attributes are undefined, define a dummy u64 value VarAttrs A; A.width = 64; A.elems = 1; A.defSign = false; A.defVector = false; A.defFloat = false; return CreateEntryBlockAllocaAttr(TheFunction,VarName,A); } Function *getFunction(std::string Name ){ // see if the function has been added to the current module if( auto *F = SCParser::TheModule->getFunction(Name) ) return F; // if not, check whether we can emit the declaration auto FI = SCParser::FunctionProtos.find(Name); if( FI != SCParser::FunctionProtos.end() ){ return FI->second->codegen(); } return nullptr; } Value *NumberExprAST::codegen() { return ConstantInt::get(SCParser::TheContext, APInt(64,Val,false)); } Value *PipeExprAST::codegen() { // Emit the body of the pipe stage if( BodyExpr.size() == 0 ) return nullptr; // Retrieve the function so we can add the necessary attributes // Pipeline attribute names are monotonically numbered from 0->N // This allows us to have a single attribute with a list of pipeline stages // included therein Function *TheFunction = Builder.GetInsertBlock()->getParent(); AttributeSet AttrSet = TheFunction->getAttributes().getFnAttributes(); unsigned AttrVal = 0; while( AttrSet.hasAttribute("pipename"+std::to_string(AttrVal)) ){ AttrVal = AttrVal + 1; } TheFunction->addFnAttr("pipename" + std::to_string(AttrVal),PipeName); TheFunction->addFnAttr("pipeline" + std::to_string(AttrVal),PipeLine); std::vector<std::string> FoundVect; // walk all the pipelines and determine if the current pipe stage // is defined across multiple pipelines. if so, raise an error in the // parser and inform the user. if( PipeLine.length() > 0 ){ std::map<std::string, GlobalVariable*>::iterator it; it = SCParser::GlobalNamedValues.find(PipeLine); if( it != SCParser::GlobalNamedValues.end() ){ for( auto &Global : SCParser::TheModule->getGlobalList() ){ AttributeSet PAttrSet = Global.getAttributes(); if( PAttrSet.hasAttribute("pipeline") ){ bool done = false; unsigned Idx = 0; while( !done ){ if( !PAttrSet.hasAttribute("pipestage" + std::to_string(Idx)) ){ done = true; }else if( PAttrSet.getAttribute("pipestage" + std::to_string(Idx)).getValueAsString().str() == PipeName ){ FoundVect.push_back(PAttrSet.getAttribute("pipeline").getValueAsString().str()); } Idx = Idx + 1; }// end while }// end if( PAtterSet.hasAttribute) }// end for( Global ) } // end if( it != end() ) } // end if( PipeLine.length() ) if( FoundVect.size() > 1 ){ return LogErrorV( "Found a collision in pipe stages for pipeline=" + PipeLine + " for pipestage=" + PipeName ); } // build the metadata MDNode *N = MDNode::get(SCParser::TheContext, MDString::get(SCParser::TheContext,PipeName)); MDNode *PN = MDNode::get(SCParser::TheContext, MDString::get(SCParser::TheContext,PipeLine)); MDNode *TmpPI = MDNode::get(SCParser::TheContext, ConstantAsMetadata::get(ConstantInt::get( SCParser::TheContext, llvm::APInt(64, (uint64_t)(Instance), false)))); MDNode *PI = MDNode::get(SCParser::TheContext, TmpPI); // assign to the global copies such that the other codegen // functions can pick up the necessary MDNode's SCParser::NameMDNode = N; SCParser::InstanceMDNode = PI; SCParser::PipelineMDNode = PN; // Walk all the body instructions, emit them and tag each // instruction with the appropriate metadata for( unsigned i=0; i<BodyExpr.size(); i++ ){ Value *BVal = BodyExpr[i]->codegen(); if( isa<Instruction>(*BVal) ){ Instruction *Inst = cast<Instruction>(BVal); Inst->setMetadata("pipe.pipeName",N); Inst->setMetadata("pipe.pipeLine",PN); Inst->setMetadata("pipe.pipeInstance",PI); } } // exit the pipe codegen block SCParser::NameMDNode = nullptr; SCParser::InstanceMDNode = nullptr; SCParser::PipelineMDNode = nullptr; // pipe expr return Constant::getNullValue(Type::getIntNTy(SCParser::TheContext,64)); } Value *DoWhileExprAST::codegen() { // Retrieve the function parent Function *TheFunction = SCParser::Builder.GetInsertBlock()->getParent(); // Retrieve a unique local label unsigned LocalLabel = GetLocalLabel(); // Make the new basic block for the loop header, inserting after current // block. // loop entry block BasicBlock *LoopBB = BasicBlock::Create(SCParser::TheContext, "entrydowhile."+std::to_string(LocalLabel), TheFunction); // Insert an explicit fall through from the current block to the LoopBB. Builder.CreateBr(LoopBB); // Start insertion in LoopBB. Builder.SetInsertPoint(LoopBB); // Emit the body of the loop. This, like any other expr, can change the // current BB. Note that we ignore the value computed by the body, but don't // allow an error. if( BodyExpr.size() == 0 ) return nullptr; for( unsigned i=0; i<BodyExpr.size(); i++ ){ BodyExpr[i]->codegen(); } // Emit the while conditional block Value *CondV = Cond->codegen(); if (!CondV){ return nullptr; } // loop exit block BasicBlock *AfterBB = BasicBlock::Create(SCParser::TheContext, "afterdowhileloop." + std::to_string(LocalLabel), TheFunction); // Insert the conditional branch for the initial state BranchInst *BI = Builder.CreateCondBr(CondV,LoopBB,AfterBB); if( SCParser::NameMDNode ){ BI->setMetadata("pipe.pipeName",SCParser::NameMDNode); BI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); BI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Anything new is inserted after the while exit Builder.SetInsertPoint(AfterBB); // while expr always returns 0 return Constant::getNullValue(Type::getIntNTy(SCParser::TheContext,64)); } Value *WhileExprAST::codegen() { // Retrieve the function parent Function *TheFunction = SCParser::Builder.GetInsertBlock()->getParent(); // Retrieve a unique local label unsigned LocalLabel = GetLocalLabel(); // Make the new basic block for the loop header, inserting after current // block. // loop entry block BasicBlock *LoopBB = BasicBlock::Create(SCParser::TheContext, "entrywhile."+std::to_string(LocalLabel), TheFunction); // Insert an explicit fall through from the current block to the LoopBB. BranchInst *BI = Builder.CreateBr(LoopBB); if( SCParser::NameMDNode ){ BI->setMetadata("pipe.pipeName",SCParser::NameMDNode); BI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); BI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // loop body block BasicBlock *EntryBB = BasicBlock::Create(SCParser::TheContext, "while."+std::to_string(LocalLabel), TheFunction); // Emit the body of the loop. This, like any other expr, can change the // current BB. Note that we ignore the value computed by the body, but don't // allow an error. Builder.SetInsertPoint(EntryBB); if( BodyExpr.size() == 0 ) return nullptr; for( unsigned i=0; i<BodyExpr.size(); i++ ){ BodyExpr[i]->codegen(); } // Insert an explicit branch back Builder.CreateBr(LoopBB); // loop exit block BasicBlock *AfterBB = BasicBlock::Create(SCParser::TheContext, "afterwhileloop." + std::to_string(LocalLabel), TheFunction); // Start insertion in LoopBB. Builder.SetInsertPoint(LoopBB); // Emit the initial conditional block Value *CondV = Cond->codegen(); if (!CondV){ return nullptr; } // Insert the conditional branch for the initial state BI = Builder.CreateCondBr(CondV,EntryBB,AfterBB); if( SCParser::NameMDNode ){ BI->setMetadata("pipe.pipeName",SCParser::NameMDNode); BI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); BI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Anything new is inserted after the while exit Builder.SetInsertPoint(AfterBB); // while expr always returns 0 return Constant::getNullValue(Type::getIntNTy(SCParser::TheContext,64)); } Value *ForExprAST::codegen() { // Create an alloca for the variable in the entry block Function *TheFunction = SCParser::Builder.GetInsertBlock()->getParent(); AllocaInst *Alloca = CreateEntryBlockAlloca(TheFunction, VarName); // Emit the start code first, without 'variable' in scope. Value *StartVal = Start->codegen(); if (!StartVal) return nullptr; // Store the value into an alloca StoreInst *SI = SCParser::Builder.CreateStore(StartVal,Alloca); if( SCParser::NameMDNode ){ SI->setMetadata("pipe.pipeName",SCParser::NameMDNode); SI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); SI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } unsigned LocalLabel = GetLocalLabel(); // Make the new basic block for the loop header, inserting after current // block. BasicBlock *LoopBB = BasicBlock::Create(SCParser::TheContext, "loop."+std::to_string(LocalLabel), TheFunction); // Insert an explicit fall through from the current block to the LoopBB. BranchInst *BI = Builder.CreateBr(LoopBB); if( SCParser::NameMDNode ){ BI->setMetadata("pipe.pipeName",SCParser::NameMDNode); BI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); BI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Start insertion in LoopBB. Builder.SetInsertPoint(LoopBB); // Within the loop, the variable is defined equal to the PHI node. If it // shadows an existing variable, we have to restore it, so save it now. AllocaInst *OldVal = NamedValues[VarName]; NamedValues[VarName] = Alloca; // Emit the body of the loop. This, like any other expr, can change the // current BB. Note that we ignore the value computed by the body, but don't // allow an error. if( BodyExpr.size() == 0 ) return nullptr; for( unsigned i=0; i<BodyExpr.size(); i++ ){ BodyExpr[i]->codegen(); } // Emit the step value. Value *StepVal = nullptr; if (Step) { StepVal = Step->codegen(); if (!StepVal) return nullptr; } else { // If not specified, use u64(0) StepVal = ConstantInt::get(SCParser::TheContext, APInt(64,0,false)); } #if 0 Value *CurVar = Builder.CreateLoad(Alloca,VarName.c_str()); Value *NextVar = Builder.CreateAdd(CurVar, StepVal, "nextvar" + std::to_string(LocalLabel)); #endif // Compute the end condition. Value *EndCond = End->codegen(); if (!EndCond) return nullptr; // reload and increment the alloca Value *CurVar = Builder.CreateLoad(Alloca,VarName.c_str()); Value *NextVar = Builder.CreateAdd(CurVar, StepVal, "nextvar" + std::to_string(LocalLabel)); SI = Builder.CreateStore(NextVar,Alloca); if( SCParser::NameMDNode ){ cast<LoadInst>(CurVar)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<LoadInst>(CurVar)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<LoadInst>(CurVar)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); cast<Instruction>(NextVar)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<Instruction>(NextVar)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<Instruction>(NextVar)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); SI->setMetadata("pipe.pipeName",SCParser::NameMDNode); SI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); SI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Convert condition to a bool by comparing non-equal to 0.0. //EndCond = Builder.CreateFCmpONE( EndCond = Builder.CreateICmpNE( EndCond, ConstantInt::get(SCParser::TheContext, APInt(1,0,false)), "loopcond" + std::to_string(LocalLabel)); if( SCParser::NameMDNode ){ cast<Instruction>(EndCond)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<Instruction>(EndCond)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<Instruction>(EndCond)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Create the "after loop" block and insert it. BasicBlock *AfterBB = BasicBlock::Create(SCParser::TheContext, "afterloop." + std::to_string(LocalLabel), TheFunction); // Insert the conditional branch into the end of LoopEndBB. BI = Builder.CreateCondBr(EndCond, LoopBB, AfterBB); if( SCParser::NameMDNode ){ BI->setMetadata("pipe.pipeName",SCParser::NameMDNode); BI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); BI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Any new code will be inserted in AfterBB. Builder.SetInsertPoint(AfterBB); // Restore the unshadowed variable. if (OldVal) NamedValues[VarName] = OldVal; else NamedValues.erase(VarName); // for expr always returns 0 return Constant::getNullValue(Type::getIntNTy(SCParser::TheContext,64)); } Value *VariableExprAST::codegen() { // Look this variable up in the function. Value *V = SCParser::NamedValues[Name]; if (!V){ // variable wasn't in the function scope, check the globals V = SCParser::GlobalNamedValues[Name]; if( !V ){ return LogErrorV("Unknown variable name: " + Name ); } } Value *LI = SCParser::Builder.CreateLoad(V,Name.c_str()); if( SCParser::NameMDNode ){ cast<LoadInst>(LI)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<LoadInst>(LI)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<LoadInst>(LI)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } return LI; } Value *VarExprAST::codegen() { std::vector<AllocaInst *> OldBindings; Function *TheFunction = Builder.GetInsertBlock()->getParent(); // walk all the variables and their initializers for (unsigned i = 0, e = VarNames.size(); i != e; ++i) { const std::string &VarName = VarNames[i].first; ExprAST *Init = VarNames[i].second.get(); // Emit the initializer before adding the variable to scope, this prevents // the initializer from referencing the variable itself, and permits // nested sets of variable definitions Value *InitVal; if (Init) { InitVal = Init->codegen(); if (!InitVal) return nullptr; } else { // If not specified, use DATATYPE(0) // derive the respective type and init the correct // type with the value if( Attrs[i].defFloat ){ InitVal = ConstantFP::get(SCParser::TheContext, APFloat(0.0)); }else{ InitVal = ConstantInt::get(SCParser::TheContext, APInt(Attrs[i].width, 0, Attrs[i].defSign)); } } AllocaInst *Alloca = CreateEntryBlockAllocaAttr(TheFunction, VarName, Attrs[i]); StoreInst *SI = Builder.CreateStore(InitVal, Alloca); if( SCParser::NameMDNode ){ SI->setMetadata("pipe.pipeName",SCParser::NameMDNode); SI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); SI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } OldBindings.push_back(SCParser::NamedValues[VarName]); SCParser::NamedValues[VarName] = Alloca; } // Codegen the body, now that all vars are in scope. Value *BodyVal = Body->codegen(); if (!BodyVal) return nullptr; // Pop all our variables from scope. #if 0 for (unsigned i = 0, e = VarNames.size(); i != e; ++i) SCParser::NamedValues[VarNames[i].first] = OldBindings[i]; #endif // Return the body computation. return BodyVal; } Value *BinaryExprAST::codegen() { // handle the special case of an assignment operator if( Op == '='){ // Assignment requires the LHS to be an identifier. // This assume we're building without RTTI because LLVM builds that way by // default. If you build LLVM with RTTI this can be changed to a // dynamic_cast for automatic error checking. VariableExprAST *LHSE = static_cast<VariableExprAST *>(LHS.get()); if (!LHSE) return LogErrorV("destination of '=' must be a variable"); // Codegen the RHS. Value *Val = RHS->codegen(); if (!Val) return nullptr; // Look up the name in the local and global symbol tables Value *Variable = SCParser::NamedValues[LHSE->getName()]; if (!Variable){ Variable = SCParser::GlobalNamedValues[LHSE->getName()]; if( !Variable ){ return LogErrorV("Unknown variable name: " + LHSE->getName()); } } StoreInst *SI = Builder.CreateStore(Val, Variable); if( SCParser::NameMDNode ){ SI->setMetadata("pipe.pipeName",SCParser::NameMDNode); SI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); SI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } return Val; } // handle the remainder of the binary operators Value *L = LHS->codegen(); Value *R = RHS->codegen(); if (!L || !R){ return nullptr; } // interrogate the types of the operands, mutate the operands if necessary Type *LT = L->getType(); Type *RT = R->getType(); // test for type mismatches if( LT->getTypeID() != RT->getTypeID() ){ // type mismatches if( LT->isFloatingPointTy() ){ // LHS is the float R = SCParser::Builder.CreateUIToFP(R,LT,"uitofptmp"); if( SCParser::NameMDNode ){ cast<Instruction>(R)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<Instruction>(R)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<Instruction>(R)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } }else{ // RHS is the float R = SCParser::Builder.CreateFPToUI(R,LT,"fptouitmp"); if( SCParser::NameMDNode ){ cast<Instruction>(R)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<Instruction>(R)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<Instruction>(R)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } } }else if( LT->getIntegerBitWidth() != RT->getIntegerBitWidth() ){ // integer type mismatch, cast to the size of the RHS R = SCParser::Builder.CreateIntCast(R,LT,true); if( SCParser::NameMDNode ){ cast<Instruction>(R)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<Instruction>(R)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<Instruction>(R)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } } Value *VI = nullptr; if( LT->isFloatingPointTy() ){ // float ops switch (Op) { case '+': VI = SCParser::Builder.CreateFAdd(L, R, "addtmp"); break; case '-': VI = SCParser::Builder.CreateFSub(L, R, "subtmp"); break; case '*': VI = SCParser::Builder.CreateFMul(L, R, "multmp"); break; case '<': VI = SCParser::Builder.CreateFCmpULT(L, R, "cmptmp"); break; case '>': VI = SCParser::Builder.CreateFCmpUGT(L, R, "cmptmp"); break; case '%': VI = SCParser::Builder.CreateFRem(L, R, "modtmp"); break; case '/': VI = SCParser::Builder.CreateFDiv(L, R, "divtmp", nullptr); break; case '&': VI = SCParser::Builder.CreateAnd(L, R, "andtmp" ); break; case '|': VI = SCParser::Builder.CreateOr(L, R, "ortmp" ); break; case '^': VI = SCParser::Builder.CreateXor(L, R, "xortmp" ); break; case dyad_shfl: L = SCParser::Builder.CreateShl(L, R, "shfltmp", false, false ); VI = SCParser::Builder.CreateUIToFP(L, R->getType(), "booltmp"); break; case dyad_shfr: VI = SCParser::Builder.CreateLShr(L, R, "lshfrtmp", false ); break; case dyad_eqeq: VI = SCParser::Builder.CreateFCmpUEQ(L, R, "cmpeq" ); break; case dyad_noteq: VI = SCParser::Builder.CreateFCmpUNE(L, R, "cmpeq" ); break; case dyad_logand: VI = SCParser::Builder.CreateAnd(L, R, "andtmp" ); break; case dyad_logor: VI = SCParser::Builder.CreateOr(L, R, "ortmp" ); break; case dyad_gte: VI = SCParser::Builder.CreateFCmpUGE(L, R, "cmptmp"); break; case dyad_lte: VI = SCParser::Builder.CreateFCmpULE(L, R, "cmptmp"); break; default: return LogErrorV("invalid binary operator"); } }else{ // integer ops switch (Op) { case '+': VI = SCParser::Builder.CreateAdd(L, R, "addtmp"); break; case '-': VI = SCParser::Builder.CreateSub(L, R, "subtmp"); break; case '*': VI = SCParser::Builder.CreateMul(L, R, "multmp"); break; case '<': VI = SCParser::Builder.CreateICmpULT(L, R, "cmptmp"); break; case '>': VI = SCParser::Builder.CreateICmpUGT(L, R, "cmptmp"); break; case '%': VI = SCParser::Builder.CreateURem(L, R, "modtmp"); break; case '/': VI = SCParser::Builder.CreateUDiv(L, R, "divtmp", true); break; case '&': VI = SCParser::Builder.CreateAnd(L, R, "andtmp" ); break; case '|': VI = SCParser::Builder.CreateOr(L, R, "ortmp" ); break; case '^': VI = SCParser::Builder.CreateXor(L, R, "xortmp" ); break; case dyad_shfl: VI = SCParser::Builder.CreateShl(L, R, "shfltmp", false, false ); break; case dyad_shfr: VI = SCParser::Builder.CreateLShr(L, R, "lshfrtmp", false ); break; case dyad_eqeq: VI = SCParser::Builder.CreateICmpEQ(L, R, "cmpeq" ); break; case dyad_noteq: VI = SCParser::Builder.CreateICmpNE(L, R, "cmpne" ); break; case dyad_logand: VI = SCParser::Builder.CreateAnd(L, R, "andtmp" ); break; case dyad_logor: VI = SCParser::Builder.CreateOr(L, R, "ortmp" ); break; case dyad_gte: VI = SCParser::Builder.CreateICmpUGE(L, R, "cmptmp"); break; case dyad_lte: VI = SCParser::Builder.CreateICmpULE(L, R, "cmptmp"); break; default: return LogErrorV("invalid binary operator"); } } if( SCParser::NameMDNode ){ cast<Instruction>(VI)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<Instruction>(VI)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<Instruction>(VI)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } return VI; // we don't currently support user-defined binary operators, so just return here // see chapter 6 in the llvm frontend tutorial } Value *CallExprAST::codegen() { // Look up the name in the global module table. Function *CalleeF = SCParser::TheModule->getFunction(Callee); if (!CalleeF){ return LogErrorV("Unknown function referenced: " + Callee ); } // If argument mismatch error. if (CalleeF->arg_size() != Args.size()) return LogErrorV("Incorrect # arguments passed"); std::vector<Value *> ArgsV; for (unsigned i = 0, e = Args.size(); i != e; ++i) { ArgsV.push_back(Args[i]->codegen()); if (!ArgsV.back()) return nullptr; } Value *CI = SCParser::Builder.CreateCall(CalleeF, ArgsV, "calltmp"); if( SCParser::NameMDNode ){ cast<Instruction>(CI)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<Instruction>(CI)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<Instruction>(CI)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } return CI; } Function *PrototypeAST::codegen() { // TODO: This eventually needs to look up the variable names // in the register class lists // If they are found, use the datatype from the register value // Otherwise, default to u64 //std::vector<Type *> Doubles(Args.size(), Type::getDoubleTy(SCParser::TheContext)); std::vector<Type *> Doubles(Args.size(), Type::getIntNTy(SCParser::TheContext,64)); FunctionType *FT = FunctionType::get(Type::getIntNTy(SCParser::TheContext,64), Doubles, false); //FunctionType::get(Type::getDoubleTy(SCParser::TheContext), Doubles, false); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, SCParser::TheModule.get()); if( InstFormat.length() > 0 ){ F->addFnAttr("instformat",InstFormat); } // Set names for all arguments. unsigned Idx = 0; for (auto &Arg : F->args()) Arg.setName(Args[Idx++]); return F; } Value *InstFormatAST::codegen(){ // instruction fields Type *VType = Type::getIntNTy(SCParser::TheContext,64); // create a generic uint64_t std::vector<std::tuple<std::string,SCInstField,std::string,unsigned>>::iterator it; for( it=Fields.begin(); it != Fields.end(); ++it ){ std::string FName = std::get<0>(*it); SCInstField FT = std::get<1>(*it); std::string RClass = std::get<2>(*it); unsigned Width = std::get<3>(*it); // search the GlobalNamedValues map for the target variable name // if its not found, then create an entry std::map<std::string, GlobalVariable*>::iterator GVit; GVit = GlobalNamedValues.find(FName); if( GVit == GlobalNamedValues.end() ){ // variable is not in the global list, create a new one GlobalVariable *val = new GlobalVariable(*SCParser::TheModule, VType, false, GlobalValue::ExternalLinkage, nullptr, Twine(FName), nullptr, GlobalVariable::NotThreadLocal, 0); if( !val ){ return LogErrorV( "Failed to lower instruction format field to global: instformat = " + Name + " field=" + FName); } // add the global to the top-level names list GlobalNamedValues[FName] = val; // add the field name to differentiate across other fields val->addAttribute("field_name",FName); // add an attribute to track the value to the instruction format val->addAttribute("instformat0",Name); // add an attribute to track the value of the instruction field width val->addAttribute("instwidth0",std::to_string(Width)); // add attributes for the field type switch( FT ){ case field_enc: val->addAttribute("fieldtype","encoding"); break; case field_reg: val->addAttribute("fieldtype","register"); val->addAttribute("regclasscontainer0",RClass); break; case field_imm: val->addAttribute("fieldtype","immediate"); break; default: return LogErrorV( "Failed to lower instruction format field to global: instformat = " + Name + " field=" + FName); break; } }else{ // variable is in the global list, add to existing entry AttributeSet AttrSet = GVit->second->getAttributes(); // ensure that the instruction fieldtype is the same std::string FType = AttrSet.getAttribute("fieldtype").getValueAsString().str(); switch( FT ){ case field_enc: if( FType != "encoding" ){ return LogWarnV( "FieldType for field=" + FName + " in instformat=" + Name + " does not match existing field type from adjacent format"); } break; case field_reg: if( FType != "register"){ return LogWarnV( "FieldType for field=" + FName + " in instformat=" + Name + " does not match existing field type from adjacent format"); } break; case field_imm: if( FType != "immediate" ){ return LogWarnV( "FieldType for field=" + FName + " in instformat=" + Name + " does not match existing field type from adjacent format"); } break; default: return LogWarnV( "Failed to lower instruction format field to global: instformat = " + Name + " field=" + FName + "; Does not match existing fieldtype"); break; } // derive the number of instruction formats unsigned NextIF = 0; while( AttrSet.hasAttribute("instformat"+std::to_string(NextIF)) ){ NextIF = NextIF+1; } // insert the new instruction format GVit->second->addAttribute("instformat"+std::to_string(NextIF),Name); // insert the new instruction width GVit->second->addAttribute("instwidth"+std::to_string(NextIF),std::to_string(Width)); // insert a new register class type if required if( FT == field_reg ){ GVit->second->addAttribute("regclasscontainer"+std::to_string(NextIF),RClass); } } } return nullptr; } Value *PipelineAST::codegen(){ // create a global variable to track the pipeline def GlobalVariable *val = new GlobalVariable(*SCParser::TheModule, Type::getIntNTy(SCParser::TheContext,64), false, GlobalValue::ExternalLinkage, nullptr, Twine(Name), nullptr, GlobalVariable::NotThreadLocal, 0); if( !val ) return LogErrorV( "Failed to lower pipeline definition to global: pipeline = " + Name); GlobalNamedValues[Name] = val; // add all the attributes val->addAttribute("pipeline", Name); for( unsigned i=0; i<Attrs.size(); i++ ){ val->addAttribute("pipeattr" + std::to_string(i), Attrs[i]); } return nullptr; } Value *RegClassAST::codegen(){ // registers for( unsigned i=0; i<Args.size(); i++ ){ Type *VType; if( (Attrs[i].defFloat) && (Attrs[i].width==32) ){ VType = Type::getFloatTy(SCParser::TheContext); }else if( (Attrs[i].defFloat) && (Attrs[i].width==64) ){ VType = Type::getDoubleTy(SCParser::TheContext); }else{ VType = Type::getIntNTy(SCParser::TheContext,Attrs[i].width); } GlobalVariable *val = new GlobalVariable(*SCParser::TheModule, VType, false, GlobalValue::ExternalLinkage, nullptr, Twine(Args[i]), nullptr, GlobalVariable::NotThreadLocal, 0 ); if( !val ){ return LogErrorV( "Failed to lower register class to global: regclass = "+ Name + " register=" + Args[i]); } GlobalNamedValues[Args[i]] = val; if( !Attrs[i].defRegClass ){ // this is a normal register // insert a special attribute to track the register val->addAttribute("register",Args[i]); // insert a special attribute to track the parent register class val->addAttribute("regclass", Name); if( PC == Args[i] ){ val->addAttribute("pc", "true"); } if( Attrs[i].defReadOnly ){ val->addAttribute("readOnly", "true"); } if( Attrs[i].defReadWrite ){ val->addAttribute("readWrite", "true"); } if( Attrs[i].defCSR ){ val->addAttribute("csr", "true"); } if( Attrs[i].defAMS ){ val->addAttribute("ams", "true"); } if( Attrs[i].defTUS ){ val->addAttribute("tus", "true"); } if( Attrs[i].defShared ){ val->addAttribute("shared", "true"); } }else{ // this is a register class // add a special attribute token val->addAttribute("regfile", Args[i] ); } } // subregisters std::vector<std::tuple<std::string,std::string,VarAttrs>>::iterator it; for( it=SubRegs.begin(); it != SubRegs.end(); ++it ){ Type *SType; if( (std::get<2>(*it).defFloat) && (std::get<2>(*it).width==32) ){ SType = Type::getFloatTy(SCParser::TheContext); }else if( (std::get<2>(*it).defFloat) && (std::get<2>(*it).width==64) ){ SType = Type::getDoubleTy(SCParser::TheContext); }else{ SType = Type::getIntNTy(SCParser::TheContext,std::get<2>(*it).width); } GlobalVariable *val = new GlobalVariable(*SCParser::TheModule, SType, false, GlobalValue::ExternalLinkage, nullptr, Twine(std::get<1>(*it)), nullptr, GlobalVariable::NotThreadLocal, 0 ); if( !val ){ return LogErrorV( "Failed to lower subregister to global: subreg = " + std::get<1>(*it) + " register=" + std::get<0>(*it) ); } //GlobalNamedValues[std::get<1>(*it)] = GlobalNamedValues[std::get<0>(*it)]; GlobalNamedValues[std::get<1>(*it)] = val; // insert a special attribute to track the subregister val->addAttribute("subregister",std::get<1>(*it)); // insert a special attribute to track the subregister to register mapping val->addAttribute("register",std::get<0>(*it)); } return nullptr; } Function *FunctionAST::codegen() { // Transfer ownership of the prototype to the FunctionsProtos map // keep a reference for use below auto &P = *Proto; SCParser::FunctionProtos[Proto->getName()] = std::move(Proto); Function *TheFunction = getFunction(P.getName()); if( !TheFunction ) return nullptr; // We don't currently support emitting user-defined binary operators // This is Chapter6 in the LLVM Frontend tutorial // Create a new basic block to start insertion into BasicBlock *BB = BasicBlock::Create(SCParser::TheContext, "entry."+P.getName(), TheFunction); SCParser::Builder.SetInsertPoint(BB); // Record the function arguments in the NamedValues map SCParser::NamedValues.clear(); for( auto &Arg : TheFunction->args()){ // create an alloca for this variable // TODO: we eventually need to record the function arg types // such that we can correctly setup the alloca's AllocaInst *Alloca = CreateEntryBlockAlloca(TheFunction,Arg.getName()); // store the initial value into the alloca StoreInst *SI = Builder.CreateStore(&Arg, Alloca); if( SCParser::NameMDNode ){ SI->setMetadata("pipe.pipeName",SCParser::NameMDNode); SI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); SI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // add arguments to the variable symbol table SCParser::NamedValues[Arg.getName()] = Alloca; } // codegen all the body elements // save the last element for the return value for( unsigned i=0; i<Body.size()-1; i++ ){ Value *BVal = Body[i]->codegen(); if( !BVal ) return nullptr; } if( Value *RetVal = Body[Body.size()-1]->codegen() ){ // Finish off the function Builder.CreateRet(RetVal); verifyFunction(*TheFunction); if( SCParser::IsOpt ){ SCParser::TheFPM->run(*TheFunction); } return TheFunction; } TheFunction->eraseFromParent(); return nullptr; } Value *IfExprAST::codegen() { Value *CondV = Cond->codegen(); if (!CondV){ return nullptr; } // Retrieve a unique local label unsigned LocalLabel = GetLocalLabel(); CondV = Builder.CreateICmpNE( CondV, ConstantInt::get(SCParser::TheContext, APInt(1,0,false)), "ifcond."+std::to_string(LocalLabel)); if( SCParser::NameMDNode ){ cast<Instruction>(CondV)->setMetadata("pipe.pipeName",SCParser::NameMDNode); cast<Instruction>(CondV)->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); cast<Instruction>(CondV)->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } Function *TheFunction = Builder.GetInsertBlock()->getParent(); // Create blocks for the then and else cases. Insert the 'then' block at the // end of the function. BasicBlock *ThenBB = BasicBlock::Create(SCParser::TheContext, "then."+std::to_string(LocalLabel), TheFunction); BasicBlock *ElseBB = BasicBlock::Create(SCParser::TheContext, "else."+std::to_string(LocalLabel)); BasicBlock *MergeBB = BasicBlock::Create(SCParser::TheContext, "ifcont."+std::to_string(LocalLabel)); BranchInst *BI = Builder.CreateCondBr(CondV, ThenBB, ElseBB); if( SCParser::NameMDNode ){ BI->setMetadata("pipe.pipeName",SCParser::NameMDNode); BI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); BI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Emit then value. Builder.SetInsertPoint(ThenBB); // Emit all the Then body values Value *TV = nullptr; for( unsigned i=0; i<ThenV.size(); i++ ){ TV = ThenV[i]->codegen(); if( !TV ) return nullptr; } BI = Builder.CreateBr(MergeBB); if( SCParser::NameMDNode ){ BI->setMetadata("pipe.pipeName",SCParser::NameMDNode); BI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); BI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Codegen of 'Then' can change the current block, update ThenBB for the PHI. ThenBB = Builder.GetInsertBlock(); // Emit else block. TheFunction->getBasicBlockList().push_back(ElseBB); Builder.SetInsertPoint(ElseBB); Value *EV = nullptr; for( unsigned i=0; i<ElseV.size(); i++ ){ EV = ElseV[i]->codegen(); if( !EV ) return nullptr; } BI = Builder.CreateBr(MergeBB); if( SCParser::NameMDNode ){ BI->setMetadata("pipe.pipeName",SCParser::NameMDNode); BI->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); BI->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } // Codegen of 'Else' can change the current block, update ElseBB for the PHI. ElseBB = Builder.GetInsertBlock(); // Emit merge block. TheFunction->getBasicBlockList().push_back(MergeBB); Builder.SetInsertPoint(MergeBB); PHINode *PN = nullptr; if( TV->getType()->isFloatingPointTy() ){ PN = Builder.CreatePHI(TV->getType(), 2, "iftmp."+std::to_string(LocalLabel)); if( SCParser::NameMDNode ){ PN->setMetadata("pipe.pipeName",SCParser::NameMDNode); PN->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); PN->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } }else{ PN = Builder.CreatePHI(TV->getType(), 2, "iftmp."+std::to_string(LocalLabel)); if( SCParser::NameMDNode ){ PN->setMetadata("pipe.pipeName",SCParser::NameMDNode); PN->setMetadata("pipe.pipeLine",SCParser::PipelineMDNode); PN->setMetadata("pipe.pipeInstance",SCParser::InstanceMDNode); } } PN->addIncoming(TV, ThenBB); if( EV != nullptr ){ // check to see if we need to adjust the size of the types if( TV->getType()->getPrimitiveSizeInBits() != EV->getType()->getPrimitiveSizeInBits() ){ EV->mutateType(TV->getType()); } PN->addIncoming(EV, ElseBB); } return PN; } //===----------------------------------------------------------------------===// // Error Handlers //===----------------------------------------------------------------------===// std::unique_ptr<ExprAST> SCParser::LogError(std::string Str) { Msgs->PrintMsg( L_ERROR, "Line " + std::to_string(Lex->GetLineNum()) + " : " + Str ); return nullptr; } std::unique_ptr<PrototypeAST> SCParser::LogErrorP(std::string Str) { LogError(Str); return nullptr; } std::unique_ptr<RegClassAST> SCParser::LogErrorR(std::string Str) { LogError(Str); return nullptr; } std::unique_ptr<PipelineAST> SCParser::LogErrorPI(std::string Str){ LogError(Str); return nullptr; } std::unique_ptr<InstFormatAST> SCParser::LogErrorIF(std::string Str) { LogError(Str); return nullptr; } std::unique_ptr<FunctionAST> SCParser::LogErrorF(std::string Str) { LogError(Str); return nullptr; } Value *LogWarnV(std::string Str){ SCParser::GMsgs->PrintMsg( L_WARN, Str ); return nullptr; } Value *LogErrorV(std::string Str){ SCParser::GMsgs->PrintMsg( L_ERROR, Str ); return nullptr; } // EOF
30.869114
118
0.612013
opensocsysarch
b3f31a5775c8fa18f9531713431aa15fd701522d
332
cpp
C++
ClickableLabel.cpp
iUltimateLP/solitaire
bd0a9ad222291d2e481790ec89c823d4b0b66f46
[ "MIT" ]
null
null
null
ClickableLabel.cpp
iUltimateLP/solitaire
bd0a9ad222291d2e481790ec89c823d4b0b66f46
[ "MIT" ]
null
null
null
ClickableLabel.cpp
iUltimateLP/solitaire
bd0a9ad222291d2e481790ec89c823d4b0b66f46
[ "MIT" ]
null
null
null
// Author: Annie Berend (5033782) - Jonathan Verbeek (5058288) #include "ClickableLabel.h" CClickableLabel::CClickableLabel(QWidget* parent, Qt::WindowFlags f) : QLabel(parent) { Q_UNUSED(f); } void CClickableLabel::mousePressEvent(QMouseEvent* ev) { Q_UNUSED(ev); // Simply emit the signal emit clicked(); }
19.529412
68
0.701807
iUltimateLP
b3f5f56d8677fa25341bdddc341db1701a723dcc
1,393
hpp
C++
services/runagent/hodisp_base.hpp
miguelvazq/HPCC-Platform
22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5
[ "Apache-2.0" ]
286
2015-01-03T12:45:17.000Z
2022-03-25T18:12:57.000Z
services/runagent/hodisp_base.hpp
miguelvazq/HPCC-Platform
22ad8e5fcb59626abfd8febecbdfccb1e9fb0aa5
[ "Apache-2.0" ]
9,034
2015-01-02T08:49:19.000Z
2022-03-31T20:34:44.000Z
services/runagent/hodisp_base.hpp
cloLN/HPCC-Platform
42ffb763a1cdcf611d3900831973d0a68e722bbe
[ "Apache-2.0" ]
208
2015-01-02T03:27:28.000Z
2022-02-11T05:54:52.000Z
/*############################################################################## HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®. 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 "jthread.hpp" #include "jlib.hpp" extern bool dispatch_abort; class c_dispatch : public Thread { public: CriticalSection cs; bool done; char * ex1; char * id; bool is_done(); c_dispatch() { done=false; ex1=0; id=0;} virtual void action()=0; virtual int run(); virtual ~c_dispatch(); }; class m_dispatch { unsigned max_disp; char * last_error; public: c_dispatch **d; void dispatch(c_dispatch * disp); bool all_done(bool no_abort); bool all_done_ex(bool no_abort); void stop(); void clear_error(); m_dispatch(unsigned max_thread); ~m_dispatch(); };
25.327273
81
0.625269
miguelvazq
b3f979a6da5f833c6825eff8927c05759d91960c
11,786
cpp
C++
can/src/main.cpp
nvitya/nvcmtests
0f8bfedf16bbe3a5803bf8a9300b1a1a73da805b
[ "Zlib" ]
null
null
null
can/src/main.cpp
nvitya/nvcmtests
0f8bfedf16bbe3a5803bf8a9300b1a1a73da805b
[ "Zlib" ]
null
null
null
can/src/main.cpp
nvitya/nvcmtests
0f8bfedf16bbe3a5803bf8a9300b1a1a73da805b
[ "Zlib" ]
null
null
null
/* ----------------------------------------------------------------------------- * This file is a part of the NVCM Tests project: https://github.com/nvitya/nvcmtests * Copyright (c) 2018 Viktor Nagy, nvitya * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from * the use of this software. Permission is granted to anyone to use this * software for any purpose, including commercial applications, and to alter * it and redistribute it freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in * a product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. * --------------------------------------------------------------------------- */ /* * file: main.cpp (CAN Test) * brief: Multi-board CAN example for NVCM * version: 1.00 * date: 2019-01-11 * authors: nvitya */ #include "platform.h" #include "hwpins.h" #include "hwclkctrl.h" #include "hwuart.h" #include "cppinit.h" #include "clockcnt.h" #include "hwcan.h" #include "traces.h" THwCan can; TCanMsg can_rxbuf[64]; TCanMsg can_txbuf[64]; THwUart conuart; // console uart #if defined(BOARD_NUCLEO_F446) || defined(BOARD_NUCLEO_F746) TGpioPin led1pin(1, 0, false); TGpioPin led2pin(1, 7, false); TGpioPin led3pin(1, 14, false); #define LED_COUNT 3 void setup_board() { // nucleo board leds led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led2pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led3pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); // USART3: Stlink USB / Serial converter // USART3_TX: PD.8 hwpinctrl.PinSetup(3, 8, PINCFG_OUTPUT | PINCFG_AF_7); // USART3_RX: Pd.9 hwpinctrl.PinSetup(3, 9, PINCFG_INPUT | PINCFG_AF_7); conuart.Init(3); // USART3 } #endif #if defined(BOARD_MIBO100_ATSAME70) TGpioPin led1pin(PORTNUM_D, 13, false); void setup_board() { led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); hwpinctrl.PinSetup(PORTNUM_A, 9, PINCFG_INPUT | PINCFG_AF_0); // UART0_RX hwpinctrl.PinSetup(PORTNUM_A, 10, PINCFG_OUTPUT | PINCFG_AF_0); // UART0_TX conuart.Init(0); } #endif #if defined(BOARD_MIBO64_ATSAME5X) TGpioPin led1pin(PORTNUM_A, 1, false); void setup_board() { led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); // SERCOM0 hwpinctrl.PinSetup(PORTNUM_A, 4, PINCFG_OUTPUT | PINCFG_AF_3); // PAD[0] = TX hwpinctrl.PinSetup(PORTNUM_A, 5, PINCFG_INPUT | PINCFG_AF_3); // PAD[1] = RX conuart.Init(0); // CAN hwpinctrl.PinSetup(PORTNUM_A, 22, PINCFG_AF_I); // CAN0_TX hwpinctrl.PinSetup(PORTNUM_A, 23, PINCFG_AF_I); // CAN0_RX can.Init(0, &can_rxbuf[0], sizeof(can_rxbuf) / sizeof(TCanMsg), &can_txbuf[0], sizeof(can_txbuf) / sizeof(TCanMsg)); } #endif #if defined(BOARD_ENEBO_A) TGpioPin led1pin(PORTNUM_D, 13, true); TGpioPin led2pin(PORTNUM_D, 14, true); TGpioPin led3pin(PORTNUM_A, 20, true); TGpioPin pin_eth_reset(PORTNUM_A, 19, false); #define LED_COUNT 3 void setup_board() { led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led2pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led3pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led3pin.Set1(); // turn on the RED pin_eth_reset.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_0); hwpinctrl.PinSetup(PORTNUM_A, 9, PINCFG_INPUT | PINCFG_AF_0); // UART0_RX hwpinctrl.PinSetup(PORTNUM_A, 10, PINCFG_OUTPUT | PINCFG_AF_0); // UART0_TX conuart.baudrate = 115200; conuart.Init(0); // Ethernet clock output: hwpinctrl.PinSetup(PORTNUM_A, 18, PINCFG_OUTPUT | PINCFG_AF_B); // PCK2 = Ethernet 25 M Clock PMC->PMC_SCER = (1 << (8 + 2)); // enable PCK2 PMC->PMC_PCK[2] = 0 | (2 << 0) // CSS(3): 2 = PLLA | ((12 - 1) << 4) // PRES(8): divisor - 1 ; /* Ethernet pins configuration ************************************************ RMII_REF_CLK ----------------------> PD0 RMII_MDIO -------------------------> PD9 RMII_MDC --------------------------> PD8 RMII_MII_CRS_DV -------------------> PD4 RMII_MII_RXD0 ---------------------> PD5 RMII_MII_RXD1 ---------------------> PD6 RMII_MII_RXER ---------------------> PD7 RMII_MII_TX_EN --------------------> PD1 RMII_MII_TXD0 ---------------------> PD2 RMII_MII_TXD1 ---------------------> PD3 */ uint32_t pinfl = PINCFG_SPEED_FAST | PINCFG_AF_0; hwpinctrl.PinSetup(PORTNUM_D, 0, pinfl); // REF CLK hwpinctrl.PinSetup(PORTNUM_D, 9, pinfl); // MDIO hwpinctrl.PinSetup(PORTNUM_D, 8, pinfl); // MDC hwpinctrl.PinSetup(PORTNUM_D, 4, pinfl); // CRS_DV hwpinctrl.PinSetup(PORTNUM_D, 5, pinfl); // RXD0 hwpinctrl.PinSetup(PORTNUM_D, 6, pinfl); // RXD1 hwpinctrl.PinSetup(PORTNUM_D, 7, pinfl); // RXER // Tie to the GND !!! hwpinctrl.PinSetup(PORTNUM_D, 1, pinfl); // TX_EN hwpinctrl.PinSetup(PORTNUM_D, 2, pinfl); // TXD0 hwpinctrl.PinSetup(PORTNUM_D, 3, pinfl); // TXD1 // CAN hwpinctrl.PinSetup(PORTNUM_B, 2, PINCFG_AF_A); // MCAN0_TX hwpinctrl.PinSetup(PORTNUM_B, 3, PINCFG_AF_A); // MCAN0_RX can.Init(0, &can_rxbuf[0], sizeof(can_rxbuf) / sizeof(TCanMsg), &can_txbuf[0], sizeof(can_txbuf) / sizeof(TCanMsg)); } #endif #if defined(BOARD_DISCOVERY_F072) TGpioPin led1pin(PORTNUM_C, 6, false); TGpioPin led2pin(PORTNUM_C, 8, false); TGpioPin led3pin(PORTNUM_C, 9, false); TGpioPin led4pin(PORTNUM_C, 7, false); #define LED_COUNT 4 #undef USE_DWT_CYCCNT void setup_board() { // direction leds led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led2pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led3pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led4pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); } #endif #if defined(BOARD_DEV_STM32F407VG) TGpioPin led1pin(4, 0, true); // PE0 void setup_board() { led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); // USART1 hwpinctrl.PinSetup(PORTNUM_A, 9, PINCFG_OUTPUT | PINCFG_AF_7); // USART1_TX hwpinctrl.PinSetup(PORTNUM_A, 10, PINCFG_INPUT | PINCFG_AF_7); // USART1_RX conuart.Init(1); } #endif #if defined(BOARD_DEV_STM32F407ZE) TGpioPin led1pin(5, 9, true); // PF9 TGpioPin led2pin(5, 10, true); // PF10 void setup_board() { led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); led2pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); // USART1 hwpinctrl.PinSetup(PORTNUM_A, 9, PINCFG_OUTPUT | PINCFG_AF_7); // USART1_TX hwpinctrl.PinSetup(PORTNUM_A, 10, PINCFG_INPUT | PINCFG_AF_7); // USART1_RX conuart.Init(1); } #endif #if defined(BOARD_ARDUINO_DUE) TGpioPin led1pin(1, 27, false); // D13 void setup_board() { led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); // UART - On the Arduino programmer interface hwpinctrl.PinSetup(0, 8, PINCFG_INPUT | PINCFG_AF_0); // UART_RXD hwpinctrl.PinSetup(0, 9, PINCFG_OUTPUT | PINCFG_AF_0); // UART_TXD conuart.Init(0); // UART } #endif #if defined(BOARD_MIN_F103) TGpioPin led1pin(2, 13, false); // PC13 void setup_board() { led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); // USART1 hwpinctrl.PinSetup(PORTNUM_A, 9, PINCFG_OUTPUT | PINCFG_AF_0); // USART1_TX hwpinctrl.PinSetup(PORTNUM_A, 10, PINCFG_INPUT | PINCFG_AF_0); // USART1_RX conuart.Init(1); // CAN PINS // Set CAN remap! RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; // enable AFIO clock uint32_t tmp; tmp = AFIO->MAPR; tmp &= ~(3 << 13); tmp |= (2 << 13); // remap CAN pints from A11, A12 to B8, B9 AFIO->MAPR = tmp; hwpinctrl.PinSetup(PORTNUM_B, 8, PINCFG_INPUT | PINCFG_AF_0); // CAN RX hwpinctrl.PinSetup(PORTNUM_B, 9, PINCFG_OUTPUT | PINCFG_AF_0); // CAN TX can.Init(1, &can_rxbuf[0], sizeof(can_rxbuf) / sizeof(TCanMsg), &can_txbuf[0], sizeof(can_txbuf) / sizeof(TCanMsg)); } #endif #if defined(BOARD_MIBO48_STM32F303) TGpioPin led1pin(PORTNUM_C, 13, false); // PC13 void setup_board() { led1pin.Setup(PINCFG_OUTPUT | PINCFG_GPIO_INIT_1); // USART1 hwpinctrl.PinSetup(PORTNUM_A, 9, PINCFG_OUTPUT | PINCFG_AF_7); // USART1_TX hwpinctrl.PinSetup(PORTNUM_A, 10, PINCFG_INPUT | PINCFG_AF_7); // USART1_RX conuart.Init(1); // CAN PINS hwpinctrl.PinSetup(PORTNUM_B, 8, PINCFG_INPUT | PINCFG_AF_9); // CAN RX hwpinctrl.PinSetup(PORTNUM_B, 9, PINCFG_INPUT | PINCFG_AF_9); // CAN TX can.Init(1, &can_rxbuf[0], sizeof(can_rxbuf) / sizeof(TCanMsg), &can_txbuf[0], sizeof(can_txbuf) / sizeof(TCanMsg)); } #endif // --------------------------------------------------------------------------------------- #ifndef LED_COUNT #define LED_COUNT 1 #endif volatile unsigned systick = 0; extern "C" void SysTick_Handler(void) { ++systick; } unsigned hbcounter = 0; void heartbeat_task() // invoked every 0.5 s { ++hbcounter; led1pin.SetTo(hbcounter >> 0); #if LED_COUNT > 1 led2pin.SetTo(hbcounter >> 1); #endif #if LED_COUNT > 2 led3pin.SetTo(hbcounter >> 2); #endif #if LED_COUNT > 3 led4pin.SetTo(hbcounter >> 3); #endif #if LED_COUNT > 4 led5pin.SetTo(hbcounter >> 4); #endif //TRACE("hbcounter = %u, systick = %u\r\n", hbcounter, systick); } // the C libraries require "_start" so we keep it as the entry point extern "C" __attribute__((noreturn)) void _start(void) { // the processor jumps here right after the reset // the MCU runs slower, using the internal RC oscillator // all variables are unstable, they will be overridden later mcu_disable_interrupts(); mcu_preinit_code(); // inline code for preparing the MCU, RAM regions. Without this even the stack does not work on some MCUs. // Set the interrupt vector table offset, so that the interrupts and exceptions work mcu_init_vector_table(); unsigned clockspeed = MCU_CLOCK_SPEED; #ifdef MCU_INPUT_FREQ if (!hwclkctrl.InitCpuClock(MCU_INPUT_FREQ, clockspeed)) #else if (!hwclkctrl.InitCpuClockIntRC(MCU_INTRC_SPEED, clockspeed)) #endif { while (1) { // the external oscillator did not start. } } // now the MCU runs faster, start the memory, and C/C++ initialization: cppinit(); // ...from now on all the variables work, static classes are initialized. // provide info to the system about the clock speed: hwclkctrl.SetClockInfo(clockspeed); mcu_enable_fpu(); // enable coprocessor if present //mcu_enable_icache(); // enable instruction cache if present clockcnt_init(); // go on with the hardware initializations setup_board(); TRACE("\r\n--------------------------\r\n"); TRACE("CAN TEST\r\n"); TRACE("Board: \"%s\"\r\n", BOARD_NAME); TRACE("SystemCoreClock: %u\r\n", SystemCoreClock); TRACE("\r\nWaiting for CAN messages...\r\n"); SysTick_Config(SystemCoreClock / 1000); mcu_enable_interrupts(); TCanMsg msg; #if 1 can.AcceptAdd(0x000, 0x000); // accept all messages can.Enable(); // start the CAN (reception) #if 1 msg.cobid = 0x203; msg.len = 8; msg.data[0] = 0x11; msg.data[1] = 0x12; msg.data[2] = 0x13; msg.data[3] = 0x14; msg.data[4] = 0x15; msg.data[5] = 0x16; msg.data[6] = 0x17; msg.data[7] = 0x18; can.StartSendMessage(&msg); #endif #endif unsigned hbclocks = SystemCoreClock; unsigned t0, t1; t0 = CLOCKCNT; // Infinite loop while (1) { t1 = CLOCKCNT; #if 1 if (can.TryRecvMessage(&msg)) { TRACE("CAN msg received: COBID=%03X, LEN=%i, DATA=", msg.cobid, msg.len); for (int i = 0; i < msg.len; ++i) { TRACE(" %02X", msg.data[i]); } TRACE("\r\n"); } #endif if (t1-t0 > hbclocks) { heartbeat_task(); t0 = t1; } } } // ----------------------------------------------------------------------------
26.545045
128
0.668844
nvitya
b3fb419b911170bdb35b3de18e425e1e06e239cf
4,245
cpp
C++
src/main.cpp
phitsc/find-api-usage
0756e2d53b1ce4f114a5de1bee9b4bdc72acf359
[ "MIT" ]
null
null
null
src/main.cpp
phitsc/find-api-usage
0756e2d53b1ce4f114a5de1bee9b4bdc72acf359
[ "MIT" ]
null
null
null
src/main.cpp
phitsc/find-api-usage
0756e2d53b1ce4f114a5de1bee9b4bdc72acf359
[ "MIT" ]
null
null
null
#include "Helpers.hpp" #include "JsonFile.hpp" #include "NotifyFunctionCallAction.hpp" #include "NotifyVariableDeclarationAction.hpp" #include "Options.hpp" #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Rewrite/Core/Rewriter.h" #include "clang/Rewrite/Frontend/FrontendActions.h" #include "clang/Tooling/CommonOptionsParser.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/ReplacementsYaml.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/YAMLTraits.h" #include <cstdlib> #include <memory> #include <string> #include <vector> using namespace clang::ast_matchers; using namespace clang::tooling; using namespace llvm; namespace boost { void throw_exception(const std::exception& e) { llvm::errs() << "Error: " << e.what(); std::exit(1); } } namespace { void printVersion(llvm::raw_ostream& ostream) { ostream << "find-api-usage version 0.1.0\n"; std::exit(0); } static cl::OptionCategory optionCategory("find-api-usage Options"); // clang-format off static cl::opt<std::string> json("json", cl::desc("Export violations to JSON file"), cl::value_desc("filename"), cl::cat(optionCategory) ); static cl::opt<bool> verbose("verbose", cl::desc("Be verbose when reporting violations"), cl::init(false), cl::cat(optionCategory) ); static cl::alias verboseAlias("v", cl::desc("Same as -verbose"), cl::aliasopt(verbose) ); static cl::list<std::string> functionCall("function-call", cl::desc("Find function (only <method>) or method (<class::method>) calls"), cl::value_desc("class::method"), cl::cat(optionCategory), cl::CommaSeparated ); static cl::alias functionCallAlias("fc", cl::desc("Same as -function-call"), cl::aliasopt(functionCall) ); static cl::list<std::string> variableDeclaration("variable-declaration", cl::desc("Find variable declarations of type <typename>"), cl::value_desc("typename"), cl::cat(optionCategory), cl::CommaSeparated ); static cl::alias variableDeclarationAlias("vd", cl::desc("Same as -variable-declaration"), cl::aliasopt(variableDeclaration) ); // clang-format off static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); // static cl::extrahelp MoreHelp("\nMore help text...\n"); template<typename T> void addOpt(Options& opts, const T& opt, OptionValue optInit = OptionValue()) { opts.add({ opt.ArgStr, opt.HelpStr, opt.getNumOccurrences() > 0 ? opt : optInit }); } template<typename ActionType> void addMatcher( MatchFinder& matchFinder, std::vector<std::unique_ptr<FrontendAction>>& actions, ActionType&& action) { matchFinder.addMatcher(action->matcher(), action.get()); actions.push_back(std::move(action)); } } // namespace int main(int argc, const char** argv) { cl::SetVersionPrinter(&printVersion); CommonOptionsParser optionsParser(argc, argv, optionCategory); ClangTool tool(optionsParser.getCompilations(), optionsParser.getSourcePathList()); // CLANG_BUILTIN_INCLUDES_DIR is defined in CMakeLists.txt // const auto clangBuiltinIncludesDir = std::string("-I") + CLANG_BUILTIN_INCLUDES_DIR; // tool.appendArgumentsAdjuster(getInsertArgumentAdjuster(clangBuiltinIncludesDir.c_str())); // tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-Wno-gnu-include-next")); Options options; addOpt(options, json, std::string()); addOpt(options, verbose, false); JsonFile jsonFile(options["json"].as<std::string>()); std::vector<std::unique_ptr<FrontendAction>> actions; MatchFinder matchFinder; for (auto& fc : functionCall) { const auto [ className, methodName ] = splitClassMethod(fc); addMatcher(matchFinder, actions, std::make_unique<NotifyFunctionCallAction>( className, methodName, options, jsonFile)); } for (auto& vd : variableDeclaration) { addMatcher(matchFinder, actions, std::make_unique<NotifyVariableDeclarationAction>( vd, options, jsonFile)); } // MatchPrinter matchPrinter; // matchFinder.addMatcher(statementMatcher, &matchPrinter); return tool.run(newFrontendActionFactory(&matchFinder).get()); }
27.745098
96
0.703887
phitsc
b605f79fd82d9f2cf5a1dc420fb2e936e2feb6cc
53
hpp
C++
src/boost_fusion_sequence_sequence_facade.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
10
2018-03-17T00:58:42.000Z
2021-07-06T02:48:49.000Z
src/boost_fusion_sequence_sequence_facade.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
2
2021-03-26T15:17:35.000Z
2021-05-20T23:55:08.000Z
src/boost_fusion_sequence_sequence_facade.hpp
miathedev/BoostForArduino
919621dcd0c157094bed4df752b583ba6ea6409e
[ "BSL-1.0" ]
4
2019-05-28T21:06:37.000Z
2021-07-06T03:06:52.000Z
#include <boost/fusion/sequence/sequence_facade.hpp>
26.5
52
0.830189
miathedev
b609d338663f54b33d30d5654149fc7c8240cc8d
60
hpp
C++
test/mocks/BowlingMock.hpp
LuckyCode7/bowling
9d00f5b2509a975143b73ef9460cd047f0bd3136
[ "MIT" ]
null
null
null
test/mocks/BowlingMock.hpp
LuckyCode7/bowling
9d00f5b2509a975143b73ef9460cd047f0bd3136
[ "MIT" ]
33
2018-08-27T20:12:23.000Z
2018-09-17T09:12:26.000Z
test/mocks/BowlingMock.hpp
LuckyCode7/bowling
9d00f5b2509a975143b73ef9460cd047f0bd3136
[ "MIT" ]
2
2018-08-28T12:05:55.000Z
2018-08-30T14:45:14.000Z
#include "../../inc/Bowling.hpp" #include "gmock/gmock.h"
12
32
0.633333
LuckyCode7
b6109d27e3e82bcc83f0a9260d4b658cbd7aa318
249
hpp
C++
include/Graphic/GLContext.hpp
xubury/OpenGLApp
60d199351ec0406b372dd0aeaaea0a5b1664a327
[ "BSD-3-Clause" ]
2
2021-06-27T12:52:57.000Z
2021-08-24T21:25:57.000Z
include/Graphic/GLContext.hpp
xubury/OpenGLApp
60d199351ec0406b372dd0aeaaea0a5b1664a327
[ "BSD-3-Clause" ]
null
null
null
include/Graphic/GLContext.hpp
xubury/OpenGLApp
60d199351ec0406b372dd0aeaaea0a5b1664a327
[ "BSD-3-Clause" ]
null
null
null
#ifndef GL_CONTEXT_HPP #define GL_CONTEXT_HPP #include "Core/Export.hpp" #include "glbinding/glbinding.h" namespace te { class TE_API GLContext { public: static void init(glbinding::GetProcAddress procAddr); }; } // namespace te #endif
14.647059
57
0.738956
xubury
b610e17609985e86cb4be0469eda24bd67abf40e
2,727
cpp
C++
Company-Google/568. Maximum Vacation Days/main.cpp
Minecodecraft/LeetCode-Minecode
185fd6efe88d8ffcad94e581915c41502a0361a0
[ "MIT" ]
1
2021-11-19T19:58:33.000Z
2021-11-19T19:58:33.000Z
Company-Google/568. Maximum Vacation Days/main.cpp
Minecodecraft/LeetCode-Minecode
185fd6efe88d8ffcad94e581915c41502a0361a0
[ "MIT" ]
null
null
null
Company-Google/568. Maximum Vacation Days/main.cpp
Minecodecraft/LeetCode-Minecode
185fd6efe88d8ffcad94e581915c41502a0361a0
[ "MIT" ]
2
2021-11-26T12:47:27.000Z
2022-01-13T16:14:46.000Z
// // main.cpp // 568. Maximum Vacation Days // // Created by Jaylen Bian on 8/4/20. // Copyright © 2020 边俊林. All rights reserved. // #include <map> #include <set> #include <queue> #include <string> #include <stack> #include <vector> #include <cstdio> #include <numeric> #include <cstdlib> #include <utility> #include <iostream> #include <algorithm> #include <unordered_map> #include <unordered_set> using namespace std; /// Solution: // Solution 1: 252ms, 25MB, use memo to optimize validate flight check. /* class Solution { public: int maxVacationDays(vector<vector<int>>& flights, vector<vector<int>>& days) { int n = flights.size(), K = days[0].size(); vector<vector<int>> dp = vector<vector<int>> (K+1, vector<int> (n, INT_MIN)); vector<vector<int>> fl = vector<vector<int>> (n, vector<int> ()); for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) if (i == j || flights[i][j]) fl[i].push_back(j); dp[0][0] = 0; for (int i = 0; i < K; ++i) { for (int j = 0; j < n; ++j) { for (int k: fl[j]) { dp[i+1][k] = max(dp[i+1][k], dp[i][j] + days[k][i]); } } } int res = 0; for (int i = 0; i < n; ++i) res = max(res, dp[K][i]); return res; } }; */ // Solution 2: // 23.9MB, use scrolling array to optimize space usage. class Solution { public: int maxVacationDays(vector<vector<int>>& flights, vector<vector<int>>& days) { int n = flights.size(), K = days[0].size(); vector<vector<int>> dp = vector<vector<int>> (2, vector<int> (n, INT_MIN)); vector<vector<int>> fl = vector<vector<int>> (n, vector<int> ()); int idx = 0; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) if (i == j || flights[i][j]) fl[i].push_back(j); dp[idx][0] = 0; for (int i = 0; i < K; ++i) { for (int j = 0; j < n; ++j) { for (int k: fl[j]) { dp[1-idx][k] = max(dp[1-idx][k], dp[idx][j] + days[k][i]); } } idx = 1 - idx; } int res = 0; for (int i = 0; i < n; ++i) res = max(res, dp[idx][i]); return res; } }; int main() { Solution sol = Solution(); vector<vector<int>> fligts = { // {0,0,0}, {0,0,0}, {0,0,0} {0,1,1}, {1,0,1}, {1,1,0} }; vector<vector<int>> days = { // {1,1,1}, {7,7,7}, {7,7,7} {7,0,0}, {0,7,0}, {0,0,7} }; int res = sol.maxVacationDays(fligts, days); cout << res << endl; return 0; }
27
85
0.468647
Minecodecraft
b61265cce8be86d0b6b855fa026e9ad404d62849
3,002
cpp
C++
src/oruw_log.cpp
asherikov/oru_walk_module
96a58b331b7d3011f414cc9b1643b44b80ea8710
[ "BSD-2-Clause" ]
9
2016-02-21T14:23:27.000Z
2021-07-30T13:27:24.000Z
src/oruw_log.cpp
asherikov/oru_walk_module
96a58b331b7d3011f414cc9b1643b44b80ea8710
[ "BSD-2-Clause" ]
null
null
null
src/oruw_log.cpp
asherikov/oru_walk_module
96a58b331b7d3011f414cc9b1643b44b80ea8710
[ "BSD-2-Clause" ]
5
2015-06-23T16:30:21.000Z
2018-08-20T11:39:32.000Z
/** * @file * @author Alexander Sherikov * @date 03.01.2012 19:17:44 MSK */ #include "oruw_log.h" #ifdef ORUW_LOG_ENABLE oruw_log *oruw_log_instance = NULL; oruw_log::oruw_log () { FJointsLog = fopen ("./oru_joints.log", "w"); FCoMLog = fopen ("./oru_com.log", "w"); FFeetLog = fopen ("./oru_feet.log", "w"); FMessages = fopen ("./oru_messages.log", "w"); } oruw_log::~oruw_log () { fclose (FJointsLog); fclose (FCoMLog); fclose (FFeetLog); fclose (FMessages); } void oruw_log::logJointValues( const jointState& state_sensor, const jointState& state_expected) { for (int i = 0; i < JOINTS_NUM; i++) { fprintf (FJointsLog, "%f ", state_sensor.q[i]); } fprintf (FJointsLog, " "); for (int i = 0; i < JOINTS_NUM; i++) { fprintf (FJointsLog, "%f ", state_expected.q[i]); } fprintf (FJointsLog, "\n"); } void oruw_log::logCoM( smpc_parameters &mpc, nao_igm& nao) { fprintf (FCoMLog, "%f %f %f ", mpc.init_state.x(), mpc.init_state.y(), mpc.hCoM); double CoM[POSITION_VECTOR_SIZE]; nao.getCoM(nao.state_sensor, CoM); fprintf (FCoMLog, "%f %f %f\n", CoM[0], CoM[1], CoM[2]); } void oruw_log::logFeet(nao_igm& nao) { double l_expected[POSITION_VECTOR_SIZE]; double l_real[POSITION_VECTOR_SIZE]; double r_expected[POSITION_VECTOR_SIZE]; double r_real[POSITION_VECTOR_SIZE]; nao.getFeetPositions ( l_expected, r_expected, l_real, r_real); fprintf (FFeetLog, "%f %f %f %f %f %f", l_expected[0], l_expected[1], l_expected[2], l_real[0], l_real[1], l_real[2]); fprintf (FFeetLog, " %f %f %f %f %f %f\n", r_expected[0], r_expected[1], r_expected[2], r_real[0], r_real[1], r_real[2]); } void oruw_log::logSolverInfo (smpc::solver *solver, int mpc_solver_type) { if (solver != NULL) { if (mpc_solver_type == SOLVER_TYPE_AS) { smpc::solver_as * solver_ptr = dynamic_cast<smpc::solver_as *>(solver); if (solver_ptr != NULL) { fprintf(oruw_log_instance->FMessages, "AS size = %i // Added = %i // Removed = %i\n", solver_ptr->active_set_size, solver_ptr->added_constraints_num, solver_ptr->removed_constraints_num); } } else if (mpc_solver_type == SOLVER_TYPE_IP) { smpc::solver_ip * solver_ptr = dynamic_cast<smpc::solver_ip *>(solver); if (solver_ptr != NULL) { fprintf(oruw_log_instance->FMessages, "ext loops = %d // int loops = %d // bs loops = %d\n", solver_ptr->ext_loop_iterations, solver_ptr->int_loop_iterations, solver_ptr->bt_search_iterations); } } } } #endif // ORUW_LOG_ENABLE
25.65812
108
0.557295
asherikov
b61751cd47b0ed253e511e2778d215edae6bcc34
593
hpp
C++
include/tao/pq/is_aggregate.hpp
huzaifanazir/taopq
8f939d33840f14d7c08311729745fe7bb8cd9898
[ "BSL-1.0" ]
69
2016-08-05T19:16:04.000Z
2018-11-24T15:13:46.000Z
include/tao/pq/is_aggregate.hpp
huzaifanazir/taopq
8f939d33840f14d7c08311729745fe7bb8cd9898
[ "BSL-1.0" ]
13
2016-11-24T16:42:28.000Z
2018-09-11T18:55:40.000Z
include/tao/pq/is_aggregate.hpp
huzaifanazir/taopq
8f939d33840f14d7c08311729745fe7bb8cd9898
[ "BSL-1.0" ]
13
2016-09-22T17:31:10.000Z
2018-10-18T02:56:49.000Z
// Copyright (c) 2021-2022 Daniel Frey and Dr. Colin Hirsch // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PQ_IS_AGGREGATE_HPP #define TAO_PQ_IS_AGGREGATE_HPP namespace tao::pq { template< typename > inline constexpr bool is_aggregate = false; template< typename T > inline constexpr bool is_aggregate_result = is_aggregate< T >; template< typename T > inline constexpr bool is_aggregate_parameter = is_aggregate< T >; } // namespace tao::pq #endif
26.954545
91
0.750422
huzaifanazir
b6204a4c927872cdb28f94311ed7c0408b6a1e04
1,552
cpp
C++
EU4toV3Tests/EU4WorldTests/WarParserTests/WarParserTests.cpp
ParadoxGameConverters/EU4toVic3
e055d5fbaadc21e37f4bce5b3a4f4c1e415598fa
[ "MIT" ]
5
2021-05-22T20:10:05.000Z
2021-05-28T08:07:05.000Z
EU4toV3Tests/EU4WorldTests/WarParserTests/WarParserTests.cpp
klorpa/EU4toVic3
36b53a76402c715f618dd88f0caf962072bda8cf
[ "MIT" ]
13
2021-05-25T08:26:11.000Z
2022-01-13T18:24:12.000Z
EU4toV3Tests/EU4WorldTests/WarParserTests/WarParserTests.cpp
Zemurin/EU4toVic3
532b9a11e0e452be54d89e12cff5fb1f84ac3d11
[ "MIT" ]
5
2021-05-22T13:45:43.000Z
2021-12-25T00:00:04.000Z
#include "WarParser/WarParser.h" #include "gtest/gtest.h" #include <gmock/gmock-matchers.h> using testing::ElementsAre; TEST(EU4World_WarParserTests, primitivesDefaultToDefaults) { std::stringstream input; const EU4::WarParser war(input); EXPECT_TRUE(war.getAttackers().empty()); EXPECT_TRUE(war.getDefenders().empty()); EXPECT_TRUE(war.getName().empty()); EXPECT_FALSE(war.getDetails().startDate.isSet()); EXPECT_EQ(0, war.getDetails().targetProvinceID); EXPECT_TRUE(war.getDetails().targetTag.empty()); EXPECT_TRUE(war.getDetails().warGoalClass.empty()); EXPECT_TRUE(war.getDetails().warGoalType.empty()); } TEST(EU4World_WarParserTests, warCanBeLoaded) { std::stringstream input; input << "name = \"Silly War\""; input << "history = {\n"; input << " 9.9.9 = { it begins }\n"; input << " 10.10.10 = { it doesn't end }\n"; input << "}\n"; input << "attackers = { ULM C01 }\n"; input << "defenders = { FRA TUR HAB }\n"; input << "take_province = {\n"; input << " province = 13\n"; input << " type = conquest\n"; input << " tag = FRA\n"; input << "}\n"; const EU4::WarParser war(input); EXPECT_THAT(war.getAttackers(), ElementsAre("ULM", "C01")); EXPECT_THAT(war.getDefenders(), ElementsAre("FRA", "TUR", "HAB")); EXPECT_EQ("Silly War", war.getName()); EXPECT_EQ(date("9.9.9"), war.getDetails().startDate); EXPECT_EQ(13, war.getDetails().targetProvinceID); EXPECT_EQ("FRA", war.getDetails().targetTag); EXPECT_EQ("take_province", war.getDetails().warGoalClass); EXPECT_EQ("conquest", war.getDetails().warGoalType); }
33.021277
67
0.690077
ParadoxGameConverters
b62106c8d6dc1b175e62efef9bab7280c4674e27
1,147
cpp
C++
acmicpc.net/3758.cpp
kbu1564/SimpleAlgorithm
7e5b0d2fe19461417d88de0addd2235da55787d3
[ "MIT" ]
4
2016-04-15T07:54:39.000Z
2021-01-11T09:02:16.000Z
acmicpc.net/3758.cpp
kbu1564/SimpleAlgorithm
7e5b0d2fe19461417d88de0addd2235da55787d3
[ "MIT" ]
null
null
null
acmicpc.net/3758.cpp
kbu1564/SimpleAlgorithm
7e5b0d2fe19461417d88de0addd2235da55787d3
[ "MIT" ]
null
null
null
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; struct scoreboard { int uid; int total; int submission; int lastTime; int prob[101]; bool operator<(const scoreboard& u) const { if (total == u.total) { if (submission == u.submission) { return lastTime < u.lastTime; } return submission < u.submission; } return total > u.total; } }; int TC; int N, K, T, M; int main() { scanf("%d", &TC); for (int i = 0; i < TC; i++) { scoreboard user[101] = { 0, }; scanf("%d %d %d %d", &N, &K, &T, &M); for (int j = 0; j < M; j++) { int uid, pid, sco; scanf("%d %d %d", &uid, &pid, &sco); scoreboard& u = user[uid]; u.uid = uid; u.lastTime = j; u.submission++; if (u.prob[pid] < sco) { // score 갱신 u.total = u.total - u.prob[pid] + sco; u.prob[pid] = sco; } } sort(user+1, user+N+1); int result = 1; for (int j = 1; user[j].uid != T && j <= N; j++) result++; for (int j = 1; j <= N; j++) { printf("%d : %d - %d 제출, %dsec\n", user[j].uid, user[j].total, user[j].submission, user[j].lastTime); } printf("%d\n", result); } return 0; }
18.803279
104
0.537053
kbu1564
b623760bb3e99bfa241a860b0b1815baea9609d6
4,954
hpp
C++
hashkitcxx/hash_utils.hpp
sineang01/hashlibcxx
3fc50e6bd69eab0b3a33d388ff22dee5e8cfea3d
[ "BSD-3-Clause" ]
null
null
null
hashkitcxx/hash_utils.hpp
sineang01/hashlibcxx
3fc50e6bd69eab0b3a33d388ff22dee5e8cfea3d
[ "BSD-3-Clause" ]
null
null
null
hashkitcxx/hash_utils.hpp
sineang01/hashlibcxx
3fc50e6bd69eab0b3a33d388ff22dee5e8cfea3d
[ "BSD-3-Clause" ]
null
null
null
/* * HashKitCXX * * Copyright (c) 2018, Simone Angeloni * 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 Thomas J Bradley 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. */ #pragma once #include <utility> #if defined(HASHLIBCXX_STD_STRING) # include <string> #endif namespace hashkitcxx { #if defined(HASHLIBCXX_STD_STRING) /** * @brief Returns the hash of the given input in hex format. * @tparam THash a default constructible object containing an accessible function * `hash_printable` with the same signature of this one. * @param message the text to hash. This function takes a string in input so the message cannot * contain \0 characters in the middle. * @return a string containing the hash of `message` in hex. */ template<class THash> std::string hash_printable(std::string && message) { THash s; return s.hash_printable(std::forward<std::string>(message)); } /** * @brief Returns the hash of the given input in hex format. * @tparam THash a default constructible object containing an accessible function * `hash_printable` with the same signature of this one. * @param message pointer to the memory location containing the byte-array to hash. * @param len the total length of `message` expressed in bytes. * @return a string containing the hash of `message` in hex. */ template<class THash> std::string hash_printable(const unsigned char * message, size_t len) { THash s; return s.hash_printable(message, len); } /** * @brief Returns the hash of the given input. * @tparam THash a default constructible object containing an accessible function `hash` with * the same signature of this one. * @param message the text to hash. This function takes a string in input so the message cannot * contain \0 characters in the middle. * @param digest pointer to the memory location to store the hash of `message`. */ template<class THash> void hash(std::string && message, unsigned char * digest) { THash s; s.hash(std::forward<std::string>(message), digest); } #endif /** * @brief Returns the hash of the given input in hex format. * @tparam THash a default constructible object containing an accessible function * `hash_printable` with the same signature of this one. * @param message pointer to the memory location containing the byte-array to hash. * @param len the total length of `message` expressed in bytes. * @param digest_printable pointer to the memory location to store the hash of `message` in hex. */ template<class THash> void hash_printable(const unsigned char * message, size_t len, char * digest_printable) noexcept { THash s; s.hash_printable(message, len, digest_printable); } /** * @brief Returns the hash of the given input. * @tparam THash a default constructible object containing an accessible function `hash` with * the same signature of this one. * @param message pointer to the memory location containing the byte-array to hash. * @param len the total length of `message` expressed in bytes. * @param digest pointer to the memory location to store the hash of `message`. */ template<class THash> void hash(const unsigned char * message, size_t len, unsigned char * digest) noexcept { THash s; s.hash(message, len, digest); } } // namespace hashkitcxx
42.34188
100
0.708317
sineang01
b6260035721425e990f5acf25a44ffc36f0f0875
1,820
hpp
C++
src/main/cpp/inverted_penguin/core/dictionary/detail/ValueDictionaryBuilderKeyIterator.hpp
tomault/inverted_penguin
0cd939de38d860d32194203048d0a70a34fcca75
[ "Apache-2.0" ]
null
null
null
src/main/cpp/inverted_penguin/core/dictionary/detail/ValueDictionaryBuilderKeyIterator.hpp
tomault/inverted_penguin
0cd939de38d860d32194203048d0a70a34fcca75
[ "Apache-2.0" ]
null
null
null
src/main/cpp/inverted_penguin/core/dictionary/detail/ValueDictionaryBuilderKeyIterator.hpp
tomault/inverted_penguin
0cd939de38d860d32194203048d0a70a34fcca75
[ "Apache-2.0" ]
null
null
null
#ifndef __INVERTED_PENGUIN__CORE__DICTIONARY__DETAIL__VALUEDICTIONARYBUILDERKEYITERATOR_HPP__ #define __INVERTED_PENGUIN__CORE__DICTIONARY__DETAIL__VALUEDICTIONARYBUILDERKEYITERATOR_HPP__ #include <inverted_penguin/core/dictionary/detail/ValueDictionaryBuilderBaseIterator.hpp> namespace inverted_penguin { namespace core { namespace dictionary { namespace detail { template <typename Builder> class ValueDictionaryBuilderKeyIterator : public ValueDictionaryBuilderBaseIterator< Builder, ValueDictionaryBuilderKeyIterator<Builder> > { private: typedef ValueDictionaryBuilderBaseIterator< Builder, ValueDictionaryBuilderKeyIterator<Builder> > ParentType; public: typedef ValueDictionaryKey value_type; typedef value_type reference; public: ValueDictionaryBuilderKeyIterator(): ValueDictionaryBuilderKeyIterator(nullptr, 0) { } ValueDictionaryBuilderKeyIterator(Builder* builder, uint32_t index): ParentType(builder, index) { } ValueDictionaryBuilderKeyIterator( const ValueDictionaryBuilderKeyIterator& ) = default; template <typename OtherIterator> ValueDictionaryBuilderKeyIterator( const ValueDictionaryBuilderBaseIterator< Builder, OtherIterator >& other): ParentType(other) { } reference operator*() const { return this->builder_->keyAt(this->index_); } ValueDictionaryBuilderKeyIterator& operator=( const ValueDictionaryBuilderKeyIterator& ) = default; template <typename OtherIterator> ValueDictionaryBuilderKeyIterator& operator=( const ValueDictionaryBuilderBaseIterator< Builder, OtherIterator >& other) { ParentType::operator=(other); return *this; } }; } } } } #endif
25.633803
93
0.740659
tomault
b62ef05d61a650ffa5ab4f4901870de0297dfba6
7,778
cpp
C++
tests/Unit/PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Test_Tov.cpp
kidder/spectre
97ae95f72320f9f67895d3303824e64de6fd9077
[ "MIT" ]
117
2017-04-08T22:52:48.000Z
2022-03-25T07:23:36.000Z
tests/Unit/PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Test_Tov.cpp
GitHimanshuc/spectre
4de4033ba36547113293fe4dbdd77591485a4aee
[ "MIT" ]
3,177
2017-04-07T21:10:18.000Z
2022-03-31T23:55:59.000Z
tests/Unit/PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Test_Tov.cpp
geoffrey4444/spectre
9350d61830b360e2d5b273fdd176dcc841dbefb0
[ "MIT" ]
85
2017-04-07T19:36:13.000Z
2022-03-01T10:21:00.000Z
// Distributed under the MIT License. // See LICENSE.txt for details. #include "Framework/TestingFramework.hpp" #include <cmath> #include <cstddef> #include <memory> #include <pup.h> #include "DataStructures/Tensor/Tensor.hpp" #include "Framework/TestHelpers.hpp" #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Tov.hpp" #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp" // IWYU pragma: keep #include "Utilities/ConstantExpressions.hpp" // IWYU pragma: no_forward_declare EquationsOfState::EquationOfState namespace { constexpr double polytropic_constant = 8.0; double expected_newtonian_radius() { /* Analytic solution in Newtonian limit for polytropic TOV integration has $R = \pi / \alpha$ ; $M = 4\pi^{2}\rho_{0c} / \alpha^{3}$ Here $\rho_{0c}$ is the central mass density and $\alpha = sqrt(2\pi/K)$ with $K$ the polytropic constant */ return M_PI / sqrt(2.0 * M_PI / polytropic_constant); } double expected_newtonian_mass(const double central_mass_density) { return 4.0 * central_mass_density * square(M_PI) / (cube(sqrt(2.0 * M_PI / polytropic_constant))); } void test_tov( const EquationsOfState::EquationOfState<true, 1>& equation_of_state, const double central_mass_density, const size_t num_pts, const size_t current_iteration, const bool newtonian_limit) { Approx custom_approx = Approx::custom().epsilon(1.0e-08).scale(1.0); const double initial_log_enthalpy = std::log(get(equation_of_state.specific_enthalpy_from_density( Scalar<double>{central_mass_density}))); const double surface_log_enthalpy = 0.0; const double step = (surface_log_enthalpy - initial_log_enthalpy) / num_pts; const double final_log_enthalpy = initial_log_enthalpy + (current_iteration + 1.0) * step; const gr::Solutions::TovSolution tov_out_full( equation_of_state, central_mass_density, surface_log_enthalpy); if (newtonian_limit) { const double final_radius{tov_out_full.outer_radius()}; const double final_mass{tov_out_full.mass(final_radius)}; CHECK(expected_newtonian_radius() == custom_approx(final_radius)); CHECK(expected_newtonian_mass(central_mass_density) == custom_approx(final_mass)); } else { // Values in relativistic limit obtained from SpEC for // polytropic_constant = 8.0 and polytropic_exponent = 2.0 constexpr double expected_relativistic_radius = 3.4685521362; constexpr double expected_relativistic_mass = 0.0531036941; const double final_radius{tov_out_full.outer_radius()}; const double final_mass{tov_out_full.mass(final_radius)}; CHECK(expected_relativistic_radius == custom_approx(final_radius)); CHECK(expected_relativistic_mass == custom_approx(final_mass)); } // Integrate only to some intermediate value, not the surface. Then compare to // interpolated values. const gr::Solutions::TovSolution tov_out_intermediate( equation_of_state, central_mass_density, final_log_enthalpy); const double intermediate_radius{tov_out_intermediate.outer_radius()}; const double intermediate_mass{ tov_out_intermediate.mass(intermediate_radius)}; const double intermediate_log_enthalpy{ tov_out_intermediate.log_specific_enthalpy(intermediate_radius)}; const double interpolated_mass{tov_out_full.mass(intermediate_radius)}; const double interpolated_log_enthalpy{ tov_out_full.log_specific_enthalpy(intermediate_radius)}; CHECK(intermediate_mass == custom_approx(interpolated_mass)); CHECK(intermediate_log_enthalpy == custom_approx(interpolated_log_enthalpy)); const auto deserialized_tov_out_full = serialize_and_deserialize(tov_out_full); const auto deserialized_tov_out_intermediate = serialize_and_deserialize(tov_out_intermediate); const double intermediate_radius_ds{ deserialized_tov_out_intermediate.outer_radius()}; const double intermediate_mass_ds{ deserialized_tov_out_intermediate.mass(intermediate_radius_ds)}; const double intermediate_log_enthalpy_ds{ deserialized_tov_out_intermediate.log_specific_enthalpy( intermediate_radius_ds)}; const double interpolated_mass_ds{ deserialized_tov_out_full.mass(intermediate_radius_ds)}; const double interpolated_log_enthalpy_ds{ deserialized_tov_out_full.log_specific_enthalpy(intermediate_radius_ds)}; CHECK(intermediate_mass_ds == custom_approx(interpolated_mass_ds)); CHECK(intermediate_log_enthalpy_ds == custom_approx(interpolated_log_enthalpy_ds)); } void test_tov_dp_dr( const std::unique_ptr<EquationsOfState::EquationOfState<true, 1>>& equation_of_state) { const gr::Solutions::TovSolution radial_tov_solution(*equation_of_state, 1.0e-3); const size_t num_radial_pts = 500; auto coords = make_with_value<tnsr::I<DataVector, 3>>(num_radial_pts, 0.0); const double dx = radial_tov_solution.outer_radius() * 1.1 / num_radial_pts; for (size_t i = 0; i < get<0>(coords).size(); ++i) { get<0>(coords)[i] = i * dx; } const auto vars = radial_tov_solution.radial_variables(*equation_of_state, coords); const auto& pressure = vars.pressure; const auto& density = vars.rest_mass_density; const auto& specific_internal_energy = vars.specific_internal_energy; const auto& dp_dr = vars.dr_pressure; const auto& radii = vars.radial_coordinate; auto custom_approx = Approx::custom().epsilon(1.e-6); for (size_t i = 2; i < num_radial_pts - 2; ++i) { CAPTURE(i); CAPTURE(radii[i]); CAPTURE(radial_tov_solution.outer_radius()); CAPTURE(get(pressure)[i]); CAPTURE(get(density)[i]); if (radii[i + 2] < radial_tov_solution.outer_radius()) { CHECK((-get(pressure)[i + 2] / 12.0 + 2.0 / 3.0 * get(pressure)[i + 1] - 2.0 / 3.0 * get(pressure)[i - 1] + get(pressure)[i - 2] / 12.0) / dx == custom_approx(dp_dr[i])); } else if (radii[i] >= radial_tov_solution.outer_radius()) { CHECK(dp_dr[i] == 0.0); } } for (size_t i = 0; i < num_radial_pts; ++i) { const double total_energy_density = get(density)[i] * (1.0 + get(specific_internal_energy)[i]); const double p = get(pressure)[i]; const double radius = radii[i]; CAPTURE(total_energy_density); CAPTURE(p); CAPTURE(radius); if (radius < radial_tov_solution.outer_radius() and radius > 0.0) { const double m = radial_tov_solution.mass(radius); CHECK(approx(dp_dr[i]) == -total_energy_density * m / square(radius) * (1.0 + p / total_energy_density) * (1.0 + 4.0 * M_PI * p * cube(radius) / m) / (1.0 - 2.0 * m / radius)); } else { CHECK(approx(dp_dr[i]) == 0.0); } } } SPECTRE_TEST_CASE("Unit.PointwiseFunctions.AnalyticSolutions.Gr.Tov", "[Unit][PointwiseFunctions]") { std::unique_ptr<EquationsOfState::EquationOfState<true, 1>> equation_of_state = std::make_unique<EquationsOfState::PolytropicFluid<true>>( polytropic_constant, 2.0); /* Each iteration of the loop is for a different value of the final log_enthalpy in the integration. This is done to test the interpolation: the integration is stopped at some final log_enthalpy between the center and surface, and values are compared to those obtained by interpolation of the full integration up to the surface. */ const size_t num_pts = 25; for (size_t i = 0; i < num_pts; i++) { test_tov(*equation_of_state, 1.0e-10, num_pts, i, true); test_tov(*equation_of_state, 1.0e-03, num_pts, i, false); } test_tov_dp_dr(equation_of_state); } } // namespace
42.972376
94
0.715222
kidder
b62ef1a537a177ccea93dc52c250127125601f6d
317
hpp
C++
gui/SettingsWidget/SettingsChoice.hpp
razaqq/PotatoAlert
4dfb54a7841ca71d8dbf58620173f2a9fc1886f2
[ "MIT" ]
20
2020-06-16T01:30:29.000Z
2022-03-08T14:54:30.000Z
gui/SettingsWidget/SettingsChoice.hpp
razaqq/PotatoAlert
4dfb54a7841ca71d8dbf58620173f2a9fc1886f2
[ "MIT" ]
26
2019-07-15T10:49:47.000Z
2022-02-16T19:25:48.000Z
gui/SettingsWidget/SettingsChoice.hpp
razaqq/PotatoAlert
4dfb54a7841ca71d8dbf58620173f2a9fc1886f2
[ "MIT" ]
5
2020-06-16T01:31:03.000Z
2022-01-22T19:43:48.000Z
// Copyright 2020 <github.com/razaqq> #pragma once #include <QWidget> #include <QString> #include <QButtonGroup> namespace PotatoAlert { class SettingsChoice : public QWidget { public: SettingsChoice(QWidget* parent, const std::vector<QString>& buttons); QButtonGroup* btnGroup; }; } // namespace PotatoAlert
16.684211
70
0.750789
razaqq
b62f03ee52db12715b387a848eb67c12e0907aee
11,350
hh
C++
src/devices/atmel/sam4s/sam4s.hh
smindinvern/usb-micro
89b24a70a422352a71f92a5d3a6df796bcf32956
[ "BSD-3-Clause" ]
null
null
null
src/devices/atmel/sam4s/sam4s.hh
smindinvern/usb-micro
89b24a70a422352a71f92a5d3a6df796bcf32956
[ "BSD-3-Clause" ]
null
null
null
src/devices/atmel/sam4s/sam4s.hh
smindinvern/usb-micro
89b24a70a422352a71f92a5d3a6df796bcf32956
[ "BSD-3-Clause" ]
null
null
null
/** * Copyright 2018 Nickolas T Lloyd <ultrageek.lloyd@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 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 _SAM4S_HH #define _SAM4S_HH #include "arm.hh" #define CHIP_FAMILY SAM4S #define SAM4S_CODE_BASE (0x00000000UL) #define SAM4S_SRAM_BASE (0x20000000UL) #define SAM4S_PERIPHERALS_BASE (0x40000000UL) #define SAM4S_EXTERNAL_SRAM_BASE (0x60000000UL) #define SAM4S_SYSTEM_BASE (0xE0000000UL) #define SAM4S_HSMCI (SAM4S_PERIPHERALS_BASE + 0x00000UL) #define SAM4S_SSC (SAM4S_PERIPHERALS_BASE + 0x04000UL) #define SAM4S_SPI (SAM4S_PERIPHERALS_BASE + 0x08000UL) #define SAM4S_TC_BASE (SAM4S_PERIPHERALS_BASE + 0x10000UL) #define SAM4S_TC(n) (SAM4S_TC_BASE + n * 0x40UL) #define SAM4S_TWI0 (SAM4S_PERIPHERALS_BASE + 0x18000UL) #define SAM4S_TWI1 (SAM4S_PERIPHERALS_BASE + 0x1C000UL) #define SAM4S_PWM (SAM4S_PERIPHERALS_BASE + 0x20000UL) #define SAM4S_USART0 (SAM4S_PERIPHERALS_BASE + 0x24000UL) #define SAM4S_USART1 (SAM4S_PERIPHERALS_BASE + 0x28000UL) #define SAM4S_UDP (SAM4S_PERIPHERALS_BASE + 0x34000UL) #define SAM4S_ADC (SAM4S_PERIPHERALS_BASE + 0x38000UL) #define SAM4S_DACC (SAM4S_PERIPHERALS_BASE + 0x3C000UL) #define SAM4S_ACC (SAM4S_PERIPHERALS_BASE + 0x40000UL) #define SAM4S_CRCCU (SAM4S_PERIPHERALS_BASE + 0x44000UL) #define SAM4S_SYSCTRL_BASE (SAM4S_PERIPHERALS_BASE + 0xE0000UL) #define SAM4S_SMC (SAM4S_SYSCTRL_BASE + 0x0000UL) #define SAM4S_MATRIX (SAM4S_SYSCTRL_BASE + 0x0200UL) #define SAM4S_PMC (SAM4S_SYSCTRL_BASE + 0x0400UL) #define SAM4S_UART0 (SAM4S_SYSCTRL_BASE + 0x0600UL) #define SAM4S_CHIPID (SAM4S_SYSCTRL_BASE + 0x0740UL) #define SAM4S_UART1 (SAM4S_SYSCTRL_BASE + 0x0800UL) #define SAM4S_EEFC(n) (SAM4S_SYSCTRL_BASE + 0x0A00UL + n * 0x200UL) #define SAM4S_EEFC0 SAM4S_EEFC(0) #define SAM4S_EEFC1 SAM4S_EEFC(1) #define SAM4S_PIO_BASE (SAM4S_SYSCTRL_BASE + 0x0E00UL) #define SAM4S_PIO(n) (SAM4S_PIO_BASE + n * 0x0200UL) #define SAM4S_PIOA SAM4S_PIO(0) #define SAM4S_PIOB SAM4S_PIO(1) #define SAM4S_PIOC SAM4S_PIO(2) #define SAM4S_RSTC (SAM4S_SYSCTRL_BASE + 0x1400UL) #define SAM4S_SUPC (SAM4S_SYSCTRL_BASE + 0x1410UL) #define SAM4S_RTT (SAM4S_SYSCTRL_BASE + 0x1430UL) #define SAM4S_WDT (SAM4S_SYSCTRL_BASE + 0x1450UL) #define SAM4S_RTC (SAM4S_SYSCTRL_BASE + 0x1460UL) #define SAM4S_GPBR (SAM4S_SYSCTRL_BASE + 0x1490UL) // PMC registers #define PMC_SCER (SAM4S_PMC + 0x0000UL) #define PMC_SCDR (SAM4S_PMC + 0x0004UL) #define PMC_SCSR (SAM4S_PMC + 0x0008UL) #define PMC_PCER0 (SAM4S_PMC + 0x0010UL) #define PMC_PCDR0 (SAM4S_PMC + 0x0014UL) #define PMC_PCSR0 (SAM4S_PMC + 0x0018UL) #define CKGR_MOR (SAM4S_PMC + 0x0020UL) #define CKGR_MCFR (SAM4S_PMC + 0x0024UL) #define CKGR_PLLAR (SAM4S_PMC + 0x0028UL) #define CKGR_PLLBR (SAM4S_PMC + 0x002CUL) #define PMC_MCKR (SAM4S_PMC + 0x0030UL) #define PMC_USB (SAM4S_PMC + 0x0038UL) #define PMC_PCK0 (SAM4S_PMC + 0x0040UL) #define PMC_PCK1 (SAM4S_PMC + 0x0044UL) #define PMC_PCK2 (SAM4S_PMC + 0x0048UL) #define PMC_IER (SAM4S_PMC + 0x0060UL) #define PMC_IDR (SAM4S_PMC + 0x0064UL) #define PMC_SR (SAM4S_PMC + 0x0068UL) #define PMC_IMR (SAM4S_PMC + 0x006CUL) #define PMC_FSMR (SAM4S_PMC + 0x0070UL) #define PMC_FSPR (SAM4S_PMC + 0x0074UL) #define PMC_FOCR (SAM4S_PMC + 0x0078UL) #define PMC_WPMR (SAM4S_PMC + 0x00E4UL) #define PMC_WPSR (SAM4S_PMC + 0x00E8UL) #define PMC_PCER1 (SAM4S_PMC + 0x0100UL) #define PMC_PCDR1 (SAM4S_PMC + 0x0104UL) #define PMC_PCSR1 (SAM4S_PMC + 0x0108UL) #define PMC_OCR (SAM4S_PMC + 0x0110UL) // EEFC registers #define EEFC_FMR(n) (SAM4S_EEFC(n) + 0x00UL) #define EEFC_FCR(n) (SAM4S_EEFC(n) + 0x04UL) #define EEFC_FSR(n) (SAM4S_EEFC(n) + 0x08UL) #define EEFC_FRR(n) (SAM4S_EEFC(n) + 0x0CUL) // WDT registers #define WDT_CR (SAM4S_WDT + 0x00UL) #define WDT_MR (SAM4S_WDT + 0x04UL) #define WDT_SR (SAM4S_WDT + 0x08UL) // TC registers #define TC_CCR(n) (SAM4S_TC(n) + 0x00UL) #define TC_CMR(n) (SAM4S_TC(n) + 0x04UL) #define TC_SMMR(n) (SAM4S_TC(n) + 0x08UL) #define TC_CV(n) (SAM4S_TC(n) + 0x10UL) #define TC_RA(n) (SAM4S_TC(n) + 0x14UL) #define TC_RB(n) (SAM4S_TC(n) + 0x18UL) #define TC_RC(n) (SAM4S_TC(n) + 0x1CUL) #define TC_SR(n) (SAM4S_TC(n) + 0x20UL) #define TC_IER(n) (SAM4S_TC(n) + 0x24UL) #define TC_IDR(n) (SAM4S_TC(n) + 0x28UL) #define TC_IMR(n) (SAM4S_TC(n) + 0x2CUL) #define TC_BCR (SAM4S_TC_BASE + 0xC0UL) #define TC_BMR (SAM4S_TC_BASE + 0xC4UL) #define TC_QIER (SAM4S_TC_BASE + 0xC8UL) #define TC_QIDR (SAM4S_TC_BASE + 0xCCUL) #define TC_QIMR (SAM4S_TC_BASE + 0xD0UL) #define TC_QISR (SAM4S_TC_BASE + 0xD4UL) #define TC_FMR (SAM4S_TC_BASE + 0xD8UL) #define TC_WPMR (SAM4S_TC_BASE + 0xE4UL) // PIO registers #define PIO_PER(n) (SAM4S_PIO(n) + 0x0000UL) #define PIO_PDR(n) (SAM4S_PIO(n) + 0x0004UL) #define PIO_PSR(n) (SAM4S_PIO(n) + 0x0008UL) #define PIO_OER(n) (SAM4S_PIO(n) + 0x0010UL) #define PIO_ODR(n) (SAM4S_PIO(n) + 0x0014UL) #define PIO_OSR(n) (SAM4S_PIO(n) + 0x0018UL) #define PIO_IFER(n) (SAM4S_PIO(n) + 0x0020UL) #define PIO_IFDR(n) (SAM4S_PIO(n) + 0x0024UL) #define PIO_IFSR(n) (SAM4S_PIO(n) + 0x0028UL) #define PIO_SODR(n) (SAM4S_PIO(n) + 0x0030UL) #define PIO_CODR(n) (SAM4S_PIO(n) + 0x0034UL) #define PIO_ODSR(n) (SAM4S_PIO(n) + 0x0038UL) #define PIO_PDSR(n) (SAM4S_PIO(n) + 0x003CUL) #define PIO_IER(n) (SAM4S_PIO(n) + 0x0040UL) #define PIO_IDR(n) (SAM4S_PIO(n) + 0x0044UL) #define PIO_IMR(n) (SAM4S_PIO(n) + 0x0048UL) #define PIO_ISR(n) (SAM4S_PIO(n) + 0x004CUL) #define PIO_MDER(n) (SAM4S_PIO(n) + 0x0050UL) #define PIO_MDDR(n) (SAM4S_PIO(n) + 0x0054UL) #define PIO_MDSR(n) (SAM4S_PIO(n) + 0x0058UL) #define PIO_PUDR(n) (SAM4S_PIO(n) + 0x0060UL) #define PIO_PUER(n) (SAM4S_PIO(n) + 0x0064UL) #define PIO_PESR(n) (SAM4S_PIO(n) + 0x0068UL) #define PIO_ABCDSR1(n) (SAM4S_PIO(n) + 0x0070UL) #define PIO_ABCDSR2(n) (SAM4S_PIO(n) + 0x0074UL) #define PIO_IFSCDR(n) (SAM4S_PIO(n) + 0x0080UL) #define PIO_IFSCER(n) (SAM4S_PIO(n) + 0x0084UL) #define PIO_IFSCSR(n) (SAM4S_PIO(n) + 0x0088UL) #define PIO_SCDR(n) (SAM4S_PIO(n) + 0x008CUL) #define PIO_PPDDR(n) (SAM4S_PIO(n) + 0x0090UL) #define PIO_PPDER(n) (SAM4S_PIO(n) + 0x0094UL) #define PIO_PPDSR(n) (SAM4S_PIO(n) + 0x0098UL) #define PIO_OWER(n) (SAM4S_PIO(n) + 0x00A0UL) #define PIO_OWDR(n) (SAM4S_PIO(n) + 0x00A4UL) #define PIO_OWSR(n) (SAM4S_PIO(n) + 0x00A8UL) #define PIO_AIMER(n) (SAM4S_PIO(n) + 0x00B0UL) #define PIO_AIMDR(n) (SAM4S_PIO(n) + 0x00B4UL) #define PIO_AIMMR(n) (SAM4S_PIO(n) + 0x00B8UL) #define PIO_ESR(n) (SAM4S_PIO(n) + 0x00C0UL) #define PIO_LSR(n) (SAM4S_PIO(n) + 0x00C4UL) #define PIO_ELSR(n) (SAM4S_PIO(n) + 0x00C8UL) #define PIO_FELLSR(n) (SAM4S_PIO(n) + 0x00D0UL) #define PIO_REHLSR(n) (SAM4S_PIO(n) + 0x00D4UL) #define PIO_FRLHSR(n) (SAM4S_PIO(n) + 0x00D8UL) #define PIO_LOCKSR(n) (SAM4S_PIO(n) + 0x00E0UL) #define PIO_WPMR(n) (SAM4S_PIO(n) + 0x00E4UL) #define PIO_WPSR(n) (SAM4S_PIO(n) + 0x00E8UL) #define PIO_SCMITT(n) (SAM4S_PIO(n) + 0x0100UL) #define PIO_PCMR(n) (SAM4S_PIO(n) + 0x0150UL) #define PIO_PCIER(n) (SAM4S_PIO(n) + 0x0154UL) #define PIO_PCIDR(n) (SAM4S_PIO(n) + 0x0158UL) #define PIO_PCIMR(n) (SAM4S_PIO(n) + 0x015CUL) #define PIO_PCISR(n) (SAM4S_PIO(n) + 0x0160UL) #define PIO_PCRHR(n) (SAM4S_PIO(n) + 0x0164UL) // UDP registers #define UDP_FRM_NUM (SAM4S_UDP + 0x000UL) #define UDP_GLB_STAT (SAM4S_UDP + 0x004UL) #define UDP_FADDR (SAM4S_UDP + 0x008UL) #define UDP_IER (SAM4S_UDP + 0x010UL) #define UDP_IDR (SAM4S_UDP + 0x014UL) #define UDP_IMR (SAM4S_UDP + 0x018UL) #define UDP_ISR (SAM4S_UDP + 0x01CUL) #define UDP_ICR (SAM4S_UDP + 0x020UL) #define UDP_RST_EP (SAM4S_UDP + 0x028UL) #define UDP_CSR(n) (SAM4S_UDP + 0x030UL + n * 0x4UL) #define UDP_FDR(n) (SAM4S_UDP + 0x050UL + n * 0x4UL) #define UDP_TXVC (SAM4S_UDP + 0x074UL) // Bus MATRIX registers #define MATRIX_MCFG0 (SAM4S_MATRIX + 0x0000UL) #define MATRIX_MCFG1 (SAM4S_MATRIX + 0x0004UL) #define MATRIX_MCFG2 (SAM4S_MATRIX + 0x0008UL) #define MATRIX_MCFG3 (SAM4S_MATRIX + 0x000CUL) #define MATRIX_SCFG0 (SAM4S_MATRIX + 0x0040UL) #define MATRIX_SCFG1 (SAM4S_MATRIX + 0x0044UL) #define MATRIX_SCFG2 (SAM4S_MATRIX + 0x0048UL) #define MATRIX_SCFG3 (SAM4S_MATRIX + 0x004CUL) #define MATRIX_SCFG4 (SAM4S_MATRIX + 0x0050UL) #define MATRIX_PRAS0 (SAM4S_MATRIX + 0x0080UL) #define MATRIX_PRAS1 (SAM4S_MATRIX + 0x0088UL) #define MATRIX_PRAS2 (SAM4S_MATRIX + 0x0090UL) #define MATRIX_PRAS3 (SAM4S_MATRIX + 0x0098UL) #define MATRIX_PRAS4 (SAM4S_MATRIX + 0x00A0UL) #define CCFG_SYSIO (SAM4S_MATRIX + 0x0114UL) #define CCFG_SMCNFCS (SAM4S_MATRIX + 0x011CUL) #define MATRIX_WPMR (SAM4S_MATRIX + 0x01E4UL) #define MATRIX_WPSR (SAM4S_MATRIX + 0x01E8UL) #endif
48.504274
84
0.668282
smindinvern
ac07cf1391399288f5a231efa432314b28a3097f
7,021
cpp
C++
src/Open3DMotion/Bindings/Python/PythonConvert.cpp
Open3DMotionGroup/Open3DMotion
302036f975eab80ccb91bb4f6f4ef58965c29f68
[ "BSD-3-Clause" ]
4
2021-03-31T20:46:16.000Z
2021-12-16T20:57:21.000Z
src/Open3DMotion/Bindings/Python/PythonConvert.cpp
Open3DMotionGroup/Open3DMotion
302036f975eab80ccb91bb4f6f4ef58965c29f68
[ "BSD-3-Clause" ]
40
2018-03-11T15:14:50.000Z
2022-03-23T18:13:48.000Z
src/Open3DMotion/Bindings/Python/PythonConvert.cpp
Open3DMotionGroup/Open3DMotion
302036f975eab80ccb91bb4f6f4ef58965c29f68
[ "BSD-3-Clause" ]
2
2018-05-12T13:45:32.000Z
2021-03-31T20:46:17.000Z
/*-- Open3DMotion Copyright (c) 2004-2018. All rights reserved. See LICENSE.txt for more information. --*/ #include "PythonConvert.h" #include "MemoryHandlerPython.h" #include "Open3DMotion/OpenORM/Leaves/TreeString.h" #include "Open3DMotion/OpenORM/Leaves/TreeBool.h" #include "Open3DMotion/OpenORM/Leaves/TreeInt32.h" #include "Open3DMotion/OpenORM/Leaves/TreeFloat64.h" #include "Open3DMotion/OpenORM/Leaves/TreeBinary.h" #include "Open3DMotion/OpenORM/Branches/TreeList.h" #include "Open3DMotion/OpenORM/Branches/TreeCompound.h" #include <memory> namespace Open3DMotion { PyObject* PythonConvert::FromTree(const TreeValue* value) { if (value == NULL) { Py_RETURN_NONE; } else if (value->ClassNameMatches(TreeString::classname)) { const TreeString* value_string = static_cast<const TreeString*> (value); std::string strcopy( value_string->Value() ); PyObject* py_string = #if PY_MAJOR_VERSION >= 3 PyUnicode_FromString(&strcopy[0]); #else PyString_FromString(&strcopy[0]); #endif return py_string; } else if (value->ClassNameMatches(TreeBool::classname)) { const TreeBool* value_bool = static_cast<const TreeBool*> (value); if (value_bool->Value()) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } } else if (value->ClassNameMatches(TreeInt32::classname)) { const TreeInt32* value_int32 = static_cast<const TreeInt32*> (value); PyObject* py_value = #if PY_MAJOR_VERSION >= 3 PyLong_FromLong(value_int32->Value()); #else PyInt_FromLong(value_int32->Value()); #endif return py_value; } else if (value->ClassNameMatches(TreeFloat64::classname)) { const TreeFloat64* value_float64 = static_cast<const TreeFloat64*> (value); PyObject* py_value = PyFloat_FromDouble(value_float64->Value()); return py_value; } else if (value->ClassNameMatches(TreeBinary::classname)) { const TreeBinary* bin = static_cast<const TreeBinary*> (value); const MemoryHandlerPython* mem = NamedClassCast<MemoryHandler, MemoryHandlerPython> ( bin->BinMemory() ); if (mem) { PyObject* py_view = mem->PythonMemoryView(); Py_INCREF(py_view); return py_view; } else { // Only support binary memory allocated using the Python allocator Py_RETURN_NONE; } } else if (value->ClassNameMatches(TreeList::classname)) { // Build list of items const TreeList* value_list = static_cast<const TreeList*> (value); PyObject* py_list = PyList_New(0); const std::vector<TreeValue*>& element_array = value_list->ElementArray(); for (std::vector<TreeValue*>::const_iterator iter(element_array.begin()); iter != element_array.end(); iter++) { // Use Append here not SetItem // To provide robustness to items we can't process (will just skip them) PyObject* py_new_item = PythonConvert::FromTree(*iter); if (py_new_item != Py_None) { PyList_Append(py_list, py_new_item); } Py_DECREF(py_new_item); } // Wrap it in a dictionary specifying the element name PyObject* py_wrapper = PyDict_New(); PyDict_SetItemString(py_wrapper, value_list->ElementName().c_str(), py_list); // Now owned only by wrapper Py_DECREF(py_list); // Return result return py_wrapper; } else if (value->ClassNameMatches(TreeCompound::classname)) { const TreeCompound* c = static_cast<const TreeCompound*> (value); PyObject* py_c = PyDict_New(); size_t n = c->NumElements(); for (size_t i = 0; i < n; i++) { const TreeCompoundNode* node = c->Node(i); PyObject* py_new_item = PythonConvert::FromTree(node->Value()); if (py_new_item != Py_None) { PyDict_SetItemString(py_c, node->Name().c_str(), py_new_item); } Py_DECREF(py_new_item); } return py_c; } else { Py_RETURN_NONE; } } TreeValue* PythonConvert::ToTree(PyObject* py_value) { if (py_value == NULL || py_value == Py_None) { return NULL; } #if PY_MAJOR_VERSION >= 3 else if (PyUnicode_Check(py_value)) { return new TreeString(PyUnicode_AsUTF8(py_value)); } #else else if (PyString_Check(py_value)) { return new TreeString( PyString_AS_STRING(py_value) ); } #endif else if (PyBool_Check(py_value)) { return new TreeBool( (py_value == Py_True) ? true : false ); } #if PY_MAJOR_VERSION < 3 else if (PyInt_Check(py_value)) { return new TreeInt32(PyInt_AsLong(py_value)); } #endif else if (PyLong_Check(py_value)) { int overflow(0); long result = PyLong_AsLongAndOverflow(py_value, &overflow); if (overflow == 0) { return new TreeInt32(result); } } else if (PyFloat_Check(py_value)) { return new TreeFloat64(PyFloat_AsDouble(py_value)); } else if (PyMemoryView_Check(py_value)) { return new TreeBinary(new MemoryHandlerPython(py_value)); } else if (PyDict_Check(py_value)) { // Might represent a list if it has one element which is a Python list object PyObject* py_list(NULL); const char* elementname(NULL); if (PyDict_Size(py_value) == 1) { PyObject* py_dict_key = NULL; PyObject* py_dict_value = NULL; Py_ssize_t pos = 0; PyDict_Next(py_value, &pos, &py_dict_key, &py_dict_value); if (py_dict_value && py_dict_key && PyList_Check(py_dict_value) && #if PY_MAJOR_VERSION >= 3 PyUnicode_Check(py_dict_key) #else PyString_Check(py_dict_key) #endif ) { py_list = py_dict_value; elementname = #if PY_MAJOR_VERSION >= 3 PyUnicode_AsUTF8(py_dict_key); #else PyString_AsString(py_dict_key); #endif } } if (py_list) { // it's a list std::unique_ptr<TreeList> result_list(new TreeList(elementname)); Py_ssize_t s = PyList_Size(py_list); for (Py_ssize_t index = 0; index < s; index++) { PyObject* py_obj = PyList_GetItem(py_list, index); TreeValue* tree_item = PythonConvert::ToTree(py_obj); if (tree_item) { result_list->Add(tree_item); } } return result_list.release(); } else { // it represents a compound object std::unique_ptr<TreeCompound> result_compound(new TreeCompound); PyObject* key = NULL; PyObject* py_element = NULL; Py_ssize_t pos = 0; while (PyDict_Next(py_value, &pos, &key, &py_element)) { #if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(key)) #else if (PyString_Check(key)) #endif { TreeValue* element = PythonConvert::ToTree(py_element); if (element != NULL) { const char* key_string = #if PY_MAJOR_VERSION >= 3 PyUnicode_AsUTF8(key); #else PyString_AsString(key); #endif result_compound->Set(key_string, element); } } } return result_compound.release(); } } return NULL; } }
27.003846
114
0.653326
Open3DMotionGroup
ac07e073c01bc815a3cb1bf9ad22da06d164be70
2,201
cpp
C++
Source/Libraries/Asi/RuntimeCommandEngine/Parameter/Union.cpp
geoffviola/RuntimeCommandEngine
0c46b2e751babe36ef72b80b356f7f7d30c5b9ec
[ "MIT" ]
null
null
null
Source/Libraries/Asi/RuntimeCommandEngine/Parameter/Union.cpp
geoffviola/RuntimeCommandEngine
0c46b2e751babe36ef72b80b356f7f7d30c5b9ec
[ "MIT" ]
null
null
null
Source/Libraries/Asi/RuntimeCommandEngine/Parameter/Union.cpp
geoffviola/RuntimeCommandEngine
0c46b2e751babe36ef72b80b356f7f7d30c5b9ec
[ "MIT" ]
null
null
null
#include "Union.hpp" #include <functional> #include <algorithm> #include <Asi/RuntimeCommandEngine/StringUtils.hpp> namespace asi { namespace runtimecommandengine { namespace parameter { Union::Union(std::string const &name, ParameterAbstract *pm1, ParameterAbstract *pm2) : ParameterAbstract(name) { unionizedParameters.push_back(std::shared_ptr<ParameterAbstract>(pm1)); unionizedParameters.push_back(std::shared_ptr<ParameterAbstract>(pm2)); } Union::~Union() {} std::string Union::GetExpectedDomainImpl() const { std::string output = std::string("{"); for (auto unionizedParameter : unionizedParameters) { if (output.length() > 1) { output += ", "; } output += unionizedParameter->GetExpectedDomain(); } output += std::string("}"); return output; } std::vector<std::string> Union::GetExpectedDomainSetImpl() const { std::vector<std::string> output; std::vector<std::string> raw_set; for (auto unionizedParameter : unionizedParameters) { for (auto item_in_parameter : unionizedParameter->GetExpectedDomainSet()) { raw_set.push_back(item_in_parameter); } } for (auto new_item : raw_set) { bool string_is_new = !std::any_of(output.begin(), output.end(), std::bind(&iequals, new_item, std::placeholders::_1)); if (string_is_new) { output.push_back(new_item); } } return output; } bool Union::isInExpectedDomain(std::string const &raw_value) const { bool output = false; for (auto unionizedParameter : unionizedParameters) { if (unionizedParameter->IsInExpectedDomain(raw_value)) { if (false == output) { output = true; } else { // return false if in multiple domains output = false; break; } } } return output; } std::string Union::generateTypeName() const { std::string output = "Union("; for (auto unionizedParameter : unionizedParameters) { if (output.length() > 6) { output += ", "; } output += unionizedParameter->GetTypeName(); } output += ")"; return output; } char const *Union::getTypeName() const { static std::string const output = generateTypeName(); return output.c_str(); } } // namespace parameter } // namespace runtimecommandengine } // namespace asi
20.37963
103
0.696502
geoffviola
ac080a5574cccf91f32bd2d6c4b5df7e03d148a5
12,229
cpp
C++
pattern/test/class_traits_test.cpp
vinders/pandora_toolbox
f32e301ebaa2b281a1ffc3d6d0c556091420520a
[ "MIT" ]
2
2020-11-19T03:23:35.000Z
2021-02-25T03:34:40.000Z
pattern/test/class_traits_test.cpp
vinders/pandora_toolbox
f32e301ebaa2b281a1ffc3d6d0c556091420520a
[ "MIT" ]
null
null
null
pattern/test/class_traits_test.cpp
vinders/pandora_toolbox
f32e301ebaa2b281a1ffc3d6d0c556091420520a
[ "MIT" ]
null
null
null
/******************************************************************************* MIT License Copyright (c) 2021 Romain Vinders 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 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 <gtest/gtest.h> #include <vector> #include <list> #include <pattern/class_traits.h> using namespace pandora::pattern; class ClassTraitsTest : public testing::Test { public: protected: //static void SetUpTestCase() {} //static void TearDownTestCase() {} void SetUp() override {} void TearDown() override {} }; // -- mocks -- template <typename _DataType> class TraitsTester final { public: TraitsTester() = default; template <typename T = _DataType> TraitsTester(enable_if_copy_constructible<T, const T& > value) : _value(value) {} template <typename T = _DataType> TraitsTester(enable_if_move_constructible<T, T&& > value) noexcept : _value(std::move(value)) {} ~TraitsTester() = default; const _DataType& value() const noexcept { return _value; } // - copy / move - template <typename T = _DataType> TraitsTester(enable_if_copy_constructible<T, const TraitsTester<T>& > rhs) : _value(rhs._value) {} template <typename T = _DataType> TraitsTester(enable_if_move_constructible<T, TraitsTester<T>&& > rhs) noexcept : _value(std::move(rhs._value)) {} template <typename T = _DataType> enable_if_copy_constructible<T, TraitsTester<_DataType>& > operator=(const TraitsTester<T>& rhs) { _value = rhs._value; return *this; } template <typename T = _DataType> enable_if_move_constructible<T, TraitsTester<_DataType>& > operator=(TraitsTester<T>&& rhs) noexcept { _value = std::move(rhs._value); return *this; } // - comparisons - template <typename T = _DataType> inline bool operator==(enable_if_operator_equals<T, const TraitsTester<T>& > rhs) const noexcept { return (this->_value == rhs._value); } template <typename T = _DataType> inline bool operator!=(enable_if_operator_equals<T, const TraitsTester<T>& > rhs) const noexcept { return !(this->operator==(rhs)); } template <typename T = _DataType> inline bool operator<(enable_if_operator_less<T, const TraitsTester<T>& > rhs) const noexcept { return (this->_value < rhs._value); } template <typename T = _DataType> inline bool operator<=(enable_if_operator_less_eq<T, const TraitsTester<T>& > rhs) const noexcept { return (this->_value <= rhs._value); } template <typename T = _DataType> inline bool operator>(enable_if_operator_greater<T, const TraitsTester<T>& > rhs) const noexcept { return (this->_value > rhs._value); } template <typename T = _DataType> inline bool operator>=(enable_if_operator_greater_eq<T, const TraitsTester<T>& > rhs) const noexcept { return (this->_value >= rhs._value); } private: _DataType _value; }; #define __P_GENERATE_MOCK(name, copyable, movable) \ template <typename T> class name { \ public: \ name() = default; \ name(const T& value) : _value(value) {} \ name(const name &) = copyable ; \ name & operator=(const name &) = copyable ; \ name(name &&) noexcept = movable ; \ name & operator=(name &&) noexcept = movable ; \ bool operator==(const name& rhs) const noexcept { return _value == rhs._value; } \ bool operator!=(const name& rhs) const noexcept { return _value != rhs._value; } \ bool operator<(const name& rhs) const noexcept { return _value < rhs._value; } \ bool operator<=(const name& rhs) const noexcept { return _value <= rhs._value; } \ bool operator>(const name& rhs) const noexcept { return _value > rhs._value; } \ bool operator>=(const name& rhs) const noexcept { return _value >= rhs._value; } \ void value(const T& val) noexcept { _value = val; } \ const T& value() const noexcept { return _value; } \ private: \ T _value; } using BaseType = int; __P_GENERATE_MOCK(Copyable, default, delete); __P_GENERATE_MOCK(Movable, delete, default); __P_GENERATE_MOCK(CopyMovable, default, default); // -- copy / move / comparisons -- TEST_F(ClassTraitsTest, baseTypeTraits) { TraitsTester<BaseType> data(42); TraitsTester<BaseType> copy(data); EXPECT_EQ(data.value(), copy.value()); EXPECT_TRUE(data.value() == copy.value()); EXPECT_FALSE(data.value() != copy.value()); EXPECT_TRUE(data.value() <= copy.value()); EXPECT_FALSE(data.value() < copy.value()); EXPECT_TRUE(data.value() >= copy.value()); EXPECT_FALSE(data.value() > copy.value()); TraitsTester<BaseType> small(4); EXPECT_FALSE(small.value() == data.value()); EXPECT_TRUE(small.value() != data.value()); EXPECT_TRUE(small.value() <= data.value()); EXPECT_TRUE(small.value() < data.value()); EXPECT_FALSE(small.value() >= data.value()); EXPECT_FALSE(small.value() > data.value()); data = small; EXPECT_EQ(small.value(), data.value()); EXPECT_TRUE(small.value() == data.value()); EXPECT_FALSE(small.value() != data.value()); } TEST_F(ClassTraitsTest, copyOnlyTraits) { TraitsTester<Copyable<int> > data(Copyable<int>(42)); TraitsTester<Copyable<int> > copy(data); EXPECT_EQ(data.value(), copy.value()); EXPECT_TRUE(data.value() == copy.value()); EXPECT_FALSE(data.value() != copy.value()); EXPECT_TRUE(data.value() <= copy.value()); EXPECT_FALSE(data.value() < copy.value()); EXPECT_TRUE(data.value() >= copy.value()); EXPECT_FALSE(data.value() > copy.value()); TraitsTester<Copyable<int> > small(Copyable<int>(4)); EXPECT_FALSE(small.value() == data.value()); EXPECT_TRUE(small.value() != data.value()); EXPECT_TRUE(small.value() <= data.value()); EXPECT_TRUE(small.value() < data.value()); EXPECT_FALSE(small.value() >= data.value()); EXPECT_FALSE(small.value() > data.value()); data = small; EXPECT_EQ(small.value(), data.value()); EXPECT_TRUE(small.value() == data.value()); EXPECT_FALSE(small.value() != data.value()); } TEST_F(ClassTraitsTest, moveOnlyTraits) { TraitsTester<Movable<int> > data(Movable<int>(42)); EXPECT_EQ(data.value(), 42); TraitsTester<Movable<int> > moved(TraitsTester<Movable<int> >(Movable<int>(42))); EXPECT_EQ(moved.value(), 42); data = TraitsTester<Movable<int> >(Movable<int>(4)); EXPECT_EQ(data.value(), 4); data = TraitsTester<Movable<int> >(Movable<int>(42)); EXPECT_EQ(data.value(), 42); EXPECT_TRUE(data.value() == moved.value()); EXPECT_FALSE(data.value() != moved.value()); EXPECT_TRUE(data.value() <= moved.value()); EXPECT_FALSE(data.value() < moved.value()); EXPECT_TRUE(data.value() >= moved.value()); EXPECT_FALSE(data.value() > moved.value()); TraitsTester<Movable<int> > small(Movable<int>(4)); EXPECT_FALSE(small.value() == data.value()); EXPECT_TRUE(small.value() != data.value()); EXPECT_TRUE(small.value() <= data.value()); EXPECT_TRUE(small.value() < data.value()); EXPECT_FALSE(small.value() >= data.value()); EXPECT_FALSE(small.value() > data.value()); moved = std::move(data); EXPECT_FALSE(small.value() == moved.value()); EXPECT_TRUE(small.value() != moved.value()); EXPECT_TRUE(small.value() <= moved.value()); EXPECT_TRUE(small.value() < moved.value()); EXPECT_FALSE(small.value() >= moved.value()); EXPECT_FALSE(small.value() > moved.value()); } TEST_F(ClassTraitsTest, copyMoveTraits) { TraitsTester<CopyMovable<int> > data(CopyMovable<int>(42)); TraitsTester<CopyMovable<int> > copy(data); EXPECT_EQ(data.value(), copy.value()); TraitsTester<CopyMovable<int> > moved(std::move(data)); EXPECT_EQ(copy.value(), moved.value()); data = copy; EXPECT_EQ(data.value(), copy.value()); EXPECT_TRUE(data.value() == moved.value()); EXPECT_FALSE(data.value() != moved.value()); EXPECT_TRUE(data.value() <= moved.value()); EXPECT_FALSE(data.value() < moved.value()); EXPECT_TRUE(data.value() >= moved.value()); EXPECT_FALSE(data.value() > moved.value()); TraitsTester<CopyMovable<int> > small(CopyMovable<int>(4)); EXPECT_FALSE(small.value() == data.value()); EXPECT_TRUE(small.value() != data.value()); EXPECT_TRUE(small.value() <= data.value()); EXPECT_TRUE(small.value() < data.value()); EXPECT_FALSE(small.value() >= data.value()); EXPECT_FALSE(small.value() > data.value()); moved = std::move(data); EXPECT_FALSE(small.value() == moved.value()); EXPECT_TRUE(small.value() != moved.value()); EXPECT_TRUE(small.value() <= moved.value()); EXPECT_TRUE(small.value() < moved.value()); EXPECT_FALSE(small.value() >= moved.value()); EXPECT_FALSE(small.value() > moved.value()); } // -- iterators -- template <typename _It> int getValue(enable_if_iterator<_It, const _It&> it) noexcept { return *it; } template <typename _It> int getValueBiDirectional(enable_if_iterator_reversible<_It, const _It&> it) noexcept { return *it; } TEST_F(ClassTraitsTest, iteratorTraits) { EXPECT_TRUE(is_forward_iterator<std::vector<char>::iterator>::value); EXPECT_TRUE(is_bidirectional_iterator<std::vector<char>::iterator>::value); EXPECT_TRUE(is_random_access_iterator<std::vector<char>::iterator>::value); EXPECT_TRUE(is_forward_iterator<std::list<char>::iterator>::value); EXPECT_TRUE(is_bidirectional_iterator<std::list<char>::iterator>::value); EXPECT_FALSE(is_random_access_iterator<std::list<char>::iterator>::value); std::vector<int> vec; vec.push_back(42); vec.push_back(24); EXPECT_TRUE(getValue<std::vector<int>::iterator>(vec.begin()) == 42); EXPECT_TRUE(getValue<std::vector<int>::iterator>(vec.begin() + 1) == 24); EXPECT_TRUE(getValueBiDirectional<std::vector<int>::iterator>(vec.begin()) == 42); EXPECT_TRUE(getValueBiDirectional<std::vector<int>::iterator>(vec.begin() + 1) == 24); } // -- constructors / assignment enablers -- template <typename T> struct EnablerTester : public ConstructorSelector<T>, public AssignmentSelector<T> { EnablerTester() = default; EnablerTester(const EnablerTester<T>& rhs) : ConstructorSelector<T>(rhs) { value = rhs.value; } EnablerTester(EnablerTester<T>&& rhs) noexcept : ConstructorSelector<T>(std::move(rhs)) { value = std::move(rhs.value); } EnablerTester& operator=(const EnablerTester<T>& rhs) { AssignmentSelector<T>::operator=(rhs); value = rhs.value; } EnablerTester& operator=(EnablerTester<T>&& rhs) noexcept { AssignmentSelector<T>::operator=(std::move(rhs)); value = std::move(rhs.value); } T value; }; TEST_F(ClassTraitsTest, enablers) { EnablerTester<BaseType> baseType; baseType.value = 42; EnablerTester<BaseType> baseCopy(baseType); EnablerTester<BaseType> baseMove(std::move(baseType)); EXPECT_TRUE(baseCopy.value == 42); EXPECT_TRUE(baseMove.value == 42); EnablerTester<Copyable<int> > copyable; copyable.value.value(42); EnablerTester<Copyable<int> > copyableCopy(copyable); EXPECT_TRUE(copyableCopy.value.value() == 42); EnablerTester<Movable<int> > movable; movable.value.value(42); EnablerTester<Movable<int> > movableMove(std::move(movable)); EXPECT_TRUE(movableMove.value.value() == 42); EnablerTester<CopyMovable<int> > copyMovable; copyMovable.value.value(42); EnablerTester<CopyMovable<int> > copyMovableCopy(copyMovable); EnablerTester<CopyMovable<int> > copyMovableMove(std::move(copyMovable)); EXPECT_TRUE(copyableCopy.value.value() == 42); EXPECT_TRUE(copyMovableMove.value.value() == 42); }
41.175084
152
0.69188
vinders
ac089581f7580d20135cc492ba7a72f259ee7f5c
1,650
hpp
C++
include/tcframe/runner/verdict/TestCaseVerdict.hpp
tcgen/tcgen
d3b79585b40995ea8fc8091ecc6b6b19c2cb46ad
[ "MIT" ]
76
2015-03-31T01:36:17.000Z
2021-12-29T08:16:25.000Z
include/tcframe/runner/verdict/TestCaseVerdict.hpp
tcgen/tcgen
d3b79585b40995ea8fc8091ecc6b6b19c2cb46ad
[ "MIT" ]
68
2016-11-28T18:58:26.000Z
2018-08-10T13:33:35.000Z
include/tcframe/runner/verdict/TestCaseVerdict.hpp
tcgen/tcgen
d3b79585b40995ea8fc8091ecc6b6b19c2cb46ad
[ "MIT" ]
17
2015-04-24T03:52:32.000Z
2022-03-11T23:28:02.000Z
#pragma once #include <string> #include <tuple> #include <utility> #include "Verdict.hpp" #include "tcframe/util.hpp" using std::move; using std::tie; namespace tcframe { struct TestCaseVerdict { private: Verdict verdict_; optional<double> points_; public: TestCaseVerdict() : TestCaseVerdict(Verdict::ac()) {} explicit TestCaseVerdict(Verdict status) : verdict_(move(status)) , points_(optional<double>()) {} TestCaseVerdict(Verdict status, double points) : verdict_(move(status)) , points_(optional<double>(points)) {} const Verdict& verdict() const { return verdict_; } const optional<double>& points() const { return points_; } bool operator==(const TestCaseVerdict& o) const { return tie(verdict_, points_) == tie(o.verdict_, o.points_); } string toBriefString() const { string points = pointsToString(); if (!points.empty()) { points = " " + points; } return verdict_.code() + points; } string toString() const { string points = pointsToString(); if (!points.empty()) { points = " [" + points + "]"; } return verdict_.name() + points; } private: string pointsToString() const { if (!points_) { return ""; } string points = StringUtils::toString(points_.value(), 2); while (points.back() == '0') { points.pop_back(); } if (points.back() == '.') { points.pop_back(); } return points; } }; }
21.428571
68
0.551515
tcgen
ac1db31f863b9a921052696d409daa33d36f3c9b
3,289
hpp
C++
libs/network/include/suil/net/zmq/operators.hpp
dccarter/suil
f97fc45deee53fef3e47b070d00b12786ef367b4
[ "MIT" ]
6
2019-06-18T03:17:50.000Z
2022-03-05T08:23:38.000Z
libs/network/include/suil/net/zmq/operators.hpp
dccarter/suil
f97fc45deee53fef3e47b070d00b12786ef367b4
[ "MIT" ]
1
2021-09-10T06:15:02.000Z
2021-09-10T06:15:02.000Z
libs/network/include/suil/net/zmq/operators.hpp
dccarter/suil
f97fc45deee53fef3e47b070d00b12786ef367b4
[ "MIT" ]
null
null
null
// // Created by Mpho Mbotho on 2020-12-11. // #ifndef LIBS_NETWORK_INCLUDE_SUIL_NET_ZMQ_OPERATORS_HPP #define LIBS_NETWORK_INCLUDE_SUIL_NET_ZMQ_OPERATORS_HPP #include <suil/net/zmq/message.hpp> #include <suil/net/zmq/common.hpp> namespace suil::net::zmq { class Socket; class SendOperator { public: virtual Socket& sock() = 0; bool sendFlags(const Message& msg, int flags, const Deadline& dd = Deadline::Inf); inline bool send(const Message& msg, const Deadline& dd = Deadline::Inf) { return Ego.sendFlags(msg, 0, dd); } bool sendFlags(const void* buf, size_t len, int flags, const Deadline& dd = Deadline::Inf); inline bool send(const void* buf, size_t len, const Deadline& dd = Deadline::Inf) { return Ego.sendFlags(buf, len, 0 /* normal flags */, dd); } template <DataBuf D> inline bool sendFlags(const D& buf, int flags, const Deadline& dd = Deadline::Inf) { return Ego.sendFlags(buf.data(), buf.size(), flags, dd); } template <DataBuf D> inline bool send(const D& buf, const Deadline& dd = Deadline::Inf) { return Ego.sendFlags(buf, 0 /* normal flags */, dd); } }; class ReceiveOperator { public: virtual Socket& sock() = 0; bool receiveFlags(Message& msg, int flags, const Deadline& dd = Deadline::Inf); bool receive(Message& msg, const Deadline& dd = Deadline::Inf) { return receiveFlags(msg, 0 /* normal flags */, dd); } bool receiveFlags(void *buf, size_t& len, int flags, const Deadline& dd = Deadline::Inf); inline bool receive(void *buf, size_t& len, const Deadline& dd = Deadline::Inf) { return Ego.receiveFlags(buf, len, 0 /* normal flags */, dd); } }; class ConnectOperator { public: virtual Socket& sock() = 0; template <typename... Endpoints> bool connect(const String& endpoint, const Endpoints&... endpoints) { if (!doConnect(endpoint)) { return false; } if constexpr (sizeof...(endpoints) > 0) { return connect(endpoints...); } return true; } template <typename... Endpoints> void disconnect(const String& endpoint, const Endpoints&... endpoints) { doDisconnect(endpoint); if constexpr (sizeof...(endpoints) > 0) { disconnect(endpoints...); } } bool isConnected() const { return mConnected != 0; } private: bool doConnect(const String& endpoint); void doDisconnect(const String& endpoint); uint16 mConnected{0}; }; class BindOperator { public: virtual Socket& sock() = 0; bool bind(const String& endpoint); #if (ZMQ_VERSION_MAJOR > 3) || ((ZMQ_VERSION_MAJOR == 3) && (ZMQ_VERSION_MINOR >= 2)) void unbind(const String& endpoint); #endif }; class MonitorOperator { public: virtual Socket& sock() = 0; #if (ZMQ_VERSION_MAJOR >= 4) bool monitor(const String& me, int events); void unMonitor(); #endif }; } #endif //LIBS_NETWORK_INCLUDE_SUIL_NET_ZMQ_OPERATORS_HPP
28.850877
99
0.591973
dccarter
ac24a1dca1f9e055edf0257c331cd118968d5bce
447
cpp
C++
tests/Hashes/sha512.cpp
httese/OpenPGP
7dce08dc8b72eeb0dcbf3df56d64606a6b957938
[ "MIT" ]
99
2015-01-06T01:53:26.000Z
2022-01-31T18:18:27.000Z
tests/Hashes/sha512.cpp
httese/OpenPGP
7dce08dc8b72eeb0dcbf3df56d64606a6b957938
[ "MIT" ]
27
2015-03-09T05:46:53.000Z
2020-05-06T02:52:18.000Z
tests/Hashes/sha512.cpp
httese/OpenPGP
7dce08dc8b72eeb0dcbf3df56d64606a6b957938
[ "MIT" ]
42
2015-03-18T03:44:43.000Z
2022-03-31T21:34:06.000Z
#include <gtest/gtest.h> #include "Hashes/Hashes.h" #include "testvectors/sha/sha512shortmsg.h" TEST(SHA512, short_msg) { ASSERT_EQ(SHA512_SHORT_MSG.size(), SHA512_SHORT_MSG_HEXDIGEST.size()); for ( unsigned int i = 0; i < SHA512_SHORT_MSG.size(); ++i ) { auto sha512 = OpenPGP::Hash::use(OpenPGP::Hash::ID::SHA512, unhexlify(SHA512_SHORT_MSG[i])); EXPECT_EQ(hexlify(sha512), SHA512_SHORT_MSG_HEXDIGEST[i]); } }
24.833333
100
0.689038
httese
ac2be19edc7de9ba922bba521358f01f2ee4791c
1,404
cpp
C++
src/CallStack.cpp
Igor-Krzywda/ib-pseudocode-interpreter
d83e05a1ab230771dc465dd899691519e56b4dea
[ "MIT" ]
2
2020-11-30T20:29:29.000Z
2020-12-11T18:04:47.000Z
src/CallStack.cpp
Igor-Krzywda/ib-pseudocode-interpreter
d83e05a1ab230771dc465dd899691519e56b4dea
[ "MIT" ]
null
null
null
src/CallStack.cpp
Igor-Krzywda/ib-pseudocode-interpreter
d83e05a1ab230771dc465dd899691519e56b4dea
[ "MIT" ]
null
null
null
#include "include/CallStack.hpp" namespace cstk{ CallStack::CallStack(ast::AST *tree, bool log){ call_stack.push(std::make_unique<ar::AR>("main", tree)); log_stack = log; } void CallStack::pop(){ call_stack.pop(); if(log_stack) print(false); } void CallStack::push_AR(std::string name, ast::AST *root){ call_stack.push(std::make_unique<ar::AR>(name, root)); } void CallStack::push(std::string key, tk::Token *terminal){ call_stack.top().get()->insert(key, terminal); } void CallStack::push(std::string key, rf::Reference *terminal){ call_stack.top().get()->insert(key, terminal); } void CallStack::push(std::string key, unsigned address, rf::Reference *terminal){ call_stack.top().get()->mutate_array(key, address, terminal); } ast::AST *CallStack::peek_for_root(){ return call_stack.top()->lookup_root(); } std::string CallStack::peek_for_name(){ return call_stack.top().get()->lookup_name(); } rf::Reference *CallStack::peek(std::string key, ast::AST *leaf){ return call_stack.top().get()->lookup(key, leaf); } bool CallStack::empty(){ return call_stack.empty(); } void CallStack::test(){ do{ call_stack.top().get()->print(); call_stack.pop(); }while(!call_stack.empty()); } void CallStack::print(bool entering){ std::cout << std::endl; call_stack.top().get()->print(); std::cout << std::endl; } }
22.645161
81
0.655271
Igor-Krzywda
ac2be949d407a3256232b2831bb8fa3b0d662481
6,538
cpp
C++
cplexlpcompare/Bound.cpp
krk/cplexlpcompare
1874c6c216f7945d0278e418923fff93b1d6adae
[ "MIT" ]
null
null
null
cplexlpcompare/Bound.cpp
krk/cplexlpcompare
1874c6c216f7945d0278e418923fff93b1d6adae
[ "MIT" ]
null
null
null
cplexlpcompare/Bound.cpp
krk/cplexlpcompare
1874c6c216f7945d0278e418923fff93b1d6adae
[ "MIT" ]
null
null
null
// Copyright (c) 2014 Kerem KAT // // 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. // // Do not hesisate to contact me about usage of the code or to make comments // about the code. Your feedback will be appreciated. // // http://dissipatedheat.com/ // http://github.com/krk/ #include "Bound.h" #include "Split.h" #include <boost/lexical_cast.hpp> #include <boost/regex.hpp> #include <boost/algorithm/string.hpp> /** \file Bound.cpp Implements Bound class. */ /** \file Bound.cpp Implements Bound class. */ using namespace boost; namespace lpcompare { regex re_varname("[a-zA-Z!\"#$%&\\(\\)/,;?@_`'{}|~][a-zA-Z0-9!\"#$%&\\(\\)/,;?@_`'{}|~.]*"); /** Inverts a BoundOp operation. \param op Operation to find inverse of. \return A BoundOp representing the inverted operation. */ BoundOp invert(BoundOp op) { switch (op){ case BoundOp::GT: case BoundOp::GTE: return BoundOp::LTE; case BoundOp::LT: case BoundOp::LTE: return BoundOp::GTE; default: return BoundOp::Free; } } /** Finds a BoundOp representation for the string op. \param op Operation to find BoundOp for. \return A BoundOp representing the operation. */ BoundOp get_boundop(std::string op) { if (op == "=") return BoundOp::EQ; if (op == ">=") return BoundOp::GTE; if (op == ">") return BoundOp::GT; if (op == "<=") return BoundOp::LTE; if (op == "<") return BoundOp::LT; if (op == "Free") return BoundOp::Free; return BoundOp::Free; } /** Finds a string representation for the BoundOp. \param op Operation to find string for. \return A string representing the BoundOp. */ std::string get_boundop(BoundOp op) { if (op == BoundOp::EQ) return "="; if (op == BoundOp::GTE) return ">="; if (op == BoundOp::GT) return ">"; if (op == BoundOp::LTE) return "<="; if (op == BoundOp::LT) return "<"; if (op == BoundOp::Free) return "Free"; return "Free"; } /** Compares two Bound instances for equality. \param other Other instance to compare self to. \return true if Bound instances are equivalent. */ bool Bound::operator==(const Bound &other) const { return other.VarName == VarName && other.LB == LB && other.LB_Op == LB_Op && other.UB == UB && other.UB_Op == UB_Op; } /** Compares two Bound instances. \param other Other instance to compare self to. \return true if self is less than other. */ bool Bound::operator<(const Bound &other) const { if (VarName > other.VarName) return false; if (VarName == other.VarName && LB > other.LB) return false; if (VarName == other.VarName && LB == other.LB && LB_Op > other.LB_Op) return false; if (VarName == other.VarName && LB == other.LB && LB_Op == other.LB_Op && UB > other.UB) return false; if (VarName == other.VarName && LB == other.LB && LB_Op == other.LB_Op && UB == other.UB && UB_Op > other.UB_Op) return false; if (other == *this) return false; return true; } /** Compares two Bound instances for inequality. \param other Other instance to compare self to. \return true if Bound instances are not equivalent. */ bool Bound::operator!=(const Bound &other) const { return !(*this == other); } /** Parses a line of the LP file representing a Bound. \param line Single line of an LP file. \return A Bound instance representing line. */ Bound *Bound::Parse(std::string line){ Bound *ret = new Bound(); std::vector<std::string> parts; trim(line); ::split(line, ' ', parts, [](const std::string& s) -> bool { return s.length() > 0; }); if (parts.size() == 0) return nullptr; // clean this setBounds mess. auto setBounds = [&ret](BoundOp op, std::string s, bool inverted) { auto check_op = inverted ? invert(op) : op; if (op == BoundOp::EQ) { ret->LB = boost::lexical_cast<float>(s); ret->UB = ret->LB; ret->LB_Op = op; ret->UB_Op = op; } else if (op == BoundOp::GT || op == BoundOp::GTE || (check_op == BoundOp::GT || check_op == BoundOp::GTE)) { ret->UB = boost::lexical_cast<float>(s); ret->UB_Op = op; } else if (op == BoundOp::LT || op == BoundOp::LTE || (check_op == BoundOp::LT || check_op == BoundOp::LTE)) { ret->LB = boost::lexical_cast<float>(s); ret->LB_Op = op; } }; cmatch what; bool isVarName = regex_match(parts[0].c_str(), what, re_varname); if (isVarName){ ret->VarName = parts[0]; auto op = get_boundop(parts[1]); if (op != BoundOp::Free) setBounds(invert(op), parts[2], false); } else{ auto op = get_boundop(parts[1]); ret->VarName = parts[2]; if (op != BoundOp::Free) setBounds(op, parts[0], false); // does have a second part? if (parts.size() == 5) { op = get_boundop(parts[3]); if (op != BoundOp::Free) setBounds(invert(op), parts[4], true); } } return ret; } /** Dumps a Bound instance to an ostream in a text format. \param bound Bound to dump. \param out */ void Bound::dump(const Bound &bound, std::ostream &out) { out << bound.LB << " " << get_boundop(bound.LB_Op) << " "; out << bound.VarName; if (bound.UB != INFTY) out << " " << get_boundop(invert(bound.UB_Op)) << " " << bound.UB; } }
26.257028
115
0.611961
krk
ac344932671d6a2385393c465c52843087d21606
2,947
hpp
C++
taskflow/cuda/cublas/cublas_helper.hpp
larkwiot/parallel
2666418e43728358d18fd6b20fa4cc90514937f9
[ "MIT" ]
null
null
null
taskflow/cuda/cublas/cublas_helper.hpp
larkwiot/parallel
2666418e43728358d18fd6b20fa4cc90514937f9
[ "MIT" ]
null
null
null
taskflow/cuda/cublas/cublas_helper.hpp
larkwiot/parallel
2666418e43728358d18fd6b20fa4cc90514937f9
[ "MIT" ]
null
null
null
#pragma once #include "cublas_handle.hpp" /** @file cublas_helper.hpp */ namespace tf { /** @brief copies vector data from host to device This method copies @c n elements from a vector @c h in host memory space to a vector @c d in GPU memory space. The storage spacing between consecutive elements is given by @c inch for the source vector @c h and by @c incd for the destination vector @c d. @tparam T data type @param stream stream to associate with this copy operation @param n number of elements @param d target device pointer @param incd spacing between consecutive elements in @c d @param h source host pointer @param inch spacing between consecutive elements in @c h */ template <typename T, std::enable_if_t<!std::is_same_v<T, void>, void>* = nullptr > void cublas_vset_async( cudaStream_t stream, size_t n, const T* h, int inch, T* d, int incd ) { TF_CHECK_CUBLAS( cublasSetVectorAsync(n, sizeof(T), h, inch, d, incd, stream), "failed to run vset_async" ); } /** @brief copies vector data from device to host This method copies @c n elements from a vector @c d in GPU memory space to a vector @c h in host memory space. The storage spacing between consecutive elements is given by @c inch for the target vector @c h and by @c incd for the source vector @c d. @tparam T data type @param stream stream to associate with this copy operation @param n number of elements @param h target host pointer @param inch spacing between consecutive elements in @c h @param d source device pointer @param incd spacing between consecutive elements in @c d */ template <typename T, std::enable_if_t<!std::is_same_v<T, void>, void>* = nullptr > void cublas_vget_async( cudaStream_t stream, size_t n, const T* d, int incd, T* h, int inch ) { TF_CHECK_CUBLAS( cublasGetVectorAsync(n, sizeof(T), d, incd, h, inch, stream), "failed to run vget_async" ); } // ---------------------------------------------------------------------------- // cublasFlowCapturer helper functions // ---------------------------------------------------------------------------- // Function: vset template <typename T, std::enable_if_t<!std::is_same_v<T, void>, void>* > cudaTask cublasFlowCapturer::vset( size_t n, const T* h, int inch, T* d, int incd ) { return on([n, h, inch, d, incd] (cudaStream_t stream) mutable { TF_CHECK_CUBLAS( cublasSetVectorAsync(n, sizeof(T), h, inch, d, incd, stream), "failed to run vset_async" ); }); } // Function: vget template <typename T, std::enable_if_t<!std::is_same_v<T, void>, void>* > cudaTask cublasFlowCapturer::vget(size_t n, const T* d, int incd, T* h, int inch) { return on([n, d, incd, h, inch] (cudaStream_t stream) mutable { TF_CHECK_CUBLAS( cublasGetVectorAsync(n, sizeof(T), d, incd, h, inch, stream), "failed to run vget_async" ); }); } } // end of namespace tf -----------------------------------------------------
28.336538
83
0.656939
larkwiot
ac3a03f2d80f0a1cf59e1f858f87e8986a4ee85b
5,905
cc
C++
build/ARM/python/swig/pyobject.py.cc
Jakgn/gem5_test
0ba7cc5213cf513cf205af7fc995cf679ebc1a3f
[ "BSD-3-Clause" ]
null
null
null
build/ARM/python/swig/pyobject.py.cc
Jakgn/gem5_test
0ba7cc5213cf513cf205af7fc995cf679ebc1a3f
[ "BSD-3-Clause" ]
null
null
null
build/ARM/python/swig/pyobject.py.cc
Jakgn/gem5_test
0ba7cc5213cf513cf205af7fc995cf679ebc1a3f
[ "BSD-3-Clause" ]
null
null
null
#include "sim/init.hh" namespace { const uint8_t data_m5_internal_pyobject[] = { 120,156,181,86,95,111,27,69,16,159,189,59,59,177,19,55, 46,81,255,209,64,141,80,132,169,32,150,16,21,15,173,42, 10,69,80,36,66,57,63,180,13,136,195,185,59,219,231,216, 119,214,237,166,197,200,121,33,21,240,128,196,135,64,60,240, 61,248,40,124,15,152,223,236,157,227,84,32,33,37,68,185, 209,122,118,119,118,230,55,191,153,221,144,138,191,10,127,239, 183,136,244,159,60,136,248,95,209,152,104,162,104,79,145,138, 21,69,77,58,168,80,254,46,69,21,122,78,180,231,80,236, 208,49,15,92,250,210,161,116,93,246,84,105,236,138,70,209, 172,78,177,71,123,21,122,148,94,36,47,174,210,65,157,242, 111,72,41,149,42,122,28,173,80,180,74,207,217,58,15,106, 98,112,149,162,186,12,106,20,173,201,160,78,179,38,197,107, 180,199,198,87,104,175,193,166,110,178,169,11,98,234,15,152, 138,120,230,34,69,13,44,103,95,158,96,165,135,149,114,198, 5,177,178,65,209,134,12,216,150,75,163,38,6,236,104,183, 253,18,7,154,252,197,127,109,197,35,179,206,226,105,156,235, 36,75,131,36,237,103,137,131,249,42,4,240,9,33,86,10, 160,62,4,80,191,147,160,20,57,5,80,71,68,10,191,137, 198,14,29,201,224,200,161,89,155,230,138,70,30,69,46,205, 249,152,10,29,43,26,40,58,118,232,43,23,11,142,88,122, 28,218,171,228,25,139,210,72,66,179,150,86,232,168,66,243, 10,117,31,207,29,40,14,106,148,255,70,223,109,137,209,85, 49,234,208,156,165,71,199,30,29,85,233,17,47,98,213,168, 6,64,212,227,57,71,202,154,110,219,99,111,119,151,194,69, 40,81,146,167,189,73,108,106,60,14,166,179,108,127,20,135, 166,93,47,167,51,189,51,237,153,161,47,235,93,0,49,153, 26,177,147,165,177,89,227,65,63,73,163,96,146,69,135,227, 216,172,194,72,208,79,198,113,16,200,228,131,201,52,203,205, 71,121,158,229,62,176,20,229,56,235,45,118,0,201,112,156, 233,184,141,211,228,24,31,230,13,86,247,167,98,17,14,136, 143,216,28,197,58,204,147,169,225,20,89,139,88,13,107,109, 36,71,132,126,143,69,103,152,77,226,78,166,199,189,253,206, 32,158,220,178,98,255,48,25,71,157,123,254,103,157,233,204, 12,179,180,163,159,37,131,78,25,246,14,43,193,8,40,131, 68,92,15,134,241,120,26,231,13,104,95,134,113,213,84,235, 170,170,92,213,86,13,30,85,248,115,213,150,179,166,118,19, 56,31,34,32,16,198,45,41,242,43,73,50,56,151,7,14, 229,91,32,192,136,255,21,50,198,52,232,98,206,145,185,47, 16,181,213,142,92,164,213,42,231,66,26,102,15,175,188,131, 60,166,36,153,175,208,168,74,150,17,76,36,75,145,124,6, 201,203,97,198,97,227,30,233,95,78,91,72,155,196,168,114, 137,176,234,50,31,245,189,144,172,219,134,227,187,146,115,51, 76,116,246,44,21,100,49,150,178,232,50,38,15,103,159,11, 78,250,6,43,158,100,135,173,176,151,166,153,105,245,162,168, 213,51,38,79,246,15,77,172,91,38,107,109,235,54,8,229, 95,44,105,179,176,55,155,150,52,65,74,153,38,246,71,148, 132,134,127,108,202,15,193,95,199,134,83,62,204,34,205,122, 152,24,196,198,135,147,230,2,139,123,229,113,194,173,118,181, 100,130,142,199,125,83,23,82,245,180,14,228,56,232,133,63, 216,253,180,55,62,140,13,214,107,211,51,124,42,134,246,160, 115,98,208,85,196,80,134,0,88,130,52,75,163,25,123,144, 132,219,48,126,85,120,180,78,96,210,37,102,209,10,203,42, 53,152,85,77,39,132,179,94,193,33,225,207,101,132,70,146, 83,85,20,58,115,233,152,219,65,219,145,122,22,175,165,112, 90,24,97,179,15,170,250,215,33,182,32,94,41,3,59,123, 116,141,23,163,123,7,22,29,9,41,116,11,231,23,228,223, 61,69,254,107,39,228,231,198,212,5,137,29,80,253,132,196, 46,194,203,239,22,140,69,121,112,210,120,122,137,167,18,180, 223,68,48,213,146,98,62,120,179,76,158,193,18,121,124,224, 45,204,241,175,253,27,64,55,254,15,128,6,22,160,91,176, 184,94,228,188,33,185,174,171,16,9,115,10,184,4,170,251, 60,152,93,1,84,203,32,93,225,75,228,81,218,144,219,64, 110,20,185,213,108,61,91,236,236,192,3,59,250,46,93,46, 186,188,70,249,77,243,236,219,89,43,235,183,12,149,62,220, 217,214,59,219,250,54,23,104,235,174,148,188,45,81,91,132, 121,60,205,185,216,228,42,8,108,1,5,82,76,65,209,174, 25,204,75,0,201,41,33,148,126,161,77,142,54,113,78,248, 213,23,248,193,157,219,48,87,23,240,92,186,194,95,93,201, 153,129,221,32,55,178,204,242,247,1,96,68,36,49,225,197, 226,119,173,71,226,44,220,246,223,56,149,229,51,187,234,223, 228,189,247,75,250,87,105,145,83,124,46,156,1,35,127,228, 123,76,33,173,63,16,242,199,105,42,56,44,213,130,15,105, 216,196,242,175,73,138,252,31,174,10,199,214,130,83,180,1, 46,21,118,124,174,202,155,227,83,250,105,169,67,28,187,164, 208,229,221,226,189,177,220,229,189,69,245,72,226,255,83,39, 247,78,151,25,224,31,246,52,150,217,130,114,23,5,117,210, 108,22,239,5,238,18,103,231,196,170,53,20,224,204,7,39, 140,64,11,189,174,54,157,165,60,191,5,241,246,34,197,170, 212,157,233,248,27,47,246,188,165,142,30,216,62,243,9,206, 240,196,171,141,106,88,50,18,46,125,140,204,162,41,24,155, 74,162,159,145,8,76,239,90,159,229,25,131,226,12,179,52, 229,35,31,242,187,67,91,4,97,177,151,15,206,169,182,252, 14,239,237,210,162,95,75,230,94,120,227,218,147,22,247,182, 158,105,31,26,127,99,225,233,170,237,44,252,42,50,51,185, 139,45,52,11,21,218,199,46,95,183,246,213,215,194,190,215, 32,94,135,120,19,22,112,152,117,74,74,200,54,156,52,126, 38,45,71,56,229,239,64,116,206,183,94,197,243,59,182,147, 221,197,91,82,227,20,220,194,181,141,154,170,58,120,201,185, 170,206,55,178,167,214,27,53,183,86,173,85,92,190,149,161, 217,84,117,183,182,86,115,254,6,38,203,165,171, }; EmbeddedPython embedded_m5_internal_pyobject( "m5/internal/pyobject.py", "/home/oslab/gem5/gem5/build/ARM/python/swig/pyobject.py", "m5.internal.pyobject", data_m5_internal_pyobject, 1437, 3372); } // anonymous namespace
55.186916
66
0.664522
Jakgn
ac40ce34cd7df48058c74b9d87949b342b7a30e5
646
cpp
C++
tests/src/ooex0.cpp
tjschweizer/pharos
4c5cea68c4489d798e341319d1d5e0d2fee71422
[ "RSA-MD" ]
3
2015-07-15T08:43:56.000Z
2021-02-28T17:53:52.000Z
tests/src/ooex0.cpp
tjschweizer/pharos
4c5cea68c4489d798e341319d1d5e0d2fee71422
[ "RSA-MD" ]
null
null
null
tests/src/ooex0.cpp
tjschweizer/pharos
4c5cea68c4489d798e341319d1d5e0d2fee71422
[ "RSA-MD" ]
null
null
null
// Copyright 2016 Carnegie Mellon University. See LICENSE file for terms. #include <stdlib.h> #include <stdio.h> /* * This basic class variable and method access */ class ClassA { private: int c,d; short g; public: int a; ClassA() { c = d = 42; g = 24; } ~ClassA() { printf("ClassA::DTOR"); } int func1() { return (int)rand(); } int func2() { return c + d; } }; int main() { ClassA *a = new ClassA(); a->a = 4; a->a += a->func1() + a->func2(); delete a; a = NULL; ClassA b; b.a = 10; b.a -= b.func1() - b.func2(); return 0; }
15.380952
75
0.49226
tjschweizer
ac4e1bbb66bcc8c05336bd9f9ae1408708622917
1,877
hpp
C++
include/trim_dht.hpp
pan3rock/discrete-hankel-transform
708d3d32e1c4170ed68322e53e26267f93e0ab9d
[ "MIT" ]
null
null
null
include/trim_dht.hpp
pan3rock/discrete-hankel-transform
708d3d32e1c4170ed68322e53e26267f93e0ab9d
[ "MIT" ]
null
null
null
include/trim_dht.hpp
pan3rock/discrete-hankel-transform
708d3d32e1c4170ed68322e53e26267f93e0ab9d
[ "MIT" ]
1
2021-06-16T09:56:44.000Z
2021-06-16T09:56:44.000Z
/* * File: trim_dht.hpp * Created Date: 2020-01-01 * Author: Lei Pan * Contact: <panlei7@gmail.com> * * Last Modified: Wednesday January 1st 2020 11:27:12 am * * MIT License * * Copyright (c) 2020 Lei Pan * * 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. * ----- * HISTORY: * Date By Comments * ---------- --- * ---------------------------------------------------------- */ #ifndef DHT_TRIM_DHT_H_ #define DHT_TRIM_DHT_H_ #include "dht.hpp" #include <Eigen/Dense> class TrimDHT : public DiscreteHankelTransform { public: TrimDHT(int order, int nr, double rmax, int nexp); ~TrimDHT(); Eigen::VectorXd perform(const Eigen::Ref<const Eigen::VectorXd> &src); Eigen::VectorXd r_sampling(); Eigen::VectorXd k_sampling(); int get_nr() const; private: Eigen::MatrixXd shift_matrix_; double rmax_extend_; }; #endif
31.283333
80
0.703783
pan3rock
ac4ec50debacbdfb80c811473fe9a903669bb5fc
68,462
cc
C++
Digit_Example/opt_two_step/gen/opt/J_swing_toe_linear_velocity_y_LeftStance.cc
prem-chand/Cassie_CFROST
da4bd51442f86e852cbb630cc91c9a380a10b66d
[ "BSD-3-Clause" ]
null
null
null
Digit_Example/opt_two_step/gen/opt/J_swing_toe_linear_velocity_y_LeftStance.cc
prem-chand/Cassie_CFROST
da4bd51442f86e852cbb630cc91c9a380a10b66d
[ "BSD-3-Clause" ]
null
null
null
Digit_Example/opt_two_step/gen/opt/J_swing_toe_linear_velocity_y_LeftStance.cc
prem-chand/Cassie_CFROST
da4bd51442f86e852cbb630cc91c9a380a10b66d
[ "BSD-3-Clause" ]
null
null
null
/* * Automatically Generated from Mathematica. * Fri 5 Nov 2021 16:29:55 GMT-04:00 */ #ifdef MATLAB_MEX_FILE #include <stdexcept> #include <cmath> #include<math.h> /** * Copied from Wolfram Mathematica C Definitions file mdefs.hpp * Changed marcos to inline functions (Eric Cousineau) */ inline double Power(double x, double y) { return pow(x, y); } inline double Sqrt(double x) { return sqrt(x); } inline double Abs(double x) { return fabs(x); } inline double Exp(double x) { return exp(x); } inline double Log(double x) { return log(x); } inline double Sin(double x) { return sin(x); } inline double Cos(double x) { return cos(x); } inline double Tan(double x) { return tan(x); } inline double ArcSin(double x) { return asin(x); } inline double ArcCos(double x) { return acos(x); } inline double ArcTan(double x) { return atan(x); } /* update ArcTan function to use atan2 instead. */ inline double ArcTan(double x, double y) { return atan2(y,x); } inline double Sinh(double x) { return sinh(x); } inline double Cosh(double x) { return cosh(x); } inline double Tanh(double x) { return tanh(x); } const double E = 2.71828182845904523536029; const double Pi = 3.14159265358979323846264; const double Degree = 0.01745329251994329576924; inline double Sec(double x) { return 1/cos(x); } inline double Csc(double x) { return 1/sin(x); } #endif /* * Sub functions */ static void output1(double *p_output1,const double *var1,const double *var2) { double t717; double t614; double t637; double t752; double t909; double t692; double t851; double t900; double t608; double t911; double t947; double t962; double t1116; double t901; double t964; double t991; double t589; double t1244; double t1260; double t1344; double t1548; double t1069; double t1435; double t1453; double t555; double t1566; double t1659; double t1690; double t1983; double t1487; double t1755; double t1773; double t379; double t2036; double t2154; double t2189; double t2362; double t1895; double t2211; double t2213; double t344; double t2371; double t2391; double t2443; double t2641; double t2241; double t2445; double t2474; double t133; double t2729; double t2743; double t2800; double t2609; double t2802; double t2817; double t2897; double t5; double t2849; double t2911; double t2914; double t2924; double t2938; double t2943; double t3031; double t3038; double t3103; double t3140; double t3315; double t3342; double t3345; double t3553; double t3557; double t3598; double t3663; double t3591; double t3665; double t3675; double t3813; double t3872; double t3884; double t3790; double t3885; double t3891; double t3961; double t3963; double t4003; double t3907; double t4087; double t4095; double t4163; double t4165; double t4169; double t4157; double t4202; double t4209; double t4287; double t4323; double t4348; double t4261; double t4363; double t4370; double t4383; double t4457; double t4461; double t4374; double t4478; double t4486; double t4522; double t4569; double t4593; double t4671; double t4677; double t4714; double t4719; double t4700; double t4725; double t4731; double t4734; double t4736; double t4737; double t4733; double t4747; double t4758; double t4770; double t4774; double t4780; double t4765; double t4794; double t4827; double t4846; double t4870; double t4947; double t4832; double t4986; double t4990; double t5018; double t5026; double t5070; double t5009; double t5080; double t5081; double t5157; double t5191; double t5243; double t5145; double t5258; double t5272; double t5337; double t5345; double t5463; double t5623; double t5674; double t5708; double t5722; double t5699; double t5742; double t5789; double t5804; double t5814; double t5823; double t5792; double t5833; double t5847; double t5883; double t5947; double t5949; double t5857; double t5963; double t5969; double t6032; double t6077; double t6127; double t6020; double t6146; double t6149; double t6177; double t6250; double t6308; double t6172; double t6324; double t6325; double t6393; double t6418; double t6428; double t6354; double t6438; double t6540; double t6595; double t6597; double t6612; double t5283; double t5483; double t5487; double t5490; double t5547; double t5549; double t5554; double t5589; double t5615; double t6563; double t6613; double t6726; double t6770; double t6773; double t6774; double t6846; double t6851; double t6870; double t6872; double t6882; double t7135; double t7199; double t4520; double t4606; double t4610; double t4629; double t4641; double t4644; double t4652; double t4653; double t4656; double t7237; double t7107; double t5488; double t5620; double t5622; double t7415; double t7416; double t7434; double t4613; double t4658; double t7261; double t7316; double t7327; double t4670; double t7617; double t7619; double t7633; double t6898; double t6923; double t7040; double t7059; double t7672; double t7694; double t7816; double t7925; double t7951; double t7958; double t8009; double t8065; double t8099; double t7643; double t7645; double t7671; double t7833; double t8449; double t8486; double t8496; double t8579; double t8586; double t8604; double t8433; double t8334; double t8392; double t8407; double t8113; double t8410; double t8535; double t8538; double t8683; double t7849; double t7855; double t7860; double t8682; double t8776; double t8135; double t8142; double t8182; double t8879; double t9708; double t9891; double t9932; double t9933; double t9369; double t9424; double t9430; double t8650; double t9601; double t9627; double t9689; double t10101; double t10103; double t10106; double t10188; double t10191; double t10201; double t9976; double t10030; double t10047; double t9316; double t8653; double t8661; double t9462; double t9692; double t8894; double t8899; double t10229; double t10232; double t10291; double t10297; double t10729; double t10747; double t10799; double t10399; double t10410; double t10430; double t10447; double t10471; double t10487; double t10508; double t10561; double t10567; double t9817; double t9822; double t11363; double t11368; double t11371; double t11402; double t11453; double t11476; double t11477; double t11533; double t10069; double t10078; double t11444; double t11446; double t11449; double t11549; double t11555; double t11572; double t11492; double t11535; double t11545; double t11275; double t11276; double t11282; double t11284; double t11288; double t11317; double t11354; double t11729; double t11730; double t11736; double t11743; double t11744; double t11737; double t11738; double t11766; double t11772; double t11783; double t11610; double t11616; double t11617; double t11626; double t11643; double t11386; double t11403; double t11414; double t11451; double t11548; double t11866; double t11870; double t11951; double t11952; double t12163; double t12168; double t12170; double t12000; double t12003; double t12004; double t12057; double t12058; double t12116; double t12119; double t12120; double t12126; double t12346; double t12395; double t12408; double t12414; double t12464; double t12466; double t12475; double t12515; double t12497; double t12518; double t12527; double t12532; double t12533; double t12535; double t12597; double t12605; double t12616; double t12634; double t12620; double t12642; double t12644; double t12646; double t12648; double t12650; double t12574; double t12575; double t12588; double t12660; double t12662; double t12664; double t12645; double t12653; double t12655; double t12411; double t12416; double t12422; double t12433; double t12438; double t12439; double t12440; double t12457; double t12461; double t12804; double t12805; double t12806; double t12803; double t12807; double t12810; double t12816; double t12817; double t12822; double t12828; double t12829; double t12815; double t12818; double t12819; double t12842; double t12843; double t12845; double t12679; double t12681; double t12686; double t12689; double t12690; double t12531; double t12565; double t12569; double t12592; double t12658; double t12869; double t12870; double t12888; double t12889; double t12964; double t12967; double t12969; double t12911; double t12915; double t12917; double t12919; double t12920; double t12921; double t12926; double t12928; double t12935; double t13023; double t13027; double t13028; double t13033; double t13030; double t13034; double t13036; double t13047; double t13051; double t13052; double t13081; double t13085; double t13087; double t13095; double t13093; double t13099; double t13101; double t13108; double t13111; double t13115; double t13103; double t13116; double t13117; double t13121; double t13130; double t13131; double t13149; double t13154; double t13156; double t13160; double t13159; double t13161; double t13164; double t13166; double t13167; double t13169; double t13165; double t13170; double t13173; double t13175; double t13176; double t13177; double t13142; double t13146; double t13147; double t13187; double t13189; double t13190; double t13174; double t13179; double t13182; double t13046; double t13053; double t13054; double t13055; double t13056; double t13057; double t13061; double t13064; double t13068; double t13364; double t13370; double t13376; double t13361; double t13379; double t13380; double t13384; double t13389; double t13383; double t13390; double t13391; double t13393; double t13394; double t13401; double t13417; double t13419; double t13420; double t13392; double t13403; double t13409; double t13430; double t13432; double t13446; double t13202; double t13204; double t13205; double t13206; double t13211; double t13118; double t13138; double t13140; double t13148; double t13183; double t13465; double t13466; double t13475; double t13479; double t13579; double t13581; double t13588; double t13509; double t13513; double t13516; double t13523; double t13531; double t13533; double t13537; double t13538; double t13548; double t13632; double t13634; double t13636; double t13637; double t13633; double t13643; double t13648; double t13653; double t13655; double t13656; double t13649; double t13666; double t13667; double t13669; double t13671; double t13672; double t13705; double t13709; double t13712; double t13714; double t13706; double t13717; double t13719; double t13721; double t13722; double t13725; double t13720; double t13727; double t13729; double t13732; double t13733; double t13734; double t13730; double t13735; double t13737; double t13744; double t13745; double t13754; double t13779; double t13789; double t13791; double t13795; double t13781; double t13796; double t13797; double t13803; double t13807; double t13809; double t13800; double t13817; double t13820; double t13827; double t13829; double t13831; double t13825; double t13832; double t13833; double t13836; double t13843; double t13844; double t13765; double t13767; double t13769; double t13855; double t13856; double t13858; double t13834; double t13847; double t13850; double t13668; double t13676; double t13683; double t13687; double t13689; double t13690; double t13693; double t13696; double t13698; double t14033; double t14034; double t14035; double t14037; double t14038; double t14043; double t14045; double t14041; double t14046; double t14049; double t14051; double t14055; double t14056; double t14050; double t14057; double t14058; double t14062; double t14063; double t14064; double t14071; double t14072; double t14073; double t14061; double t14065; double t14068; double t14081; double t14082; double t14084; double t13875; double t13878; double t13880; double t13885; double t13888; double t13738; double t13757; double t13758; double t13778; double t13853; double t14098; double t14100; double t14112; double t14113; double t14184; double t14185; double t14188; double t14128; double t14129; double t14130; double t14146; double t14147; double t14149; double t14156; double t14159; double t14162; double t14215; double t14216; double t14220; double t14233; double t14230; double t14234; double t14237; double t14240; double t14241; double t14242; double t14239; double t14243; double t14248; double t14262; double t14263; double t14264; double t14259; double t14266; double t14267; double t14272; double t14278; double t14283; double t14301; double t14302; double t14303; double t14307; double t14304; double t14309; double t14310; double t14312; double t14313; double t14314; double t14311; double t14315; double t14317; double t14321; double t14327; double t14333; double t14320; double t14334; double t14336; double t14339; double t14344; double t14347; double t14337; double t14350; double t14352; double t14354; double t14358; double t14359; double t14376; double t14380; double t14382; double t14386; double t14383; double t14387; double t14388; double t14391; double t14392; double t14393; double t14389; double t14394; double t14395; double t14397; double t14398; double t14399; double t14396; double t14404; double t14406; double t14409; double t14411; double t14412; double t14407; double t14414; double t14415; double t14418; double t14419; double t14421; double t14371; double t14372; double t14373; double t14426; double t14429; double t14431; double t14416; double t14422; double t14423; double t14268; double t14284; double t14286; double t14287; double t14288; double t14289; double t14291; double t14294; double t14296; double t14601; double t14602; double t14608; double t14609; double t14610; double t14613; double t14614; double t14612; double t14615; double t14616; double t14621; double t14632; double t14633; double t14618; double t14636; double t14637; double t14640; double t14646; double t14648; double t14638; double t14649; double t14650; double t14653; double t14654; double t14655; double t14669; double t14670; double t14672; double t14652; double t14657; double t14659; double t14685; double t14688; double t14690; double t14440; double t14441; double t14443; double t14444; double t14446; double t14353; double t14363; double t14366; double t14374; double t14425; double t14704; double t14705; double t14721; double t14723; double t14777; double t14780; double t14783; double t14740; double t14741; double t14742; double t14747; double t14749; double t14754; double t14758; double t14761; double t14762; double t14815; double t14819; double t14820; double t14823; double t14818; double t14825; double t14826; double t14829; double t14830; double t14831; double t14828; double t14832; double t14835; double t14839; double t14841; double t14842; double t14836; double t14844; double t14845; double t14848; double t14849; double t14851; double t14846; double t14852; double t14853; double t14855; double t14856; double t14857; double t14875; double t14877; double t14878; double t14879; double t14876; double t14880; double t14881; double t14883; double t14884; double t14886; double t14882; double t14887; double t14890; double t14893; double t14895; double t14896; double t14892; double t14897; double t14900; double t14902; double t14903; double t14904; double t14901; double t14905; double t14906; double t14908; double t14909; double t14910; double t14907; double t14912; double t14913; double t14917; double t14919; double t14920; double t14930; double t14933; double t14934; double t14936; double t14931; double t14937; double t14938; double t14941; double t14942; double t14944; double t14940; double t14945; double t14947; double t14951; double t14953; double t14954; double t14950; double t14956; double t14957; double t14959; double t14960; double t14961; double t14958; double t14962; double t14963; double t14966; double t14969; double t14970; double t14964; double t14971; double t14972; double t14975; double t14976; double t14977; double t14924; double t14925; double t14926; double t14983; double t14985; double t14986; double t14974; double t14980; double t14981; double t14854; double t14860; double t14861; double t14864; double t14866; double t14867; double t14870; double t14871; double t14872; double t15103; double t15104; double t15105; double t15106; double t15107; double t15109; double t15110; double t15108; double t15111; double t15112; double t15114; double t15115; double t15116; double t15113; double t15117; double t15118; double t15120; double t15121; double t15122; double t15119; double t15123; double t15124; double t15126; double t15127; double t15128; double t15125; double t15129; double t15130; double t15132; double t15133; double t15134; double t15139; double t15140; double t15141; double t15131; double t15135; double t15136; double t15146; double t15148; double t15149; double t14995; double t14997; double t14998; double t14999; double t15000; double t14916; double t14921; double t14922; double t14927; double t14982; double t15157; double t15158; double t15165; double t15166; double t15192; double t15193; double t15194; double t15174; double t15175; double t15176; double t15178; double t15179; double t15180; double t15182; double t15183; double t15184; double t15224; double t15225; double t15226; double t15236; double t15238; double t15239; double t15228; double t15229; double t15230; double t15232; double t15233; double t15234; double t15268; double t15269; double t15271; double t15273; double t15274; double t15275; double t15243; double t15244; double t15245; double t15250; double t15252; double t15253; double t15259; double t15260; double t15261; double t15263; double t15264; double t15265; double t15302; double t15303; double t15304; double t15306; double t15307; double t15308; double t15281; double t15282; double t15283; double t15285; double t15286; double t15287; double t15293; double t15295; double t15296; double t15298; double t15299; double t15300; double t15337; double t15338; double t15339; double t15341; double t15342; double t15343; double t15316; double t15317; double t15318; double t15320; double t15321; double t15323; double t15329; double t15330; double t15331; double t15333; double t15334; double t15335; double t15369; double t15370; double t15371; double t15373; double t15374; double t15375; double t15349; double t15350; double t15351; double t15353; double t15354; double t15355; double t15361; double t15362; double t15363; double t15365; double t15366; double t15367; double t15402; double t15403; double t15404; double t15406; double t15407; double t15408; double t15382; double t15383; double t15384; double t15386; double t15387; double t15388; double t15394; double t15395; double t15396; double t15398; double t15399; double t15400; double t15414; double t15415; double t15416; double t15418; double t15419; double t15420; double t15427; double t15428; double t15429; double t15440; double t15441; double t15442; double t15444; double t15445; double t15446; double t15431; double t15432; double t15433; double t15137; double t15142; double t15143; double t15144; double t15145; double t15150; double t15151; double t15152; double t15153; double t15154; double t15155; double t15156; double t15451; double t15456; double t15452; double t15453; double t15454; double t15435; double t15436; double t15437; double t15439; double t15447; double t15461; double t15462; double t15468; double t15469; double t15496; double t15498; double t15500; double t15477; double t15478; double t15479; double t15481; double t15482; double t15483; double t15485; double t15486; double t15487; double t2867; double t3161; double t3202; t717 = Cos(var1[30]); t614 = Cos(var1[31]); t637 = Sin(var1[30]); t752 = Sin(var1[31]); t909 = Cos(var1[26]); t692 = -1.*t614*t637; t851 = -1.*t717*t752; t900 = t692 + t851; t608 = Sin(var1[26]); t911 = -1.*t717*t614; t947 = t637*t752; t962 = t911 + t947; t1116 = Cos(var1[25]); t901 = -1.*t608*t900; t964 = t909*t962; t991 = t901 + t964; t589 = Sin(var1[25]); t1244 = t909*t900; t1260 = t608*t962; t1344 = t1244 + t1260; t1548 = Cos(var1[24]); t1069 = t589*t991; t1435 = t1116*t1344; t1453 = t1069 + t1435; t555 = Sin(var1[24]); t1566 = t1116*t991; t1659 = -1.*t589*t1344; t1690 = t1566 + t1659; t1983 = Cos(var1[23]); t1487 = -1.*t555*t1453; t1755 = t1548*t1690; t1773 = t1487 + t1755; t379 = Sin(var1[23]); t2036 = t1548*t1453; t2154 = t555*t1690; t2189 = t2036 + t2154; t2362 = Cos(var1[22]); t1895 = -1.*t379*t1773; t2211 = t1983*t2189; t2213 = t1895 + t2211; t344 = Sin(var1[22]); t2371 = t1983*t1773; t2391 = t379*t2189; t2443 = t2371 + t2391; t2641 = Cos(var1[21]); t2241 = -1.*t344*t2213; t2445 = t2362*t2443; t2474 = t2241 + t2445; t133 = Sin(var1[21]); t2729 = t2362*t2213; t2743 = t344*t2443; t2800 = t2729 + t2743; t2609 = t133*t2474; t2802 = t2641*t2800; t2817 = t2609 + t2802; t2897 = Cos(var1[3]); t5 = Cos(var1[5]); t2849 = Sin(var1[3]); t2911 = Cos(var1[4]); t2914 = t2641*t2474; t2924 = -1.*t133*t2800; t2938 = t2914 + t2924; t2943 = t2911*t2938; t3031 = Sin(var1[4]); t3038 = Sin(var1[5]); t3103 = t2817*t3031*t3038; t3140 = t2943 + t3103; t3315 = -1.*t2938*t3031; t3342 = t2911*t2817*t3038; t3345 = t3315 + t3342; t3553 = -0.866025*t614; t3557 = 0. + t3553; t3598 = 0.866025*t752; t3663 = 0. + t3598; t3591 = -1.*t3557*t637; t3665 = t717*t3663; t3675 = 0. + t3591 + t3665; t3813 = t717*t3557; t3872 = t637*t3663; t3884 = 0. + t3813 + t3872; t3790 = t608*t3675; t3885 = t909*t3884; t3891 = 0. + t3790 + t3885; t3961 = t909*t3675; t3963 = -1.*t608*t3884; t4003 = 0. + t3961 + t3963; t3907 = -1.*t589*t3891; t4087 = t1116*t4003; t4095 = 0. + t3907 + t4087; t4163 = t1116*t3891; t4165 = t589*t4003; t4169 = 0. + t4163 + t4165; t4157 = t555*t4095; t4202 = t1548*t4169; t4209 = 0. + t4157 + t4202; t4287 = t1548*t4095; t4323 = -1.*t555*t4169; t4348 = 0. + t4287 + t4323; t4261 = t379*t4209; t4363 = t1983*t4348; t4370 = 0. + t4261 + t4363; t4383 = t1983*t4209; t4457 = -1.*t379*t4348; t4461 = 0. + t4383 + t4457; t4374 = t344*t4370; t4478 = t2362*t4461; t4486 = 0. + t4374 + t4478; t4522 = t2362*t4370; t4569 = -1.*t344*t4461; t4593 = 0. + t4522 + t4569; t4671 = 0.5*t614; t4677 = 0. + t4671; t4714 = -0.5*t752; t4719 = 0. + t4714; t4700 = -1.*t4677*t637; t4725 = t717*t4719; t4731 = 0. + t4700 + t4725; t4734 = t717*t4677; t4736 = t637*t4719; t4737 = 0. + t4734 + t4736; t4733 = t608*t4731; t4747 = t909*t4737; t4758 = 0. + t4733 + t4747; t4770 = t909*t4731; t4774 = -1.*t608*t4737; t4780 = 0. + t4770 + t4774; t4765 = -1.*t589*t4758; t4794 = t1116*t4780; t4827 = 0. + t4765 + t4794; t4846 = t1116*t4758; t4870 = t589*t4780; t4947 = 0. + t4846 + t4870; t4832 = t555*t4827; t4986 = t1548*t4947; t4990 = 0. + t4832 + t4986; t5018 = t1548*t4827; t5026 = -1.*t555*t4947; t5070 = 0. + t5018 + t5026; t5009 = t379*t4990; t5080 = t1983*t5070; t5081 = 0. + t5009 + t5080; t5157 = t1983*t4990; t5191 = -1.*t379*t5070; t5243 = 0. + t5157 + t5191; t5145 = t344*t5081; t5258 = t2362*t5243; t5272 = 0. + t5145 + t5258; t5337 = t2362*t5081; t5345 = -1.*t344*t5243; t5463 = 0. + t5337 + t5345; t5623 = 0.05456*t614; t5674 = 0. + t5623; t5708 = -0.05456*t752; t5722 = 0. + t5708; t5699 = -1.*t5674*t637; t5742 = t717*t5722; t5789 = 0. + t5699 + t5742; t5804 = t717*t5674; t5814 = t637*t5722; t5823 = 0. + t5804 + t5814; t5792 = t608*t5789; t5833 = t909*t5823; t5847 = 0. + t5792 + t5833; t5883 = t909*t5789; t5947 = -1.*t608*t5823; t5949 = 0. + t5883 + t5947; t5857 = -1.*t589*t5847; t5963 = t1116*t5949; t5969 = 0. + t5857 + t5963; t6032 = t1116*t5847; t6077 = t589*t5949; t6127 = 0. + t6032 + t6077; t6020 = t555*t5969; t6146 = t1548*t6127; t6149 = 0. + t6020 + t6146; t6177 = t1548*t5969; t6250 = -1.*t555*t6127; t6308 = 0. + t6177 + t6250; t6172 = t379*t6149; t6324 = t1983*t6308; t6325 = 0. + t6172 + t6324; t6393 = t1983*t6149; t6418 = -1.*t379*t6308; t6428 = 0. + t6393 + t6418; t6354 = t344*t6325; t6438 = t2362*t6428; t6540 = 0. + t6354 + t6438; t6595 = t2362*t6325; t6597 = -1.*t344*t6428; t6612 = 0. + t6595 + t6597; t5283 = -1.*t133*t5272; t5483 = t2641*t5463; t5487 = 0. + t5283 + t5483; t5490 = 0.866025*t5; t5547 = t2641*t5272; t5549 = t133*t5463; t5554 = 0. + t5547 + t5549; t5589 = t5554*t3038; t5615 = 0. + t5490 + t5589; t6563 = -1.*t133*t6540; t6613 = t2641*t6612; t6726 = 0. + t6563 + t6613; t6770 = -1.*t6726*t3031; t6773 = -0.0315*t5; t6774 = t2641*t6540; t6846 = t133*t6612; t6851 = 0. + t6774 + t6846; t6870 = t6851*t3038; t6872 = 0. + t6773 + t6870; t6882 = t2911*t6872; t7135 = -1.*t5487*t3031; t7199 = t2911*t5615; t4520 = -1.*t133*t4486; t4606 = t2641*t4593; t4610 = 0. + t4520 + t4606; t4629 = 0.5*t5; t4641 = t2641*t4486; t4644 = t133*t4593; t4652 = 0. + t4641 + t4644; t4653 = t4652*t3038; t4656 = 0. + t4629 + t4653; t7237 = 0. + t7135 + t7199; t7107 = 0. + t6770 + t6882; t5488 = t2911*t5487; t5620 = t3031*t5615; t5622 = 0. + t5488 + t5620; t7415 = t2911*t6726; t7416 = t3031*t6872; t7434 = 0. + t7415 + t7416; t4613 = -1.*t4610*t3031; t4658 = t2911*t4656; t7261 = -1.*t2911*t6726; t7316 = -1.*t3031*t6872; t7327 = t7261 + t7316; t4670 = 0. + t4613 + t4658; t7617 = -1.*t2911*t4610; t7619 = -1.*t3031*t4656; t7633 = t7617 + t7619; t6898 = t6770 + t6882; t6923 = -1.*t2911*t5487; t7040 = -1.*t3031*t5615; t7059 = t6923 + t7040; t7672 = t5*t6851; t7694 = 0.0315*t3038; t7816 = 0. + t7672 + t7694; t7925 = t2911*t4610; t7951 = t3031*t4656; t7958 = 0. + t7925 + t7951; t8009 = t5*t4652; t8065 = -0.5*t3038; t8099 = 0. + t8009 + t8065; t7643 = t5*t5554; t7645 = -0.866025*t3038; t7671 = 0. + t7643 + t7645; t7833 = t7671*t7816; t8449 = 0.0315*t5; t8486 = -1.*t6851*t3038; t8496 = t8449 + t8486; t8579 = -0.5*t5; t8586 = -1.*t4652*t3038; t8604 = t8579 + t8586; t8433 = t7672 + t7694; t8334 = -0.866025*t5; t8392 = -1.*t5554*t3038; t8407 = t8334 + t8392; t8113 = -1.*t8099*t7816; t8410 = t7816*t8407; t8535 = t7671*t8496; t8538 = t7643 + t7645; t8683 = t8009 + t8065; t7849 = t7237*t7107; t7855 = t5622*t7434; t7860 = t7833 + t7849 + t7855; t8682 = -1.*t8099*t8496; t8776 = -1.*t7816*t8604; t8135 = -1.*t7107*t4670; t8142 = -1.*t7434*t7958; t8182 = t8113 + t8135 + t8142; t8879 = -1.*t6726*t4610; t9708 = t6563 + t6613; t9891 = -1.*t2641*t5272; t9932 = -1.*t133*t5463; t9933 = t9891 + t9932; t9369 = -1.*t2641*t6540; t9424 = -1.*t133*t6612; t9430 = t9369 + t9424; t8650 = t5487*t6726; t9601 = -1.*t2641*t4486; t9627 = -1.*t133*t4593; t9689 = t9601 + t9627; t10101 = -1.*t133*t2474; t10103 = -1.*t2641*t2800; t10106 = t10101 + t10103; t10188 = t2911*t10106; t10191 = t2938*t3031*t3038; t10201 = t10188 + t10191; t9976 = t9933*t6726; t10030 = t5487*t9430; t10047 = t5283 + t5483; t9316 = t4520 + t4606; t8653 = t5615*t6872; t8661 = t8650 + t7833 + t8653; t9462 = -1.*t9430*t4610; t9692 = -1.*t6726*t9689; t8894 = -1.*t6872*t4656; t8899 = t8879 + t8113 + t8894; t10229 = t5*t9708*t7671; t10232 = t5*t10047*t7816; t10291 = -1.*t5*t9708*t8099; t10297 = -1.*t5*t9316*t7816; t10729 = -1.*t9689*t3031; t10747 = t2911*t9316*t3038; t10799 = t10729 + t10747; t10399 = -1.*t9430*t3031; t10410 = t2911*t9708*t3038; t10430 = t10399 + t10410; t10447 = t2911*t9430; t10471 = t9708*t3031*t3038; t10487 = t10447 + t10471; t10508 = -1.*t9933*t3031; t10561 = t2911*t10047*t3038; t10567 = t10508 + t10561; t9817 = -1.*t6851*t4652; t9822 = 0.01575 + t8879 + t9817; t11363 = -1.*t344*t4370; t11368 = -1.*t2362*t4461; t11371 = t11363 + t11368; t11402 = t4522 + t4569; t11453 = -1.*t344*t6325; t11476 = -1.*t2362*t6428; t11477 = t11453 + t11476; t11533 = t6595 + t6597; t10069 = t5554*t6851; t10078 = -0.027279787500000003 + t8650 + t10069; t11444 = t2641*t11371; t11446 = -1.*t133*t11402; t11449 = t11444 + t11446; t11549 = t133*t11477; t11555 = t2641*t11533; t11572 = t11549 + t11555; t11492 = t2641*t11477; t11535 = -1.*t133*t11533; t11545 = t11492 + t11535; t11275 = -1.*t344*t5081; t11276 = -1.*t2362*t5243; t11282 = t11275 + t11276; t11284 = t2641*t11282; t11288 = t5337 + t5345; t11317 = -1.*t133*t11288; t11354 = t11284 + t11317; t11729 = -1.*t2362*t2213; t11730 = -1.*t344*t2443; t11736 = t11729 + t11730; t11743 = t133*t11736; t11744 = t2914 + t11743; t11737 = t2641*t11736; t11738 = t10101 + t11737; t11766 = t2911*t11738; t11772 = t11744*t3031*t3038; t11783 = t11766 + t11772; t11610 = t5487*t11545; t11616 = t11354*t6726; t11617 = t133*t11282; t11626 = t2641*t11288; t11643 = t11617 + t11626; t11386 = t133*t11371; t11403 = t2641*t11402; t11414 = t11386 + t11403; t11451 = -1.*t6726*t11449; t11548 = -1.*t11545*t4610; t11866 = t5*t11572*t7671; t11870 = t5*t11643*t7816; t11951 = -1.*t5*t11572*t8099; t11952 = -1.*t5*t11414*t7816; t12163 = -1.*t11449*t3031; t12168 = t2911*t11414*t3038; t12170 = t12163 + t12168; t12000 = -1.*t11545*t3031; t12003 = t2911*t11572*t3038; t12004 = t12000 + t12003; t12057 = t2911*t11545; t12058 = t11572*t3031*t3038; t12116 = t12057 + t12058; t12119 = -1.*t11354*t3031; t12120 = t2911*t11643*t3038; t12126 = t12119 + t12120; t12346 = -1.*t379*t4990; t12395 = -1.*t1983*t5070; t12408 = t12346 + t12395; t12414 = t5157 + t5191; t12464 = -1.*t379*t4209; t12466 = -1.*t1983*t4348; t12475 = t12464 + t12466; t12515 = t4383 + t4457; t12497 = -1.*t344*t12475; t12518 = t2362*t12515; t12527 = t12497 + t12518; t12532 = t2362*t12475; t12533 = t344*t12515; t12535 = t12532 + t12533; t12597 = -1.*t379*t6149; t12605 = -1.*t1983*t6308; t12616 = t12597 + t12605; t12634 = t6393 + t6418; t12620 = -1.*t344*t12616; t12642 = t2362*t12634; t12644 = t12620 + t12642; t12646 = t2362*t12616; t12648 = t344*t12634; t12650 = t12646 + t12648; t12574 = t2641*t12527; t12575 = -1.*t133*t12535; t12588 = t12574 + t12575; t12660 = t133*t12644; t12662 = t2641*t12650; t12664 = t12660 + t12662; t12645 = t2641*t12644; t12653 = -1.*t133*t12650; t12655 = t12645 + t12653; t12411 = -1.*t344*t12408; t12416 = t2362*t12414; t12422 = t12411 + t12416; t12433 = t2641*t12422; t12438 = t2362*t12408; t12439 = t344*t12414; t12440 = t12438 + t12439; t12457 = -1.*t133*t12440; t12461 = t12433 + t12457; t12804 = -1.*t1983*t1773; t12805 = -1.*t379*t2189; t12806 = t12804 + t12805; t12803 = t344*t2213; t12807 = t2362*t12806; t12810 = t12803 + t12807; t12816 = -1.*t344*t12806; t12817 = t2729 + t12816; t12822 = t2641*t12810; t12828 = t133*t12817; t12829 = t12822 + t12828; t12815 = -1.*t133*t12810; t12818 = t2641*t12817; t12819 = t12815 + t12818; t12842 = t2911*t12819; t12843 = t12829*t3031*t3038; t12845 = t12842 + t12843; t12679 = t5487*t12655; t12681 = t12461*t6726; t12686 = t133*t12422; t12689 = t2641*t12440; t12690 = t12686 + t12689; t12531 = t133*t12527; t12565 = t2641*t12535; t12569 = t12531 + t12565; t12592 = -1.*t6726*t12588; t12658 = -1.*t12655*t4610; t12869 = t5*t12664*t7671; t12870 = t5*t12690*t7816; t12888 = -1.*t5*t12664*t8099; t12889 = -1.*t5*t12569*t7816; t12964 = -1.*t12588*t3031; t12967 = t2911*t12569*t3038; t12969 = t12964 + t12967; t12911 = -1.*t12655*t3031; t12915 = t2911*t12664*t3038; t12917 = t12911 + t12915; t12919 = t2911*t12655; t12920 = t12664*t3031*t3038; t12921 = t12919 + t12920; t12926 = -1.*t12461*t3031; t12928 = t2911*t12690*t3038; t12935 = t12926 + t12928; t13023 = -1.*t555*t4827; t13027 = -1.*t1548*t4947; t13028 = t13023 + t13027; t13033 = t5018 + t5026; t13030 = -1.*t379*t13028; t13034 = t1983*t13033; t13036 = t13030 + t13034; t13047 = t1983*t13028; t13051 = t379*t13033; t13052 = t13047 + t13051; t13081 = -1.*t555*t4095; t13085 = -1.*t1548*t4169; t13087 = t13081 + t13085; t13095 = t4287 + t4323; t13093 = -1.*t379*t13087; t13099 = t1983*t13095; t13101 = t13093 + t13099; t13108 = t1983*t13087; t13111 = t379*t13095; t13115 = t13108 + t13111; t13103 = -1.*t344*t13101; t13116 = t2362*t13115; t13117 = t13103 + t13116; t13121 = t2362*t13101; t13130 = t344*t13115; t13131 = t13121 + t13130; t13149 = -1.*t555*t5969; t13154 = -1.*t1548*t6127; t13156 = t13149 + t13154; t13160 = t6177 + t6250; t13159 = -1.*t379*t13156; t13161 = t1983*t13160; t13164 = t13159 + t13161; t13166 = t1983*t13156; t13167 = t379*t13160; t13169 = t13166 + t13167; t13165 = -1.*t344*t13164; t13170 = t2362*t13169; t13173 = t13165 + t13170; t13175 = t2362*t13164; t13176 = t344*t13169; t13177 = t13175 + t13176; t13142 = t2641*t13117; t13146 = -1.*t133*t13131; t13147 = t13142 + t13146; t13187 = t133*t13173; t13189 = t2641*t13177; t13190 = t13187 + t13189; t13174 = t2641*t13173; t13179 = -1.*t133*t13177; t13182 = t13174 + t13179; t13046 = -1.*t344*t13036; t13053 = t2362*t13052; t13054 = t13046 + t13053; t13055 = t2641*t13054; t13056 = t2362*t13036; t13057 = t344*t13052; t13061 = t13056 + t13057; t13064 = -1.*t133*t13061; t13068 = t13055 + t13064; t13364 = -1.*t1548*t1453; t13370 = -1.*t555*t1690; t13376 = t13364 + t13370; t13361 = t379*t1773; t13379 = t1983*t13376; t13380 = t13361 + t13379; t13384 = -1.*t379*t13376; t13389 = t2371 + t13384; t13383 = t344*t13380; t13390 = t2362*t13389; t13391 = t13383 + t13390; t13393 = t2362*t13380; t13394 = -1.*t344*t13389; t13401 = t13393 + t13394; t13417 = t2641*t13391; t13419 = t133*t13401; t13420 = t13417 + t13419; t13392 = -1.*t133*t13391; t13403 = t2641*t13401; t13409 = t13392 + t13403; t13430 = t2911*t13409; t13432 = t13420*t3031*t3038; t13446 = t13430 + t13432; t13202 = t5487*t13182; t13204 = t13068*t6726; t13205 = t133*t13054; t13206 = t2641*t13061; t13211 = t13205 + t13206; t13118 = t133*t13117; t13138 = t2641*t13131; t13140 = t13118 + t13138; t13148 = -1.*t6726*t13147; t13183 = -1.*t13182*t4610; t13465 = t5*t13190*t7671; t13466 = t5*t13211*t7816; t13475 = -1.*t5*t13190*t8099; t13479 = -1.*t5*t13140*t7816; t13579 = -1.*t13147*t3031; t13581 = t2911*t13140*t3038; t13588 = t13579 + t13581; t13509 = -1.*t13182*t3031; t13513 = t2911*t13190*t3038; t13516 = t13509 + t13513; t13523 = t2911*t13182; t13531 = t13190*t3031*t3038; t13533 = t13523 + t13531; t13537 = -1.*t13068*t3031; t13538 = t2911*t13211*t3038; t13548 = t13537 + t13538; t13632 = t4765 + t4794; t13634 = -1.*t1116*t4758; t13636 = -1.*t589*t4780; t13637 = t13634 + t13636; t13633 = -1.*t555*t13632; t13643 = t1548*t13637; t13648 = t13633 + t13643; t13653 = t1548*t13632; t13655 = t555*t13637; t13656 = t13653 + t13655; t13649 = -1.*t379*t13648; t13666 = t1983*t13656; t13667 = t13649 + t13666; t13669 = t1983*t13648; t13671 = t379*t13656; t13672 = t13669 + t13671; t13705 = t3907 + t4087; t13709 = -1.*t1116*t3891; t13712 = -1.*t589*t4003; t13714 = t13709 + t13712; t13706 = -1.*t555*t13705; t13717 = t1548*t13714; t13719 = t13706 + t13717; t13721 = t1548*t13705; t13722 = t555*t13714; t13725 = t13721 + t13722; t13720 = -1.*t379*t13719; t13727 = t1983*t13725; t13729 = t13720 + t13727; t13732 = t1983*t13719; t13733 = t379*t13725; t13734 = t13732 + t13733; t13730 = -1.*t344*t13729; t13735 = t2362*t13734; t13737 = t13730 + t13735; t13744 = t2362*t13729; t13745 = t344*t13734; t13754 = t13744 + t13745; t13779 = t5857 + t5963; t13789 = -1.*t1116*t5847; t13791 = -1.*t589*t5949; t13795 = t13789 + t13791; t13781 = -1.*t555*t13779; t13796 = t1548*t13795; t13797 = t13781 + t13796; t13803 = t1548*t13779; t13807 = t555*t13795; t13809 = t13803 + t13807; t13800 = -1.*t379*t13797; t13817 = t1983*t13809; t13820 = t13800 + t13817; t13827 = t1983*t13797; t13829 = t379*t13809; t13831 = t13827 + t13829; t13825 = -1.*t344*t13820; t13832 = t2362*t13831; t13833 = t13825 + t13832; t13836 = t2362*t13820; t13843 = t344*t13831; t13844 = t13836 + t13843; t13765 = t2641*t13737; t13767 = -1.*t133*t13754; t13769 = t13765 + t13767; t13855 = t133*t13833; t13856 = t2641*t13844; t13858 = t13855 + t13856; t13834 = t2641*t13833; t13847 = -1.*t133*t13844; t13850 = t13834 + t13847; t13668 = -1.*t344*t13667; t13676 = t2362*t13672; t13683 = t13668 + t13676; t13687 = t2641*t13683; t13689 = t2362*t13667; t13690 = t344*t13672; t13693 = t13689 + t13690; t13696 = -1.*t133*t13693; t13698 = t13687 + t13696; t14033 = -1.*t589*t991; t14034 = -1.*t1116*t1344; t14035 = t14033 + t14034; t14037 = t555*t14035; t14038 = t14037 + t1755; t14043 = t1548*t14035; t14045 = t14043 + t13370; t14041 = t379*t14038; t14046 = t1983*t14045; t14049 = t14041 + t14046; t14051 = t1983*t14038; t14055 = -1.*t379*t14045; t14056 = t14051 + t14055; t14050 = t344*t14049; t14057 = t2362*t14056; t14058 = t14050 + t14057; t14062 = t2362*t14049; t14063 = -1.*t344*t14056; t14064 = t14062 + t14063; t14071 = t2641*t14058; t14072 = t133*t14064; t14073 = t14071 + t14072; t14061 = -1.*t133*t14058; t14065 = t2641*t14064; t14068 = t14061 + t14065; t14081 = t2911*t14068; t14082 = t14073*t3031*t3038; t14084 = t14081 + t14082; t13875 = t5487*t13850; t13878 = t13698*t6726; t13880 = t133*t13683; t13885 = t2641*t13693; t13888 = t13880 + t13885; t13738 = t133*t13737; t13757 = t2641*t13754; t13758 = t13738 + t13757; t13778 = -1.*t6726*t13769; t13853 = -1.*t13850*t4610; t14098 = t5*t13858*t7671; t14100 = t5*t13888*t7816; t14112 = -1.*t5*t13858*t8099; t14113 = -1.*t5*t13758*t7816; t14184 = -1.*t13769*t3031; t14185 = t2911*t13758*t3038; t14188 = t14184 + t14185; t14128 = -1.*t13850*t3031; t14129 = t2911*t13858*t3038; t14130 = t14128 + t14129; t14146 = t2911*t13850; t14147 = t13858*t3031*t3038; t14149 = t14146 + t14147; t14156 = -1.*t13698*t3031; t14159 = t2911*t13888*t3038; t14162 = t14156 + t14159; t14215 = -1.*t608*t4731; t14216 = -1.*t909*t4737; t14220 = t14215 + t14216; t14233 = t4770 + t4774; t14230 = t589*t14220; t14234 = t1116*t14233; t14237 = t14230 + t14234; t14240 = t1116*t14220; t14241 = -1.*t589*t14233; t14242 = t14240 + t14241; t14239 = -1.*t555*t14237; t14243 = t1548*t14242; t14248 = t14239 + t14243; t14262 = t1548*t14237; t14263 = t555*t14242; t14264 = t14262 + t14263; t14259 = -1.*t379*t14248; t14266 = t1983*t14264; t14267 = t14259 + t14266; t14272 = t1983*t14248; t14278 = t379*t14264; t14283 = t14272 + t14278; t14301 = -1.*t608*t3675; t14302 = -1.*t909*t3884; t14303 = t14301 + t14302; t14307 = t3961 + t3963; t14304 = t589*t14303; t14309 = t1116*t14307; t14310 = t14304 + t14309; t14312 = t1116*t14303; t14313 = -1.*t589*t14307; t14314 = t14312 + t14313; t14311 = -1.*t555*t14310; t14315 = t1548*t14314; t14317 = t14311 + t14315; t14321 = t1548*t14310; t14327 = t555*t14314; t14333 = t14321 + t14327; t14320 = -1.*t379*t14317; t14334 = t1983*t14333; t14336 = t14320 + t14334; t14339 = t1983*t14317; t14344 = t379*t14333; t14347 = t14339 + t14344; t14337 = -1.*t344*t14336; t14350 = t2362*t14347; t14352 = t14337 + t14350; t14354 = t2362*t14336; t14358 = t344*t14347; t14359 = t14354 + t14358; t14376 = -1.*t608*t5789; t14380 = -1.*t909*t5823; t14382 = t14376 + t14380; t14386 = t5883 + t5947; t14383 = t589*t14382; t14387 = t1116*t14386; t14388 = t14383 + t14387; t14391 = t1116*t14382; t14392 = -1.*t589*t14386; t14393 = t14391 + t14392; t14389 = -1.*t555*t14388; t14394 = t1548*t14393; t14395 = t14389 + t14394; t14397 = t1548*t14388; t14398 = t555*t14393; t14399 = t14397 + t14398; t14396 = -1.*t379*t14395; t14404 = t1983*t14399; t14406 = t14396 + t14404; t14409 = t1983*t14395; t14411 = t379*t14399; t14412 = t14409 + t14411; t14407 = -1.*t344*t14406; t14414 = t2362*t14412; t14415 = t14407 + t14414; t14418 = t2362*t14406; t14419 = t344*t14412; t14421 = t14418 + t14419; t14371 = t2641*t14352; t14372 = -1.*t133*t14359; t14373 = t14371 + t14372; t14426 = t133*t14415; t14429 = t2641*t14421; t14431 = t14426 + t14429; t14416 = t2641*t14415; t14422 = -1.*t133*t14421; t14423 = t14416 + t14422; t14268 = -1.*t344*t14267; t14284 = t2362*t14283; t14286 = t14268 + t14284; t14287 = t2641*t14286; t14288 = t2362*t14267; t14289 = t344*t14283; t14291 = t14288 + t14289; t14294 = -1.*t133*t14291; t14296 = t14287 + t14294; t14601 = -1.*t909*t900; t14602 = -1.*t608*t962; t14608 = t14601 + t14602; t14609 = t1116*t14608; t14610 = t14033 + t14609; t14613 = t589*t14608; t14614 = t1566 + t14613; t14612 = t555*t14610; t14615 = t1548*t14614; t14616 = t14612 + t14615; t14621 = t1548*t14610; t14632 = -1.*t555*t14614; t14633 = t14621 + t14632; t14618 = t379*t14616; t14636 = t1983*t14633; t14637 = t14618 + t14636; t14640 = t1983*t14616; t14646 = -1.*t379*t14633; t14648 = t14640 + t14646; t14638 = t344*t14637; t14649 = t2362*t14648; t14650 = t14638 + t14649; t14653 = t2362*t14637; t14654 = -1.*t344*t14648; t14655 = t14653 + t14654; t14669 = t2641*t14650; t14670 = t133*t14655; t14672 = t14669 + t14670; t14652 = -1.*t133*t14650; t14657 = t2641*t14655; t14659 = t14652 + t14657; t14685 = t2911*t14659; t14688 = t14672*t3031*t3038; t14690 = t14685 + t14688; t14440 = t5487*t14423; t14441 = t14296*t6726; t14443 = t133*t14286; t14444 = t2641*t14291; t14446 = t14443 + t14444; t14353 = t133*t14352; t14363 = t2641*t14359; t14366 = t14353 + t14363; t14374 = -1.*t6726*t14373; t14425 = -1.*t14423*t4610; t14704 = t5*t14431*t7671; t14705 = t5*t14446*t7816; t14721 = -1.*t5*t14431*t8099; t14723 = -1.*t5*t14366*t7816; t14777 = -1.*t14373*t3031; t14780 = t2911*t14366*t3038; t14783 = t14777 + t14780; t14740 = -1.*t14423*t3031; t14741 = t2911*t14431*t3038; t14742 = t14740 + t14741; t14747 = t2911*t14423; t14749 = t14431*t3031*t3038; t14754 = t14747 + t14749; t14758 = -1.*t14296*t3031; t14761 = t2911*t14446*t3038; t14762 = t14758 + t14761; t14815 = t4700 + t4725; t14819 = -1.*t717*t4677; t14820 = -1.*t637*t4719; t14823 = t14819 + t14820; t14818 = -1.*t608*t14815; t14825 = t909*t14823; t14826 = t14818 + t14825; t14829 = t909*t14815; t14830 = t608*t14823; t14831 = t14829 + t14830; t14828 = t589*t14826; t14832 = t1116*t14831; t14835 = t14828 + t14832; t14839 = t1116*t14826; t14841 = -1.*t589*t14831; t14842 = t14839 + t14841; t14836 = -1.*t555*t14835; t14844 = t1548*t14842; t14845 = t14836 + t14844; t14848 = t1548*t14835; t14849 = t555*t14842; t14851 = t14848 + t14849; t14846 = -1.*t379*t14845; t14852 = t1983*t14851; t14853 = t14846 + t14852; t14855 = t1983*t14845; t14856 = t379*t14851; t14857 = t14855 + t14856; t14875 = t3591 + t3665; t14877 = -1.*t717*t3557; t14878 = -1.*t637*t3663; t14879 = t14877 + t14878; t14876 = -1.*t608*t14875; t14880 = t909*t14879; t14881 = t14876 + t14880; t14883 = t909*t14875; t14884 = t608*t14879; t14886 = t14883 + t14884; t14882 = t589*t14881; t14887 = t1116*t14886; t14890 = t14882 + t14887; t14893 = t1116*t14881; t14895 = -1.*t589*t14886; t14896 = t14893 + t14895; t14892 = -1.*t555*t14890; t14897 = t1548*t14896; t14900 = t14892 + t14897; t14902 = t1548*t14890; t14903 = t555*t14896; t14904 = t14902 + t14903; t14901 = -1.*t379*t14900; t14905 = t1983*t14904; t14906 = t14901 + t14905; t14908 = t1983*t14900; t14909 = t379*t14904; t14910 = t14908 + t14909; t14907 = -1.*t344*t14906; t14912 = t2362*t14910; t14913 = t14907 + t14912; t14917 = t2362*t14906; t14919 = t344*t14910; t14920 = t14917 + t14919; t14930 = t5699 + t5742; t14933 = -1.*t717*t5674; t14934 = -1.*t637*t5722; t14936 = t14933 + t14934; t14931 = -1.*t608*t14930; t14937 = t909*t14936; t14938 = t14931 + t14937; t14941 = t909*t14930; t14942 = t608*t14936; t14944 = t14941 + t14942; t14940 = t589*t14938; t14945 = t1116*t14944; t14947 = t14940 + t14945; t14951 = t1116*t14938; t14953 = -1.*t589*t14944; t14954 = t14951 + t14953; t14950 = -1.*t555*t14947; t14956 = t1548*t14954; t14957 = t14950 + t14956; t14959 = t1548*t14947; t14960 = t555*t14954; t14961 = t14959 + t14960; t14958 = -1.*t379*t14957; t14962 = t1983*t14961; t14963 = t14958 + t14962; t14966 = t1983*t14957; t14969 = t379*t14961; t14970 = t14966 + t14969; t14964 = -1.*t344*t14963; t14971 = t2362*t14970; t14972 = t14964 + t14971; t14975 = t2362*t14963; t14976 = t344*t14970; t14977 = t14975 + t14976; t14924 = t2641*t14913; t14925 = -1.*t133*t14920; t14926 = t14924 + t14925; t14983 = t133*t14972; t14985 = t2641*t14977; t14986 = t14983 + t14985; t14974 = t2641*t14972; t14980 = -1.*t133*t14977; t14981 = t14974 + t14980; t14854 = -1.*t344*t14853; t14860 = t2362*t14857; t14861 = t14854 + t14860; t14864 = t2641*t14861; t14866 = t2362*t14853; t14867 = t344*t14857; t14870 = t14866 + t14867; t14871 = -1.*t133*t14870; t14872 = t14864 + t14871; t15103 = t614*t637; t15104 = t717*t752; t15105 = t15103 + t15104; t15106 = t608*t15105; t15107 = t15106 + t964; t15109 = t909*t15105; t15110 = t15109 + t14602; t15108 = -1.*t589*t15107; t15111 = t1116*t15110; t15112 = t15108 + t15111; t15114 = t1116*t15107; t15115 = t589*t15110; t15116 = t15114 + t15115; t15113 = t555*t15112; t15117 = t1548*t15116; t15118 = t15113 + t15117; t15120 = t1548*t15112; t15121 = -1.*t555*t15116; t15122 = t15120 + t15121; t15119 = t379*t15118; t15123 = t1983*t15122; t15124 = t15119 + t15123; t15126 = t1983*t15118; t15127 = -1.*t379*t15122; t15128 = t15126 + t15127; t15125 = t344*t15124; t15129 = t2362*t15128; t15130 = t15125 + t15129; t15132 = t2362*t15124; t15133 = -1.*t344*t15128; t15134 = t15132 + t15133; t15139 = t2641*t15130; t15140 = t133*t15134; t15141 = t15139 + t15140; t15131 = -1.*t133*t15130; t15135 = t2641*t15134; t15136 = t15131 + t15135; t15146 = t2911*t15136; t15148 = t15141*t3031*t3038; t15149 = t15146 + t15148; t14995 = t5487*t14981; t14997 = t14872*t6726; t14998 = t133*t14861; t14999 = t2641*t14870; t15000 = t14998 + t14999; t14916 = t133*t14913; t14921 = t2641*t14920; t14922 = t14916 + t14921; t14927 = -1.*t6726*t14926; t14982 = -1.*t14981*t4610; t15157 = t5*t14986*t7671; t15158 = t5*t15000*t7816; t15165 = -1.*t5*t14986*t8099; t15166 = -1.*t5*t14922*t7816; t15192 = -1.*t14926*t3031; t15193 = t2911*t14922*t3038; t15194 = t15192 + t15193; t15174 = -1.*t14981*t3031; t15175 = t2911*t14986*t3038; t15176 = t15174 + t15175; t15178 = t2911*t14981; t15179 = t14986*t3031*t3038; t15180 = t15178 + t15179; t15182 = -1.*t14872*t3031; t15183 = t2911*t15000*t3038; t15184 = t15182 + t15183; t15224 = -0.05456*t614*t637; t15225 = -0.05456*t717*t752; t15226 = t15224 + t15225; t15236 = -0.05456*t717*t614; t15238 = 0.05456*t637*t752; t15239 = t15236 + t15238; t15228 = 0.866025*t614*t637; t15229 = 0.866025*t717*t752; t15230 = t15228 + t15229; t15232 = 0.866025*t717*t614; t15233 = -0.866025*t637*t752; t15234 = t15232 + t15233; t15268 = -1.*t608*t15226; t15269 = t909*t15239; t15271 = t15268 + t15269; t15273 = t909*t15226; t15274 = t608*t15239; t15275 = t15273 + t15274; t15243 = -0.5*t614*t637; t15244 = -0.5*t717*t752; t15245 = t15243 + t15244; t15250 = -0.5*t717*t614; t15252 = 0.5*t637*t752; t15253 = t15250 + t15252; t15259 = -1.*t608*t15230; t15260 = t909*t15234; t15261 = t15259 + t15260; t15263 = t909*t15230; t15264 = t608*t15234; t15265 = t15263 + t15264; t15302 = t589*t15271; t15303 = t1116*t15275; t15304 = t15302 + t15303; t15306 = t1116*t15271; t15307 = -1.*t589*t15275; t15308 = t15306 + t15307; t15281 = -1.*t608*t15245; t15282 = t909*t15253; t15283 = t15281 + t15282; t15285 = t909*t15245; t15286 = t608*t15253; t15287 = t15285 + t15286; t15293 = t589*t15261; t15295 = t1116*t15265; t15296 = t15293 + t15295; t15298 = t1116*t15261; t15299 = -1.*t589*t15265; t15300 = t15298 + t15299; t15337 = -1.*t555*t15304; t15338 = t1548*t15308; t15339 = t15337 + t15338; t15341 = t1548*t15304; t15342 = t555*t15308; t15343 = t15341 + t15342; t15316 = t589*t15283; t15317 = t1116*t15287; t15318 = t15316 + t15317; t15320 = t1116*t15283; t15321 = -1.*t589*t15287; t15323 = t15320 + t15321; t15329 = -1.*t555*t15296; t15330 = t1548*t15300; t15331 = t15329 + t15330; t15333 = t1548*t15296; t15334 = t555*t15300; t15335 = t15333 + t15334; t15369 = -1.*t379*t15339; t15370 = t1983*t15343; t15371 = t15369 + t15370; t15373 = t1983*t15339; t15374 = t379*t15343; t15375 = t15373 + t15374; t15349 = -1.*t555*t15318; t15350 = t1548*t15323; t15351 = t15349 + t15350; t15353 = t1548*t15318; t15354 = t555*t15323; t15355 = t15353 + t15354; t15361 = -1.*t379*t15331; t15362 = t1983*t15335; t15363 = t15361 + t15362; t15365 = t1983*t15331; t15366 = t379*t15335; t15367 = t15365 + t15366; t15402 = -1.*t344*t15371; t15403 = t2362*t15375; t15404 = t15402 + t15403; t15406 = t2362*t15371; t15407 = t344*t15375; t15408 = t15406 + t15407; t15382 = -1.*t379*t15351; t15383 = t1983*t15355; t15384 = t15382 + t15383; t15386 = t1983*t15351; t15387 = t379*t15355; t15388 = t15386 + t15387; t15394 = -1.*t344*t15363; t15395 = t2362*t15367; t15396 = t15394 + t15395; t15398 = t2362*t15363; t15399 = t344*t15367; t15400 = t15398 + t15399; t15414 = -1.*t344*t15384; t15415 = t2362*t15388; t15416 = t15414 + t15415; t15418 = t2362*t15384; t15419 = t344*t15388; t15420 = t15418 + t15419; t15427 = t2641*t15396; t15428 = -1.*t133*t15400; t15429 = t15427 + t15428; t15440 = t133*t15404; t15441 = t2641*t15408; t15442 = t15440 + t15441; t15444 = t2641*t15404; t15445 = -1.*t133*t15408; t15446 = t15444 + t15445; t15431 = t2641*t15416; t15432 = -1.*t133*t15420; t15433 = t15431 + t15432; t15137 = -1.*t15136*t3031; t15142 = t2911*t15141*t3038; t15143 = t15137 + t15142; t15144 = var2[2]*t15143; t15145 = -1.*t5*t15141*t2849; t15150 = t2897*t15149; t15151 = t15145 + t15150; t15152 = var2[0]*t15151; t15153 = t2897*t5*t15141; t15154 = t2849*t15149; t15155 = t15153 + t15154; t15156 = var2[1]*t15155; t15451 = t5487*t15446; t15456 = t6726*t15433; t15452 = t133*t15416; t15453 = t2641*t15420; t15454 = t15452 + t15453; t15435 = t133*t15396; t15436 = t2641*t15400; t15437 = t15435 + t15436; t15439 = -1.*t6726*t15429; t15447 = -1.*t4610*t15446; t15461 = t5*t15442*t7671; t15462 = t5*t15454*t7816; t15468 = -1.*t5*t15442*t8099; t15469 = -1.*t5*t15437*t7816; t15496 = -1.*t15429*t3031; t15498 = t2911*t15437*t3038; t15500 = t15496 + t15498; t15477 = -1.*t15446*t3031; t15478 = t2911*t15442*t3038; t15479 = t15477 + t15478; t15481 = t2911*t15446; t15482 = t15442*t3031*t3038; t15483 = t15481 + t15482; t15485 = -1.*t15433*t3031; t15486 = t2911*t15454*t3038; t15487 = t15485 + t15486; t2867 = -1.*t5*t2817*t2849; t3161 = t2897*t3140; t3202 = t2867 + t3161; p_output1[0]=(-1.*t2849*t3140 - 1.*t2817*t2897*t5)*var2[0] + t3202*var2[1]; p_output1[1]=t2897*t3345*var2[0] + t2849*t3345*var2[1] + (-1.*t2911*t2938 - 1.*t2817*t3031*t3038)*var2[2] + (t4670*(t5622*t6898 + t7059*t7107 + t7237*t7327 + (t7135 + t7199)*t7434) + t7633*t7860 + t7237*(-1.*t4670*t7327 - 1.*(t4613 + t4658)*t7434 - 1.*t7107*t7633 - 1.*t6898*t7958) + t7059*t8182)*var2[3]; p_output1[2]=(t2817*t2849*t3038 + t2817*t2897*t3031*t5)*var2[0] + (-1.*t2817*t2897*t3038 + t2817*t2849*t3031*t5)*var2[1] + t2817*t2911*t5*var2[2] + (t2911*t8182*t8538 + t4670*(t8410 + t3031*t5622*t8433 + t2911*t7237*t8433 + t8535 + t2911*t7107*t8538 + t3031*t7434*t8538) + t2911*t7860*t8683 + t7237*(-1.*t2911*t4670*t8433 - 1.*t3031*t7958*t8433 + t8682 - 1.*t2911*t7107*t8683 - 1.*t3031*t7434*t8683 + t8776))*var2[3] + (t8099*(t8410 + t5615*t8433 + t8535 + t6872*t8538) + t8604*t8661 + t7671*(-1.*t4656*t8433 + t8682 - 1.*t6872*t8683 + t8776) + t8407*t8899)*var2[4]; p_output1[3]=(t10201*t2897 - 1.*t2849*t2938*t5)*var2[0] + (t10201*t2849 + t2897*t2938*t5)*var2[1] + (-1.*t10106*t3031 + t2911*t2938*t3038)*var2[2] + (t10799*t7860 + t10567*t8182 + t7237*(t10291 + t10297 - 1.*t10430*t4670 - 1.*t10799*t7107 - 1.*t10487*t7958 - 1.*t7434*(t3031*t3038*t9316 + t2911*t9689)) + t4670*(t10229 + t10232 + t10487*t5622 + t10567*t7107 + t10430*t7237 + t7434*(t10047*t3031*t3038 + t2911*t9933)))*var2[3] + (t10047*t5*t8899 + t5*t8661*t9316 + t7671*(t10291 + t10297 - 1.*t3038*t6872*t9316 + t9462 + t9692 - 1.*t3038*t4656*t9708) + t8099*(t10030 + t10229 + t10232 + t10047*t3038*t6872 + t3038*t5615*t9708 + t9976))*var2[4] + (t10078*t9689 + t5487*(-1.*t6851*t9316 + t9462 + t9692 - 1.*t4652*t9708) + t9822*t9933 + t4610*(t10030 + t10047*t6851 + t5554*t9708 + t9976))*var2[5]; p_output1[4]=(t11783*t2897 - 1.*t11744*t2849*t5)*var2[0] + (t11783*t2849 + t11744*t2897*t5)*var2[1] + (-1.*t11738*t3031 + t11744*t2911*t3038)*var2[2] + (t4670*(t11866 + t11870 + t12116*t5622 + t12126*t7107 + t12004*t7237 + (t11354*t2911 + t11643*t3031*t3038)*t7434) + t12170*t7860 + t7237*(t11951 + t11952 - 1.*t12004*t4670 - 1.*t12170*t7107 - 1.*(t11449*t2911 + t11414*t3031*t3038)*t7434 - 1.*t12116*t7958) + t12126*t8182)*var2[3] + ((t11451 + t11548 + t11951 + t11952 - 1.*t11572*t3038*t4656 - 1.*t11414*t3038*t6872)*t7671 + (t11610 + t11616 + t11866 + t11870 + t11572*t3038*t5615 + t11643*t3038*t6872)*t8099 + t11414*t5*t8661 + t11643*t5*t8899)*var2[4] + (t10078*t11449 + t5487*(t11451 + t11548 - 1.*t11572*t4652 - 1.*t11414*t6851) + t4610*(t11610 + t11616 + t11572*t5554 + t11643*t6851) + t11354*t9822)*var2[5] + (0.5*(t11533*t5272 + t11477*t5463 + t11288*t6540 + t11282*t6612) + 0.866025*(-1.*t11533*t4486 - 1.*t11477*t4593 - 1.*t11402*t6540 - 1.*t11371*t6612))*var2[21]; p_output1[5]=(t12845*t2897 - 1.*t12829*t2849*t5)*var2[0] + (t12845*t2849 + t12829*t2897*t5)*var2[1] + (-1.*t12819*t3031 + t12829*t2911*t3038)*var2[2] + (t4670*(t12869 + t12870 + t12921*t5622 + t12935*t7107 + t12917*t7237 + (t12461*t2911 + t12690*t3031*t3038)*t7434) + t12969*t7860 + t7237*(t12888 + t12889 - 1.*t12917*t4670 - 1.*t12969*t7107 - 1.*(t12588*t2911 + t12569*t3031*t3038)*t7434 - 1.*t12921*t7958) + t12935*t8182)*var2[3] + ((t12592 + t12658 + t12888 + t12889 - 1.*t12664*t3038*t4656 - 1.*t12569*t3038*t6872)*t7671 + (t12679 + t12681 + t12869 + t12870 + t12664*t3038*t5615 + t12690*t3038*t6872)*t8099 + t12569*t5*t8661 + t12690*t5*t8899)*var2[4] + (t10078*t12588 + t5487*(t12592 + t12658 - 1.*t12664*t4652 - 1.*t12569*t6851) + t4610*(t12679 + t12681 + t12664*t5554 + t12690*t6851) + t12461*t9822)*var2[5] + (0.5*(t12650*t5272 + t12644*t5463 + t12440*t6540 + t12422*t6612) + 0.866025*(-1.*t12650*t4486 - 1.*t12644*t4593 - 1.*t12535*t6540 - 1.*t12527*t6612))*var2[21] + (0.5*(t12634*t5081 + t12616*t5243 + t12414*t6325 + t12408*t6428) + 0.866025*(-1.*t12634*t4370 - 1.*t12616*t4461 - 1.*t12515*t6325 - 1.*t12475*t6428))*var2[22]; p_output1[6]=(t13446*t2897 - 1.*t13420*t2849*t5)*var2[0] + (t13446*t2849 + t13420*t2897*t5)*var2[1] + (-1.*t13409*t3031 + t13420*t2911*t3038)*var2[2] + (t4670*(t13465 + t13466 + t13533*t5622 + t13548*t7107 + t13516*t7237 + (t13068*t2911 + t13211*t3031*t3038)*t7434) + t13588*t7860 + t7237*(t13475 + t13479 - 1.*t13516*t4670 - 1.*t13588*t7107 - 1.*(t13147*t2911 + t13140*t3031*t3038)*t7434 - 1.*t13533*t7958) + t13548*t8182)*var2[3] + ((t13148 + t13183 + t13475 + t13479 - 1.*t13190*t3038*t4656 - 1.*t13140*t3038*t6872)*t7671 + (t13202 + t13204 + t13465 + t13466 + t13190*t3038*t5615 + t13211*t3038*t6872)*t8099 + t13140*t5*t8661 + t13211*t5*t8899)*var2[4] + (t10078*t13147 + t5487*(t13148 + t13183 - 1.*t13190*t4652 - 1.*t13140*t6851) + t4610*(t13202 + t13204 + t13190*t5554 + t13211*t6851) + t13068*t9822)*var2[5] + (0.5*(t13177*t5272 + t13173*t5463 + t13061*t6540 + t13054*t6612) + 0.866025*(-1.*t13177*t4486 - 1.*t13173*t4593 - 1.*t13131*t6540 - 1.*t13117*t6612))*var2[21] + (0.5*(t13169*t5081 + t13164*t5243 + t13052*t6325 + t13036*t6428) + 0.866025*(-1.*t13169*t4370 - 1.*t13164*t4461 - 1.*t13115*t6325 - 1.*t13101*t6428))*var2[22] + (-0.5*(t13160*t4990 + t13156*t5070 + t13033*t6149 + t13028*t6308) - 0.866025*(-1.*t13160*t4209 - 1.*t13156*t4348 - 1.*t13095*t6149 - 1.*t13087*t6308))*var2[23]; p_output1[7]=(t14084*t2897 - 1.*t14073*t2849*t5)*var2[0] + (t14084*t2849 + t14073*t2897*t5)*var2[1] + (-1.*t14068*t3031 + t14073*t2911*t3038)*var2[2] + (t4670*(t14098 + t14100 + t14149*t5622 + t14162*t7107 + t14130*t7237 + (t13698*t2911 + t13888*t3031*t3038)*t7434) + t14188*t7860 + t7237*(t14112 + t14113 - 1.*t14130*t4670 - 1.*t14188*t7107 - 1.*(t13769*t2911 + t13758*t3031*t3038)*t7434 - 1.*t14149*t7958) + t14162*t8182)*var2[3] + ((t13778 + t13853 + t14112 + t14113 - 1.*t13858*t3038*t4656 - 1.*t13758*t3038*t6872)*t7671 + (t13875 + t13878 + t14098 + t14100 + t13858*t3038*t5615 + t13888*t3038*t6872)*t8099 + t13758*t5*t8661 + t13888*t5*t8899)*var2[4] + (t10078*t13769 + t5487*(t13778 + t13853 - 1.*t13858*t4652 - 1.*t13758*t6851) + t4610*(t13875 + t13878 + t13858*t5554 + t13888*t6851) + t13698*t9822)*var2[5] + (0.5*(t13844*t5272 + t13833*t5463 + t13693*t6540 + t13683*t6612) + 0.866025*(-1.*t13844*t4486 - 1.*t13833*t4593 - 1.*t13754*t6540 - 1.*t13737*t6612))*var2[21] + (0.5*(t13831*t5081 + t13820*t5243 + t13672*t6325 + t13667*t6428) + 0.866025*(-1.*t13831*t4370 - 1.*t13820*t4461 - 1.*t13734*t6325 - 1.*t13729*t6428))*var2[22] + (-0.5*(t13809*t4990 + t13797*t5070 + t13656*t6149 + t13648*t6308) - 0.866025*(-1.*t13809*t4209 - 1.*t13797*t4348 - 1.*t13725*t6149 - 1.*t13719*t6308))*var2[23] + (0.5*(t13795*t4827 + t13779*t4947 + t13637*t5969 + t13632*t6127) + 0.866025*(-1.*t13795*t4095 - 1.*t13779*t4169 - 1.*t13714*t5969 - 1.*t13705*t6127))*var2[24]; p_output1[8]=(t14690*t2897 - 1.*t14672*t2849*t5)*var2[0] + (t14690*t2849 + t14672*t2897*t5)*var2[1] + (-1.*t14659*t3031 + t14672*t2911*t3038)*var2[2] + (t4670*(t14704 + t14705 + t14754*t5622 + t14762*t7107 + t14742*t7237 + (t14296*t2911 + t14446*t3031*t3038)*t7434) + t14783*t7860 + t7237*(t14721 + t14723 - 1.*t14742*t4670 - 1.*t14783*t7107 - 1.*(t14373*t2911 + t14366*t3031*t3038)*t7434 - 1.*t14754*t7958) + t14762*t8182)*var2[3] + ((t14374 + t14425 + t14721 + t14723 - 1.*t14431*t3038*t4656 - 1.*t14366*t3038*t6872)*t7671 + (t14440 + t14441 + t14704 + t14705 + t14431*t3038*t5615 + t14446*t3038*t6872)*t8099 + t14366*t5*t8661 + t14446*t5*t8899)*var2[4] + (t10078*t14373 + t5487*(t14374 + t14425 - 1.*t14431*t4652 - 1.*t14366*t6851) + t4610*(t14440 + t14441 + t14431*t5554 + t14446*t6851) + t14296*t9822)*var2[5] + (0.5*(t14421*t5272 + t14415*t5463 + t14291*t6540 + t14286*t6612) + 0.866025*(-1.*t14421*t4486 - 1.*t14415*t4593 - 1.*t14359*t6540 - 1.*t14352*t6612))*var2[21] + (0.5*(t14412*t5081 + t14406*t5243 + t14283*t6325 + t14267*t6428) + 0.866025*(-1.*t14412*t4370 - 1.*t14406*t4461 - 1.*t14347*t6325 - 1.*t14336*t6428))*var2[22] + (-0.5*(t14399*t4990 + t14395*t5070 + t14264*t6149 + t14248*t6308) - 0.866025*(-1.*t14399*t4209 - 1.*t14395*t4348 - 1.*t14333*t6149 - 1.*t14317*t6308))*var2[23] + (0.5*(t14393*t4827 + t14388*t4947 + t14242*t5969 + t14237*t6127) + 0.866025*(-1.*t14393*t4095 - 1.*t14388*t4169 - 1.*t14314*t5969 - 1.*t14310*t6127))*var2[24] + (0.5*(t14386*t4758 + t14382*t4780 + t14233*t5847 + t14220*t5949) + 0.866025*(-1.*t14386*t3891 - 1.*t14382*t4003 - 1.*t14307*t5847 - 1.*t14303*t5949))*var2[25]; p_output1[9]=t15144 + t15152 + t15156 + (t4670*(t15157 + t15158 + t15180*t5622 + t15184*t7107 + t15176*t7237 + (t14872*t2911 + t15000*t3031*t3038)*t7434) + t15194*t7860 + t7237*(t15165 + t15166 - 1.*t15176*t4670 - 1.*t15194*t7107 - 1.*(t14926*t2911 + t14922*t3031*t3038)*t7434 - 1.*t15180*t7958) + t15184*t8182)*var2[3] + ((t14927 + t14982 + t15165 + t15166 - 1.*t14986*t3038*t4656 - 1.*t14922*t3038*t6872)*t7671 + (t14995 + t14997 + t15157 + t15158 + t14986*t3038*t5615 + t15000*t3038*t6872)*t8099 + t14922*t5*t8661 + t15000*t5*t8899)*var2[4] + (t10078*t14926 + t5487*(t14927 + t14982 - 1.*t14986*t4652 - 1.*t14922*t6851) + t4610*(t14995 + t14997 + t14986*t5554 + t15000*t6851) + t14872*t9822)*var2[5] + (0.5*(t14977*t5272 + t14972*t5463 + t14870*t6540 + t14861*t6612) + 0.866025*(-1.*t14977*t4486 - 1.*t14972*t4593 - 1.*t14920*t6540 - 1.*t14913*t6612))*var2[21] + (0.5*(t14970*t5081 + t14963*t5243 + t14857*t6325 + t14853*t6428) + 0.866025*(-1.*t14970*t4370 - 1.*t14963*t4461 - 1.*t14910*t6325 - 1.*t14906*t6428))*var2[22] + (-0.5*(t14961*t4990 + t14957*t5070 + t14851*t6149 + t14845*t6308) - 0.866025*(-1.*t14961*t4209 - 1.*t14957*t4348 - 1.*t14904*t6149 - 1.*t14900*t6308))*var2[23] + (0.5*(t14954*t4827 + t14947*t4947 + t14842*t5969 + t14835*t6127) + 0.866025*(-1.*t14954*t4095 - 1.*t14947*t4169 - 1.*t14896*t5969 - 1.*t14890*t6127))*var2[24] + (0.5*(t14944*t4758 + t14938*t4780 + t14831*t5847 + t14826*t5949) + 0.866025*(-1.*t14944*t3891 - 1.*t14938*t4003 - 1.*t14886*t5847 - 1.*t14881*t5949))*var2[25] + (0.5*(t14936*t4731 + t14930*t4737 + t14823*t5789 + t14815*t5823) + 0.866025*(-1.*t14936*t3675 - 1.*t14930*t3884 - 1.*t14879*t5789 - 1.*t14875*t5823))*var2[26]; p_output1[10]=t15144 + t15152 + t15156 + (t4670*(t15461 + t15462 + t15483*t5622 + t15487*t7107 + t15479*t7237 + (t15433*t2911 + t15454*t3031*t3038)*t7434) + t15500*t7860 + t7237*(t15468 + t15469 - 1.*t15479*t4670 - 1.*t15500*t7107 - 1.*(t15429*t2911 + t15437*t3031*t3038)*t7434 - 1.*t15483*t7958) + t15487*t8182)*var2[3] + ((t15439 + t15447 + t15468 + t15469 - 1.*t15442*t3038*t4656 - 1.*t15437*t3038*t6872)*t7671 + (t15451 + t15456 + t15461 + t15462 + t15442*t3038*t5615 + t15454*t3038*t6872)*t8099 + t15437*t5*t8661 + t15454*t5*t8899)*var2[4] + (t10078*t15429 + t5487*(t15439 + t15447 - 1.*t15442*t4652 - 1.*t15437*t6851) + t4610*(t15451 + t15456 + t15442*t5554 + t15454*t6851) + t15433*t9822)*var2[5] + (0.866025*(-1.*t15408*t4486 - 1.*t15404*t4593 - 1.*t15400*t6540 - 1.*t15396*t6612) + 0.5*(t15408*t5272 + t15404*t5463 + t15420*t6540 + t15416*t6612))*var2[21] + (0.866025*(-1.*t15375*t4370 - 1.*t15371*t4461 - 1.*t15367*t6325 - 1.*t15363*t6428) + 0.5*(t15375*t5081 + t15371*t5243 + t15388*t6325 + t15384*t6428))*var2[22] + (-0.866025*(-1.*t15343*t4209 - 1.*t15339*t4348 - 1.*t15335*t6149 - 1.*t15331*t6308) - 0.5*(t15343*t4990 + t15339*t5070 + t15355*t6149 + t15351*t6308))*var2[23] + (0.866025*(-1.*t15308*t4095 - 1.*t15304*t4169 - 1.*t15300*t5969 - 1.*t15296*t6127) + 0.5*(t15308*t4827 + t15304*t4947 + t15323*t5969 + t15318*t6127))*var2[24] + (0.866025*(-1.*t15275*t3891 - 1.*t15271*t4003 - 1.*t15265*t5847 - 1.*t15261*t5949) + 0.5*(t15275*t4758 + t15271*t4780 + t15287*t5847 + t15283*t5949))*var2[25] + (0.866025*(-1.*t15239*t3675 - 1.*t15226*t3884 - 1.*t15234*t5789 - 1.*t15230*t5823) + 0.5*(t15239*t4731 + t15226*t4737 + t15253*t5789 + t15245*t5823))*var2[26] + (0.866025*(0.05456*t3663*t614 - 0.866025*t5722*t614 + 0.05456*t3557*t752 - 0.866025*t5674*t752) + 0.5*(-0.05456*t4719*t614 - 0.5*t5722*t614 - 0.05456*t4677*t752 - 0.5*t5674*t752))*var2[30]; p_output1[11]=t3202; p_output1[12]=t2849*t3140 + t2817*t2897*t5; p_output1[13]=t3345; p_output1[14]=t4670*t7860 + t7237*t8182; p_output1[15]=t8099*t8661 + t7671*t8899; p_output1[16]=t10078*t4610 + t5487*t9822; p_output1[17]=0.866025*(0.01575 - 1.*t4486*t6540 - 1.*t4593*t6612) + 0.5*(-0.027279787500000003 + t5272*t6540 + t5463*t6612); p_output1[18]=0.866025*(0.01575 - 1.*t4370*t6325 - 1.*t4461*t6428) + 0.5*(-0.027279787500000003 + t5081*t6325 + t5243*t6428); p_output1[19]=-0.866025*(0.01575 - 1.*t4209*t6149 - 1.*t4348*t6308) - 0.5*(-0.027279787500000003 + t4990*t6149 + t5070*t6308); p_output1[20]=0.866025*(0.01575 - 1.*t4095*t5969 - 1.*t4169*t6127) + 0.5*(-0.027279787500000003 + t4827*t5969 + t4947*t6127); p_output1[21]=0.866025*(0.01575 - 1.*t3891*t5847 - 1.*t4003*t5949) + 0.5*(-0.027279787500000003 + t4758*t5847 + t4780*t5949); p_output1[22]=0.866025*(0.01575 - 1.*t3675*t5789 - 1.*t3884*t5823) + 0.5*(-0.027279787500000003 + t4731*t5789 + t4737*t5823); p_output1[23]=0.866025*(0.01575 - 1.*t3557*t5674 - 1.*t3663*t5722) + 0.5*(-0.027279787500000003 + t4677*t5674 + t4719*t5722); p_output1[24]=0.0545599618421; } #ifdef MATLAB_MEX_FILE #include "mex.h" /* * Main function */ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { size_t mrows, ncols; double *var1,*var2; double *p_output1; /* Check for proper number of arguments. */ if( nrhs != 2) { mexErrMsgIdAndTxt("MATLAB:MShaped:invalidNumInputs", "Two input(s) required (var1,var2)."); } else if( nlhs > 1) { mexErrMsgIdAndTxt("MATLAB:MShaped:maxlhs", "Too many output arguments."); } /* The input must be a noncomplex double vector or scaler. */ mrows = mxGetM(prhs[0]); ncols = mxGetN(prhs[0]); if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) || ( !(mrows == 36 && ncols == 1) && !(mrows == 1 && ncols == 36))) { mexErrMsgIdAndTxt( "MATLAB:MShaped:inputNotRealVector", "var1 is wrong."); } mrows = mxGetM(prhs[1]); ncols = mxGetN(prhs[1]); if( !mxIsDouble(prhs[1]) || mxIsComplex(prhs[1]) || ( !(mrows == 36 && ncols == 1) && !(mrows == 1 && ncols == 36))) { mexErrMsgIdAndTxt( "MATLAB:MShaped:inputNotRealVector", "var2 is wrong."); } /* Assign pointers to each input. */ var1 = mxGetPr(prhs[0]); var2 = mxGetPr(prhs[1]); /* Create matrices for return arguments. */ plhs[0] = mxCreateDoubleMatrix((mwSize) 25, (mwSize) 1, mxREAL); p_output1 = mxGetPr(plhs[0]); /* Call the calculation subroutine. */ output1(p_output1,var1,var2); } #else // MATLAB_MEX_FILE #include "J_swing_toe_linear_velocity_y_LeftStance.hh" namespace LeftStance { void J_swing_toe_linear_velocity_y_LeftStance_raw(double *p_output1, const double *var1,const double *var2) { // Call Subroutines output1(p_output1, var1, var2); } } #endif // MATLAB_MEX_FILE
26.587184
1,864
0.663697
prem-chand
ac51bc97c1ffacf6975b4cf6660f38767d3f2de6
20,274
cpp
C++
tests/local_rma.cpp
tehrengruber/GHEX
f164bb625aaa106f77d31d45fce05c4711b066f0
[ "BSD-3-Clause" ]
null
null
null
tests/local_rma.cpp
tehrengruber/GHEX
f164bb625aaa106f77d31d45fce05c4711b066f0
[ "BSD-3-Clause" ]
null
null
null
tests/local_rma.cpp
tehrengruber/GHEX
f164bb625aaa106f77d31d45fce05c4711b066f0
[ "BSD-3-Clause" ]
null
null
null
/* * GridTools * * Copyright (c) 2014-2020, ETH Zurich * All rights reserved. * * Please, refer to the LICENSE file in the root directory. * SPDX-License-Identifier: BSD-3-Clause * */ #include <gtest/gtest.h> #include <thread> #include <array> #include <gridtools/common/array.hpp> #ifndef GHEX_TEST_USE_UCX #include <ghex/transport_layer/mpi/context.hpp> using transport = gridtools::ghex::tl::mpi_tag; #else #include <ghex/transport_layer/ucx/context.hpp> using transport = gridtools::ghex::tl::ucx_tag; #endif #include <ghex/bulk_communication_object.hpp> #include <ghex/structured/pattern.hpp> #include <ghex/structured/rma_range_generator.hpp> #include <ghex/structured/regular/domain_descriptor.hpp> #include <ghex/structured/regular/field_descriptor.hpp> #include <ghex/structured/regular/halo_generator.hpp> struct simulation_1 { #ifdef __CUDACC__ template<typename T> struct cuda_deleter { void operator()(T* ptr) { cudaFree(ptr); } }; #endif template<typename T, std::size_t N> using array_type = gridtools::array<T,N>; using T1 = double; using T2 = float; using T3 = int; using TT1 = array_type<T1,3>; using TT2 = array_type<T2,3>; using TT3 = array_type<T3,3>; using context_type = typename gridtools::ghex::tl::context_factory<transport>::context_type; using context_ptr_type = std::unique_ptr<context_type>; using domain_descriptor_type = gridtools::ghex::structured::regular::domain_descriptor<int,std::integral_constant<int, 3>>; using halo_generator_type = gridtools::ghex::structured::regular::halo_generator<int,std::integral_constant<int, 3>>; template<typename T, typename Arch, int... Is> using field_descriptor_type = gridtools::ghex::structured::regular::field_descriptor<T,Arch,domain_descriptor_type, ::gridtools::layout_map<Is...>>; // decomposition: 4 domains in x-direction, 1 domain in z-direction, rest in y-direction // each MPI rank owns two domains: either first or last two domains in x-direction // // +---------> x // | // | +------<0>------+------<1>------+ // | | +----+ +----+ | +----+ +----+ | // v | | 0 | | 1 | | | 2 | | 3 | | // | +----+ +----+ | +----+ +----+ | // y +------<2>------+------<3>------+ // | +----+ +----+ | +----+ +----+ | // | | 4 | | 5 | | | 6 | | 7 | | // | +----+ +----+ | +----+ +----+ | // +------<4>------+------<5>------+ // | +----+ +----+ | +----+ +----+ | // | | 8 | | 9 | | | 10 | | 11 | | // . . . . . . . . . . . // . . . . . . . . . . . // context_ptr_type context_ptr; context_type& context; const std::array<int,3> local_ext; const std::array<bool,3> periodic; const std::array<int,3> g_first; const std::array<int,3> g_last; const std::array<int,3> offset; const std::array<int,3> local_ext_buffer; const int max_memory; std::vector<TT1> field_1a_raw; std::vector<TT1> field_1b_raw; std::vector<TT2> field_2a_raw; std::vector<TT2> field_2b_raw; std::vector<TT3> field_3a_raw; std::vector<TT3> field_3b_raw; #ifdef __CUDACC__ std::unique_ptr<TT1,cuda_deleter<TT1>> field_1a_raw_gpu; std::unique_ptr<TT1,cuda_deleter<TT1>> field_1b_raw_gpu; std::unique_ptr<TT2,cuda_deleter<TT2>> field_2a_raw_gpu; std::unique_ptr<TT2,cuda_deleter<TT2>> field_2b_raw_gpu; std::unique_ptr<TT3,cuda_deleter<TT3>> field_3a_raw_gpu; std::unique_ptr<TT3,cuda_deleter<TT3>> field_3b_raw_gpu; #endif /* __CUDACC__ */ std::vector<domain_descriptor_type> local_domains; std::array<int,6> halos; halo_generator_type halo_gen; using pattern_type = std::remove_reference_t<decltype( gridtools::ghex::make_pattern<gridtools::ghex::structured::grid>(context, halo_gen, local_domains))>; pattern_type pattern; field_descriptor_type<TT1, gridtools::ghex::cpu, 2, 1, 0> field_1a; field_descriptor_type<TT1, gridtools::ghex::cpu, 2, 1, 0> field_1b; field_descriptor_type<TT2, gridtools::ghex::cpu, 2, 1, 0> field_2a; field_descriptor_type<TT2, gridtools::ghex::cpu, 2, 1, 0> field_2b; field_descriptor_type<TT3, gridtools::ghex::cpu, 2, 1, 0> field_3a; field_descriptor_type<TT3, gridtools::ghex::cpu, 2, 1, 0> field_3b; #ifdef __CUDACC__ field_descriptor_type<TT1, gridtools::ghex::gpu, 2, 1, 0> field_1a_gpu; field_descriptor_type<TT1, gridtools::ghex::gpu, 2, 1, 0> field_1b_gpu; field_descriptor_type<TT2, gridtools::ghex::gpu, 2, 1, 0> field_2a_gpu; field_descriptor_type<TT2, gridtools::ghex::gpu, 2, 1, 0> field_2b_gpu; field_descriptor_type<TT3, gridtools::ghex::gpu, 2, 1, 0> field_3a_gpu; field_descriptor_type<TT3, gridtools::ghex::gpu, 2, 1, 0> field_3b_gpu; #endif /* __CUDACC__ */ typename context_type::communicator_type comm; std::vector<typename context_type::communicator_type> comms; bool mt; using co_type = decltype(gridtools::ghex::make_communication_object<pattern_type>(comm)); std::vector<co_type> basic_cos; std::vector<gridtools::ghex::generic_bulk_communication_object> cos; simulation_1(bool multithread = false) : context_ptr{ gridtools::ghex::tl::context_factory<transport>::create(MPI_COMM_WORLD) } , context{*context_ptr} , local_ext{4,3,2} , periodic{true,true,true} , g_first{0,0,0} , g_last{local_ext[0]*4-1, ((context.size()-1)/2+1)*local_ext[1]-1, local_ext[2]-1} , offset{3,3,3} , local_ext_buffer{local_ext[0]+2*offset[0], local_ext[1]+2*offset[1], local_ext[2]+2*offset[2]} , max_memory{local_ext_buffer[0]*local_ext_buffer[1]*local_ext_buffer[2]} , field_1a_raw(max_memory) , field_1b_raw(max_memory) , field_2a_raw(max_memory) , field_2b_raw(max_memory) , field_3a_raw(max_memory) , field_3b_raw(max_memory) #ifdef __CUDACC__ , field_1a_raw_gpu([this](){ void* ptr; cudaMalloc(&ptr, max_memory*sizeof(TT1)); return (TT1*)ptr; }()) , field_1b_raw_gpu([this](){ void* ptr; cudaMalloc(&ptr, max_memory*sizeof(TT1)); return (TT1*)ptr; }()) , field_2a_raw_gpu([this](){ void* ptr; cudaMalloc(&ptr, max_memory*sizeof(TT2)); return (TT2*)ptr; }()) , field_2b_raw_gpu([this](){ void* ptr; cudaMalloc(&ptr, max_memory*sizeof(TT2)); return (TT2*)ptr; }()) , field_3a_raw_gpu([this](){ void* ptr; cudaMalloc(&ptr, max_memory*sizeof(TT3)); return (TT3*)ptr; }()) , field_3b_raw_gpu([this](){ void* ptr; cudaMalloc(&ptr, max_memory*sizeof(TT3)); return (TT3*)ptr; }()) #endif /* __CUDACC__ */ , local_domains{ domain_descriptor_type{ context.rank()*2, std::array<int,3>{ ((context.rank()%2)*2 )*local_ext[0], (context.rank()/2 )*local_ext[1], 0}, std::array<int,3>{ ((context.rank()%2)*2+1)*local_ext[0]-1, (context.rank()/2+1)*local_ext[1]-1, local_ext[2]-1}}, domain_descriptor_type{ context.rank()*2+1, std::array<int,3>{ ((context.rank()%2)*2+1)*local_ext[0], (context.rank()/2 )*local_ext[1], 0}, std::array<int,3>{ ((context.rank()%2)*2+2)*local_ext[0]-1, (context.rank()/2+1)*local_ext[1]-1, local_ext[2]-1}}} , halos{2,2,2,2,2,2} , halo_gen(g_first, g_last, halos, periodic) , pattern{gridtools::ghex::make_pattern<gridtools::ghex::structured::grid>(context, halo_gen, local_domains)} , field_1a{gridtools::ghex::wrap_field<gridtools::ghex::cpu,::gridtools::layout_map<2,1,0>>(local_domains[0], field_1a_raw.data(), offset, local_ext_buffer)} , field_1b{gridtools::ghex::wrap_field<gridtools::ghex::cpu,::gridtools::layout_map<2,1,0>>(local_domains[1], field_1b_raw.data(), offset, local_ext_buffer)} , field_2a{gridtools::ghex::wrap_field<gridtools::ghex::cpu,::gridtools::layout_map<2,1,0>>(local_domains[0], field_2a_raw.data(), offset, local_ext_buffer)} , field_2b{gridtools::ghex::wrap_field<gridtools::ghex::cpu,::gridtools::layout_map<2,1,0>>(local_domains[1], field_2b_raw.data(), offset, local_ext_buffer)} , field_3a{gridtools::ghex::wrap_field<gridtools::ghex::cpu,::gridtools::layout_map<2,1,0>>(local_domains[0], field_3a_raw.data(), offset, local_ext_buffer)} , field_3b{gridtools::ghex::wrap_field<gridtools::ghex::cpu,::gridtools::layout_map<2,1,0>>(local_domains[1], field_3b_raw.data(), offset, local_ext_buffer)} #ifdef __CUDACC__ , field_1a_gpu{gridtools::ghex::wrap_field<gridtools::ghex::gpu,::gridtools::layout_map<2,1,0>>(local_domains[0], field_1a_raw_gpu.get(), offset, local_ext_buffer)} , field_1b_gpu{gridtools::ghex::wrap_field<gridtools::ghex::gpu,::gridtools::layout_map<2,1,0>>(local_domains[1], field_1b_raw_gpu.get(), offset, local_ext_buffer)} , field_2a_gpu{gridtools::ghex::wrap_field<gridtools::ghex::gpu,::gridtools::layout_map<2,1,0>>(local_domains[0], field_2a_raw_gpu.get(), offset, local_ext_buffer)} , field_2b_gpu{gridtools::ghex::wrap_field<gridtools::ghex::gpu,::gridtools::layout_map<2,1,0>>(local_domains[1], field_2b_raw_gpu.get(), offset, local_ext_buffer)} , field_3a_gpu{gridtools::ghex::wrap_field<gridtools::ghex::gpu,::gridtools::layout_map<2,1,0>>(local_domains[0], field_3a_raw_gpu.get(), offset, local_ext_buffer)} , field_3b_gpu{gridtools::ghex::wrap_field<gridtools::ghex::gpu,::gridtools::layout_map<2,1,0>>(local_domains[1], field_3b_raw_gpu.get(), offset, local_ext_buffer)} #endif /* __CUDACC__ */ , comm{ context.get_serial_communicator() } , mt{multithread} { fill_values(local_domains[0], field_1a); fill_values(local_domains[1], field_1b); fill_values(local_domains[0], field_2a); fill_values(local_domains[1], field_2b); fill_values(local_domains[0], field_3a); fill_values(local_domains[1], field_3b); #ifdef __CUDACC__ cudaMemcpy(field_1a_raw_gpu.get(), field_1a_raw.data(), max_memory*sizeof(TT1), cudaMemcpyHostToDevice); cudaMemcpy(field_1b_raw_gpu.get(), field_1b_raw.data(), max_memory*sizeof(TT1), cudaMemcpyHostToDevice); cudaMemcpy(field_2a_raw_gpu.get(), field_2a_raw.data(), max_memory*sizeof(TT2), cudaMemcpyHostToDevice); cudaMemcpy(field_2b_raw_gpu.get(), field_2b_raw.data(), max_memory*sizeof(TT2), cudaMemcpyHostToDevice); cudaMemcpy(field_3a_raw_gpu.get(), field_3a_raw.data(), max_memory*sizeof(TT3), cudaMemcpyHostToDevice); cudaMemcpy(field_3b_raw_gpu.get(), field_3b_raw.data(), max_memory*sizeof(TT3), cudaMemcpyHostToDevice); #endif /* __CUDACC__ */ if (!mt) { comms.push_back(context.get_communicator()); basic_cos.push_back(gridtools::ghex::make_communication_object<pattern_type>(comms[0])); #ifndef __CUDACC__ auto bco = gridtools::ghex::bulk_communication_object< gridtools::ghex::structured::rma_range_generator, pattern_type, field_descriptor_type<TT1, gridtools::ghex::cpu, 2, 1, 0>, field_descriptor_type<TT2, gridtools::ghex::cpu, 2, 1, 0>, field_descriptor_type<TT3, gridtools::ghex::cpu, 2, 1, 0> > (basic_cos[0]); bco.add_field(pattern(field_1a)); bco.add_field(pattern(field_1b)); bco.add_field(pattern(field_2a)); bco.add_field(pattern(field_2b)); bco.add_field(pattern(field_3a)); bco.add_field(pattern(field_3b)); #else auto bco = gridtools::ghex::bulk_communication_object< gridtools::ghex::structured::rma_range_generator, pattern_type, field_descriptor_type<TT1, gridtools::ghex::gpu, 2, 1, 0>, field_descriptor_type<TT2, gridtools::ghex::gpu, 2, 1, 0>, field_descriptor_type<TT3, gridtools::ghex::gpu, 2, 1, 0> > (basic_cos[0]); bco.add_field(pattern(field_1a_gpu)); bco.add_field(pattern(field_1b_gpu)); bco.add_field(pattern(field_2a_gpu)); bco.add_field(pattern(field_2b_gpu)); bco.add_field(pattern(field_3a_gpu)); bco.add_field(pattern(field_3b_gpu)); #endif cos.emplace_back( std::move(bco) ); } else { comms.push_back(context.get_communicator()); comms.push_back(context.get_communicator()); basic_cos.push_back(gridtools::ghex::make_communication_object<pattern_type>(comms[0])); basic_cos.push_back(gridtools::ghex::make_communication_object<pattern_type>(comms[1])); #ifndef __CUDACC__ auto bco0 = gridtools::ghex::bulk_communication_object< gridtools::ghex::structured::rma_range_generator, pattern_type, field_descriptor_type<TT1, gridtools::ghex::cpu, 2, 1, 0>, field_descriptor_type<TT2, gridtools::ghex::cpu, 2, 1, 0>, field_descriptor_type<TT3, gridtools::ghex::cpu, 2, 1, 0> > (basic_cos[0]); bco0.add_field(pattern(field_1a)); bco0.add_field(pattern(field_2a)); bco0.add_field(pattern(field_3a)); auto bco1 = gridtools::ghex::bulk_communication_object< gridtools::ghex::structured::rma_range_generator, pattern_type, field_descriptor_type<TT1, gridtools::ghex::cpu, 2, 1, 0>, field_descriptor_type<TT2, gridtools::ghex::cpu, 2, 1, 0>, field_descriptor_type<TT3, gridtools::ghex::cpu, 2, 1, 0> > (basic_cos[1]); bco1.add_field(pattern(field_1b)); bco1.add_field(pattern(field_2b)); bco1.add_field(pattern(field_3b)); #else auto bco0 = gridtools::ghex::bulk_communication_object< gridtools::ghex::structured::rma_range_generator, pattern_type, field_descriptor_type<TT1, gridtools::ghex::gpu, 2, 1, 0>, field_descriptor_type<TT2, gridtools::ghex::gpu, 2, 1, 0>, field_descriptor_type<TT3, gridtools::ghex::gpu, 2, 1, 0> > (basic_cos[0]); bco0.add_field(pattern(field_1a_gpu)); bco0.add_field(pattern(field_2a_gpu)); bco0.add_field(pattern(field_3a_gpu)); auto bco1 = gridtools::ghex::bulk_communication_object< gridtools::ghex::structured::rma_range_generator, pattern_type, field_descriptor_type<TT1, gridtools::ghex::gpu, 2, 1, 0>, field_descriptor_type<TT2, gridtools::ghex::gpu, 2, 1, 0>, field_descriptor_type<TT3, gridtools::ghex::gpu, 2, 1, 0> > (basic_cos[1]); bco1.add_field(pattern(field_1b_gpu)); bco1.add_field(pattern(field_2b_gpu)); bco1.add_field(pattern(field_3b_gpu)); #endif cos.emplace_back( std::move(bco0) ); cos.emplace_back( std::move(bco1) ); } } void exchange() { if (!mt) { cos[0].exchange().wait(); } else { std::vector<std::thread> threads; threads.push_back(std::thread{[this]() -> void { cos[0].exchange().wait(); }}); threads.push_back(std::thread{[this]() -> void { cos[1].exchange().wait(); }}); for (auto& t : threads) t.join(); } } bool check() { #ifdef __CUDACC__ cudaMemcpy(field_1a_raw.data(), field_1a_raw_gpu.get(), max_memory*sizeof(TT1), cudaMemcpyDeviceToHost); cudaMemcpy(field_1b_raw.data(), field_1b_raw_gpu.get(), max_memory*sizeof(TT1), cudaMemcpyDeviceToHost); cudaMemcpy(field_2a_raw.data(), field_2a_raw_gpu.get(), max_memory*sizeof(TT2), cudaMemcpyDeviceToHost); cudaMemcpy(field_2b_raw.data(), field_2b_raw_gpu.get(), max_memory*sizeof(TT2), cudaMemcpyDeviceToHost); cudaMemcpy(field_3a_raw.data(), field_3a_raw_gpu.get(), max_memory*sizeof(TT3), cudaMemcpyDeviceToHost); cudaMemcpy(field_3b_raw.data(), field_3b_raw_gpu.get(), max_memory*sizeof(TT3), cudaMemcpyDeviceToHost); #endif /* __CUDACC__ */ bool passed =true; passed = passed && test_values(local_domains[0], field_1a); passed = passed && test_values(local_domains[1], field_1b); passed = passed && test_values(local_domains[0], field_2a); passed = passed && test_values(local_domains[1], field_2b); passed = passed && test_values(local_domains[0], field_3a); passed = passed && test_values(local_domains[1], field_3b); return passed; } private: template<typename Field> void fill_values(const domain_descriptor_type& d, Field& f) { using T = typename Field::value_type::value_type; int xl = 0; for (int x=d.first()[0]; x<=d.last()[0]; ++x, ++xl) { int yl = 0; for (int y=d.first()[1]; y<=d.last()[1]; ++y, ++yl) { int zl = 0; for (int z=d.first()[2]; z<=d.last()[2]; ++z, ++zl) { f(xl,yl,zl) = array_type<T,3>{(T)x,(T)y,(T)z}; } } } } template<typename Field> bool test_values(const domain_descriptor_type& d, const Field& f) { using T = typename Field::value_type::value_type; bool passed = true; const int i = d.domain_id()%2; int rank = comm.rank(); int size = comm.size(); int xl = -halos[0]; int hxl = halos[0]; int hxr = halos[1]; // hack begin: make it work with 1 rank (works with even number of ranks otherwise) if (i==0 && size==1)//comm.rank()%2 == 0 && comm.rank()+1 == comm.size()) { xl = 0; hxl = 0; } if (i==1 && size==1)//comm.rank()%2 == 0 && comm.rank()+1 == comm.size()) { hxr = 0; } // hack end for (int x=d.first()[0]-hxl; x<=d.last()[0]+hxr; ++x, ++xl) { if (i==0 && x<d.first()[0] && !periodic[0]) continue; if (i==1 && x>d.last()[0] && !periodic[0]) continue; T x_wrapped = (((x-g_first[0])+(g_last[0]-g_first[0]+1))%(g_last[0]-g_first[0]+1) + g_first[0]); int yl = -halos[2]; for (int y=d.first()[1]-halos[2]; y<=d.last()[1]+halos[3]; ++y, ++yl) { if (d.domain_id()<2 && y<d.first()[1] && !periodic[1]) continue; if (d.domain_id()>size-3 && y>d.last()[1] && !periodic[1]) continue; T y_wrapped = (((y-g_first[1])+(g_last[1]-g_first[1]+1))%(g_last[1]-g_first[1]+1) + g_first[1]); int zl = -halos[4]; for (int z=d.first()[2]-halos[4]; z<=d.last()[2]+halos[5]; ++z, ++zl) { if (z<d.first()[2] && !periodic[2]) continue; if (z>d.last()[2] && !periodic[2]) continue; T z_wrapped = (((z-g_first[2])+(g_last[2]-g_first[2]+1))%(g_last[2]-g_first[2]+1) + g_first[2]); const auto& value = f(xl,yl,zl); if(value[0]!=x_wrapped || value[1]!=y_wrapped || value[2]!=z_wrapped) { passed = false; std::cout << "(" << xl << ", " << yl << ", " << zl << ") values found != expected: " << "(" << value[0] << ", " << value[1] << ", " << value[2] << ") != " << "(" << x_wrapped << ", " << y_wrapped << ", " << z_wrapped << ") " //<< std::endl; << i << " " << rank << std::endl; } } } } return passed; } }; TEST(local_rma, single) { simulation_1 sim(false); sim.exchange(); sim.exchange(); sim.exchange(); EXPECT_TRUE(sim.check()); } TEST(local_rma, multi) { simulation_1 sim(true); sim.exchange(); sim.exchange(); sim.exchange(); EXPECT_TRUE(sim.check()); }
47.816038
168
0.600523
tehrengruber
ac55c026973d593bb04d9328d5c30a28fa0ef43a
3,267
hpp
C++
NonOpt/src/NonOptDeclarations.hpp
frankecurtis/NonOpt
f81ff1c818dcde382cf6045a671bf8bc1d3a3467
[ "MIT" ]
4
2021-06-27T18:13:59.000Z
2022-01-25T00:36:56.000Z
NonOpt/src/NonOptDeclarations.hpp
frankecurtis/NonOpt
f81ff1c818dcde382cf6045a671bf8bc1d3a3467
[ "MIT" ]
null
null
null
NonOpt/src/NonOptDeclarations.hpp
frankecurtis/NonOpt
f81ff1c818dcde382cf6045a671bf8bc1d3a3467
[ "MIT" ]
1
2021-06-27T18:14:02.000Z
2021-06-27T18:14:02.000Z
// Copyright (C) 2022 Frank E. Curtis // // This code is published under the MIT License. // // Author(s) : Frank E. Curtis #ifndef __NONOPTDECLARATIONS_HPP__ #define __NONOPTDECLARATIONS_HPP__ #include "NonOptException.hpp" namespace NonOpt { /** @name Exceptions */ //@{ /** * NonOpt exceptions */ DECLARE_EXCEPTION(NONOPT_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(NONOPT_OBJECTIVE_SIMILARITY_EXCEPTION); DECLARE_EXCEPTION(NONOPT_OBJECTIVE_TOLERANCE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_CPU_TIME_LIMIT_EXCEPTION); DECLARE_EXCEPTION(NONOPT_ITERATE_NORM_LIMIT_EXCEPTION); DECLARE_EXCEPTION(NONOPT_ITERATION_LIMIT_EXCEPTION); DECLARE_EXCEPTION(NONOPT_FUNCTION_EVALUATION_LIMIT_EXCEPTION); DECLARE_EXCEPTION(NONOPT_GRADIENT_EVALUATION_LIMIT_EXCEPTION); DECLARE_EXCEPTION(NONOPT_APPROXIMATE_HESSIAN_UPDATE_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_DERIVATIVE_CHECKER_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_DIRECTION_COMPUTATION_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_FUNCTION_EVALUATION_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_FUNCTION_EVALUATION_ASSERT_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_GRADIENT_EVALUATION_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_GRADIENT_EVALUATION_ASSERT_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_LINE_SEARCH_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_POINT_SET_UPDATE_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_PROBLEM_DATA_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_SYMMETRIC_MATRIX_ASSERT_EXCEPTION); DECLARE_EXCEPTION(NONOPT_TERMINATION_FAILURE_EXCEPTION); DECLARE_EXCEPTION(NONOPT_VECTOR_ASSERT_EXCEPTION); /** * Approximate Hessian update exceptions */ DECLARE_EXCEPTION(AH_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(AH_EVALUATION_FAILURE_EXCEPTION); DECLARE_EXCEPTION(AH_NORM_TOLERANCE_VIOLATION_EXCEPTION); DECLARE_EXCEPTION(AH_PRODUCT_TOLERANCE_VIOLATION_EXCEPTION); /** * Derivative checker exceptions */ DECLARE_EXCEPTION(DE_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(DE_FAILURE_EXCEPTION); /** * Direction computation exceptions */ DECLARE_EXCEPTION(DC_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(DC_CPU_TIME_LIMIT_EXCEPTION); DECLARE_EXCEPTION(DC_EVALUATION_FAILURE_EXCEPTION); DECLARE_EXCEPTION(DC_ITERATION_LIMIT_EXCEPTION); DECLARE_EXCEPTION(DC_QP_FAILURE_EXCEPTION); /** * Line search exceptions */ DECLARE_EXCEPTION(LS_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(LS_EVALUATION_FAILURE_EXCEPTION); DECLARE_EXCEPTION(LS_INTERVAL_TOO_SMALL_EXCEPTION); DECLARE_EXCEPTION(LS_ITERATION_LIMIT_EXCEPTION); DECLARE_EXCEPTION(LS_STEPSIZE_TOO_SMALL_EXCEPTION); /** * Point set update exceptions */ DECLARE_EXCEPTION(PS_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(PS_FAILURE_EXCEPTION); /** * QP solver exceptions */ DECLARE_EXCEPTION(QP_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(QP_CPU_TIME_LIMIT_EXCEPTION); DECLARE_EXCEPTION(QP_FACTORIZATION_ERROR_EXCEPTION); DECLARE_EXCEPTION(QP_INPUT_ERROR_EXCEPTION); DECLARE_EXCEPTION(QP_ITERATION_LIMIT_EXCEPTION); DECLARE_EXCEPTION(QP_NAN_ERROR_EXCEPTION); /** * Symmetric matrix exceptions */ DECLARE_EXCEPTION(SM_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(SM_FAILURE_EXCEPTION); /** * Termination exceptions */ DECLARE_EXCEPTION(TE_SUCCESS_EXCEPTION); DECLARE_EXCEPTION(TE_EVALUATION_FAILURE_EXCEPTION); //@} } // namespace NonOpt #endif /* __NONOPTDECLARATIONS_HPP__ */
33.336735
71
0.87083
frankecurtis
ac58cf061ed70b7dfa63ab56eb4f5a2748a7e370
5,274
cpp
C++
Chapter_8_Advanced_Topics/8.7_Problem_Decomposition/kattis_umbraldecoding.cpp
BrandonTang89/CP4_Code
5114471f439978dd11f6f2cbf6af20ca654593da
[ "MIT" ]
2
2021-12-29T04:12:59.000Z
2022-03-30T09:32:19.000Z
Chapter_8_Advanced_Topics/8.7_Problem_Decomposition/kattis_umbraldecoding.cpp
BrandonTang89/CP4_Code
5114471f439978dd11f6f2cbf6af20ca654593da
[ "MIT" ]
null
null
null
Chapter_8_Advanced_Topics/8.7_Problem_Decomposition/kattis_umbraldecoding.cpp
BrandonTang89/CP4_Code
5114471f439978dd11f6f2cbf6af20ca654593da
[ "MIT" ]
1
2022-03-01T06:12:46.000Z
2022-03-01T06:12:46.000Z
/**Kattis - umbraldecoding * A question that is simple in theory, but hard in practise. The hint given is recursive subdivision. Ie, we * for a given umbra and rectangle, we try to cut away all the umbra parts of the rectangle. If the rectangle * is completely in the umbra, we ignore it. If its completely out of the umbra, we add it to our output. Else, * we cut the rectangle into 4 almost equally sized parts and repeat. The key challenge is determining if the * rectangle is completely in the umbra or completely out of the umbra. The first can be achieved by observing * that if all 4 corners of the rectangle are in the umbra, then the rectangle is in the umbra. The second can be * done by first determining the point on the rectangle with the lowest value of abs(x-p)^3 + abs(y-q)^3. I first * used some super complex times of ternary search to achieve this, but it didn't work with large numbers well. * I then realised that we can just check if the center of the umbra is in the rectangle, if so then we definitely * are not out of the umbra. else the lowest point will be the point on the rectangle's border which is closest * to the center of the umbra. Then we just check if this point is inside the umbra. * * To check if a point is inside the umbra, note that we should check if the point is super far away and if so, * don't continue checking (since the check will overflow and its obviously impossible for the point to be in the * umbra). * * Time: O(?), Space: O(?) */ #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; #define fast_cin() \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); ll val(tuple<int, int, int> safe_pt, int x, int y) { auto [p, q, b] = safe_pt; return (ll)abs(x - p) * (ll)abs(x - p) * (ll)abs(x - p) + (ll)abs(y - q) * (ll)abs(y - q) * (ll)abs(y - q); } bool inside(tuple<int, int, int> safe_pt, int x, int y) { return (val(safe_pt, x, y) <= (ll)get<2>(safe_pt)); } bool point_in_rect(tuple<int, int, int> pt, tuple<int, int, int, int> rect) { auto [x, y, b] = pt; auto [x1, y1, x2, y2] = rect; return (x >= x1 && x <= x2 && y >= y1 && y <= y2); } pair<int, int> get_lowest_point2(tuple<int, int, int> safe_pt, tuple<int, int, int, int> rect) { auto [x0, y0, x1, y1] = rect; auto [p, q, b] = safe_pt; int x, y; if (x0 <= p && p <= x1) { x = p; } else if (x0 > p) { x = x0; } else { x = x1; } if (y0 <= q && q <= y1) { y = q; } else if (y0 > q) { y = y0; } else { y = y1; } return {x, y}; } void process_rect(vector<tuple<int, int, int, int>> &dest_rects, tuple<int, int, int, int> rect, int p, int q, int b) { auto [x0, y0, x1, y1] = rect; // cout << "dealing with : " << x0 << " " << y0 << " " << x1 << " " << y1 << endl; // if the entire rect is inside the umbra, just ignore vector<pair<int, int>> corners = {{x0, y0}, {x0, y1}, {x1, y0}, {x1, y1}}; bool all_inside = true; for (auto [x, y] : corners) { if (abs(x - p) + abs(y - q) > 1000 || !inside(make_tuple(p, q, b), x, y)) { all_inside = false; break; } } if (all_inside) { return; } // if the rect is completely outside the umbra, just add it if (!point_in_rect(make_tuple(p, q, b), rect)) { // check for obviously outside the umbra auto lowest = get_lowest_point2(make_tuple(p, q, b), rect); if (abs(lowest.first - p) + abs(lowest.second - q) > 1000 || !inside(make_tuple(p, q, b), lowest.first, lowest.second)) { dest_rects.push_back(rect); return; } } // if the rect is partially inside the umbra, split it // cout << "splitting" << endl; int half_x = (x0 + x1) / 2, half_y = (y0 + y1) / 2; process_rect(dest_rects, make_tuple(x0, y0, half_x, half_y), p, q, b); if (half_x + 1 <= x1) { process_rect(dest_rects, make_tuple(half_x + 1, y0, x1, half_y), p, q, b); } if (half_y + 1 <= y1) { process_rect(dest_rects, make_tuple(x0, half_y + 1, half_x, y1), p, q, b); } if (half_x + 1 <= x1 && half_y + 1 <= y1) { process_rect(dest_rects, make_tuple(half_x + 1, half_y + 1, x1, y1), p, q, b); } } vector<tuple<int, int, int, int>> rects1, rects2; int n, k; int main() { cin >> n >> k; int p, q, b; rects1.push_back({0, 0, n, n}); for (int i = 0; i < k; i++) { auto &source_rects = (i % 2 == 0) ? rects1 : rects2; auto &dest_rects = (i % 2 == 0) ? rects2 : rects1; cin >> p >> q >> b; dest_rects.clear(); for (auto rect : source_rects) { process_rect(dest_rects, rect, p, q, b); } } auto &final_rects = (k % 2 == 0) ? rects1 : rects2; ll ans = 0; for (auto &rect : final_rects) { auto &[x0, y0, x1, y1] = rect; ans += ((ll)x1 - x0 + 1) * ((ll)y1 - y0 + 1); } cout << ans << endl; return 0; }
37.671429
114
0.575465
BrandonTang89
ac5ea52c9afcfe26282ea760f82a4e5a0d2f5b4b
5,199
cpp
C++
image_tools/src/cv_mat_sensor_msgs_image_type_adapter.cpp
swgu931/demos
3af19c93c7abd9a83caca47de0780e941faeb22b
[ "Apache-2.0" ]
1
2021-05-17T02:06:11.000Z
2021-05-17T02:06:11.000Z
image_tools/src/cv_mat_sensor_msgs_image_type_adapter.cpp
swgu931/demos
3af19c93c7abd9a83caca47de0780e941faeb22b
[ "Apache-2.0" ]
null
null
null
image_tools/src/cv_mat_sensor_msgs_image_type_adapter.cpp
swgu931/demos
3af19c93c7abd9a83caca47de0780e941faeb22b
[ "Apache-2.0" ]
null
null
null
// Copyright 2021 Open Source Robotics Foundation, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <memory> #include <string> #include <utility> #include <variant> // NOLINT[build/include_order] #include "sensor_msgs/msg/image.hpp" #include "std_msgs/msg/header.hpp" #include "image_tools/cv_mat_sensor_msgs_image_type_adapter.hpp" namespace image_tools { namespace { int encoding2mat_type(const std::string & encoding) { if (encoding == "mono8") { return CV_8UC1; } else if (encoding == "bgr8") { return CV_8UC3; } else if (encoding == "mono16") { return CV_16SC1; } else if (encoding == "rgba8") { return CV_8UC4; } else if (encoding == "bgra8") { return CV_8UC4; } else if (encoding == "32FC1") { return CV_32FC1; } else if (encoding == "rgb8") { return CV_8UC3; } else if (encoding == "yuv422") { return CV_8UC2; } else { throw std::runtime_error("Unsupported encoding type"); } } template<typename T> struct NotNull { NotNull(const T * pointer_in, const char * msg) : pointer(pointer_in) { if (pointer == nullptr) { throw std::invalid_argument(msg); } } const T * pointer; }; } // namespace ROSCvMatContainer::ROSCvMatContainer( std::unique_ptr<sensor_msgs::msg::Image> unique_sensor_msgs_image) : header_(NotNull( unique_sensor_msgs_image.get(), "unique_sensor_msgs_image cannot be nullptr" ).pointer->header), frame_( unique_sensor_msgs_image->height, unique_sensor_msgs_image->width, encoding2mat_type(unique_sensor_msgs_image->encoding), unique_sensor_msgs_image->data.data(), unique_sensor_msgs_image->step), storage_(std::move(unique_sensor_msgs_image)) {} ROSCvMatContainer::ROSCvMatContainer( std::shared_ptr<sensor_msgs::msg::Image> shared_sensor_msgs_image) : header_(shared_sensor_msgs_image->header), frame_( shared_sensor_msgs_image->height, shared_sensor_msgs_image->width, encoding2mat_type(shared_sensor_msgs_image->encoding), shared_sensor_msgs_image->data.data(), shared_sensor_msgs_image->step), storage_(shared_sensor_msgs_image) {} ROSCvMatContainer::ROSCvMatContainer( const cv::Mat & mat_frame, const std_msgs::msg::Header & header, bool is_bigendian) : header_(header), frame_(mat_frame), storage_(nullptr), is_bigendian_(is_bigendian) {} ROSCvMatContainer::ROSCvMatContainer( cv::Mat && mat_frame, const std_msgs::msg::Header & header, bool is_bigendian) : header_(header), frame_(std::forward<cv::Mat>(mat_frame)), storage_(nullptr), is_bigendian_(is_bigendian) {} ROSCvMatContainer::ROSCvMatContainer( const sensor_msgs::msg::Image & sensor_msgs_image) : ROSCvMatContainer(std::make_unique<sensor_msgs::msg::Image>(sensor_msgs_image)) {} bool ROSCvMatContainer::is_owning() const { return std::holds_alternative<nullptr_t>(storage_); } const cv::Mat & ROSCvMatContainer::cv_mat() const { return frame_; } cv::Mat ROSCvMatContainer::cv_mat() { return frame_; } const std_msgs::msg::Header & ROSCvMatContainer::header() const { return header_; } std_msgs::msg::Header & ROSCvMatContainer::header() { return header_; } std::shared_ptr<const sensor_msgs::msg::Image> ROSCvMatContainer::get_sensor_msgs_msg_image_pointer() const { if (!std::holds_alternative<std::shared_ptr<sensor_msgs::msg::Image>>(storage_)) { return nullptr; } return std::get<std::shared_ptr<sensor_msgs::msg::Image>>(storage_); } std::unique_ptr<sensor_msgs::msg::Image> ROSCvMatContainer::get_sensor_msgs_msg_image_pointer_copy() const { auto unique_image = std::make_unique<sensor_msgs::msg::Image>(); this->get_sensor_msgs_msg_image_copy(*unique_image); return unique_image; } void ROSCvMatContainer::get_sensor_msgs_msg_image_copy( sensor_msgs::msg::Image & sensor_msgs_image) const { sensor_msgs_image.height = frame_.rows; sensor_msgs_image.width = frame_.cols; switch (frame_.type()) { case CV_8UC1: sensor_msgs_image.encoding = "mono8"; break; case CV_8UC3: sensor_msgs_image.encoding = "bgr8"; break; case CV_16SC1: sensor_msgs_image.encoding = "mono16"; break; case CV_8UC4: sensor_msgs_image.encoding = "rgba8"; break; default: throw std::runtime_error("unsupported encoding type"); } sensor_msgs_image.step = static_cast<sensor_msgs::msg::Image::_step_type>(frame_.step); size_t size = frame_.step * frame_.rows; sensor_msgs_image.data.resize(size); memcpy(&sensor_msgs_image.data[0], frame_.data, size); sensor_msgs_image.header = header_; } bool ROSCvMatContainer::is_bigendian() const { return is_bigendian_; } } // namespace image_tools
25.360976
89
0.727255
swgu931
ac60bc98616bb2b1e6daa39cb231744e40d510af
4,767
cpp
C++
modules/trivia/cmd_ping.cpp
brainboxdotcc/triviabot
d074256f38a002bfb9d352c4f80bc45f19a71384
[ "Apache-2.0" ]
23
2020-06-28T18:07:03.000Z
2022-03-02T20:12:47.000Z
modules/trivia/cmd_ping.cpp
brainboxdotcc/triviabot
d074256f38a002bfb9d352c4f80bc45f19a71384
[ "Apache-2.0" ]
4
2020-10-08T13:37:39.000Z
2022-03-26T22:41:19.000Z
modules/trivia/cmd_ping.cpp
brainboxdotcc/triviabot
d074256f38a002bfb9d352c4f80bc45f19a71384
[ "Apache-2.0" ]
13
2020-10-08T13:32:02.000Z
2021-12-02T00:00:28.000Z
/************************************************************************************ * * TriviaBot, The trivia bot for discord based on Fruitloopy Trivia for ChatSpike IRC * * Copyright 2004 Craig Edwards <support@brainbox.cc> * * Core based on Sporks, the Learning Discord Bot, Craig Edwards (c) 2019. * * 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 <dpp/dpp.h> #include <fmt/format.h> #include <sporks/modules.h> #include <sporks/regex.h> #include <string> #include <cstdint> #include <fstream> #include <streambuf> #include <sporks/stringops.h> #include <sporks/statusfield.h> #include <sporks/database.h> #include "state.h" #include "trivia.h" #include "webrequest.h" #include "commands.h" command_ping_t::command_ping_t(class TriviaModule* _creator, const std::string &_base_command, bool adm, const std::string& descr, std::vector<dpp::command_option> options) : command_t(_creator, _base_command, adm, descr, options) { } void command_ping_t::call(const in_cmd &cmd, std::stringstream &tokens, guild_settings_t &settings, const std::string &username, bool is_moderator, dpp::channel* c, dpp::user* user) { /* Get REST and DB ping times. REST time is given to us by D++, get simple DB time by timing a query */ dpp::cluster* cluster = this->creator->GetBot()->core; double discord_api_ping = cluster->rest_ping * 1000; double start = dpp::utility::time_f(); db::resultset q = db::query("SHOW TABLES", {}); double db_ping = (dpp::utility::time_f() - start) * 1000; start = dpp::utility::time_f(); /* Get TriviaBot API time by timing an arbitrary request */ cluster->request(std::string(creator->GetBot()->IsDevMode() ? BACKEND_HOST_DEV : BACKEND_HOST_LIVE) + "/api/", dpp::m_get, [cluster, discord_api_ping, start, db_ping, this, cmd, settings](auto callback) { double tb_api_ping = (dpp::utility::time_f() - start) * 1000; bool shardstatus = true; long lastcluster = -1; std::vector<field_t> fields = { {_("DISCPING", settings), fmt::format("{:.02f} ms\n<:blank:667278047006949386>", discord_api_ping), true }, {_("APIPING", settings), fmt::format("{:.02f} ms\n<:blank:667278047006949386>", tb_api_ping), true }, {_("DBPING", settings), fmt::format("{:.02f} ms\n<:blank:667278047006949386>", db_ping), true }, }; field_t f; std::string desc; /* Get shards from database, as we can't directly see shards on other clusters */ db::resultset shardq = db::query("SELECT * FROM infobot_shard_status ORDER BY cluster_id, id", {}); for (auto & shard : shardq) { /* Arrange shards by cluster, each cluster in an embed field */ if (lastcluster != std::stol(shard["cluster_id"])) { if (lastcluster != -1) { if (f.value.empty()) { f.value = "(error)"; } fields.push_back(f); } f = { _("CLUSTER", settings) + " " + shard["cluster_id"], "", true }; } /* Green circle: Shard UP * Wrench emoji: Shard down for less than 15 mins; Under maintainence * Red circle: Shard down over 15 mins; DOWN */ try { lastcluster = std::stol(shard["cluster_id"]); uint64_t ds = stoull(shard["down_since"]); uint32_t sid = std::stoul(shard["id"]); f.value += "`" + fmt::format("{:02d}", sid) + "`: " + (shard["connected"] == "1" && shard["online"] == "1" ? ":green_circle: ": (shard["down_since"].empty() && time(nullptr) - ds > 60 * 15 ? ":red_circle: " : "<:wrench:546395191892901909> ")) + "\n"; if (shard["connected"] == "0" || shard["online"] == "0") { shardstatus = false; } } catch (const std::exception &) { } } if (f.value.empty()) { f.value = "(error)"; } fields.push_back(f); creator->EmbedWithFields( cmd.interaction_token, cmd.command_id, settings, _("PONG", settings), fields, cmd.channel_id, "https://triviabot.co.uk/", "", "", ":ping_pong: " + ((shardstatus == true && tb_api_ping < 200 && discord_api_ping < 800 && db_ping < 3 ? _("OKPING", settings) : _("BADPING", settings))) + "\n\n**" + _("PINGKEY", settings) + "**\n<:blank:667278047006949386>" ); creator->CacheUser(cmd.author_id, cmd.user, cmd.member, cmd.channel_id); }); }
45.4
254
0.634571
brainboxdotcc
ac632f73acca4ed129cbe6e7824e8fdcf53f23aa
525
cpp
C++
acwing/91.cpp
PIPIKAI/ACM
b8e4416a29c0619946c9b73b0fe5699b6e96e782
[ "MIT" ]
null
null
null
acwing/91.cpp
PIPIKAI/ACM
b8e4416a29c0619946c9b73b0fe5699b6e96e782
[ "MIT" ]
null
null
null
acwing/91.cpp
PIPIKAI/ACM
b8e4416a29c0619946c9b73b0fe5699b6e96e782
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; const int maxn=20+7,maxm=1<<20; int n; int dp[maxm][maxn],w[maxn][maxn]; int main(int argc, char const *argv[]) { cin>>n; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cin>>w[i][j]; } } memset(dp,0x3f,sizeof(dp)); dp[1][0]=0; for(int i=0;i<1<<n;i++){ for(int j=0;j<n;j++){ if(i>>j & 1){ for(int k=0;k<n;k++){ if(i^(1<<j) >> k & 1){ dp[i][j]=min(dp[i][j],dp[i^(1<<j)][k]+w[k][j]); } } } } } cout<<dp[(1<<n)-1][n-1]<<endl; return 0; }
18.103448
53
0.481905
PIPIKAI
ac653b32c826c812cd7dd162bd50f2ffd44a7415
2,507
hh
C++
neb/inc/com/centreon/logging/file.hh
sdelafond/centreon-broker
21178d98ed8a061ca71317d23c2026dbc4edaca2
[ "Apache-2.0" ]
null
null
null
neb/inc/com/centreon/logging/file.hh
sdelafond/centreon-broker
21178d98ed8a061ca71317d23c2026dbc4edaca2
[ "Apache-2.0" ]
null
null
null
neb/inc/com/centreon/logging/file.hh
sdelafond/centreon-broker
21178d98ed8a061ca71317d23c2026dbc4edaca2
[ "Apache-2.0" ]
null
null
null
/* ** Copyright 2011-2014 Centreon ** ** 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. ** ** For more information : contact@centreon.com */ #ifndef CC_LOGGING_FILE_HH # define CC_LOGGING_FILE_HH # include <cstdio> # include <string> # include "com/centreon/logging/backend.hh" # include "com/centreon/namespace.hh" CC_BEGIN() namespace logging { /** * @class file file.hh "com/centreon/logging/file.hh" * @brief Log messages to file. */ class file : public backend { public: file( FILE* file, bool is_sync = true, bool show_pid = true, time_precision show_timestamp = second, bool show_thread_id = false, long long max_size = 0); file( std::string const& path, bool is_sync = true, bool show_pid = true, time_precision show_timestamp = second, bool show_thread_id = false, long long max_size = 0); virtual ~file() throw (); void close() throw (); std::string const& filename() const throw (); void log( unsigned long long types, unsigned int verbose, char const* msg, unsigned int size) throw (); void open(); void reopen(); protected: virtual void _max_size_reached(); private: file(file const& right); file& operator=(file const& right); void _flush() throw (); long long _max_size; std::string _path; FILE* _out; long long _size; }; } CC_END() #endif // !CC_LOGGING_FILE_HH
31.734177
75
0.523734
sdelafond
ac6f2ae80439a44b9a8967181f581e1ae4ea4350
3,933
cc
C++
src/buffer.cc
libattachsql/libattachsql
7b82164efd09292a62f086a05bd6401ce8c23167
[ "Apache-2.0" ]
25
2015-01-14T07:47:57.000Z
2017-11-07T01:42:21.000Z
src/buffer.cc
libattachsql/libattachsql
7b82164efd09292a62f086a05bd6401ce8c23167
[ "Apache-2.0" ]
25
2015-01-11T23:56:12.000Z
2020-08-28T15:10:08.000Z
src/buffer.cc
libattachsql/libattachsql
7b82164efd09292a62f086a05bd6401ce8c23167
[ "Apache-2.0" ]
16
2015-02-24T18:30:30.000Z
2018-03-28T15:29:07.000Z
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * Copyright 2014 Hewlett-Packard Development Company, L.P. * * 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 "config.h" #include "common.h" #include "buffer.h" #include <stdio.h> #include <string.h> #include <stdlib.h> buffer_st *attachsql_buffer_create() { buffer_st *buffer; buffer= new (std::nothrow) buffer_st; if (buffer == NULL) { return NULL; } buffer->buffer= (char*)malloc(ATTACHSQL_DEFAULT_BUFFER_SIZE); if (buffer->buffer == NULL) { delete buffer; return NULL; } buffer->buffer_read_ptr= buffer->buffer; buffer->buffer_write_ptr= buffer->buffer; buffer->buffer_size= ATTACHSQL_DEFAULT_BUFFER_SIZE; return buffer; } void attachsql_buffer_free(buffer_st *buffer) { free(buffer->buffer); delete buffer; } size_t attachsql_buffer_get_available(buffer_st *buffer) { if (buffer == NULL) { return 0; } return buffer->buffer_size - ((size_t)(buffer->buffer_read_ptr - buffer->buffer) + buffer->buffer_used); } attachsql_ret_t attachsql_buffer_increase(buffer_st *buffer) { if (buffer == NULL) { return ATTACHSQL_RET_PARAMETER_ERROR; } size_t buffer_available= attachsql_buffer_get_available(buffer); /* if the we have lots of stale data just shift * algorithm for this at the moment is if only half the buffer is available * move it */ if (buffer_available + buffer->buffer_used < (buffer->buffer_size / 2)) { memmove(buffer->buffer, buffer->buffer_read_ptr, buffer->buffer_used); buffer->buffer_write_ptr= buffer->buffer + buffer->buffer_used; } else { size_t buffer_write_size= buffer->buffer_write_ptr - buffer->buffer; size_t buffer_read_size= buffer->buffer_read_ptr - buffer->buffer; size_t packet_end_size; if (buffer->packet_end_ptr != NULL) { packet_end_size= buffer->packet_end_ptr - buffer->buffer; } else { packet_end_size= 0; } size_t new_size= buffer->buffer_size * 2; char *realloc_buffer= (char*)realloc(buffer->buffer, new_size); if (realloc_buffer == NULL) { return ATTACHSQL_RET_OUT_OF_MEMORY_ERROR; } buffer->buffer_size= new_size; buffer->buffer= realloc_buffer; /* Move pointers because buffer may have moved in RAM */ buffer->buffer_write_ptr= realloc_buffer + buffer_write_size; buffer->buffer_read_ptr= realloc_buffer + buffer_read_size; buffer->packet_end_ptr= realloc_buffer + packet_end_size; } return ATTACHSQL_RET_OK; } /* Moves the write pointer and returns the amount of unread data in the buffer */ void attachsql_buffer_move_write_ptr(buffer_st *buffer, size_t len) { buffer->buffer_write_ptr+= len; buffer->buffer_used+= len; } size_t attachsql_buffer_unread_data(buffer_st *buffer) { return (size_t)(buffer->buffer_write_ptr - buffer->buffer_read_ptr); } void attachsql_buffer_packet_read_end(buffer_st *buffer) { // If the buffer is now empty, reset it. Otherwise make sure the read ptr // points to the end of the packet. Should maybe move this to buffer.cc if (buffer->packet_end_ptr == buffer->buffer_write_ptr) { asdebug("Truncating buffer"); buffer->buffer_read_ptr= buffer->buffer; buffer->buffer_write_ptr= buffer->buffer; buffer->buffer_used= 0; buffer->packet_end_ptr= buffer->buffer; } else { buffer->buffer_read_ptr= buffer->packet_end_ptr; } }
27.697183
106
0.720315
libattachsql
ac70d504b1c0e1e0db989e94b45fb4d284ee9c44
1,551
cpp
C++
source/main-http-ipv6.cpp
EmbeddedPlanet/mbed-os-example-http
e1f7713462f0ce16f555770c9eb8370b3ff6bb21
[ "MIT" ]
null
null
null
source/main-http-ipv6.cpp
EmbeddedPlanet/mbed-os-example-http
e1f7713462f0ce16f555770c9eb8370b3ff6bb21
[ "MIT" ]
null
null
null
source/main-http-ipv6.cpp
EmbeddedPlanet/mbed-os-example-http
e1f7713462f0ce16f555770c9eb8370b3ff6bb21
[ "MIT" ]
null
null
null
#include "select-demo.h" #if DEMO == DEMO_HTTP_IPV6 #include "mbed.h" #include "network-helper.h" #include "http_request.h" void dump_response(HttpResponse* res) { printf("Status: %d - %s\n", res->get_status_code(), res->get_status_message().c_str()); printf("Headers:\n"); for (size_t ix = 0; ix < res->get_headers_length(); ix++) { printf("\t%s: %s\n", res->get_headers_fields()[ix]->c_str(), res->get_headers_values()[ix]->c_str()); } printf("\nBody (%d bytes):\n\n%s\n", res->get_body_length(), res->get_body_as_string().c_str()); } int main() { NetworkInterface* network = connect_to_default_network_interface(); if (!network) { printf("Cannot connect to the network, see serial output\n"); return 1; } // Do a GET request to icanhazip.com which returns the public IPv6 address for the device // This page is only accessible over IPv6 { // By default the body is automatically parsed and stored in a buffer, this is memory heavy. // To receive chunked response, pass in a callback as last parameter to the constructor. HttpRequest* get_req = new HttpRequest(network, HTTP_GET, "http://ipv6.icanhazip.com"); HttpResponse* get_res = get_req->send(); if (!get_res) { printf("HttpRequest failed (error code %d)\n", get_req->get_error()); return 1; } printf("\n----- HTTP GET response -----\n"); dump_response(get_res); delete get_req; } wait(osWaitForever); } #endif
31.653061
109
0.631206
EmbeddedPlanet
ac73ca9b3d1ceac2d0918cce6430fc39232d48de
677
cc
C++
benchmarks/timer_event_loop.cc
toffaletti/libten
00c6dcc91c8d769c74ed9063277b1120c9084427
[ "Apache-2.0" ]
23
2015-02-28T12:51:54.000Z
2021-07-21T10:34:20.000Z
benchmarks/timer_event_loop.cc
toffaletti/libten
00c6dcc91c8d769c74ed9063277b1120c9084427
[ "Apache-2.0" ]
1
2015-04-26T05:44:18.000Z
2015-04-26T05:44:18.000Z
benchmarks/timer_event_loop.cc
toffaletti/libten
00c6dcc91c8d769c74ed9063277b1120c9084427
[ "Apache-2.0" ]
8
2015-05-04T08:04:11.000Z
2020-09-07T11:30:56.000Z
#include "ten/task.hh" #include "ten/descriptors.hh" #include <iostream> using namespace ten; using namespace std::chrono; static void yield_task() { uint64_t counter = 0; task::spawn([&] { for (;;) { this_task::yield(); ++counter; } }); for (;;) { this_task::sleep_for(seconds{1}); std::cout << "counter: " << counter << "\n"; counter = 0; } } int main() { return task::main([] { task::spawn(yield_task); for (int i=0; i<1000; ++i) { task::spawn([] { this_task::sleep_for(milliseconds{random() % 1000}); }); } }); }
19.911765
68
0.480059
toffaletti
ac797247f8bce3a9b5dec447c4db6216ae5e039f
13,010
cpp
C++
GIOVANNI/gambatte/gambatte_qt/src/framework/src/videodialog.cpp
ReallyEvilFish/1234
d4f77bf2177c381e07d596aa425bc1a048305c03
[ "MIT" ]
9
2021-02-03T05:44:48.000Z
2022-03-19T12:42:52.000Z
GIOVANNI/gambatte/gambatte_qt/src/framework/src/videodialog.cpp
ReallyEvilFish/1234
d4f77bf2177c381e07d596aa425bc1a048305c03
[ "MIT" ]
5
2020-08-09T13:04:51.000Z
2022-03-25T11:41:48.000Z
GIOVANNI/gambatte/gambatte_qt/src/framework/src/videodialog.cpp
Manurocker95/GiovanniEmulator
d4f77bf2177c381e07d596aa425bc1a048305c03
[ "MIT" ]
null
null
null
// // Copyright (C) 2007 by sinamas <sinamas at users.sourceforge.net> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License version 2 for more details. // // You should have received a copy of the GNU General Public License // version 2 along with this program; if not, write to the // Free Software Foundation, Inc., // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. // #include "videodialog.h" #include "blitterconf.h" #include "mainwindow.h" #include <QComboBox> #include <QGroupBox> #include <QHBoxLayout> #include <QLabel> #include <QPushButton> #include <QRadioButton> #include <QSettings> #include <QVBoxLayout> #include <functional> VideoDialog::ScalingMethodSelector::ScalingMethodSelector(QWidget *parent) : unrestrictedScalingButton_(new QRadioButton(QObject::tr("None"), parent)) , keepRatioButton_(new QRadioButton(QObject::tr("Keep aspect ratio"), parent)) , integerScalingButton_(new QRadioButton(QObject::tr("Only scale by integer factors"), parent)) , scaling_(ScalingMethod(filterValue(QSettings().value("video/scalingType", scaling_keep_ratio).toInt(), num_scaling_methods, 0, scaling_keep_ratio))) { reject(); } VideoDialog::ScalingMethodSelector::~ScalingMethodSelector() { QSettings settings; settings.setValue("video/scalingType", scaling_); } void VideoDialog::ScalingMethodSelector::addToLayout(QLayout *const containingLayout) { QGroupBox *const groupBox = addWidget(containingLayout, new QGroupBox(QObject::tr("Scaling restrictions"))); groupBox->setLayout(new QVBoxLayout); groupBox->layout()->addWidget(unrestrictedScalingButton_); groupBox->layout()->addWidget(keepRatioButton_); groupBox->layout()->addWidget(integerScalingButton_); } void VideoDialog::ScalingMethodSelector::accept() { if (integerScalingButton_->isChecked()) { scaling_ = scaling_integer; } else if (keepRatioButton_->isChecked()) { scaling_ = scaling_keep_ratio; } else scaling_ = scaling_unrestricted; } void VideoDialog::ScalingMethodSelector::reject() { switch (scaling_) { case scaling_unrestricted: unrestrictedScalingButton_->click(); break; case scaling_keep_ratio: keepRatioButton_->click(); break; case scaling_integer: integerScalingButton_->click(); break; } } static void fillResBox(QComboBox *const box, QSize const &sourceSize, std::vector<ResInfo> const &resVector) { long maxArea = 0; std::size_t maxAreaI = 0; for (std::size_t i = 0; i < resVector.size(); ++i) { int const hres = resVector[i].w; int const vres = resVector[i].h; if (hres >= sourceSize.width() && vres >= sourceSize.height()) { box->addItem(QString::number(hres) + 'x' + QString::number(vres), static_cast<uint>(i)); } else { long area = long(std::min(hres, sourceSize.width())) * std::min(vres, sourceSize.height()); if (area > maxArea) { maxArea = area; maxAreaI = i; } } } // add resolution giving maximal area if all resolutions are too small. if (box->count() < 1 && maxArea) { box->addItem(QString::number(resVector[maxAreaI].w) + 'x' + QString::number(resVector[maxAreaI].h), static_cast<uint>(maxAreaI)); } } static QComboBox * createResBox(QSize const &sourceSize, std::vector<ResInfo> const &resVector, int defaultIndex, QWidget *parent) { QComboBox *box = new QComboBox(parent); fillResBox(box, sourceSize, resVector); box->setCurrentIndex(box->findData(defaultIndex)); return box; } static auto_vector<PersistComboBox> createFullResSelectors(QSize const &sourceSize, MainWindow const &mw, QWidget *parent) { auto_vector<PersistComboBox> v(mw.screens()); for (std::size_t i = 0; i < v.size(); ++i) { v.reset(i, new PersistComboBox("video/fullRes" + QString::number(i), createResBox(sourceSize, mw.modeVector(i), mw.currentResIndex(i), parent))); } return v; } static void addRates(QComboBox *box, std::vector<short> const &rates) { for (std::size_t i = 0; i < rates.size(); ++i) box->addItem(QString::number(rates[i] / 10.0) + " Hz"); } static QComboBox * createHzBox(std::vector<short> const &rates, std::size_t defaultIndex, QWidget *parent) { QComboBox *box = new QComboBox(parent); addRates(box, rates); box->setCurrentIndex(defaultIndex); return box; } static auto_vector<PersistComboBox> createFullHzSelectors( auto_vector<PersistComboBox> const &fullResSelectors, MainWindow const &mw, QWidget *parent) { auto_vector<PersistComboBox> v(fullResSelectors.size()); for (std::size_t i = 0; i < v.size(); ++i) { int resBoxIndex = fullResSelectors[i]->box()->currentIndex(); std::size_t resIndex = fullResSelectors[i]->box()->itemData(resBoxIndex).toUInt(); std::vector<short> const &rates = resBoxIndex >= 0 ? mw.modeVector(i)[resIndex].rates : std::vector<short>(); std::size_t defaultRateIndex = resIndex == mw.currentResIndex(i) ? mw.currentRateIndex(i) : 0; v.reset(i, new PersistComboBox("video/hz" + QString::number(i), createHzBox(rates, defaultRateIndex, parent))); } return v; } static QComboBox * createEngineBox(MainWindow const &mw, QWidget *parent) { QComboBox *box = new QComboBox(parent); for (std::size_t i = 0, n = mw.numBlitters(); i < n; ++i) { ConstBlitterConf bconf = mw.blitterConf(i); box->addItem(bconf.nameString()); if (QWidget *w = bconf.settingsWidget()) { w->hide(); w->setParent(parent); } } return box; } static QComboBox * createSourceBox(std::vector<VideoDialog::VideoSourceInfo> const &sourceInfos, QWidget *parent) { QComboBox *const box = new QComboBox(parent); for (std::size_t i = 0; i < sourceInfos.size(); ++i) box->addItem(sourceInfos[i].label, sourceInfos[i].size); return box; } VideoDialog::VideoDialog(MainWindow const &mw, std::vector<VideoSourceInfo> const &sourceInfos, QString const &sourcesLabel, QWidget *parent) : QDialog(parent) , mw_(mw) , engineSelector_("video/engine", createEngineBox(mw, this)) , sourceSelector_("video/source", createSourceBox(sourceInfos, this)) , fullResSelectors_(createFullResSelectors( sourceSelector_.box()->itemData(sourceSelector_.box()->currentIndex()).toSize(), mw, this)) , fullHzSelectors_(createFullHzSelectors(fullResSelectors_, mw, this)) , scalingMethodSelector_(this) , engineWidget_() { setWindowTitle(tr("Video Settings")); QVBoxLayout *const mainLayout = new QVBoxLayout(this); QVBoxLayout *const topLayout = addLayout(mainLayout, new QVBoxLayout, Qt::AlignTop); { QHBoxLayout *hLayout = addLayout(topLayout, new QHBoxLayout); hLayout->addWidget(new QLabel(tr("Video engine:"))); hLayout->addWidget(engineSelector_.box()); } if ((engineWidget_ = mw.blitterConf(engineSelector_.box()->currentIndex()).settingsWidget())) { topLayout->addWidget(engineWidget_); engineWidget_->show(); } for (std::size_t i = 0; i < fullResSelectors_.size(); ++i) { if (mw.modeVector(i).empty()) { fullResSelectors_[i]->box()->hide(); fullHzSelectors_[i]->box()->hide(); } else { QHBoxLayout *const hLayout = addLayout(topLayout, new QHBoxLayout); hLayout->addWidget(new QLabel(tr("Full screen mode (") + mw.screenName(i) + "):")); QHBoxLayout *const hhLayout = addLayout(hLayout, new QHBoxLayout); hhLayout->addWidget(fullResSelectors_[i]->box()); hhLayout->addWidget(fullHzSelectors_[i]->box()); } } scalingMethodSelector_.addToLayout(topLayout); if (sourceSelector_.box()->count() > 1) { QHBoxLayout *hLayout = addLayout(topLayout, new QHBoxLayout); hLayout->addWidget(new QLabel(sourcesLabel)); sourceSelector_.box()->setParent(0); // reparent to fix tab order hLayout->addWidget(sourceSelector_.box()); } else { sourceSelector_.box()->hide(); } QHBoxLayout *const hLayout = addLayout(mainLayout, new QHBoxLayout, Qt::AlignBottom | Qt::AlignRight); QPushButton *const okButton = addWidget(hLayout, new QPushButton(tr("OK"))); QPushButton *const cancelButton = addWidget(hLayout, new QPushButton(tr("Cancel"))); okButton->setDefault(true); connect(engineSelector_.box(), SIGNAL(currentIndexChanged(int)), this, SLOT(engineChange(int))); for (std::size_t i = 0; i < fullResSelectors_.size(); ++i) { connect(fullResSelectors_[i]->box(), SIGNAL(currentIndexChanged(int)), this, SLOT(resIndexChange(int))); } connect(sourceSelector_.box(), SIGNAL(currentIndexChanged(int)), this, SLOT(sourceChange(int))); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); } void VideoDialog::engineChange(int const index) { QBoxLayout *const topLayout = static_cast<QBoxLayout *>(layout()->itemAt(0)->layout()); if (engineWidget_) { engineWidget_->hide(); topLayout->removeWidget(engineWidget_); } if ((engineWidget_ = mw_.blitterConf(index).settingsWidget())) { topLayout->insertWidget(1, engineWidget_); engineWidget_->show(); } } void VideoDialog::resIndexChange(std::size_t const screen, int const index) { QComboBox const *const resBox = fullResSelectors_[screen]->box(); std::vector<short> const &rates = index >= 0 ? mw_.modeVector(screen)[resBox->itemData(index).toUInt()].rates : std::vector<short>(); fullHzSelectors_[screen]->box()->clear(); addRates(fullHzSelectors_[screen]->box(), rates); } void VideoDialog::resIndexChange(int const index) { for (std::size_t i = 0; i < fullResSelectors_.size(); ++i) { if (sender() == fullResSelectors_[i]->box()) return resIndexChange(i, index); } } void VideoDialog::sourceChange(int const sourceIndex) { QSize const sourceSize = sourceSelector_.box()->itemData(sourceIndex).toSize(); for (std::size_t i = 0; i < fullResSelectors_.size(); ++i) { QComboBox *const resBox = fullResSelectors_[i]->box(); QString const oldText = resBox->currentText(); disconnect(resBox, SIGNAL(currentIndexChanged(int)), this, SLOT(resIndexChange(int))); resBox->clear(); fillResBox(resBox, sourceSize, mw_.modeVector(i)); int const foundOldTextIndex = resBox->findText(oldText); if (foundOldTextIndex >= 0) { resBox->setCurrentIndex(foundOldTextIndex); } else { resIndexChange(i, resBox->currentIndex()); } connect(resBox, SIGNAL(currentIndexChanged(int)), this, SLOT(resIndexChange(int))); } } std::size_t VideoDialog::fullResIndex(std::size_t screen) const { PersistComboBox const *sel = fullResSelectors_[screen]; return sel->box()->itemData(sel->index()).toUInt(); } std::size_t VideoDialog::fullRateIndex(std::size_t screen) const { return fullHzSelectors_[screen]->index(); } QSize const VideoDialog::sourceSize() const { return sourceSelector_.box()->itemData(sourceIndex()).toSize(); } void VideoDialog::accept() { engineSelector_.accept(); scalingMethodSelector_.accept(); sourceSelector_.accept(); std::for_each(fullResSelectors_.begin(), fullResSelectors_.end(), std::mem_fun(&PersistComboBox::accept)); std::for_each(fullHzSelectors_.begin(), fullHzSelectors_.end(), std::mem_fun(&PersistComboBox::accept)); QDialog::accept(); } void VideoDialog::reject() { for (std::size_t i = 0, n = mw_.numBlitters(); i < n; ++i) mw_.blitterConf(i).rejectSettings(); engineSelector_.reject(); scalingMethodSelector_.reject(); sourceSelector_.reject(); std::for_each(fullResSelectors_.begin(), fullResSelectors_.end(), std::mem_fun(&PersistComboBox::reject)); std::for_each(fullHzSelectors_.begin(), fullHzSelectors_.end(), std::mem_fun(&PersistComboBox::reject)); QDialog::reject(); } void applySettings(MainWindow &mw, VideoDialog const &vd) { { BlitterConf const curBlitter = mw.currentBlitterConf(); for (std::size_t i = 0, n = mw.numBlitters(); i < n; ++i) { if (mw.blitterConf(i) != curBlitter) mw.blitterConf(i).acceptSettings(); } QSize const srcSize = vd.sourceSize(); mw.setVideoFormatAndBlitter(srcSize, vd.blitterNo()); curBlitter.acceptSettings(); } mw.setScalingMethod(vd.scalingMethod()); for (std::size_t i = 0, n = mw.screens(); i < n; ++i) mw.setFullScreenMode(i, vd.fullResIndex(i), vd.fullRateIndex(i)); }
35.643836
104
0.681937
ReallyEvilFish
ac7cd725bfe35dc35b265b5c06414b7affacf105
95
cpp
C++
src/objects/abstractscene.cpp
hardware/ObjectViewer
718922e00a6f3e83510e6091f7630ac3c0e5066b
[ "MIT" ]
52
2015-02-26T04:00:19.000Z
2021-04-25T03:18:25.000Z
src/common/abstractscene.cpp
hardware/OpenGLSBExamplesQt
62c3e1bb1e47e20e6f82074c95814cf24915ba14
[ "MIT" ]
2
2017-03-15T02:11:06.000Z
2017-12-04T12:26:06.000Z
src/objects/abstractscene.cpp
hardware/ObjectViewer
718922e00a6f3e83510e6091f7630ac3c0e5066b
[ "MIT" ]
21
2015-09-09T13:59:02.000Z
2021-04-25T03:18:27.000Z
#include "abstractscene.h" AbstractScene::AbstractScene(QObject* parent) : QObject(parent) {}
23.75
66
0.768421
hardware
ac8744075523a0fda39d277e97d845adb9df9eeb
1,432
hpp
C++
include/stats/bmo_stats.hpp
kthohr/BaseMatrixOps
cfcb4c9dac79c8ccac3816b26220c77dc0ae90c8
[ "Apache-2.0" ]
null
null
null
include/stats/bmo_stats.hpp
kthohr/BaseMatrixOps
cfcb4c9dac79c8ccac3816b26220c77dc0ae90c8
[ "Apache-2.0" ]
1
2022-02-11T15:51:19.000Z
2022-02-11T15:51:19.000Z
include/stats/bmo_stats.hpp
kthohr/BaseMatrixOps
cfcb4c9dac79c8ccac3816b26220c77dc0ae90c8
[ "Apache-2.0" ]
null
null
null
/*################################################################################ ## ## Copyright (C) 2011-2022 Keith O'Hara ## ## This file is part of the StatsLib C++ library. ## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. ## You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, software ## distributed under the License is distributed on an "AS IS" BASIS, ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ## See the License for the specific language governing permissions and ## limitations under the License. ## ################################################################################*/ #ifndef BMO_STATS_INCLUDES #define BMO_STATS_INCLUDES #ifndef BMO_RNG_ENGINE_TYPE #define BMO_RNG_ENGINE_TYPE std::mt19937_64; #endif namespace bmo_stats { using rand_engine_t = BMO_RNG_ENGINE_TYPE; template<typename T> using return_t = typename std::conditional<std::is_integral<T>::value,double,T>::type; template<typename ...T> using common_t = typename std::common_type<T...>::type; template<typename ...T> using common_return_t = return_t<common_t<T...>>; // #include "runif.hpp" #include "rnorm.hpp" #include "rind.hpp" } #endif
27.538462
86
0.623603
kthohr
12bfd5cc825b258a9dd1d176f615140311e6c74a
407
cpp
C++
test/supgid.cpp
fitenne/yamc
26141cb61eff63521cd282389495c8a9b9a1604d
[ "MIT" ]
1
2022-03-27T05:01:04.000Z
2022-03-27T05:01:04.000Z
test/supgid.cpp
fitenne/yamc
26141cb61eff63521cd282389495c8a9b9a1604d
[ "MIT" ]
null
null
null
test/supgid.cpp
fitenne/yamc
26141cb61eff63521cd282389495c8a9b9a1604d
[ "MIT" ]
null
null
null
// try setgroups #include <grp.h> #include <sys/types.h> #include <unistd.h> #include <cstring> #include <iostream> using namespace std; int main() { gid_t grps[32] = {0}; setgroups(1, grps); cout << "setgroups: " << strerror(errno) << endl; auto sz = getgroups(32, grps); for (int i = 0; i < sz; ++i) { cout << "in group: " << grps[i] << endl; } return 0; }
18.5
53
0.545455
fitenne
12c66e731734a8a69df3cbdeb29137a9e830bfb8
1,143
cpp
C++
src/tempe/objects.cpp
ondra-novak/tempe
faaae56c186597a090ece9afa66ad0388ee69a88
[ "MIT" ]
null
null
null
src/tempe/objects.cpp
ondra-novak/tempe
faaae56c186597a090ece9afa66ad0388ee69a88
[ "MIT" ]
null
null
null
src/tempe/objects.cpp
ondra-novak/tempe
faaae56c186597a090ece9afa66ad0388ee69a88
[ "MIT" ]
null
null
null
#include "interfaces.h" #include "objects.h" namespace Tempe { GCReg::GCReg() :prev(0), next(0) { } GCReg::~GCReg() { unregisterFromGC(); } void GCReg::registerToGC(GCReg &root) { next = root.next; prev = &root; if (next) next->prev = this; root.next = this; // LS_LOG.debug("Registered object: %1") << (natural)this; } void GCReg::unregisterFromGC() { if (next) next->prev = prev; if (prev) prev->next = next; next = prev = 0; // LS_LOG.debug("Unregistered object: %1") << (natural)this; } bool GCReg::isRegistered() const { return next != 0 || prev != 0; } Object *Object::clear() { JSON::PNode hold = this; fields.clear(); return this; } Array *Array::clear() { JSON::PNode hold = this; list.clear(); return this; } GCRegRoot *GCRegRoot::clear() { return this; } void GCRegRoot::clearAll() { GCReg *x = next; AutoArray<std::pair<Value, GCReg *>, SmallAlloc<256> > regs; while (x) { regs.add(std::make_pair(Value(dynamic_cast<JSON::INode *>(x)), x)); x = x->next; } for (natural i = 0; i < regs.length(); i++) { regs[i].second->clear(); } } }
15.875
70
0.592301
ondra-novak
12c7750a932f50dd13613f9f00857cbf59afed13
11,837
cp
C++
Sources_Common/Offline/Recording/CCalendarRecord.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
12
2015-04-21T16:10:43.000Z
2021-11-05T13:41:46.000Z
Sources_Common/Offline/Recording/CCalendarRecord.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
2
2015-11-02T13:32:11.000Z
2019-07-10T21:11:21.000Z
Sources_Common/Offline/Recording/CCalendarRecord.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
6
2015-01-12T08:49:12.000Z
2021-03-27T09:11:10.000Z
/* Copyright (c) 2007 Cyrus Daboo. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // Source for an Mail Record class #include "CCalendarRecord.h" #include "CLocalCommon.h" #include "CCalendarProtocol.h" #include "CCalendarStoreNode.h" #include "CLog.h" #include "CRFC822.h" #include "CUnicodeStdLib.h" #include "CICalendar.h" #include <memory> CCalendarRecord::CCalendarRecord() { } #pragma mark ____________________________Calendar actions void CCalendarRecord::Create(const calstore::CCalendarStoreNode& node) { // Only if allowed if (!mRecord.IsSet(eCreate)) return; push_back(new CCalendarAction(CCalendarAction::eCreate, mCurrentID, node)); } void CCalendarRecord::Delete(const calstore::CCalendarStoreNode& node) { // Only if allowed if (!mRecord.IsSet(eDelete)) return; push_back(new CCalendarAction(CCalendarAction::eDelete, mCurrentID, node)); } void CCalendarRecord::Rename(const calstore::CCalendarStoreNode& node, const cdstring& newname) { // Only if allowed if (!mRecord.IsSet(eRename)) return; push_back(new CCalendarAction(CCalendarAction::eRename, mCurrentID, node, newname)); } void CCalendarRecord::Change(const calstore::CCalendarStoreNode& node) { // Only if allowed if (!mRecord.IsSet(eChange)) return; push_back(new CCalendarAction(CCalendarAction::eChange, mCurrentID, node)); } #pragma mark ____________________________Playback // Playback processing bool CCalendarRecord::Playback(calstore::CCalendarProtocol* remote, calstore::CCalendarProtocol* local) { // Check for forced logging bool log_created = false; std::auto_ptr<cdofstream> fout; if (!mLog && CLog::AllowPlaybackLog()) { cdstring temp_name = mDescriptor + ".log"; fout.reset(new cdofstream(temp_name, std::ios_base::out | std::ios_base::trunc | std::ios_base::binary)); SetLog(fout.get()); log_created = true; } bool clone_opened = false; bool result = true; try { if (mLog) { *mLog << os_endl << os_endl << "----" << os_endl; *mLog << "Starting Calendar Playback: " << CRFC822::GetRFC822Date() << os_endl << std::flush; } // Read in the entire journal Open(); if (mLog) *mLog << "Opened Playback log: " << mDescriptor << os_endl << std::flush; // Compact the playback to minimise operations CompactPlayback(); if (size()) { // Open main connection remote->Open(); remote->Logon(); if (mLog) *mLog << "Opened remote server: " << remote->GetAccountName() << os_endl << std::flush; } // Cache useful items mPlayRemote = remote; mPlayLocal = local; // Now run the play back while(size()) { // Play the top item PlaybackItem(*static_cast<CCalendarAction*>(*begin())); // Done with top element erase(begin()); } } catch (...) { CLOG_LOGCATCH(...); // Playback failed for some reason result = false; } // Close remote connection if (remote->IsOpen() && mLog) *mLog << "Closed remote server: " << remote->GetAccountName() << os_endl << std::flush; remote->Close(); // Clear it out clear(); mNextID = 1; // If no failure clear out the file if (result) { // Close and delete record file mStream.close(); ::remove_utf8(mDescriptor); if (mLog) *mLog << "Closed Playback log (cleared): " << mDescriptor << os_endl << std::flush; } else { // Close and delete existing mStream.close(); ::remove_utf8(mDescriptor); // Create/open new one #if __dest_os == __mac_os || __dest_os == __mac_os_x StCreatorType file(cMulberryCreator, cMailboxRecordType); #endif mStream.open(mDescriptor, std::ios_base::in | std::ios_base::out | std::ios_base::trunc | std::ios_base::binary); // Add next id tag at start mStream.seekp(0, std::ios_base::beg); mStream.write(reinterpret_cast<const char*>(&mNextID), sizeof(unsigned long)); // Write out items for(const_iterator iter = begin(); iter != end(); iter++) (*iter)->WriteToStream(mStream); mStream << std::flush; Close(); if (mLog) *mLog << "Closed Playback log (not cleared): " << mDescriptor << os_endl << std::flush; } if (mLog) *mLog << os_endl << (result ? "Playback complete (no error): " : "Playback complete (error): ") << CRFC822::GetRFC822Date() << os_endl << os_endl << std::flush; if (log_created) SetLog(NULL); return result; } void CCalendarRecord::PlaybackItem(CCalendarAction& action) { try { switch(action.GetAction()) { // Addressbook actions case CCalendarAction::eCreate: Playback_Create(action); break; case CCalendarAction::eDelete: Playback_Delete(action); break; case CCalendarAction::eRename: Playback_Rename(action); break; case CCalendarAction::eChange: Playback_Change(action); break; default:; } } catch (...) { CLOG_LOGCATCH(...); // Fail silently for now } } void CCalendarRecord::Playback_Create(CCalendarAction& action) { try { // Create temp remote object std::auto_ptr<calstore::CCalendarStoreNode> node(new calstore::CCalendarStoreNode(mPlayRemote, mPlayRemote->GetStoreRoot(), action.GetCalendarAction().mIsDir, false, false, action.GetCalendarAction().mName)); // Create on server mPlayRemote->CreateCalendar(*node.get()); if (mLog) *mLog << " Create Calendar: " << action.GetCalendarAction().mName << " succeeded" << os_endl << std::flush; } catch (...) { CLOG_LOGCATCH(...); if (mLog) *mLog << " Create Calendar: " << action.GetCalendarAction().mName << " failed" << os_endl << std::flush; CLOG_LOGRETHROW; throw; } } void CCalendarRecord::Playback_Delete(CCalendarAction& action) { try { // Create temp remote object std::auto_ptr<calstore::CCalendarStoreNode> node(new calstore::CCalendarStoreNode(mPlayRemote, mPlayRemote->GetStoreRoot(), action.GetCalendarAction().mIsDir, false, false, action.GetCalendarAction().mName)); // Delete on server mPlayRemote->DeleteCalendar(*node.get()); if (mLog) *mLog << " Delete Calendar: " << action.GetCalendarAction().mName << " succeeded" << os_endl << std::flush; } catch (...) { CLOG_LOGCATCH(...); if (mLog) *mLog << " Delete Calendar: " << action.GetCalendarAction().mName << " failed" << os_endl << std::flush; CLOG_LOGRETHROW; throw; } } void CCalendarRecord::Playback_Rename(CCalendarAction& action) { try { // Create temp remote object std::auto_ptr<calstore::CCalendarStoreNode> node(new calstore::CCalendarStoreNode(mPlayRemote, mPlayRemote->GetStoreRoot(), action.GetCalendarActionRename().first.mIsDir, false, false, action.GetCalendarActionRename().first.mName)); // Rename on server mPlayRemote->RenameCalendar(*node.get(), action.GetCalendarActionRename().second); if (mLog) *mLog << " Rename Calendar from: " << action.GetCalendarActionRename().first.mName << " to: " << action.GetCalendarActionRename().second << " succeeded" << os_endl << std::flush; } catch (...) { CLOG_LOGCATCH(...); if (mLog) *mLog << " Rename Calendar from: " << action.GetCalendarActionRename().first.mName << " to: " << action.GetCalendarActionRename().second << " failed" << os_endl << std::flush; CLOG_LOGRETHROW; throw; } } void CCalendarRecord::Playback_Change(CCalendarAction& action) { std::auto_ptr<calstore::CCalendarStoreNode> node; std::auto_ptr<iCal::CICalendar> cal; try { // Create temp node and calendar node.reset(new calstore::CCalendarStoreNode(mPlayRemote, mPlayRemote->GetStoreRoot(), action.GetCalendarAction().mIsDir, false, false, action.GetCalendarAction().mName)); cal.reset(new iCal::CICalendar); node->SetCalendar(cal.get()); #if 0 // Read in calendar from local store mPlayLocal->ReadFullCalendar(*node.get(), *cal.get()); // Write to server (will result in sync if required) mPlayRemote->WriteFullCalendar(*node.get(), *cal.get()); // Write back to local store since changes have been propagated mPlayLocal->WriteFullCalendar(*node.get(), *cal.get()); #else // Just opening the calendar will cause sync mPlayRemote->OpenCalendar(*node.get(), *cal.get()); #endif // Clean-up node->SetCalendar(NULL); if (mLog) *mLog << " Change Calendar: " << action.GetCalendarAction().mName << " succeeded" << os_endl << std::flush; } catch (...) { CLOG_LOGCATCH(...); if (mLog) *mLog << " Change Calendar: " << action.GetCalendarAction().mName << " failed" << os_endl << std::flush; // Clean-up if (node.get() != NULL) node->SetCalendar(NULL); CLOG_LOGRETHROW; throw; } } // Playback processing void CCalendarRecord::CompactPlayback() { // I don't know what to do here yet // Step 1: compact all change actions into one CompactChange(); // Step 2: remove all non-create actions on the same calendar prior to a delete // and remove all actions if create/delete pair exists CompactDelete(); } // Compact multiple changes into one void CCalendarRecord::CompactChange() { for(iterator iter1 = begin(); iter1 != end(); iter1++) { CCalendarAction* action1 = static_cast<CCalendarAction*>(*iter1); if (action1->GetAction() != CCalendarAction::eChange) continue; for(iterator iter2 = iter1 + 1; iter2 != end(); iter2++) { CCalendarAction* action2 = static_cast<CCalendarAction*>(*iter1); if (action1->GetCalendarName() == action2->GetCalendarName()) { // Remove the duplicate erase(iter2); iter2--; } } } if (mLog) *mLog << " Compacting Playback log: multiple changes." << os_endl << std::flush; if (CLog::AllowPlaybackLog() && CLog::AllowAuthenticationLog()) { cdofstream fout(mDescriptor + "1.txt"); WriteItemsToStream(fout, true); } } // Compact actions when delete is present void CCalendarRecord::CompactDelete() { for(iterator iter1 = begin(); iter1 != end(); iter1++) { CCalendarAction* action1 = static_cast<CCalendarAction*>(*iter1); // Only processing delete actions after the first one if ((action1->GetAction() != CCalendarAction::eDelete) || (iter1 == begin())) continue; // Look at all previous ones back to the beginning for(iterator iter2 = iter1 - 1; iter2 != begin(); iter2--) { CCalendarAction* action2 = static_cast<CCalendarAction*>(*iter1); // Only worried about ones on the same calendar if (action1->GetCalendarName() == action2->GetCalendarName()) { // If we have a create operation then delete that and the delete delete action // and stop processing this one if (action2->GetAction() == CCalendarAction::eCreate) { erase(iter1); iter1--; erase(iter2); iter1--; break; } // Remove any change operations as they are pointless when the calendar is being deleted at the end else if (action2->GetAction() == CCalendarAction::eChange) { erase(iter2); iter1--; } } } } if (mLog) *mLog << " Compacting Playback log: no actions before delete." << os_endl << std::flush; if (CLog::AllowPlaybackLog() && CLog::AllowAuthenticationLog()) { cdofstream fout(mDescriptor + "2.txt"); WriteItemsToStream(fout, true); } } #pragma mark ____________________________Stream Ops #if __dest_os == __mac_os || __dest_os == __mac_os_x OSType CCalendarRecord::GetMacFileType() const { return cMailboxRecordType; } #endif CRecordableAction* CCalendarRecord::NewAction() const { return new CCalendarAction(); }
25.510776
234
0.686407
mulberry-mail
12c943c9be937b025f938736a35698821c794ff5
3,887
cpp
C++
Code/WSTrainingTJM/FrmTXTRead/WriteExcelMod.m/src/WriteExcelDlg.cpp
msdos41/CATIA_CAA_V5
bf831f7ecc3c4937b227782ee8bebf7c6675792a
[ "MIT" ]
5
2019-11-14T05:42:38.000Z
2022-03-12T12:51:46.000Z
Code/WSTrainingTJM/FrmTXTRead/WriteExcelMod.m/src/WriteExcelDlg.cpp
msdos41/CATIA_CAA_V5
bf831f7ecc3c4937b227782ee8bebf7c6675792a
[ "MIT" ]
null
null
null
Code/WSTrainingTJM/FrmTXTRead/WriteExcelMod.m/src/WriteExcelDlg.cpp
msdos41/CATIA_CAA_V5
bf831f7ecc3c4937b227782ee8bebf7c6675792a
[ "MIT" ]
4
2020-01-02T13:48:07.000Z
2022-01-05T04:23:30.000Z
// COPYRIGHT Dassault Systemes 2018 //=================================================================== // // WriteExcelDlg.cpp // The dialog : WriteExcelDlg // //=================================================================== // // Usage notes: // //=================================================================== // // Dec 2018 Creation: Code generated by the CAA wizard Administrator //=================================================================== #include "WriteExcelDlg.h" #include "CATApplicationFrame.h" #include "CATDlgGridConstraints.h" #include "CATMsgCatalog.h" #ifdef WriteExcelDlg_ParameterEditorInclude #include "CATIParameterEditorFactory.h" #include "CATIParameterEditor.h" #include "CATICkeParm.h" #endif //------------------------------------------------------------------------- // Constructor //------------------------------------------------------------------------- WriteExcelDlg::WriteExcelDlg() : CATDlgDialog ((CATApplicationFrame::GetApplicationFrame())->GetMainWindow(), //CAA2 WIZARD CONSTRUCTOR DECLARATION SECTION "WriteExcelDlg",CATDlgWndBtnOKCancel|CATDlgWndTitleBarHelp|CATDlgGridLayout //END CAA2 WIZARD CONSTRUCTOR DECLARATION SECTION ) { //CAA2 WIZARD CONSTRUCTOR INITIALIZATION SECTION _Container003 = NULL; _Container004 = NULL; _LabelSavePath = NULL; _EditorSavePath = NULL; _PushButtonSelectPath = NULL; _Container008 = NULL; _PushButtonReadXls = NULL; //END CAA2 WIZARD CONSTRUCTOR INITIALIZATION SECTION } //------------------------------------------------------------------------- // Destructor //------------------------------------------------------------------------- WriteExcelDlg::~WriteExcelDlg() { // Do not delete the control elements of your dialog: // this is done automatically // -------------------------------------------------- //CAA2 WIZARD DESTRUCTOR DECLARATION SECTION _Container003 = NULL; _Container004 = NULL; _LabelSavePath = NULL; _EditorSavePath = NULL; _PushButtonSelectPath = NULL; _Container008 = NULL; _PushButtonReadXls = NULL; //END CAA2 WIZARD DESTRUCTOR DECLARATION SECTION } void WriteExcelDlg::Build() { // TODO: This call builds your dialog from the layout declaration file // ------------------------------------------------------------------- //CAA2 WIZARD WIDGET CONSTRUCTION SECTION _Container003 = new CATDlgContainer(this, "Container003"); _Container003 -> SetRectDimensions(1, 1, 1, 5); _Container003 -> SetGridConstraints(0, 1, 1, 1, CATGRID_4SIDES); _Container004 = new CATDlgContainer(this, "Container004"); _Container004 -> SetRectDimensions(1, 1, 1, 1); _Container004 -> SetGridConstraints(1, 0, 1, 1, CATGRID_4SIDES); _LabelSavePath = new CATDlgLabel(this, "LabelSavePath"); _LabelSavePath -> SetGridConstraints(2, 0, 1, 1, CATGRID_4SIDES); _EditorSavePath = new CATDlgEditor(this, "EditorSavePath", CATDlgEdtReadOnly); _EditorSavePath -> SetVisibleTextWidth(25); _EditorSavePath -> SetGridConstraints(2, 2, 1, 1, CATGRID_4SIDES); _PushButtonSelectPath = new CATDlgPushButton(this, "PushButtonSelectPath"); _PushButtonSelectPath -> SetGridConstraints(2, 4, 1, 1, CATGRID_4SIDES); _Container008 = new CATDlgContainer(this, "Container008"); _Container008 -> SetRectDimensions(1, 1, 1, 5); _Container008 -> SetGridConstraints(2, 3, 1, 1, CATGRID_4SIDES); _PushButtonReadXls = new CATDlgPushButton(this, "PushButtonReadXls"); _PushButtonReadXls -> SetGridConstraints(3, 4, 1, 1, CATGRID_4SIDES); //END CAA2 WIZARD WIDGET CONSTRUCTION SECTION //CAA2 WIZARD CALLBACK DECLARATION SECTION //END CAA2 WIZARD CALLBACK DECLARATION SECTION } CATDlgEditor* WriteExcelDlg::GetEditorSavePath() { return _EditorSavePath; } CATDlgPushButton* WriteExcelDlg::GetPushButtonSelectPath() { return _PushButtonSelectPath; } CATDlgPushButton* WriteExcelDlg::GetPushButtonReadExcel() { return _PushButtonReadXls; }
33.222222
79
0.63185
msdos41